-var xmlhttp = false;
-
var active_feed_cat = false;
var active_tab = false;
-var xmlhttp = Ajax.getTransport();
-
var init_params = new Array();
var caller_subop = false;
var sanity_check_done = false;
var hotkey_prefix = false;
-function infobox_callback() {
- if (xmlhttp.readyState == 4) {
- infobox_callback2(xmlhttp);
- }
-}
-
-function infobox_submit_callback() {
- if (xmlhttp.readyState == 4) {
- infobox_submit_callback2(xmlhttp);
- }
-}
-
-
function replace_pubkey_callback(transport) {
try {
var link = document.getElementById("pubGenAddress");
}
}
-function userlist_callback() {
- var container = document.getElementById('prefContent');
- if (xmlhttp.readyState == 4) {
- container.innerHTML=xmlhttp.responseText;
- notify("");
- remove_splash();
+function userlist_callback2(transport) {
+ try {
+ var container = document.getElementById('prefContent');
+ if (transport.readyState == 4) {
+ container.innerHTML=transport.responseText;
+ notify("");
+ remove_splash();
+ }
+ } catch (e) {
+ exception_error("userlist_callback2", e);
}
}
}
}
-function notify_callback() {
- if (xmlhttp.readyState == 4) {
- notify_callback2(xmlhttp);
- }
-}
-
function notify_callback2(transport) {
notify_info(transport.responseText);
}
}
-function changepass_callback() {
+function changepass_callback2(transport) {
try {
- if (xmlhttp.readyState == 4) {
- if (xmlhttp.responseText.indexOf("ERROR: ") == 0) {
- notify_error(xmlhttp.responseText.replace("ERROR: ", ""));
+ if (transport.responseText.indexOf("ERROR: ") == 0) {
+ notify_error(transport.responseText.replace("ERROR: ", ""));
} else {
- notify_info(xmlhttp.responseText);
+ notify_info(transport.responseText);
var warn = document.getElementById("default_pass_warning");
if (warn) warn.style.display = "none";
}
document.forms['change_pass_form'].reset();
- }
} catch (e) {
- exception_error("changepass_callback", e);
+ exception_error("changepass_callback2", e);
}
}
function updateUsersList(sort_key) {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
- var user_search = document.getElementById("user_search");
- var search = "";
- if (user_search) { search = user_search.value; }
+ try {
- xmlhttp.open("GET", "backend.php?op=pref-users&sort="
- + param_escape(sort_key) +
- "&search=" + param_escape(search), true);
- xmlhttp.onreadystatechange=userlist_callback;
- xmlhttp.send(null);
+ var user_search = document.getElementById("user_search");
+ var search = "";
+ if (user_search) { search = user_search.value; }
+
+ var query = "backend.php?op=pref-users&sort="
+ + param_escape(sort_key) +
+ "&search=" + param_escape(search);
+
+ new Ajax.Request(query, {
+ onComplete: function(transport) {
+ userlist_callback2(transport);
+ } });
+ } catch (e) {
+ exception_error("updateUsersList", e);
+ }
}
function addLabel() {
function addFeedCat() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
var cat = document.getElementById("fadd_cat");
if (cat.value.length == 0) {
}
function addUser() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
- var sqlexp = document.getElementById("uadd_box");
-
- if (sqlexp.value.length == 0) {
- alert(__("Can't add user: no login specified."));
- } else {
- notify_progress("Adding user...");
+ try {
- xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
- param_escape(sqlexp.value), true);
-
- xmlhttp.onreadystatechange=userlist_callback;
- xmlhttp.send(null);
+ var sqlexp = document.getElementById("uadd_box");
+
+ if (sqlexp.value.length == 0) {
+ alert(__("Can't add user: no login specified."));
+ } else {
+ notify_progress("Adding user...");
+
+ var query = "backend.php?op=pref-users&subop=add&login=" +
+ param_escape(sqlexp.value);
+
+ new Ajax.Request(query, {
+ onComplete: function(transport) {
+ userlist_callback2(transport);
+ } });
+
+ sqlexp.value = "";
+ }
- sqlexp.value = "";
+ } catch (e) {
+ exception_error("addUser", e);
}
-
}
function editUser(id) {
function removeSelectedUsers() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
- var sel_rows = getSelectedUsers();
-
- if (sel_rows.length > 0) {
-
- var ok = confirm(__("Remove selected users?"));
+ try {
- if (ok) {
- notify_progress("Removing selected users...");
+ var sel_rows = getSelectedUsers();
+
+ if (sel_rows.length > 0) {
+
+ var ok = confirm(__("Remove selected users?"));
+
+ if (ok) {
+ notify_progress("Removing selected users...");
+
+ var query = "backend.php?op=pref-users&subop=remove&ids="+
+ param_escape(sel_rows.toString());
+
+ new Ajax.Request(query, {
+ onComplete: function(transport) {
+ userlist_callback2(transport);
+ } });
+
+ }
- xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
- param_escape(sel_rows.toString()), true);
- xmlhttp.onreadystatechange=userlist_callback;
- xmlhttp.send(null);
+ } else {
+ alert(__("No users are selected."));
}
- } else {
- alert(__("No users are selected."));
+ } catch (e) {
+ exception_error("removeSelectedUsers", e);
}
return false;
function purgeSelectedFeeds() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
var sel_rows = getSelectedFeeds();
if (sel_rows.length > 0) {
function removeSelectedFeedCats() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
var sel_rows = getSelectedFeedCats();
if (sel_rows.length > 0) {
function feedEditCancel() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
try {
document.getElementById("subscribe_to_feed_btn").disabled = false;
document.getElementById("top25_feeds_btn").disabled = false;
function userEditCancel() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
selectPrefRows('user', false); // cleanup feed selection
closeInfoBox();
function filterEditCancel() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
try {
document.getElementById("create_filter_btn").disabled = false;
selectPrefRows('filter', false); // cleanup feed selection
function userEditSave() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
- var login = document.forms["user_edit_form"].login.value;
+ try {
- if (login.length == 0) {
- alert(__("Login field cannot be blank."));
- return;
- }
+ var login = document.forms["user_edit_form"].login.value;
- notify_progress("Saving user...");
-
- closeInfoBox();
-
- var query = Form.serialize("user_edit_form");
+ if (login.length == 0) {
+ alert(__("Login field cannot be blank."));
+ return;
+ }
+
+ notify_progress("Saving user...");
+
+ closeInfoBox();
+
+ var query = Form.serialize("user_edit_form");
+
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ userlist_callback2(transport);
+ } });
- xmlhttp.open("GET", "backend.php?" + query, true);
- xmlhttp.onreadystatechange=userlist_callback;
- xmlhttp.send(null);
+ } catch (e) {
+ exception_error("userEditSave", e);
+ }
return false;
+
}
}
function resetSelectedUserPass() {
- var rows = getSelectedUsers();
-
- if (rows.length == 0) {
- alert(__("No users are selected."));
- return;
- }
-
- if (rows.length > 1) {
- alert(__("Please select only one user."));
- return;
- }
- var ok = confirm(__("Reset password of selected user?"));
+ try {
- if (ok) {
- notify_progress("Resetting password for selected user...");
+ var rows = getSelectedUsers();
- var id = rows[0];
+ if (rows.length == 0) {
+ alert(__("No users are selected."));
+ return;
+ }
+
+ if (rows.length > 1) {
+ alert(__("Please select only one user."));
+ return;
+ }
+
+ var ok = confirm(__("Reset password of selected user?"));
+
+ if (ok) {
+ notify_progress("Resetting password for selected user...");
+
+ var id = rows[0];
+
+ var query = "backend.php?op=pref-users&subop=resetPass&id=" +
+ param_escape(id);
+
+ new Ajax.Request(query, {
+ onComplete: function(transport) {
+ userlist_callback2(transport);
+ } });
- xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
- param_escape(id), true);
- xmlhttp.onreadystatechange=userlist_callback;
- xmlhttp.send(null);
+ }
+
+ } catch (e) {
+ exception_error("resetSelectedUserPass", e);
}
}
try {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
try {
var c = document.getElementById('prefContent');
c.scrollTop = 0;
}
}
-function backend_sanity_check_callback() {
+function backend_sanity_check_callback2(transport) {
- if (xmlhttp.readyState == 4) {
+ try {
- try {
+ if (sanity_check_done) {
+ fatalError(11, "Sanity check request received twice. This can indicate "+
+ "presence of Firebug or some other disrupting extension. "+
+ "Please disable it and try again.");
+ return;
+ }
- if (sanity_check_done) {
- fatalError(11, "Sanity check request received twice. This can indicate "+
- "presence of Firebug or some other disrupting extension. "+
- "Please disable it and try again.");
- return;
- }
+ if (!transport.responseXML) {
+ fatalError(3, "Sanity Check: Received reply is not XML",
+ transport.responseText);
+ return;
+ }
- if (!xmlhttp.responseXML) {
- fatalError(3, "Sanity Check: Received reply is not XML",
- xmlhttp.responseText);
- return;
- }
-
- var reply = xmlhttp.responseXML.firstChild.firstChild;
-
- if (!reply) {
- fatalError(3, "Sanity Check: Invalid RPC reply", xmlhttp.responseText);
- return;
- }
-
- var error_code = reply.getAttribute("error-code");
-
- if (error_code && error_code != 0) {
- return fatalError(error_code, reply.getAttribute("error-msg"));
- }
+ var reply = transport.responseXML.firstChild.firstChild;
+
+ if (!reply) {
+ fatalError(3, "Sanity Check: Invalid RPC reply", transport.responseText);
+ return;
+ }
+
+ var error_code = reply.getAttribute("error-code");
- debug("sanity check ok");
+ if (error_code && error_code != 0) {
+ return fatalError(error_code, reply.getAttribute("error-msg"));
+ }
- var params = reply.nextSibling;
+ debug("sanity check ok");
- if (params) {
- debug('reading init-params...');
- var param = params.firstChild;
+ var params = reply.nextSibling;
- while (param) {
- var k = param.getAttribute("key");
- var v = param.getAttribute("value");
- debug(k + " => " + v);
- init_params[k] = v;
- param = param.nextSibling;
- }
+ if (params) {
+ debug('reading init-params...');
+ var param = params.firstChild;
+
+ while (param) {
+ var k = param.getAttribute("key");
+ var v = param.getAttribute("value");
+ debug(k + " => " + v);
+ init_params[k] = v;
+ param = param.nextSibling;
}
+ }
- sanity_check_done = true;
+ sanity_check_done = true;
- init_second_stage();
+ init_second_stage();
- } catch (e) {
- exception_error("backend_sanity_check_callback", e);
- }
- }
+ } catch (e) {
+ exception_error("backend_sanity_check_callback", e);
+ }
}
function init_second_stage() {
debug('debug mode activated');
}
- // IE kludge
- if (!xmlhttp) {
- document.getElementById("prefContent").innerHTML =
- "<b>Fatal error:</b> This program needs XmlHttpRequest " +
- "to function properly. Your browser doesn't seem to support it.";
- return;
- }
-
loading_set_progress(30);
- xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
- xmlhttp.onreadystatechange=backend_sanity_check_callback;
- xmlhttp.send(null);
+ var query = "backend.php?op=rpc&subop=sanityCheck";
+
+ new Ajax.Request(query, {
+ onComplete: function(transport) {
+ backend_sanity_check_callback2(transport);
+ } });
} catch (e) {
exception_error("init", e);
try {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return false;
- }
-
var f = document.forms["change_pass_form"];
if (f) {
var query = Form.serialize("change_pass_form");
notify_progress("Trying to change password...");
-
- xmlhttp.open("POST", "backend.php", true);
- xmlhttp.onreadystatechange=changepass_callback;
- xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xmlhttp.send(query);
+
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ changepass_callback2(transport);
+ } });
+
} catch (e) {
exception_error("changeUserPassword", e);
try {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return false;
- }
-
var query = Form.serialize("change_email_form");
notify_progress("Trying to change e-mail...");
- xmlhttp.open("POST", "backend.php", true);
- xmlhttp.onreadystatechange=notify_callback;
- xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xmlhttp.send(query);
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ notify_callback2(transport);
+ } });
} catch (e) {
exception_error("changeUserPassword", e);
function pubRegenKey() {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return false;
- }
-
var ok = confirm(__("Replace current publishing address with a new one?"));
if (ok) {
return false;
}
-function pubToClipboard() {
-
- try {
-
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return false;
- }
-
- var link = document.getElementById("pubGenAddress");
- alert(link.href);
-
- } catch (e) {
- exception_error("pubToClipboard", e);
- }
-
- return false;
-}
-
function validatePrefsSave() {
try {
query = query + "&subop=save-config";
debug(query);
- xmlhttp.open("POST", "backend.php", true);
- xmlhttp.onreadystatechange=notify_callback;
- xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
- xmlhttp.send(query);
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ notify_callback2(transport);
+ } });
+
}
} catch (e) {
function feedsEditSave() {
try {
- if (!xmlhttp_ready(xmlhttp)) {
- printLockingError();
- return
- }
-
var ok = confirm(__("Save changes to selected feeds?"));
if (ok) {