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

add remove music functionality

parent da5be247
......@@ -77,6 +77,11 @@
return this.save[param_list[0]];
})
.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))
.push(function (jio_gadget) {
return jio_gadget.allDocs.apply(jio_gadget, param_list);
......@@ -118,6 +123,14 @@
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) {
var header = this.__element.getElementsByTagName("h1")[0];
header.innerHTML = param_list[0];
......
......@@ -13,15 +13,17 @@
.declareMethod('createJio', function (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,
that = this;
/* if (that.save.data !== undefined) {
if (that.save.data !== undefined) {
return that.save;
}*/
return storage.allDocs.apply(storage, arguments)
}
return storage.allDocs(options)
.then(function (result) {
that.save = result;
if (options.save) {
that.save = result;
}
return result;
});
})
......@@ -62,6 +64,10 @@
var storage = this.state_parameter_dict.jio_storage;
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 () {
var storage = this.state_parameter_dict.jio_storage;
return storage.put.apply(storage, arguments);
......
......@@ -14,7 +14,13 @@
{{#each rows}}
<li>
<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}}
</script>
......@@ -30,12 +36,12 @@
<input type="search" class="research" placeholder="research..."/>
<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>
</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" >
<ul>
<li><a data-role="button" class="offline" data-icon="search">offline</a></li>
......
......@@ -10,6 +10,7 @@
.getElementById('rows-template').innerHTML,
rows_template = Handlebars.compile(rows_template_source);
gk.declareAcquiredMethod("allDocs", "allDocs")
.declareAcquiredMethod("jio_remove", "jio_remove")
.declareAcquiredMethod("displayThisPage", "displayThisPage")
.declareAcquiredMethod("displayThisTitle", "displayThisTitle")
.declareAcquiredMethod("plCreateHttpStorage", "plCreateHttpStorage")
......@@ -40,6 +41,13 @@
gadget.__element.getElementsByClassName('online')[0]
.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 () {
return gadget.allDocs({"include_docs": true});
})
......@@ -67,8 +75,10 @@
$(list).listview("refresh");
})
.fail(function (error) {
document.getElementsByTagName('body')[0].textContent =
"network error: ip maybe not defined";
if ((error instanceof RSVP.CancellationError)) {
document.getElementsByTagName('body')[0].textContent =
JSON.stringify(error);
}
});
})
.declareMethod('startService', function () {
......
......@@ -57,7 +57,7 @@
if (!(error instanceof RSVP.CancellationError)) {
info_context.innerHTML +=
input_context.files[uploaded].name +
" failed : storage insufficient";
" failed : storage maybe insufficient";
return g.plEnablePage();
}
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