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

Loading…
Cancel
Save