Commit 66adf726 authored by Xiaowu Zhang's avatar Xiaowu Zhang

combine play/pause command

parent 46e356eb
......@@ -18,7 +18,6 @@
that,
next_context,
play_context,
stop_context,
addMusic_context,
list_context,
currentId = -1,
......@@ -27,7 +26,7 @@
titleSave,
playlist = [];
function nextId() {
if (totalId === -1) {
if (totalId <= 0) {
return -1;
}
currentId += 1;
......@@ -79,7 +78,6 @@
var array = g.__element.getElementsByTagName('a');
next_context = array[0];
play_context = array[1];
stop_context = array[array.length - 3];
addMusic_context = array[array.length - 2];
list_context = array[array.length - 1];
that = g;
......@@ -130,13 +128,9 @@
});
}, 1000);
volume.setMax(3);
that.showPage("play").then(function (result) {
play_context.href = result;
});
that.showPage("stop").then(function (result) {
stop_context.href = result;
play_context.href = result;
});
that.showPage("addMusic").then(function (result) {
addMusic_context.href = result;
});
......@@ -165,7 +159,6 @@
animation.display();
next_context.style.display = "";
play_context.style.display = "";
stop_context.style.display = "";
addMusic_context.style.display = "";
list_context.style.display = "";
})
......@@ -176,7 +169,6 @@
animation.noDisplay();
next_context.style.display = "none";
play_context.style.display = "none";
stop_context.style.display = "none";
addMusic_context.style.display = "none";
list_context.style.display = "none";
})
......@@ -199,6 +191,7 @@
if (options.page === "addMusic") {
animation.stopAnimation();
that.noDisplay();
list.noDisplay();
io.display();
return;
}
......@@ -206,6 +199,7 @@
if (options.page === "playlist") {
animation.stopAnimation();
that.noDisplay();
io.noDisplay();
list.initList(playlist);
list.display();
return;
......@@ -217,11 +211,19 @@
that.display();
if (options.page === "play") {
that.showPage("stop").then(function (result) {
play_context.href = result;
play_context.innerHTML = "stop";
});
control.playSong();
animation.showAnimation();
return;
}
if (options.page === "stop") {
that.showPage("play").then(function (result) {
play_context.href = result;
play_context.innerHTML = "play";
});
control.stopSong();
animation.stopAnimation();
return;
......@@ -246,6 +248,11 @@
animation.showAnimation();
});
});
} else {
error.noDisplay();
list.noDisplay();
io.noDisplay();
that.display();
}
});
}(window, rJS, jQuery, RSVP));
......@@ -24,7 +24,7 @@
<div data-role="navbar">
<ul>
<li> <a class="next">next</a></li>
<li> <a class="play">play</a></li>
<li> <a class="play">stop</a></li>
</ul>
</div>
</div>
......@@ -60,7 +60,6 @@
<div data-role="footer" data-position="fullscreen">
<div data-role="navbar">
<ul>
<li> <a class="stop">stop</a></li>
<li> <a class="addMusic">addMusic</a></li>
<li> <a href="#page=playlist">playlist</a></li>
</ul>
......
......@@ -65,13 +65,16 @@
.declareMethod("display", function (options) {
this.canvas.style.display = "";
this.mirror.style.display = "";
this.visualize.style.display = "";
})
.declareMethod("noDisplay", function (options) {
this.canvas.style.display = "none";
this.mirror.style.display = "none";
this.visualize.style.display = "none";
});
gk.ready(function (g) {
g.visualize = g.__element.getElementsByTagName('div')[0];
g.canvas = g.__element.getElementsByTagName('canvas')[0];
g.mirror = g.__element.getElementsByTagName('canvas')[1];
});
......
......@@ -7,7 +7,7 @@
input_context;
gk.declareMethod('createIO', function (description, key) {
// indexedDB.deleteDatabase("jio:test");
// indexedDB.deleteDatabase("jio:test");
this.jio = jIO.createJIO(description);
this.key = key;
return this.jio.put({
......@@ -70,10 +70,12 @@
"m")
.then(function () {
g.showAllIO().then(function (result) {
var array = Object.keys(result),
i;
for (i = 0; i < array.length; i += 1) {
g.playlist.push(array[i]);
if (result !== undefined) {
var array = Object.keys(result),
i;
for (i = 0; i < array.length; i += 1) {
g.playlist.push(array[i]);
}
}
g.sendPlaylist(g.playlist);
});
......
......@@ -15,7 +15,7 @@
var i,
docFragment = document.createDocumentFragment(),
li;
// this.list.innerHTML = "";
this.list.innerHTML = "";
for (i = 0; i < array.length; i += 1) {
li = document.createElement("li");
li.innerHTML =
......
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