<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Feed actions:') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFeed')"><?php echo __('Subscribe to feed...') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcEditFeed')"><?php echo __('Edit this feed...') ?></div>
- <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRescoreFeed')"><?php echo __('Rescore feed') ?></div> -->
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRemoveFeed')"><?php echo __('Unsubscribe') ?></div>
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('All feeds:') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
- <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div>
- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> -->
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
<?php
function viewfeed(params) {
const feed = params.feed;
- let is_cat = params.is_cat;
- let offset = params.offset;
- let background = params.background;
- let infscroll_req = params.infscroll_req;
+ let is_cat = !!params.is_cat || false;
+ let offset = params.offset || 0;
+ let background = params.background || false;
+ let infscroll_req = params.infscroll_req || false;
const can_wait = params.can_wait;
const viewfeed_debug = params.viewfeed_debug;
const method = params.method;
- if (is_cat == undefined)
- is_cat = false;
- else
- is_cat = !!is_cat;
-
- if (offset == undefined) offset = 0;
- if (background == undefined) background = false;
if (infscroll_req == undefined) infscroll_req = false;
last_requested_article = 0;
query += "&cat=" + is_cat;
- console.log(query);
-
if (can_wait && _viewfeed_timeout) {
setFeedExpandoIcon(getActiveFeedId(), activeFeedIsCat(), 'images/blank_icon.gif');
clearTimeout(_viewfeed_timeout);
}
const timeout_ms = can_wait ? 250 : 0;
- _viewfeed_timeout = setTimeout(function() {
-
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- try {
- setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
- headlines_callback2(transport, offset, background, infscroll_req);
- PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
- } catch (e) {
- exception_error(e);
- }
- } });
+ _viewfeed_timeout = setTimeout(() => {
+
+ xhrPost("backend.php", query, (transport) => {
+ try {
+ setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
+ headlines_callback2(transport, offset, background, infscroll_req);
+ PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
+ } catch (e) {
+ exception_error(e);
+ }
+ });
+
}, timeout_ms); // Wait 250ms
}
counters_last_request = timestamp;
- let query = "?op=rpc&method=getAllCounters&seq=" + next_seq();
+ let query = {op: "rpc", method: "getAllCounters", seq: next_seq()};
if (!force)
- query = query + "&last_article_id=" + getInitParam("last_article_id");
+ query.last_article_id = getInitParam("last_article_id");
- console.log(query);
-
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- handle_rpc_json(transport);
- } });
+ xhrPost("backend.php", query, (transport) => {
+ handle_rpc_json(transport);
+ });
} else {
console.log("request_counters: rate limit reached: " + (timestamp - counters_last_request));
updateFloatingTitle(true);
}
- const catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
- id + "&is_cat=false";
-
- console.log(catchup_query);
-
notify_progress("Loading, please wait...", true);
- new Ajax.Request("backend.php", {
- parameters: catchup_query,
- onComplete: function (transport) {
- handle_rpc_json(transport);
- }
- } );
-
- //return viewCurrentFeed('MarkAllReadGR:' + id);
+ xhrPost("backend.php", { op: "rpc", method: "catchupFeed", feed_id: id, is_cat: false}, (transport) => {
+ handle_rpc_json(transport);
+ });
}
}
is_cat: is_cat, mode: mode, search_query: last_search_query[0],
search_lang: last_search_query[1]};
- console.log(catchup_query);
-
notify_progress("Loading, please wait...", true);
- new Ajax.Request("backend.php", {
- parameters: catchup_query,
- onComplete: function(transport) {
- handle_rpc_json(transport);
+ xhrPost("backend.php", catchup_query, (transport) => {
+ handle_rpc_json(transport);
- const show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
+ const show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
- if (show_next_feed) {
- const nuf = getNextUnreadFeed(feed, is_cat);
+ if (show_next_feed) {
+ const nuf = getNextUnreadFeed(feed, is_cat);
- if (nuf) {
- viewfeed({feed: nuf, is_cat: is_cat});
- }
- } else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
- viewCurrentFeed();
- }
-
- notify("");
- } });
+ if (nuf) {
+ viewfeed({feed: nuf, is_cat: is_cat});
+ }
+ } else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
+ viewCurrentFeed();
+ }
+ notify("");
+ });
}
function decrementFeedCounter(feed, is_cat) {
/* global dijit, __ */
-var loading_progress = 0;
-var sanity_check_done = false;
-var init_params = {};
-var _label_base_index = -1024;
-var notify_hide_timerid = false;
+let init_params = {};
+let _label_base_index = -1024;
+let loading_progress = 0;
+let notify_hide_timerid = false;
Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
function (callOriginal, options) {
}
);
+/* xhr shorthand helpers */
+
+function xhrPost(url, params, complete) {
+ console.log("xhrPost:", params);
+ new Ajax.Request(url, {
+ parameters: params,
+ onComplete: complete
+ });
+}
+
+function xhrJson(url, params, complete) {
+ xhrPost(url, params, (reply) => {
+ try {
+ const obj = JSON.parse(reply.responseText);
+ complete(obj);
+ } catch (e) {
+ console.error("xhrJson", e, reply);
+ complete(null);
+ }
+
+ })
+}
+
/* add method to remove element from array */
Array.prototype.remove = function(s) {
const msg = e.toString();
try {
- new Ajax.Request("backend.php", {
- parameters: {op: "rpc", method: "log",
+ xhrPost("backend.php",
+ {op: "rpc", method: "log",
file: e.fileName ? e.fileName : filename,
line: e.lineNumber ? e.lineNumber : lineno,
msg: msg, context: e.stack},
- onComplete: function (transport) {
+ (transport) => {
console.warn(transport.responseText);
- } });
+ });
} catch (e) {
console.error("Exception while trying to log the error.", e);
function backend_sanity_check_callback(transport) {
- if (sanity_check_done) {
- fatalError(11, "Sanity check request received twice. This can indicate "+
- "presence of Firebug or some other disrupting extension. "+
- "Please disable it and try again.");
- return;
- }
-
const reply = JSON.parse(transport.responseText);
if (!reply) {
window.PluginHost && PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, init_params);
}
- sanity_check_done = true;
-
init_second_stage();
-
}
function genUrlChangeKey(feed, is_cat) {
}
function activeFeedIsCat() {
- return _active_feed_is_cat;
+ return !!_active_feed_is_cat;
}
function getActiveFeedId() {
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
- const query_str = "backend.php?op=feeds&method=catchupAll";
-
notify_progress("Marking all feeds as read...");
- //console.log("catchupAllFeeds Q=" + query_str);
-
- new Ajax.Request("backend.php", {
- parameters: query_str,
- onComplete: function(transport) {
- request_counters(true);
- viewCurrentFeed();
- } });
+ xhrPost("backend.php", {op: "feeds", method: "catchupAll"}, () => {
+ request_counters(true);
+ viewCurrentFeed();
+ });
global_unread = 0;
updateTitle("");
init_hotkey_actions();
- new Ajax.Request("backend.php", {
- parameters: {
- op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
- hasMp3: hasMp3,
- clientTzOffset: clientTzOffset,
- hasSandbox: hasSandbox
- },
- onComplete: function (transport) {
- backend_sanity_check_callback(transport);
- }
+ const params = {
+ op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
+ hasMp3: hasMp3,
+ clientTzOffset: clientTzOffset,
+ hasSandbox: hasSandbox
+ };
+
+ xhrPost("backend.php", params, (transport) => {
+ try {
+ backend_sanity_check_callback(transport);
+ } catch (e) {
+ console.error(e);
+ }
});
+
} catch (e) {
exception_error(e);
}
reverseHeadlineOrder();
};
hotkey_actions["feed_toggle_vgroup"] = function() {
- const query_str = "?op=rpc&method=togglepref&key=VFEED_GROUP_BY_FEED";
-
- new Ajax.Request("backend.php", {
- parameters: query_str,
- onComplete: function(transport) {
- viewCurrentFeed();
- } });
-
+ xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => {
+ viewCurrentFeed();
+ })
};
hotkey_actions["catchup_all"] = function() {
catchupAllFeeds();
notify_progress("Loading, please wait...");
const value = isCdmMode() ? "false" : "true";
- const query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value;
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- setInitParam("combined_display_mode",
- !getInitParam("combined_display_mode"));
-
- closeArticlePanel();
- viewCurrentFeed();
+ xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => {
+ setInitParam("combined_display_mode",
+ !getInitParam("combined_display_mode"));
- } });
+ closeArticlePanel();
+ viewCurrentFeed();
+ })
};
hotkey_actions["toggle_cdm_expanded"] = function() {
notify_progress("Loading, please wait...");
- const value = getInitParam("cdm_expanded") ? "false" : "true";
- const query = "?op=rpc&method=setpref&key=CDM_EXPANDED&value=" + value;
+ const value = getInitParam("cdm_expanded") ? "false" : "true";
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- setInitParam("cdm_expanded", !getInitParam("cdm_expanded"));
- viewCurrentFeed();
- } });
+ xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
+ setInitParam("cdm_expanded", !getInitParam("cdm_expanded"));
+ viewCurrentFeed();
+ });
};
}
case "qmcShowOnlyUnread":
toggleDispRead();
break;
- case "qmcAddFilter":
- quickAddFilter();
- break;
- case "qmcAddLabel":
- addLabel();
- break;
- case "qmcRescoreFeed":
- rescoreCurrentFeed();
- break;
case "qmcToggleWidescreen":
if (!isCdmMode()) {
_widescreen_mode = !_widescreen_mode;
const hide = !(getInitParam("hide_read_feeds") == "1");
- hideOrShowFeeds(hide);
-
- const query = "?op=rpc&method=setpref&key=HIDE_READ_FEEDS&value=" +
- param_escape(hide);
-
- setInitParam("hide_read_feeds", hide);
-
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- } });
-
+ xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => {
+ hideOrShowFeeds(hide);
+ setInitParam("hide_read_feeds", hide);
+ });
}
function parse_runtime_info(data) {
return viewCurrentFeed('');
}
-function rescoreCurrentFeed() {
-
- const actid = getActiveFeedId();
-
- if (activeFeedIsCat() || actid < 0) {
- alert(__("You can't rescore this kind of feed."));
- return;
- }
-
- if (!actid) {
- alert(__("Please select some feed first."));
- return;
- }
-
- const fn = getFeedName(actid);
- const pr = __("Rescore articles in %s?").replace("%s", fn);
-
- if (confirm(pr)) {
- notify_progress("Rescoring articles...");
-
- const query = "?op=pref-feeds&method=rescore&quiet=1&ids=" + actid;
-
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function() {
- viewCurrentFeed();
- } });
- }
-}
-
function hotkey_handler(e) {
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
if (netalert) netalert.hide();
- } else
- if (netalert)
- netalert.show();
- else
- notify_error("Communication problem with server.");
+ return reply;
+
+ } else {
+ if (netalert)
+ netalert.show();
+ else
+ notify_error("Communication problem with server.");
+ }
} catch (e) {
if (netalert)
console.error(e);
}
- return true;
+ return false;
}
function switchPanelMode(wide) {
if (article_id) view(article_id);
- new Ajax.Request("backend.php", {
- parameters: "op=rpc&method=setpanelmode&wide=" + (wide ? 1 : 0),
- onComplete: function(transport) {
- console.log(transport.responseText);
- } });
+ xhrPost("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0});
}
function update_random_feed() {
console.log("in update_random_feed");
- new Ajax.Request("backend.php", {
- parameters: "op=rpc&method=updateRandomFeed",
- onComplete: function(transport) {
- handle_rpc_json(transport, true);
- window.setTimeout(update_random_feed, 30*1000);
- } });
+ xhrPost("backend.php", { op: "rpc", method: "updateRandomFeed" }, (transport) => {
+ handle_rpc_json(transport, true);
+ window.setTimeout(update_random_feed, 30*1000);
+ });
}
function hash_get(key) {
let vgroup_last_feed = false;
let post_under_pointer = false;
-let last_requested_article = false;
+let last_requested_article = 0;
let catchup_id_batch = [];
let catchup_timeout_id = false;
let has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
function headlines_callback2(transport, offset, background, infscroll_req) {
- handle_rpc_json(transport);
+ const reply = handle_rpc_json(transport);
console.log("headlines_callback2 [offset=" + offset + "] B:" + background + " I:" + infscroll_req);
- let is_cat = false;
- let feed_id = false;
+ if (background)
+ return;
- let reply = false;
-
- try {
- reply = JSON.parse(transport.responseText);
- } catch (e) {
- console.error(e);
- }
+ var is_cat = false;
+ var feed_id = false;
if (reply) {
feed_id = reply['headlines']['id'];
last_search_query = reply['headlines']['search_query'];
- if (background) {
- let content = reply['headlines']['content'];
-
- content = content + "<div id='headlines-spacer'></div>";
- return;
- }
+ console.log(feed_id, getActiveFeedId(), is_cat, activeFeedIsCat());
if (feed_id != -7 && (feed_id != getActiveFeedId() || is_cat != activeFeedIsCat()))
return;
- /* dijit.getEnclosingWidget(
- document.forms["main_toolbar_form"].update).attr('disabled',
- is_cat || feed_id <= 0); */
-
try {
if (infscroll_req == false) {
$("headlines-frame").scrollTop = 0;
current_first_id = reply['headlines']['first_id'];
const counters = reply['counters'];
const articles = reply['articles'];
- //var runtime_info = reply['runtime-info'];
if (infscroll_req == false) {
loaded_article_ids = [];
reply['headlines']['toolbar'],
{parseContent: true});
- /*dojo.html.set($("headlines-frame"),
- reply['headlines']['content'],
- {parseContent: true});
-
- $$("#headlines-frame div[id*='RROW']").each(function(row) {
- loaded_article_ids.push(row.id);
- });*/
-
$("headlines-frame").innerHTML = '';
- var tmp = new Element("div");
+ let tmp = document.createElement("div");
tmp.innerHTML = reply['headlines']['content'];
dojo.parser.parse(tmp);
}
}
- var hsp = $("headlines-spacer");
+ let hsp = $("headlines-spacer");
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
dijit.byId('headlines-frame').domNode.appendChild(hsp);
const c = dijit.byId("headlines-frame");
const ids = getSelectedArticleIds2();
- var hsp = $("headlines-spacer");
+ let hsp = $("headlines-spacer");
if (hsp)
c.domNode.removeChild(hsp);
- var tmp = new Element("div");
+ let tmp = document.createElement("div");
tmp.innerHTML = reply['headlines']['content'];
dojo.parser.parse(tmp);
while (tmp.hasChildNodes()) {
- var row = tmp.removeChild(tmp.firstChild);
+ let row = tmp.removeChild(tmp.firstChild);
if (loaded_article_ids.indexOf(row.id) == -1 || row.hasClassName("cdmFeedTitle")) {
dijit.byId("headlines-frame").domNode.appendChild(row);
console.log("restore selected ids: " + ids);
- for (var i = 0; i < ids.length; i++) {
+ for (let i = 0; i < ids.length; i++) {
markHeadline(ids[i]);
}
const first_id_changed = reply['headlines']['first_id_changed'];
console.log("first id changed:" + first_id_changed);
- var hsp = $("headlines-spacer");
+ let hsp = $("headlines-spacer");
if (hsp) {
if (first_id_changed) {
}
if (articles) {
- for (var i = 0; i < articles.length; i++) {
+ for (let i = 0; i < articles.length; i++) {
const a_id = articles[i]['id'];
cache_set("article:" + a_id, articles[i]['content']);
}