Commit dd5b7008 authored by Xiaowu Zhang's avatar Xiaowu Zhang

add display noDisplay methods for optimization

parent b354cac2
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
volume = all_param[3]; volume = all_param[3];
title = all_param[4]; title = all_param[4];
io = all_param[5]; io = all_param[5];
that.display();
window.setInterval(function () { window.setInterval(function () {
control.getCurrentTime() control.getCurrentTime()
.then(function (e) { .then(function (e) {
...@@ -139,6 +140,30 @@ ...@@ -139,6 +140,30 @@
}); });
rJS(window) rJS(window)
.declareMethod("display", function (options) {
io.noDisplay();
title.display();
time.display();
volume.display();
animation.display();
next_context.style.display = "";
play_context.style.display = "";
stop_context.style.display = "";
addMusic_context.style.display = "";
})
.declareMethod("noDisplay", function (options) {
if (options === "addPage") {
io.display();
}
title.noDisplay();
time.noDisplay();
volume.noDisplay();
animation.noDisplay();
next_context.style.display = "none";
play_context.style.display = "none";
stop_context.style.display = "none";
addMusic_context.style.display = "none";
})
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
var id = nextId(), var id = nextId(),
name = playlist[id]; name = playlist[id];
......
<!DOCTYPE html>
<html lang="en">
<head>
<title>errorPage</title>
<!-- renderjs -->
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<!-- custom script -->
<script src="./error.js" type="text/javascript"></script>
</head>
<body>
<div >
</div>
</body>
</html>
/*global rJS, window*/
/*jslint nomen: true*/
(function (window, rJS) {
"use strict";
var h2_context;
rJS(window)
.ready(function (g) {
h2_context = g.__element.getElementsByTagName('div')[0];
})
.declareMethod("display", function (options) {
h2_context.innerHTML = " <h2>ERROR:Music not found</h2>";
})
.declareMethod("noDisplay", function (options) {
h2_context.innerHTML = "";
});
}(window, rJS));
...@@ -13,5 +13,10 @@ ...@@ -13,5 +13,10 @@
<script src="./interface.js" type="text/javascript"></script> <script src="./interface.js" type="text/javascript"></script>
</head> </head>
<body> <body>
<div class = "audioplayer" data-gadget-url="./audioplayer.html" data-gadget-scope="audioplayer">
</div>
<div class = "error" data-gadget-url="./error.html" data-gadget-scope="error">
</div>
</body> </body>
</html> </html>
/*global console, jQuery, rJS, RSVP, alert */ /*global window, rJS, RSVP*/
/*jslint nomen: true*/ /*jslint nomen: true*/
(function (window, rJS, $) { (function (window, rJS) {
"use strict"; "use strict";
var gadget, var gadget,
top, top,
innerHTML; error;
rJS(window) rJS(window)
.allowPublicAcquisition("ErrorPage", function () { .allowPublicAcquisition("ErrorPage", function () {
top.__element.innerHTML = "ERROR:music does't exist"; error.display();
top.dropGadget("audioplayer"); gadget.noDisplay();
top.newPage = true; top.newPage = true;
}) })
.allowPublicAcquisition("addPage", function () { .allowPublicAcquisition("addPage", function () {
innerHTML = top.__element.innerHTML; gadget.noDisplay("addPage");
top.__element.innerHTML = " ";
top.declareGadget("../audioplayer_io/index.html",
{ element: top.__element,
scope : "io"
}
);
top.newPage = true; top.newPage = true;
top.addPage = true;
}) })
.allowPublicAcquisition("showPage", function (param_list) { .allowPublicAcquisition("showPage", function (param_list) {
return this.aq_pleasePublishMyState({page: param_list[0]}); return this.aq_pleasePublishMyState({page: param_list[0]});
...@@ -29,25 +22,29 @@ ...@@ -29,25 +22,29 @@
top = g; top = g;
top.newPage = false; top.newPage = false;
top.addPage = false; top.addPage = false;
top.declareGadget("./audioplayer.html", RSVP.all([
{element: top.__element} g.getDeclaredGadget(
) "audioplayer"
.then(function (result) { ),
gadget = result; g.getDeclaredGadget(
"error"
)
])
.then(function (all_param) {
gadget = all_param[0];
error = all_param[1];
error.noDisplay();
}); });
}) })
.declareMethod("render", function (options) { .declareMethod("render", function (options) {
if (top.newPage === true) { if (top.newPage === true) {
if (top.addPage === true) {
top.addPage = false;
top.dropGadget("io");
}
top.__element.innerHTML = innerHTML;
top.newPage = false; top.newPage = false;
} else { error.noDisplay();
if (gadget !== undefined) { gadget.display();
gadget.render(options); return;
} }
if (gadget !== undefined) {
gadget.render(options);
} }
}); });
}(window, rJS, jQuery)); }(window, rJS));
...@@ -59,6 +59,14 @@ ...@@ -59,6 +59,14 @@
window.cancelAnimationFrame( window.cancelAnimationFrame(
this.animationPlayId this.animationPlayId
); //stop the previous animation ); //stop the previous animation
})
.declareMethod("display", function (options) {
this.canvas.style.display = "";
this.mirror.style.display = "";
})
.declareMethod("noDisplay", function (options) {
this.canvas.style.display = "none";
this.mirror.style.display = "none";
}); });
gk.ready(function (g) { gk.ready(function (g) {
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
(function (window, jIO, rJS) { (function (window, jIO, rJS) {
"use strict"; "use strict";
var gk = rJS(window); var gk = rJS(window),
input_context;
gk.declareMethod('createIO', function (description, key) { gk.declareMethod('createIO', function (description, key) {
// indexedDB.deleteDatabase("jio:test"); // indexedDB.deleteDatabase("jio:test");
...@@ -31,6 +32,12 @@ ...@@ -31,6 +32,12 @@
return "jio getIO error : " + response.target.result; return "jio getIO error : " + response.target.result;
}); });
}) })
.declareMethod('display', function (attachment) {
input_context.style.display = "";
})
.declareMethod('noDisplay', function (attachment) {
input_context.style.display = "none";
})
.declareMethod('setIO', function (attachment, file) { .declareMethod('setIO', function (attachment, file) {
var gadget = this; var gadget = this;
return gadget.jio.putAttachment({ return gadget.jio.putAttachment({
...@@ -55,7 +62,7 @@ ...@@ -55,7 +62,7 @@
}) })
.declareAcquiredMethod("sendPlaylist", "sendPlaylist"); .declareAcquiredMethod("sendPlaylist", "sendPlaylist");
gk.ready(function (g) { gk.ready(function (g) {
var input_context = g.__element.getElementsByTagName('input')[0]; input_context = g.__element.getElementsByTagName('input')[0];
g.playlist = []; g.playlist = [];
g.createIO({ "type" : "indexeddb", g.createIO({ "type" : "indexeddb",
"database": "test"}, "database": "test"},
...@@ -70,7 +77,6 @@ ...@@ -70,7 +77,6 @@
g.sendPlaylist(g.playlist); g.sendPlaylist(g.playlist);
}); });
}); });
input_context.onchange = function () { input_context.onchange = function () {
var tmp, var tmp,
index, index,
......
...@@ -18,6 +18,12 @@ ...@@ -18,6 +18,12 @@
.declareMethod('getMax', function () { .declareMethod('getMax', function () {
return this.bar.max; return this.bar.max;
}) })
.declareMethod('display', function (attachment) {
this.bar.style.display = "";
})
.declareMethod('noDisplay', function (attachment) {
this.bar.style.display = "none";
})
.declareAcquiredMethod("setCurrentTime", "setCurrentTime"); .declareAcquiredMethod("setCurrentTime", "setCurrentTime");
gk.ready(function (g) { gk.ready(function (g) {
g.bar = g.__element.getElementsByTagName('progress')[0]; g.bar = g.__element.getElementsByTagName('progress')[0];
......
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
}) })
.declareMethod('getSize', function (size) { .declareMethod('getSize', function (size) {
return this.input.size; return this.input.size;
})
.declareMethod('display', function (attachment) {
this.input.style.display = "";
})
.declareMethod('noDisplay', function (attachment) {
this.input.style.display = "none";
}); });
gk.ready(function (g) { gk.ready(function (g) {
g.scroll = new BannerObject(); g.scroll = new BannerObject();
......
...@@ -17,11 +17,18 @@ ...@@ -17,11 +17,18 @@
.declareMethod('getMax', function () { .declareMethod('getMax', function () {
return this.bar.max; return this.bar.max;
}) })
.declareMethod('display', function (attachment) {
this.bar.style.display = "";
})
.declareMethod('noDisplay', function (attachment) {
this.bar.style.display = "none";
})
.declareAcquiredMethod("setVolume", "setVolume") .declareAcquiredMethod("setVolume", "setVolume")
.declareAcquiredMethod("getVolume", "getVolume"); //xxxx .declareAcquiredMethod("getVolume", "getVolume"); //xxxx
gk.ready(function (g) { gk.ready(function (g) {
g.bar = g.__element.getElementsByTagName('progress')[0]; g.bar = g.__element.getElementsByTagName('progress')[0];
g.bar.max = 1000; g.bar.max = 1000;
//g.bar.style.display = "none";
g.bar.onclick = function (e) { g.bar.onclick = function (e) {
var posX = e.clientX, var posX = e.clientX,
targetLeft = $(g.bar).offset().left; targetLeft = $(g.bar).offset().left;
......
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