2009-07-02 11:30:21 -07:00
|
|
|
/**
|
2009-07-11 05:03:36 -07:00
|
|
|
* Manage file selection state.
|
2009-07-02 11:30:21 -07:00
|
|
|
*/
|
2009-07-11 05:03:36 -07:00
|
|
|
function select_file(li) {
|
|
|
|
|
$(li).toggleClass("selected");
|
|
|
|
|
if ($("#gServerAdd span.selected").length) {
|
2009-08-05 22:17:03 -07:00
|
|
|
$("#gServerAddAddButton").enable(true).removeClass("ui-state-disabled");
|
2009-07-02 11:49:45 -07:00
|
|
|
} else {
|
2009-08-05 22:17:03 -07:00
|
|
|
$("#gServerAddAddButton").enable(false).addClass("ui-state-disabled");
|
2009-07-02 11:49:45 -07:00
|
|
|
}
|
2009-07-02 11:23:40 -07:00
|
|
|
}
|
|
|
|
|
|
2009-07-11 05:03:36 -07:00
|
|
|
/**
|
|
|
|
|
* Load a new directory
|
|
|
|
|
*/
|
|
|
|
|
function open_dir(path) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: GET_CHILDREN_URL.replace("__PATH__", path),
|
|
|
|
|
success: function(data, textStatus) {
|
|
|
|
|
$("#gServerAddTree").html(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-07 21:16:36 -07:00
|
|
|
function start_add() {
|
|
|
|
|
var paths = [];
|
2009-07-11 05:03:36 -07:00
|
|
|
$.each($("#gServerAdd span.selected"), function () {
|
|
|
|
|
paths.push($(this).attr("file"));
|
2009-06-04 23:23:11 +08:00
|
|
|
});
|
2009-07-11 05:03:36 -07:00
|
|
|
|
2009-07-07 21:16:36 -07:00
|
|
|
$.ajax({
|
|
|
|
|
url: START_URL,
|
|
|
|
|
type: "POST",
|
|
|
|
|
async: false,
|
|
|
|
|
data: { "paths[]": paths },
|
|
|
|
|
dataType: "json",
|
|
|
|
|
success: function(data, textStatus) {
|
2009-07-09 10:46:27 -07:00
|
|
|
$("#gStatus").html(data.status);
|
2009-07-07 21:16:36 -07:00
|
|
|
$("#gServerAdd .gProgressBar").progressbar("value", data.percent_complete);
|
|
|
|
|
setTimeout(function() { run_add(data.url); }, 0);
|
2009-06-04 23:23:11 +08:00
|
|
|
}
|
|
|
|
|
});
|
2009-07-07 21:16:36 -07:00
|
|
|
return false;
|
2009-06-04 23:23:11 +08:00
|
|
|
}
|
|
|
|
|
|
2009-07-07 21:16:36 -07:00
|
|
|
function run_add(url) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
|
async: false,
|
2009-03-10 21:30:33 +00:00
|
|
|
dataType: "json",
|
2009-02-28 20:12:54 +00:00
|
|
|
success: function(data, textStatus) {
|
2009-07-09 10:46:27 -07:00
|
|
|
$("#gStatus").html(data.status);
|
2009-07-07 21:16:36 -07:00
|
|
|
$("#gServerAdd .gProgressBar").progressbar("value", data.percent_complete);
|
|
|
|
|
if (data.done) {
|
2009-08-18 05:16:11 +08:00
|
|
|
$("#gServerAddProgress").slideUp();
|
2009-03-24 17:41:20 +00:00
|
|
|
} else {
|
2009-07-07 21:16:36 -07:00
|
|
|
setTimeout(function() { run_add(url); }, 0);
|
2009-03-24 17:41:20 +00:00
|
|
|
}
|
2009-07-07 21:16:36 -07:00
|
|
|
}
|
2009-02-28 20:12:54 +00:00
|
|
|
});
|
2009-04-06 00:15:45 +00:00
|
|
|
}
|
|
|
|
|
|