remove some more raw xmlhttp code

master
Andrew Dolgov 18 years ago
parent 9bc082151a
commit 288487e429

@ -718,14 +718,14 @@ function parse_counters(reply, scheduled_call) {
} }
} }
function parse_counters_reply(xmlhttp, scheduled_call) { function parse_counters_reply(transport, scheduled_call) {
if (!xmlhttp.responseXML) { if (!transport.responseXML) {
notify_error("Backend did not return valid XML", true); notify_error("Backend did not return valid XML", true);
return; return;
} }
var reply = xmlhttp.responseXML.firstChild; var reply = transport.responseXML.firstChild;
if (!reply) { if (!reply) {
notify_error("Backend did not return expected XML object", true); notify_error("Backend did not return expected XML object", true);
@ -1275,38 +1275,33 @@ function closeInfoBox(cleanup) {
function displayDlg(id, param) { function displayDlg(id, param) {
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
return
}
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
xmlhttp.open("GET", "backend.php?op=dlg&id=" +
param_escape(id) + "&param=" + param_escape(param), true);
xmlhttp.onreadystatechange=infobox_callback;
xmlhttp.send(null);
disableHotkeys(); disableHotkeys();
var query = "backend.php?op=dlg&id=" +
param_escape(id) + "&param=" + param_escape(param);
new Ajax.Request(query, {
onComplete: function (transport) {
infobox_callback2(transport);
} });
return false; return false;
} }
function infobox_submit_callback() { function infobox_submit_callback2(transport) {
if (xmlhttp.readyState == 4) { closeInfoBox();
closeInfoBox();
try {
// called from prefs, reload tab
if (active_tab) {
selectTab(active_tab, false);
}
} catch (e) { }
if (xmlhttp.responseText) { try {
notify_info(xmlhttp.responseText); // called from prefs, reload tab
if (active_tab) {
selectTab(active_tab, false);
} }
} catch (e) { }
if (transport.responseText) {
notify_info(transport.responseText);
} }
} }
@ -1352,19 +1347,8 @@ function infobox_callback2(transport) {
} }
} }
function infobox_callback() {
if (xmlhttp.readyState == 4) {
infobox_callback2(xmlhttp);
}
}
function addFilter() { function addFilter() {
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
return
}
var form = document.forms['filter_add_form']; var form = document.forms['filter_add_form'];
var reg_exp = form.reg_exp.value; var reg_exp = form.reg_exp.value;
@ -1375,9 +1359,10 @@ function addFilter() {
var query = Form.serialize("filter_add_form"); var query = Form.serialize("filter_add_form");
xmlhttp.open("GET", "backend.php?" + query, true); new Ajax.Request("backend.php?" + query, {
xmlhttp.onreadystatechange=infobox_submit_callback; onComplete: function (transport) {
xmlhttp.send(null); infobox_submit_callback2(transport);
} });
return true; return true;
} }
@ -1396,11 +1381,6 @@ function isValidURL(s) {
function qaddFeed() { function qaddFeed() {
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
return
}
var form = document.forms['feed_add_form']; var form = document.forms['feed_add_form'];
var feed_url = form.feed_url.value; var feed_url = form.feed_url.value;
@ -1421,14 +1401,11 @@ function qaddFeed() {
debug("subscribe q: " + query); debug("subscribe q: " + query);
/* xmlhttp.open("GET", "backend.php?" + query, true); new Ajax.Request("backend.php", {
xmlhttp.onreadystatechange=dlg_frefresh_callback; parameters: query,
xmlhttp.send(null); */ onComplete: function(transport) {
dlg_frefresh_callback(transport);
xmlhttp.open("POST", "backend.php", true); } });
xmlhttp.onreadystatechange=dlg_frefresh_callback;
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send(query);
return false; return false;
} }
@ -1667,35 +1644,46 @@ Position.Center = function(element, parent) {
element.style.left = (pw/2) - (w/2) - Position.deltaX + "px"; element.style.left = (pw/2) - (w/2) - Position.deltaX + "px";
} }
function labeltest_callback() {
var container = document.getElementById('label_test_result');
if (xmlhttp.readyState == 4) {
container.innerHTML=xmlhttp.responseText; function labeltest_callback(transport) {
try {
var container = document.getElementById('label_test_result');
container.innerHTML = transport.responseText;
if (!Element.visible(container)) { if (!Element.visible(container)) {
Effect.SlideDown(container, { duration : 0.5 }); Effect.SlideDown(container, { duration : 0.5 });
} }
notify(""); notify("");
} catch (e) {
exception_error("labeltest_callback", e);
} }
} }
function labelTest() { function labelTest() {
var container = document.getElementById('label_test_result'); try {
var container = document.getElementById('label_test_result');
var form = document.forms['label_edit_form']; var form = document.forms['label_edit_form'];
var sql_exp = form.sql_exp.value; var sql_exp = form.sql_exp.value;
var description = form.description.value; var description = form.description.value;
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" + var query = "backend.php?op=pref-labels&subop=test&expr=" +
param_escape(sql_exp) + "&descr=" + param_escape(description), true); param_escape(sql_exp) + "&descr=" + param_escape(description);
xmlhttp.onreadystatechange=labeltest_callback; new Ajax.Request(query, {
xmlhttp.send(null); onComplete: function (transport) {
labeltest_callback(transport);
} });
return false; return false;
} catch (e) {
exception_error("labelTest", e);
}
} }

@ -13,6 +13,19 @@ var caller_subop = false;
var sanity_check_done = false; var sanity_check_done = 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() { function replace_pubkey_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
try { try {
@ -82,31 +95,29 @@ function feedlist_callback() {
/* stub for subscription dialog */ /* stub for subscription dialog */
function dlg_frefresh_callback() { function dlg_frefresh_callback(transport) {
if (xmlhttp.readyState == 4) {
// setTimeout("updateFeedList()", 500);
try {
var container = document.getElementById('prefContent');
container.innerHTML=xmlhttp.responseText;
selectTab("feedConfig", true);
if (caller_subop) {
var tuple = caller_subop.split(":");
if (tuple[0] == 'editFeed') {
window.setTimeout('editFeed('+tuple[1]+')', 100);
}
caller_subop = false; try {
} var container = document.getElementById('prefContent');
if (typeof correctPNG != 'undefined') { container.innerHTML=transport.responseText;
correctPNG(); selectTab("feedConfig", true);
if (caller_subop) {
var tuple = caller_subop.split(":");
if (tuple[0] == 'editFeed') {
window.setTimeout('editFeed('+tuple[1]+')', 100);
} }
notify("");
} catch (e) { caller_subop = false;
exception_error("feedlist_callback", e);
} }
if (typeof correctPNG != 'undefined') {
correctPNG();
}
notify("");
} catch (e) {
exception_error("feedlist_callback", e);
} }
} }
function filterlist_callback() { function filterlist_callback() {

Loading…
Cancel
Save