Commit e7be7c4a authored by Xiaowu Zhang's avatar Xiaowu Zhang

remove onclick event in audioplayer

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