Commit 0f223c59 authored by Tristan Cavelier's avatar Tristan Cavelier

dashboard scripts supports more than 1000 times

parent 025d3217
...@@ -319,8 +319,9 @@ function command(method, num) { ...@@ -319,8 +319,9 @@ function command(method, num) {
} }
} }
function doCommandNTimes(method) { function doCommandNTimes(method, i) {
var i = -1, n = 0, lock, promise_list = []; var n = 0, lock, promise_list = [];
i = i > 0 ? i : 0;
n = parseInt(select("#times").value, 10); n = parseInt(select("#times").value, 10);
lock = select("#times-lock").checked; lock = select("#times-lock").checked;
if (!lock) { if (!lock) {
...@@ -329,10 +330,13 @@ function doCommandNTimes(method) { ...@@ -329,10 +330,13 @@ function doCommandNTimes(method) {
if (!isFinite(n)) { if (!isFinite(n)) {
n = 1; n = 1;
} }
while (++i < n) { return command(method, ++i).
promise_list.push(command(method, i)); then(function (answer) {
} if (i < n) {
return RSVP.all(promise_list); return doCommandNTimes(method, i);
}
return answer;
});
} }
function post() { function post() {
...@@ -376,24 +380,24 @@ function scriptLogLocalStorage() { ...@@ -376,24 +380,24 @@ function scriptLogLocalStorage() {
function scriptRemoveAllDocs() { function scriptRemoveAllDocs() {
var original_metadata_value = select('#metadata').value; var original_metadata_value = select('#metadata').value;
return command("allDocs").then(function (answer) { return command("allDocs").then(function (answer) {
return RSVP.all(answer.data.rows.map(function (row) { return jIO.util.forEach(answer.data.rows, function (row) {
select("#metadata").value = JSON.stringify({"_id": row.id}); select("#metadata").value = JSON.stringify({"_id": row.id});
var ret = command("remove"); var ret = command("remove");
select('#metadata').value = original_metadata_value; select('#metadata').value = original_metadata_value;
return ret; return ret;
})); });
}); });
} }
function scriptRepairAllDocs() { function scriptRepairAllDocs() {
var original_metadata_value = select('#metadata').value; var original_metadata_value = select('#metadata').value;
return command("allDocs").then(function (answer) { return command("allDocs").then(function (answer) {
return RSVP.all(answer.data.rows.map(function (row) { return jIO.util.forEach(answer.data.rows, function (row) {
select("#metadata").value = JSON.stringify({"_id": row.id}); select("#metadata").value = JSON.stringify({"_id": row.id});
var ret = command("repair"); var ret = command("repair");
select('#metadata').value = original_metadata_value; select("#metadata").value = original_metadata_value;
return ret; return ret;
})); });
}); });
} }
//--> //-->
......
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