remove raw xmlhttp code from tt-rss.js

master
Andrew Dolgov 18 years ago
parent 4ffa126ec3
commit f3c6bf6e3d

@ -1,4 +1,3 @@
var xmlhttp = false;
var total_unread = 0;
var first_run = true;
var display_tags = false;
@ -7,7 +6,7 @@ var active_title_text = "";
var current_subtitle = "";
var daemon_enabled = false;
var daemon_refresh_only = false;
var _qfd_deleted_feed = 0;
//var _qfd_deleted_feed = 0;
var firsttime_update = true;
var cookie_lifetime = 0;
var active_feed_id = 0;
@ -15,8 +14,6 @@ var active_feed_is_cat = false;
var number_of_feeds = 0;
var sanity_check_done = false;
var xmlhttp = Ajax.getTransport();
var init_params = new Object();
function tagsAreDisplayed() {
@ -51,11 +48,8 @@ function toggleTags(show_all) {
}
}
function dlg_frefresh_callback() {
if (xmlhttp.readyState == 4) {
// notify(xmlhttp.responseText);
if (getActiveFeedId() == _qfd_deleted_feed) {
function dlg_frefresh_callback(transport, deleted_feed) {
if (getActiveFeedId() == deleted_feed) {
var h = document.getElementById("headlines-frame");
if (h) {
h.innerHTML = "<div class='whiteBox'>" + __('No feed selected.') + "</div>";
@ -64,7 +58,6 @@ function dlg_frefresh_callback() {
setTimeout('updateFeedList(false, false)', 50);
closeInfoBox();
}
}
function refetch_callback2(transport) {
@ -88,9 +81,7 @@ function refetch_callback2(transport) {
}
}
function backend_sanity_check_callback() {
if (xmlhttp.readyState == 4) {
function backend_sanity_check_callback(transport) {
try {
@ -101,15 +92,15 @@ function backend_sanity_check_callback() {
return;
}
if (!xmlhttp.responseXML) {
fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
if (!transport.responseXML) {
fatalError(3, "[D001, Received reply is not XML]: " + transport.responseText);
return;
}
var reply = xmlhttp.responseXML.firstChild.firstChild;
var reply = transport.responseXML.firstChild.firstChild;
if (!reply) {
fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
fatalError(3, "[D002, Invalid RPC reply]: " + transport.responseText);
return;
}
@ -143,7 +134,6 @@ function backend_sanity_check_callback() {
} catch (e) {
exception_error("backend_sanity_check_callback", e);
}
}
}
function scheduleFeedUpdate(force) {
@ -315,7 +305,7 @@ function updateTitle(s) {
function genericSanityCheck() {
if (!xmlhttp) fatalError(1);
// if (!Ajax.getTransport()) fatalError(1);
setCookie("ttrss_vf_test", "TEST");
@ -349,9 +339,10 @@ function init() {
var params = "&ua=" + param_escape(navigator.userAgent);
xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck" + params, true);
xmlhttp.onreadystatechange=backend_sanity_check_callback;
xmlhttp.send(null);
new Ajax.Request("backend.php?op=rpc&subop=sanityCheck" + params, {
onComplete: function(transport) {
backend_sanity_check_callback(transport);
} });
} catch (e) {
exception_error("init", e);
@ -498,16 +489,13 @@ function qfdDelete(feed_id) {
notify_progress("Removing feed...");
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
return
}
var query = "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id;
_qfd_deleted_feed = feed_id;
new Ajax.Request(query, {
onComplete: function(transport) {
dlg_frefresh_callback(transport, feed_id);
} });
xmlhttp.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id);
xmlhttp.onreadystatechange=dlg_frefresh_callback;
xmlhttp.send(null);
return false;
}
@ -521,11 +509,6 @@ function updateFeedTitle(t) {
function toggleDispRead() {
try {
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
return
}
var hide_read_feeds = (getInitParam("hide_read_feeds") == "1");
hide_read_feeds = !hide_read_feeds;
@ -536,11 +519,6 @@ function toggleDispRead() {
storeInitParam("hide_read_feeds", hide_read_feeds, true);
/* var query = "backend.php?op=rpc&subop=setpref" +
"&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds);
new Ajax.Request(query); */
} catch (e) {
exception_error("toggleDispRead", e);
}
@ -662,21 +640,18 @@ function feedEditSave() {
try {
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
return
}
// FIXME: add parameter validation
var query = Form.serialize("edit_feed_form");
notify_progress("Saving feed...");
xmlhttp.open("POST", "backend.php", true);
xmlhttp.onreadystatechange=dlg_frefresh_callback;
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send(query);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
dlg_frefresh_callback(transport);
} });
closeInfoBox();
@ -696,20 +671,16 @@ function labelEditSave() {
try {
if (!xmlhttp_ready(xmlhttp)) {
printLockingError();
return
}
closeInfoBox();
notify_progress("Saving label...");
query = Form.serialize("label_edit_form");
xmlhttp.open("GET", "backend.php?" + query, true);
xmlhttp.onreadystatechange=dlg_frefresh_callback;
xmlhttp.send(null);
new Ajax.Request("backend.php?" + query, {
onComplete: function(transport) {
dlg_frefresh_callback(transport);
} });
return false;

Loading…
Cancel
Save