remove some more raw xmlhttp code

This commit is contained in:
Andrew Dolgov 2007-08-25 13:11:54 +01:00
parent 9bc082151a
commit 288487e429
2 changed files with 92 additions and 93 deletions

View File

@ -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,25 +1275,22 @@ 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 { try {
@ -1303,10 +1300,8 @@ function infobox_submit_callback() {
} }
} catch (e) { } } catch (e) { }
if (xmlhttp.responseText) { if (transport.responseText) {
notify_info(xmlhttp.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,20 +1644,25 @@ 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() {
try {
var container = document.getElementById('label_test_result'); var container = document.getElementById('label_test_result');
var form = document.forms['label_edit_form']; var form = document.forms['label_edit_form'];
@ -1690,12 +1672,18 @@ function labelTest() {
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);
}
} }

View File

@ -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,13 +95,11 @@ 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 { try {
var container = document.getElementById('prefContent'); var container = document.getElementById('prefContent');
container.innerHTML=xmlhttp.responseText; container.innerHTML=transport.responseText;
selectTab("feedConfig", true); selectTab("feedConfig", true);
if (caller_subop) { if (caller_subop) {
@ -106,7 +117,7 @@ function dlg_frefresh_callback() {
} catch (e) { } catch (e) {
exception_error("feedlist_callback", e); exception_error("feedlist_callback", e);
} }
}
} }
function filterlist_callback() { function filterlist_callback() {