Commit 33236ff1 authored by Xiaowu Zhang's avatar Xiaowu Zhang

add remove music functionality

parent da5be247
...@@ -77,6 +77,11 @@ ...@@ -77,6 +77,11 @@
return this.save[param_list[0]]; return this.save[param_list[0]];
}) })
.allowPublicAcquisition("allDocs", function (param_list) { .allowPublicAcquisition("allDocs", function (param_list) {
if (this.storageType !== 0) {
param_list[0].save = true;
} else {
param_list[0].save = false;
}
return this.getDeclaredGadget(storageType(this.storageType)) return this.getDeclaredGadget(storageType(this.storageType))
.push(function (jio_gadget) { .push(function (jio_gadget) {
return jio_gadget.allDocs.apply(jio_gadget, param_list); return jio_gadget.allDocs.apply(jio_gadget, param_list);
...@@ -118,6 +123,14 @@ ...@@ -118,6 +123,14 @@
return jio_gadget.get.apply(jio_gadget, param_list); return jio_gadget.get.apply(jio_gadget, param_list);
}); });
}) })
.allowPublicAcquisition("jio_remove", function (param_list) {
if (this.storageType === 0) {
return this.getDeclaredGadget(storageType(this.storageType))
.push(function (jio_gadget) {
return jio_gadget.remove.apply(jio_gadget, param_list);
});
}
})
.allowPublicAcquisition("displayThisTitle", function (param_list) { .allowPublicAcquisition("displayThisTitle", function (param_list) {
var header = this.__element.getElementsByTagName("h1")[0]; var header = this.__element.getElementsByTagName("h1")[0];
header.innerHTML = param_list[0]; header.innerHTML = param_list[0];
......
...@@ -13,15 +13,17 @@ ...@@ -13,15 +13,17 @@
.declareMethod('createJio', function (jio_options) { .declareMethod('createJio', function (jio_options) {
this.state_parameter_dict.jio_storage = jIO.createJIO(jio_options); this.state_parameter_dict.jio_storage = jIO.createJIO(jio_options);
}) })
.declareMethod('allDocs', function () { .declareMethod('allDocs', function (options) {
var storage = this.state_parameter_dict.jio_storage, var storage = this.state_parameter_dict.jio_storage,
that = this; that = this;
/* if (that.save.data !== undefined) { if (that.save.data !== undefined) {
return that.save; return that.save;
}*/ }
return storage.allDocs.apply(storage, arguments) return storage.allDocs(options)
.then(function (result) { .then(function (result) {
that.save = result; if (options.save) {
that.save = result;
}
return result; return result;
}); });
}) })
...@@ -62,6 +64,10 @@ ...@@ -62,6 +64,10 @@
var storage = this.state_parameter_dict.jio_storage; var storage = this.state_parameter_dict.jio_storage;
return storage.post.apply(storage, arguments); return storage.post.apply(storage, arguments);
}) })
.declareMethod('remove', function () {
var storage = this.state_parameter_dict.jio_storage;
return storage.remove.apply(storage, arguments);
})
.declareMethod('put', function () { .declareMethod('put', function () {
var storage = this.state_parameter_dict.jio_storage; var storage = this.state_parameter_dict.jio_storage;
return storage.put.apply(storage, arguments); return storage.put.apply(storage, arguments);
......
...@@ -14,7 +14,13 @@ ...@@ -14,7 +14,13 @@
{{#each rows}} {{#each rows}}
<li> <li>
<a href=#page=control&id={{this.id}}> <a href=#page=control&id={{this.id}}>
{{this.doc.title}} </a></li> {{this.doc.title}}
</a>
<a href=#page=playlist&id={{this.id}}&action=delete>
data-rel=popup
data-position-to=window
</a>
</li>
{{/each}} {{/each}}
</script> </script>
...@@ -30,12 +36,12 @@ ...@@ -30,12 +36,12 @@
<input type="search" class="research" placeholder="research..."/> <input type="search" class="research" placeholder="research..."/>
<div data-role="content"> <div data-role="content">
<ul data-role="listview" data-split-theme="d"> <ul data-role="listview" data-split-icon="delete" data-split-theme="d">
</ul> </ul>
</div> </div>
<div data-role="footer" data-position="fixed" data-theme="b"> <div data-role="footer" data-position="fixed" data-theme="b">
<div data-role="navbar" > <div data-role="navbar" >
<ul> <ul>
<li><a data-role="button" class="offline" data-icon="search">offline</a></li> <li><a data-role="button" class="offline" data-icon="search">offline</a></li>
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
.getElementById('rows-template').innerHTML, .getElementById('rows-template').innerHTML,
rows_template = Handlebars.compile(rows_template_source); rows_template = Handlebars.compile(rows_template_source);
gk.declareAcquiredMethod("allDocs", "allDocs") gk.declareAcquiredMethod("allDocs", "allDocs")
.declareAcquiredMethod("jio_remove", "jio_remove")
.declareAcquiredMethod("displayThisPage", "displayThisPage") .declareAcquiredMethod("displayThisPage", "displayThisPage")
.declareAcquiredMethod("displayThisTitle", "displayThisTitle") .declareAcquiredMethod("displayThisTitle", "displayThisTitle")
.declareAcquiredMethod("plCreateHttpStorage", "plCreateHttpStorage") .declareAcquiredMethod("plCreateHttpStorage", "plCreateHttpStorage")
...@@ -40,6 +41,13 @@ ...@@ -40,6 +41,13 @@
gadget.__element.getElementsByClassName('online')[0] gadget.__element.getElementsByClassName('online')[0]
.href = param_list[2]; .href = param_list[2];
}) })
.push(function () {
var id = options.id;
if (options.action === "delete") {
delete options.id;
return gadget.jio_remove({"_id" : id});
}
})
.push(function () { .push(function () {
return gadget.allDocs({"include_docs": true}); return gadget.allDocs({"include_docs": true});
}) })
...@@ -67,8 +75,10 @@ ...@@ -67,8 +75,10 @@
$(list).listview("refresh"); $(list).listview("refresh");
}) })
.fail(function (error) { .fail(function (error) {
document.getElementsByTagName('body')[0].textContent = if ((error instanceof RSVP.CancellationError)) {
"network error: ip maybe not defined"; document.getElementsByTagName('body')[0].textContent =
JSON.stringify(error);
}
}); });
}) })
.declareMethod('startService', function () { .declareMethod('startService', function () {
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
if (!(error instanceof RSVP.CancellationError)) { if (!(error instanceof RSVP.CancellationError)) {
info_context.innerHTML += info_context.innerHTML +=
input_context.files[uploaded].name + input_context.files[uploaded].name +
" failed : storage insufficient"; " failed : storage maybe insufficient";
return g.plEnablePage(); return g.plEnablePage();
} }
document.getElementsByTagName('body')[0].textContent = document.getElementsByTagName('body')[0].textContent =
......
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