Commit cc1c64af authored by Xiaowu Zhang's avatar Xiaowu Zhang

fix uri unknown bug

parent 15efd68b
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
.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);
this.save = {};
}) })
.declareMethod('allDocs', function (options) { .declareMethod('allDocs', function (options) {
var storage = this.state_parameter_dict.jio_storage, var storage = this.state_parameter_dict.jio_storage,
...@@ -35,7 +36,8 @@ ...@@ -35,7 +36,8 @@
if (result.data !== undefined) { if (result.data !== undefined) {
length = result.data.rows.length; length = result.data.rows.length;
for (i = 0; i < length; i += 1) { for (i = 0; i < length; i += 1) {
if (result.data.rows[i].id === encodeURI(param._id)) { //xxx if ((result.data.rows[i].id === encodeURI(param._id))
|| (result.data.rows[i].id === param._id)) {
return ({"data": {"title" : result.data.rows[i].doc.title}}); return ({"data": {"title" : result.data.rows[i].doc.title}});
} }
} }
......
...@@ -158,6 +158,7 @@ ...@@ -158,6 +158,7 @@
gk.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") gk.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_remove", "jio_remove")
.declareAcquiredMethod("plSave", "plSave") .declareAcquiredMethod("plSave", "plSave")
.declareAcquiredMethod("plGive", "plGive") .declareAcquiredMethod("plGive", "plGive")
.declareAcquiredMethod("displayThisPage", "displayThisPage") .declareAcquiredMethod("displayThisPage", "displayThisPage")
...@@ -216,8 +217,14 @@ ...@@ -216,8 +217,14 @@
g.url = URL.createObjectURL(blob); g.url = URL.createObjectURL(blob);
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
window.location = g.__element if (!(error instanceof RSVP.CancellationError)) {
.getElementsByClassName("next")[0].href; window.location = g.__element
.getElementsByClassName("next")[0].href;
if ((error.status === "404")
&& (error.method === "getAttachment")) {
return g.jio_remove({"_id" : error.id});
}
}
}); });
} }
}) })
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
.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("plSave", "plSave")
.declareAcquiredMethod("plGive", "plGive")
.declareAcquiredMethod("jio_remove", "jio_remove") .declareAcquiredMethod("jio_remove", "jio_remove")
.declareAcquiredMethod("displayThisPage", "displayThisPage") .declareAcquiredMethod("displayThisPage", "displayThisPage")
.declareAcquiredMethod("displayThisTitle", "displayThisTitle") .declareAcquiredMethod("displayThisTitle", "displayThisTitle")
...@@ -42,7 +44,14 @@ ...@@ -42,7 +44,14 @@
.href = param_list[2]; .href = param_list[2];
}) })
.push(function () { .push(function () {
return gadget.plGive("ip");
})
.push(function (value) {
var id = options.id; var id = options.id;
if (value !== undefined) {
gadget.__element.getElementsByClassName('inputIp')[0]
.value = value;
}
if (options.action === "delete") { if (options.action === "delete") {
delete options.id; delete options.id;
return gadget.jio_remove({"_id" : id}); return gadget.jio_remove({"_id" : id});
...@@ -75,9 +84,9 @@ ...@@ -75,9 +84,9 @@
$(list).listview("refresh"); $(list).listview("refresh");
}) })
.fail(function (error) { .fail(function (error) {
if ((error instanceof RSVP.CancellationError)) { if (!(error instanceof RSVP.CancellationError)) {
document.getElementsByTagName('body')[0].textContent = document.getElementsByTagName('body')[0].textContent =
JSON.stringify(error); "network ip not correct";
} }
}); });
}) })
...@@ -105,7 +114,13 @@ ...@@ -105,7 +114,13 @@
}); });
}), }),
loopEventListener(ip, "change", false, function () { loopEventListener(ip, "change", false, function () {
return g.plCreateHttpStorage(ip.value); return new RSVP.Queue()
.push(function () {
return g.plCreateHttpStorage(ip.value);
})
.push(function () {
return g.plSave({"ip": ip.value});
});
}) })
]);//any ]);//any
});//rsvp });//rsvp
......
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