use xhrPost in more places; various minor cleanup

This commit is contained in:
Andrew Dolgov 2018-11-29 22:21:09 +03:00
parent 0267212454
commit 0d27227359
5 changed files with 133 additions and 240 deletions

View File

@ -245,15 +245,12 @@
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Feed actions:') ?></div> <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('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('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" onclick="quickMenuGo('qmcRemoveFeed')"><?php echo __('Unsubscribe') ?></div>
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('All feeds:') ?></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('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" 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" 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('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> <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
<?php <?php

View File

@ -61,21 +61,14 @@ function cleanup_memory(root) {
function viewfeed(params) { function viewfeed(params) {
const feed = params.feed; const feed = params.feed;
let is_cat = params.is_cat; let is_cat = !!params.is_cat || false;
let offset = params.offset; let offset = params.offset || 0;
let background = params.background; let background = params.background || false;
let infscroll_req = params.infscroll_req; let infscroll_req = params.infscroll_req || false;
const can_wait = params.can_wait; const can_wait = params.can_wait;
const viewfeed_debug = params.viewfeed_debug; const viewfeed_debug = params.viewfeed_debug;
const method = params.method; 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; if (infscroll_req == undefined) infscroll_req = false;
last_requested_article = 0; last_requested_article = 0;
@ -148,8 +141,6 @@ function viewfeed(params) {
query += "&cat=" + is_cat; query += "&cat=" + is_cat;
console.log(query);
if (can_wait && _viewfeed_timeout) { if (can_wait && _viewfeed_timeout) {
setFeedExpandoIcon(getActiveFeedId(), activeFeedIsCat(), 'images/blank_icon.gif'); setFeedExpandoIcon(getActiveFeedId(), activeFeedIsCat(), 'images/blank_icon.gif');
clearTimeout(_viewfeed_timeout); clearTimeout(_viewfeed_timeout);
@ -162,19 +153,18 @@ function viewfeed(params) {
} }
const timeout_ms = can_wait ? 250 : 0; const timeout_ms = can_wait ? 250 : 0;
_viewfeed_timeout = setTimeout(function() { _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);
}
});
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);
}
} });
}, timeout_ms); // Wait 250ms }, timeout_ms); // Wait 250ms
} }
@ -235,18 +225,14 @@ function request_counters(force) {
counters_last_request = timestamp; counters_last_request = timestamp;
let query = "?op=rpc&method=getAllCounters&seq=" + next_seq(); let query = {op: "rpc", method: "getAllCounters", seq: next_seq()};
if (!force) if (!force)
query = query + "&last_article_id=" + getInitParam("last_article_id"); query.last_article_id = getInitParam("last_article_id");
console.log(query); xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
new Ajax.Request("backend.php", { });
parameters: query,
onComplete: function(transport) {
handle_rpc_json(transport);
} });
} else { } else {
console.log("request_counters: rate limit reached: " + (timestamp - counters_last_request)); console.log("request_counters: rate limit reached: " + (timestamp - counters_last_request));
@ -481,21 +467,11 @@ function catchupFeedInGroup(id) {
updateFloatingTitle(true); 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); notify_progress("Loading, please wait...", true);
new Ajax.Request("backend.php", { xhrPost("backend.php", { op: "rpc", method: "catchupFeed", feed_id: id, is_cat: false}, (transport) => {
parameters: catchup_query, handle_rpc_json(transport);
onComplete: function (transport) { });
handle_rpc_json(transport);
}
} );
//return viewCurrentFeed('MarkAllReadGR:' + id);
} }
} }
@ -532,30 +508,25 @@ function catchupFeed(feed, is_cat, mode) {
is_cat: is_cat, mode: mode, search_query: last_search_query[0], is_cat: is_cat, mode: mode, search_query: last_search_query[0],
search_lang: last_search_query[1]}; search_lang: last_search_query[1]};
console.log(catchup_query);
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
new Ajax.Request("backend.php", { xhrPost("backend.php", catchup_query, (transport) => {
parameters: catchup_query, handle_rpc_json(transport);
onComplete: function(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) { if (show_next_feed) {
const nuf = getNextUnreadFeed(feed, is_cat); const nuf = getNextUnreadFeed(feed, is_cat);
if (nuf) { if (nuf) {
viewfeed({feed: nuf, is_cat: is_cat}); viewfeed({feed: nuf, is_cat: is_cat});
} }
} else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) { } else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
viewCurrentFeed(); viewCurrentFeed();
} }
notify("");
} });
notify("");
});
} }
function decrementFeedCounter(feed, is_cat) { function decrementFeedCounter(feed, is_cat) {

View File

@ -1,10 +1,9 @@
/* global dijit, __ */ /* global dijit, __ */
var loading_progress = 0; let init_params = {};
var sanity_check_done = false; let _label_base_index = -1024;
var init_params = {}; let loading_progress = 0;
var _label_base_index = -1024; let notify_hide_timerid = false;
var notify_hide_timerid = false;
Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap( Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
function (callOriginal, options) { function (callOriginal, options) {
@ -24,6 +23,29 @@ Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
} }
); );
/* 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 */ /* add method to remove element from array */
Array.prototype.remove = function(s) { Array.prototype.remove = function(s) {
@ -46,14 +68,14 @@ function exception_error(e, e_compat, filename, lineno, colno) {
const msg = e.toString(); const msg = e.toString();
try { try {
new Ajax.Request("backend.php", { xhrPost("backend.php",
parameters: {op: "rpc", method: "log", {op: "rpc", method: "log",
file: e.fileName ? e.fileName : filename, file: e.fileName ? e.fileName : filename,
line: e.lineNumber ? e.lineNumber : lineno, line: e.lineNumber ? e.lineNumber : lineno,
msg: msg, context: e.stack}, msg: msg, context: e.stack},
onComplete: function (transport) { (transport) => {
console.warn(transport.responseText); console.warn(transport.responseText);
} }); });
} catch (e) { } catch (e) {
console.error("Exception while trying to log the error.", e); console.error("Exception while trying to log the error.", e);
@ -1082,13 +1104,6 @@ function unsubscribeFeed(feed_id, title) {
function backend_sanity_check_callback(transport) { 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); const reply = JSON.parse(transport.responseText);
if (!reply) { if (!reply) {
@ -1120,10 +1135,7 @@ function backend_sanity_check_callback(transport) {
window.PluginHost && PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, init_params); window.PluginHost && PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, init_params);
} }
sanity_check_done = true;
init_second_stage(); init_second_stage();
} }
function genUrlChangeKey(feed, is_cat) { function genUrlChangeKey(feed, is_cat) {

View File

@ -19,7 +19,7 @@ function get_seq() {
} }
function activeFeedIsCat() { function activeFeedIsCat() {
return _active_feed_is_cat; return !!_active_feed_is_cat;
} }
function getActiveFeedId() { function getActiveFeedId() {
@ -113,18 +113,12 @@ function catchupAllFeeds() {
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
const query_str = "backend.php?op=feeds&method=catchupAll";
notify_progress("Marking all feeds as read..."); notify_progress("Marking all feeds as read...");
//console.log("catchupAllFeeds Q=" + query_str); xhrPost("backend.php", {op: "feeds", method: "catchupAll"}, () => {
request_counters(true);
new Ajax.Request("backend.php", { viewCurrentFeed();
parameters: query_str, });
onComplete: function(transport) {
request_counters(true);
viewCurrentFeed();
} });
global_unread = 0; global_unread = 0;
updateTitle(""); updateTitle("");
@ -253,17 +247,21 @@ function init() {
init_hotkey_actions(); init_hotkey_actions();
new Ajax.Request("backend.php", { const params = {
parameters: { op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
op: "rpc", method: "sanityCheck", hasAudio: hasAudio, hasMp3: hasMp3,
hasMp3: hasMp3, clientTzOffset: clientTzOffset,
clientTzOffset: clientTzOffset, hasSandbox: hasSandbox
hasSandbox: hasSandbox };
},
onComplete: function (transport) { xhrPost("backend.php", params, (transport) => {
backend_sanity_check_callback(transport); try {
} backend_sanity_check_callback(transport);
} catch (e) {
console.error(e);
}
}); });
} catch (e) { } catch (e) {
exception_error(e); exception_error(e);
} }
@ -443,14 +441,9 @@ function init_hotkey_actions() {
reverseHeadlineOrder(); reverseHeadlineOrder();
}; };
hotkey_actions["feed_toggle_vgroup"] = function() { hotkey_actions["feed_toggle_vgroup"] = function() {
const query_str = "?op=rpc&method=togglepref&key=VFEED_GROUP_BY_FEED"; xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => {
viewCurrentFeed();
new Ajax.Request("backend.php", { })
parameters: query_str,
onComplete: function(transport) {
viewCurrentFeed();
} });
}; };
hotkey_actions["catchup_all"] = function() { hotkey_actions["catchup_all"] = function() {
catchupAllFeeds(); catchupAllFeeds();
@ -533,31 +526,24 @@ function init_hotkey_actions() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
const value = isCdmMode() ? "false" : "true"; const value = isCdmMode() ? "false" : "true";
const query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value;
new Ajax.Request("backend.php", { xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => {
parameters: query, setInitParam("combined_display_mode",
onComplete: function(transport) { !getInitParam("combined_display_mode"));
setInitParam("combined_display_mode",
!getInitParam("combined_display_mode"));
closeArticlePanel(); closeArticlePanel();
viewCurrentFeed(); viewCurrentFeed();
})
} });
}; };
hotkey_actions["toggle_cdm_expanded"] = function() { hotkey_actions["toggle_cdm_expanded"] = function() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
const value = getInitParam("cdm_expanded") ? "false" : "true"; const value = getInitParam("cdm_expanded") ? "false" : "true";
const query = "?op=rpc&method=setpref&key=CDM_EXPANDED&value=" + value;
new Ajax.Request("backend.php", { xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
parameters: query, setInitParam("cdm_expanded", !getInitParam("cdm_expanded"));
onComplete: function(transport) { viewCurrentFeed();
setInitParam("cdm_expanded", !getInitParam("cdm_expanded")); });
viewCurrentFeed();
} });
}; };
} }
@ -685,15 +671,6 @@ function quickMenuGo(opid) {
case "qmcShowOnlyUnread": case "qmcShowOnlyUnread":
toggleDispRead(); toggleDispRead();
break; break;
case "qmcAddFilter":
quickAddFilter();
break;
case "qmcAddLabel":
addLabel();
break;
case "qmcRescoreFeed":
rescoreCurrentFeed();
break;
case "qmcToggleWidescreen": case "qmcToggleWidescreen":
if (!isCdmMode()) { if (!isCdmMode()) {
_widescreen_mode = !_widescreen_mode; _widescreen_mode = !_widescreen_mode;
@ -719,18 +696,10 @@ function toggleDispRead() {
const hide = !(getInitParam("hide_read_feeds") == "1"); const hide = !(getInitParam("hide_read_feeds") == "1");
hideOrShowFeeds(hide); xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => {
hideOrShowFeeds(hide);
const query = "?op=rpc&method=setpref&key=HIDE_READ_FEEDS&value=" + setInitParam("hide_read_feeds", hide);
param_escape(hide); });
setInitParam("hide_read_feeds", hide);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
} });
} }
function parse_runtime_info(data) { function parse_runtime_info(data) {
@ -797,36 +766,6 @@ function viewModeChanged() {
return viewCurrentFeed(''); 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) { function hotkey_handler(e) {
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return; if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
@ -966,11 +905,14 @@ function handle_rpc_json(transport, scheduled_call) {
if (netalert) netalert.hide(); if (netalert) netalert.hide();
} else return reply;
if (netalert)
netalert.show(); } else {
else if (netalert)
notify_error("Communication problem with server."); netalert.show();
else
notify_error("Communication problem with server.");
}
} catch (e) { } catch (e) {
if (netalert) if (netalert)
@ -981,7 +923,7 @@ function handle_rpc_json(transport, scheduled_call) {
console.error(e); console.error(e);
} }
return true; return false;
} }
function switchPanelMode(wide) { function switchPanelMode(wide) {
@ -1027,22 +969,16 @@ function switchPanelMode(wide) {
if (article_id) view(article_id); if (article_id) view(article_id);
new Ajax.Request("backend.php", { xhrPost("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0});
parameters: "op=rpc&method=setpanelmode&wide=" + (wide ? 1 : 0),
onComplete: function(transport) {
console.log(transport.responseText);
} });
} }
function update_random_feed() { function update_random_feed() {
console.log("in update_random_feed"); console.log("in update_random_feed");
new Ajax.Request("backend.php", { xhrPost("backend.php", { op: "rpc", method: "updateRandomFeed" }, (transport) => {
parameters: "op=rpc&method=updateRandomFeed", handle_rpc_json(transport, true);
onComplete: function(transport) { window.setTimeout(update_random_feed, 30*1000);
handle_rpc_json(transport, true); });
window.setTimeout(update_random_feed, 30*1000);
} });
} }
function hash_get(key) { function hash_get(key) {

View File

@ -5,7 +5,7 @@ let _active_article_id = 0;
let vgroup_last_feed = false; let vgroup_last_feed = false;
let post_under_pointer = false; let post_under_pointer = false;
let last_requested_article = false; let last_requested_article = 0;
let catchup_id_batch = []; let catchup_id_batch = [];
let catchup_timeout_id = false; let catchup_timeout_id = false;
@ -22,20 +22,15 @@ let _catchup_request_sent = false;
let has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null; let has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
function headlines_callback2(transport, offset, background, infscroll_req) { 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); console.log("headlines_callback2 [offset=" + offset + "] B:" + background + " I:" + infscroll_req);
let is_cat = false; if (background)
let feed_id = false; return;
let reply = false; var is_cat = false;
var feed_id = false;
try {
reply = JSON.parse(transport.responseText);
} catch (e) {
console.error(e);
}
if (reply) { if (reply) {
@ -43,20 +38,11 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
feed_id = reply['headlines']['id']; feed_id = reply['headlines']['id'];
last_search_query = reply['headlines']['search_query']; last_search_query = reply['headlines']['search_query'];
if (background) { console.log(feed_id, getActiveFeedId(), is_cat, activeFeedIsCat());
let content = reply['headlines']['content'];
content = content + "<div id='headlines-spacer'></div>";
return;
}
if (feed_id != -7 && (feed_id != getActiveFeedId() || is_cat != activeFeedIsCat())) if (feed_id != -7 && (feed_id != getActiveFeedId() || is_cat != activeFeedIsCat()))
return; return;
/* dijit.getEnclosingWidget(
document.forms["main_toolbar_form"].update).attr('disabled',
is_cat || feed_id <= 0); */
try { try {
if (infscroll_req == false) { if (infscroll_req == false) {
$("headlines-frame").scrollTop = 0; $("headlines-frame").scrollTop = 0;
@ -85,7 +71,6 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
current_first_id = reply['headlines']['first_id']; current_first_id = reply['headlines']['first_id'];
const counters = reply['counters']; const counters = reply['counters'];
const articles = reply['articles']; const articles = reply['articles'];
//var runtime_info = reply['runtime-info'];
if (infscroll_req == false) { if (infscroll_req == false) {
loaded_article_ids = []; loaded_article_ids = [];
@ -94,17 +79,9 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
reply['headlines']['toolbar'], reply['headlines']['toolbar'],
{parseContent: true}); {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 = ''; $("headlines-frame").innerHTML = '';
var tmp = new Element("div"); let tmp = document.createElement("div");
tmp.innerHTML = reply['headlines']['content']; tmp.innerHTML = reply['headlines']['content'];
dojo.parser.parse(tmp); dojo.parser.parse(tmp);
@ -118,7 +95,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
} }
} }
var hsp = $("headlines-spacer"); let hsp = $("headlines-spacer");
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"}); if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
dijit.byId('headlines-frame').domNode.appendChild(hsp); dijit.byId('headlines-frame').domNode.appendChild(hsp);
@ -140,17 +117,17 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
const c = dijit.byId("headlines-frame"); const c = dijit.byId("headlines-frame");
const ids = getSelectedArticleIds2(); const ids = getSelectedArticleIds2();
var hsp = $("headlines-spacer"); let hsp = $("headlines-spacer");
if (hsp) if (hsp)
c.domNode.removeChild(hsp); c.domNode.removeChild(hsp);
var tmp = new Element("div"); let tmp = document.createElement("div");
tmp.innerHTML = reply['headlines']['content']; tmp.innerHTML = reply['headlines']['content'];
dojo.parser.parse(tmp); dojo.parser.parse(tmp);
while (tmp.hasChildNodes()) { 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")) { if (loaded_article_ids.indexOf(row.id) == -1 || row.hasClassName("cdmFeedTitle")) {
dijit.byId("headlines-frame").domNode.appendChild(row); dijit.byId("headlines-frame").domNode.appendChild(row);
@ -166,7 +143,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
console.log("restore selected ids: " + ids); 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]); markHeadline(ids[i]);
} }
@ -183,7 +160,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
const first_id_changed = reply['headlines']['first_id_changed']; const first_id_changed = reply['headlines']['first_id_changed'];
console.log("first id changed:" + first_id_changed); console.log("first id changed:" + first_id_changed);
var hsp = $("headlines-spacer"); let hsp = $("headlines-spacer");
if (hsp) { if (hsp) {
if (first_id_changed) { if (first_id_changed) {
@ -199,7 +176,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
} }
if (articles) { if (articles) {
for (var i = 0; i < articles.length; i++) { for (let i = 0; i < articles.length; i++) {
const a_id = articles[i]['id']; const a_id = articles[i]['id'];
cache_set("article:" + a_id, articles[i]['content']); cache_set("article:" + a_id, articles[i]['content']);
} }