Commit c50738ce authored by Xiaowu Zhang's avatar Xiaowu Zhang

fix invalide url bug in audioplayer

parent 345846aa
...@@ -52,8 +52,10 @@ ...@@ -52,8 +52,10 @@
}) })
.ready(function (g) { .ready(function (g) {
var next_context = g.__element.getElementsByTagName('button')[0], var next_context = g.__element.getElementsByTagName('button')[0],
command_context = g.__element.getElementsByTagName('button')[1]; command_context = g.__element.getElementsByTagName('button')[1],
initialUrl = location.href; index;
index = location.href.indexOf('#');
initialUrl = location.href.slice(0, index);
RSVP.all([ RSVP.all([
g.getDeclaredGadget( g.getDeclaredGadget(
"control" "control"
...@@ -89,7 +91,7 @@ ...@@ -89,7 +91,7 @@
control.setSong(id).then(function () { control.setSong(id).then(function () {
control.playSong(); control.playSong();
control.getTitle().then(function (value) { control.getTitle().then(function (value) {
window.history.pushState(null, null, initialUrl + value); window.history.pushState(null, null, initialUrl + "#" + value);
}); });
}); });
}; };
...@@ -116,7 +118,7 @@ ...@@ -116,7 +118,7 @@
window.addEventListener("popstate", function (e) { window.addEventListener("popstate", function (e) {
var href = location.href, var href = location.href,
name, name,
lastIndex = href.lastIndexOf('/') + 1; lastIndex = href.lastIndexOf('#') + 1;
if (lastIndex !== href.length) { if (lastIndex !== href.length) {
name = href.slice(lastIndex); name = href.slice(lastIndex);
control.setSong(name).then(function () { control.setSong(name).then(function () {
...@@ -128,6 +130,10 @@ ...@@ -128,6 +130,10 @@
title.setMessage("audio player"); title.setMessage("audio player");
} }
}, false); }, false);
//xxx
window.onhashchange = function () {
console.log("hash change\n");
};
}) })
.fail(function (e) { .fail(function (e) {
console.log("[ERROR]: " + e); console.log("[ERROR]: " + e);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment