Commit e7be7c4a authored by Xiaowu Zhang's avatar Xiaowu Zhang

remove onclick event in audioplayer

parent be871646
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
<div class = "audioplayer"> <div class = "audioplayer">
<a class = "next">next</a> <a class = "next">next</a>
<a class = "command">play/pause</a> <a class = "play">play</a>
<a class = "stop">stop</a>
<!-- data-gadget-sandbox="iframe" --> <!-- data-gadget-sandbox="iframe" -->
<div class = "control" data-gadget-url="../audioplayer_control/index.html" data-gadget-scope="control"> <div class = "control" data-gadget-url="../audioplayer_control/index.html" data-gadget-scope="control">
</div> </div>
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
totalId = -1, totalId = -1,
that, that,
next_context, next_context,
command_context, play_context,
stop_context,
currentId, currentId,
initializeFlag = false; initializeFlag = false;
function nextId() { function nextId() {
...@@ -77,7 +78,8 @@ ...@@ -77,7 +78,8 @@
}) })
.ready(function (g) { .ready(function (g) {
next_context = g.__element.getElementsByTagName('a')[0]; next_context = g.__element.getElementsByTagName('a')[0];
command_context = g.__element.getElementsByTagName('a')[1]; play_context = g.__element.getElementsByTagName('a')[1];
stop_context = g.__element.getElementsByTagName('a')[2];
that = g; that = g;
initializeFlag = false; initializeFlag = false;
RSVP.all([ RSVP.all([
...@@ -110,15 +112,12 @@ ...@@ -110,15 +112,12 @@
}); });
}, 1000); }, 1000);
volume.setMax(3); volume.setMax(3);
command_context.onclick = function () { that.showPage("play").then(function (result) {
control.isPaused().then(function (paused) { play_context.href = result;
if (paused) { });
control.playSong(); that.showPage("stop").then(function (result) {
} else { stop_context.href = result;
control.stopSong(); });
}
});
};
//volume configure //volume configure
control.getVolume().then(function (value) { control.getVolume().then(function (value) {
volume.setValue(value); volume.setValue(value);
...@@ -148,6 +147,14 @@ ...@@ -148,6 +147,14 @@
}); });
}); });
if (options.page !== undefined) { if (options.page !== undefined) {
if (options.page === "play") {
control.playSong();
return;
}
if (options.page === "stop") {
control.stopSong();
return;
}
control.setSong(options.page).then(function (result) { control.setSong(options.page).then(function (result) {
if (result === -1) { if (result === -1) {
control.stopSong() control.stopSong()
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
top; top;
rJS(window) rJS(window)
.allowPublicAcquisition("ErrorPage", function () { .allowPublicAcquisition("ErrorPage", function () {
top.__element.innerHTML = "ERROR"; top.__element.innerHTML = "ERROR:music does't exist";
top.error = true; top.error = true;
}) })
.allowPublicAcquisition("showPage", function (param_list) { .allowPublicAcquisition("showPage", function (param_list) {
...@@ -27,8 +27,7 @@ ...@@ -27,8 +27,7 @@
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
if (top.error === true) { if (top.error === true) {
top.__element.innerHTML = " "; top.__element.innerHTML = " ";
top.dropGadget("audioplayer").then(function (e) { top.dropGadget("audioplayer").then(function () {
console.log(e);
top.declareGadget("./audioplayer.html", top.declareGadget("./audioplayer.html",
{ element: top.__element, { element: top.__element,
scope : "audioplayer"} scope : "audioplayer"}
......
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