remove raw xmlhttp code from tt-rss.js
This commit is contained in:
parent
4ffa126ec3
commit
f3c6bf6e3d
187
tt-rss.js
187
tt-rss.js
|
@ -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,20 +48,16 @@ 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);
|
var h = document.getElementById("headlines-frame");
|
||||||
|
if (h) {
|
||||||
if (getActiveFeedId() == _qfd_deleted_feed) {
|
h.innerHTML = "<div class='whiteBox'>" + __('No feed selected.') + "</div>";
|
||||||
var h = document.getElementById("headlines-frame");
|
|
||||||
if (h) {
|
|
||||||
h.innerHTML = "<div class='whiteBox'>" + __('No feed selected.') + "</div>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout('updateFeedList(false, false)', 50);
|
setTimeout('updateFeedList(false, false)', 50);
|
||||||
closeInfoBox();
|
closeInfoBox();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function refetch_callback2(transport) {
|
function refetch_callback2(transport) {
|
||||||
|
@ -88,61 +81,58 @@ function refetch_callback2(transport) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function backend_sanity_check_callback() {
|
function backend_sanity_check_callback(transport) {
|
||||||
|
|
||||||
if (xmlhttp.readyState == 4) {
|
try {
|
||||||
|
|
||||||
try {
|
if (sanity_check_done) {
|
||||||
|
fatalError(11, "Sanity check request received twice. This can indicate "+
|
||||||
if (sanity_check_done) {
|
"presence of Firebug or some other disrupting extension. "+
|
||||||
fatalError(11, "Sanity check request received twice. This can indicate "+
|
"Please disable it and try again.");
|
||||||
"presence of Firebug or some other disrupting extension. "+
|
return;
|
||||||
"Please disable it and try again.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xmlhttp.responseXML) {
|
|
||||||
fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var reply = xmlhttp.responseXML.firstChild.firstChild;
|
|
||||||
|
|
||||||
if (!reply) {
|
|
||||||
fatalError(3, "[D002, 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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
debug("sanity check ok");
|
|
||||||
|
|
||||||
var params = reply.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;
|
|
||||||
|
|
||||||
init_second_stage();
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
exception_error("backend_sanity_check_callback", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!transport.responseXML) {
|
||||||
|
fatalError(3, "[D001, Received reply is not XML]: " + transport.responseText);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var reply = transport.responseXML.firstChild.firstChild;
|
||||||
|
|
||||||
|
if (!reply) {
|
||||||
|
fatalError(3, "[D002, Invalid RPC reply]: " + transport.responseText);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var error_code = reply.getAttribute("error-code");
|
||||||
|
|
||||||
|
if (error_code && error_code != 0) {
|
||||||
|
return fatalError(error_code, reply.getAttribute("error-msg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("sanity check ok");
|
||||||
|
|
||||||
|
var params = reply.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;
|
||||||
|
|
||||||
|
init_second_stage();
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("backend_sanity_check_callback", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -535,11 +518,6 @@ function toggleDispRead() {
|
||||||
hideOrShowFeeds(getFeedsContext().document, hide_read_feeds);
|
hideOrShowFeeds(getFeedsContext().document, hide_read_feeds);
|
||||||
|
|
||||||
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,21 +671,17 @@ 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;
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue