prefs: some async work (4)

This commit is contained in:
Andrew Dolgov 2009-01-24 08:25:21 +01:00
parent 60715b53d5
commit 23e51f4092
1 changed files with 73 additions and 83 deletions

156
prefs.js
View File

@ -53,12 +53,6 @@ function replace_pubkey_callback() {
} }
} }
function feedlist_callback() {
if (xmlhttp.readyState == 4) {
return feedlist_callback2(xmlhttp);
}
}
function feedlist_callback2(transport) { function feedlist_callback2(transport) {
try { try {
@ -102,13 +96,6 @@ function filterlist_callback2(transport) {
remove_splash(); remove_splash();
} }
function filterlist_callback() {
if (xmlhttp.readyState == 4) {
filterlist_callback2(xmlhttp);
}
}
function labellist_callback2(transport) { function labellist_callback2(transport) {
try { try {
@ -566,27 +553,32 @@ function removeSelectedUsers() {
function removeSelectedFilters() { function removeSelectedFilters() {
if (!xmlhttp_ready(xmlhttp)) { try {
printLockingError();
return
}
var sel_rows = getSelectedFilters(); var sel_rows = getSelectedFilters();
if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected filters?"));
if (ok) {
notify_progress("Removing selected filters...");
xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+ if (sel_rows.length > 0) {
param_escape(sel_rows.toString()), true);
xmlhttp.onreadystatechange=filterlist_callback; var ok = confirm(__("Remove selected filters?"));
xmlhttp.send(null);
if (ok) {
notify_progress("Removing selected filters...");
var query = "backend.php?op=pref-filters&subop=remove&ids="+
param_escape(sel_rows.toString());
new Ajax.Request(query, {
onComplete: function(transport) {
filterlist_callback2(transport);
} });
}
} else {
alert(__("No filters are selected."));
} }
} else {
alert(__("No filters are selected.")); } catch (e) {
exception_error("removeSelectedFilters", e);
} }
return false; return false;
@ -831,31 +823,24 @@ function userEditSave() {
function filterEditSave() { function filterEditSave() {
if (!xmlhttp_ready(xmlhttp)) { try {
printLockingError();
return
}
/* if (!is_opera()) { notify_progress("Saving filter...");
var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
if (reg_exp.length == 0) { var query = "backend.php?" + Form.serialize("filter_edit_form");
alert("Filter expression field cannot be blank.");
return; closeInfoBox();
}
} */ document.getElementById("create_filter_btn").disabled = false;
notify_progress("Saving filter..."); new Ajax.Request(query, {
onComplete: function(transport) {
filterlist_callback2(transport);
} });
var query = Form.serialize("filter_edit_form"); } catch (e) {
exception_error("filterEditSave", e);
closeInfoBox(); }
document.getElementById("create_filter_btn").disabled = false;
xmlhttp.open("GET", "backend.php?" + query, true);
xmlhttp.onreadystatechange=filterlist_callback;
xmlhttp.send(null);
return false; return false;
} }
@ -1031,22 +1016,25 @@ function validateOpmlImport() {
} }
function updateFilterList(sort_key) { function updateFilterList(sort_key) {
try {
if (!xmlhttp_ready(xmlhttp)) { var filter_search = document.getElementById("filter_search");
printLockingError(); var search = "";
return if (filter_search) { search = filter_search.value; }
var query = "backend.php?op=pref-filters&sort=" +
param_escape(sort_key) +
"&search=" + param_escape(search);
new Ajax.Request(query, {
onComplete: function(transport) {
filterlist_callback2(transport);
} });
} catch (e) {
exception_error("updateFilterList", e);
} }
var filter_search = document.getElementById("filter_search");
var search = "";
if (filter_search) { search = filter_search.value; }
xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" +
param_escape(sort_key) +
"&search=" + param_escape(search), true);
xmlhttp.onreadystatechange=filterlist_callback;
xmlhttp.send(null);
} }
function updateLabelList(sort_key) { function updateLabelList(sort_key) {
@ -1951,30 +1939,32 @@ function removeFilter(id, title) {
function unsubscribeFeed(id, title) { function unsubscribeFeed(id, title) {
if (!xmlhttp_ready(xmlhttp)) { try {
printLockingError();
return
}
var msg = __("Unsubscribe from %s?").replace("%s", title); var msg = __("Unsubscribe from %s?").replace("%s", title);
var ok = confirm(msg);
if (ok) {
closeInfoBox();
notify_progress("Removing feed...");
xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+ var ok = confirm(msg);
param_escape(id), true);
xmlhttp.onreadystatechange=filterlist_callback; if (ok) {
xmlhttp.send(null); closeInfoBox();
notify_progress("Removing feed...");
var query = "backend.php?op=pref-feeds&subop=remove&ids="+
param_escape(id);
new Ajax.Request(query, {
onComplete: function(transport) {
feedlist_callback2(transport);
} });
}
} catch (e) {
exception_error("unsubscribeFeed", e);
} }
return false; return false;
return false;
} }
function feedsEditSave() { function feedsEditSave() {