eslint-related fixes

This commit is contained in:
Andrew Dolgov 2018-11-29 20:07:23 +03:00
parent 79c5035920
commit 424e28db6b
5 changed files with 568 additions and 592 deletions

View File

@ -15,12 +15,12 @@ function resetCounterCache() {
function loadMoreHeadlines() { function loadMoreHeadlines() {
console.log("loadMoreHeadlines"); console.log("loadMoreHeadlines");
var offset = 0; let offset = 0;
var view_mode = document.forms["main_toolbar_form"].view_mode.value; const view_mode = document.forms["main_toolbar_form"].view_mode.value;
var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length; const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
var num_all = $$("#headlines-frame > div[id*=RROW]").length; const num_all = $$("#headlines-frame > div[id*=RROW]").length;
var num_unread = getFeedUnread(getActiveFeedId(), activeFeedIsCat()); const num_unread = getFeedUnread(getActiveFeedId(), activeFeedIsCat());
// TODO implement marked & published // TODO implement marked & published
@ -48,7 +48,7 @@ function loadMoreHeadlines() {
} }
function cleanup_memory(root) { function cleanup_memory(root) {
var dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode); const dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode);
dijits.each(function (d) { dijits.each(function (d) {
dojo.destroy(d.domNode); dojo.destroy(d.domNode);
@ -60,14 +60,14 @@ function cleanup_memory(root) {
} }
function viewfeed(params) { function viewfeed(params) {
var feed = params.feed; const feed = params.feed;
var is_cat = params.is_cat; let is_cat = params.is_cat;
var offset = params.offset; let offset = params.offset;
var background = params.background; let background = params.background;
var infscroll_req = params.infscroll_req; let infscroll_req = params.infscroll_req;
var can_wait = params.can_wait; const can_wait = params.can_wait;
var viewfeed_debug = params.viewfeed_debug; const viewfeed_debug = params.viewfeed_debug;
var method = params.method; const method = params.method;
if (is_cat == undefined) if (is_cat == undefined)
is_cat = false; is_cat = false;
@ -96,7 +96,7 @@ function viewfeed(params) {
} }
if (infscroll_req) { if (infscroll_req) {
var timestamp = get_timestamp(); const timestamp = get_timestamp();
if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) { if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) {
//console.log("infscroll request in progress, aborting"); //console.log("infscroll request in progress, aborting");
@ -109,9 +109,9 @@ function viewfeed(params) {
Form.enable("main_toolbar_form"); Form.enable("main_toolbar_form");
var toolbar_query = Form.serialize("main_toolbar_form"); const toolbar_query = Form.serialize("main_toolbar_form");
var query = "?op=feeds&method=view&feed=" + param_escape(feed) + "&" + let query = "?op=feeds&method=view&feed=" + param_escape(feed) + "&" +
toolbar_query; toolbar_query;
if (method) query += "&m=" + param_escape(method); if (method) query += "&m=" + param_escape(method);
@ -135,11 +135,9 @@ function viewfeed(params) {
if (vgroup_last_feed) { if (vgroup_last_feed) {
query = query + "&vgrlf=" + param_escape(vgroup_last_feed); query = query + "&vgrlf=" + param_escape(vgroup_last_feed);
} }
} else { } else if (!is_cat && feed == getActiveFeedId() && !params.method) {
if (!is_cat && feed == getActiveFeedId() && !params.method) {
query = query + "&m=ForceUpdate"; query = query + "&m=ForceUpdate";
} }
}
Form.enable("main_toolbar_form"); Form.enable("main_toolbar_form");
@ -163,7 +161,7 @@ function viewfeed(params) {
window.open("backend.php" + query + "&debug=1&csrf_token=" + getInitParam("csrf_token")); window.open("backend.php" + query + "&debug=1&csrf_token=" + getInitParam("csrf_token"));
} }
var timeout_ms = can_wait ? 250 : 0; const timeout_ms = can_wait ? 250 : 0;
_viewfeed_timeout = setTimeout(function() { _viewfeed_timeout = setTimeout(function() {
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -200,7 +198,7 @@ function feedlist_init() {
if (getInitParam("is_default_pw")) { if (getInitParam("is_default_pw")) {
console.warn("user password is at default value"); console.warn("user password is at default value");
var dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
title: __("Your password is at default value"), title: __("Your password is at default value"),
href: "backend.php?op=dlg&method=defaultpasswordwarning", href: "backend.php?op=dlg&method=defaultpasswordwarning",
id: 'infoBox', id: 'infoBox',
@ -229,15 +227,15 @@ function feedlist_init() {
function request_counters(force) { function request_counters(force) {
var date = new Date(); const date = new Date();
var timestamp = Math.round(date.getTime() / 1000); const timestamp = Math.round(date.getTime() / 1000);
if (force || timestamp - counters_last_request > 5) { if (force || timestamp - counters_last_request > 5) {
console.log("scheduling request of counters..."); console.log("scheduling request of counters...");
counters_last_request = timestamp; counters_last_request = timestamp;
var 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 = query + "&last_article_id=" + getInitParam("last_article_id");
@ -260,8 +258,8 @@ function request_counters(force) {
// http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html // http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html
function counter_is_equal(a, b) { function counter_is_equal(a, b) {
// Create arrays of property names // Create arrays of property names
var aProps = Object.getOwnPropertyNames(a); const aProps = Object.getOwnPropertyNames(a);
var bProps = Object.getOwnPropertyNames(b); const bProps = Object.getOwnPropertyNames(b);
// If number of properties is different, // If number of properties is different,
// objects are not equivalent // objects are not equivalent
@ -269,8 +267,8 @@ function counter_is_equal(a, b) {
return false; return false;
} }
for (var i = 0; i < aProps.length; i++) { for (let i = 0; i < aProps.length; i++) {
var propName = aProps[i]; const propName = aProps[i];
// If values of same property are not equal, // If values of same property are not equal,
// objects are not equivalent // objects are not equivalent
@ -286,19 +284,19 @@ function counter_is_equal(a, b) {
function parse_counters(elems) { function parse_counters(elems) {
for (var l = 0; l < elems.length; l++) { for (let l = 0; l < elems.length; l++) {
if (_counters_prev[l] && counter_is_equal(elems[l], _counters_prev[l])) { if (_counters_prev[l] && counter_is_equal(elems[l], _counters_prev[l])) {
continue; continue;
} }
var id = elems[l].id; const id = elems[l].id;
var kind = elems[l].kind; const kind = elems[l].kind;
var ctr = parseInt(elems[l].counter); const ctr = parseInt(elems[l].counter);
var error = elems[l].error; const error = elems[l].error;
var has_img = elems[l].has_img; const has_img = elems[l].has_img;
var updated = elems[l].updated; const updated = elems[l].updated;
var auxctr = parseInt(elems[l].auxcounter); const auxctr = parseInt(elems[l].auxcounter);
if (id == "global-unread") { if (id == "global-unread") {
global_unread = ctr; global_unread = ctr;
@ -340,7 +338,7 @@ function parse_counters(elems) {
function getFeedUnread(feed, is_cat) { function getFeedUnread(feed, is_cat) {
try { try {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree && tree.model) if (tree && tree.model)
return tree.model.getFeedUnread(feed, is_cat); return tree.model.getFeedUnread(feed, is_cat);
@ -354,7 +352,7 @@ function getFeedUnread(feed, is_cat) {
function getFeedCategory(feed) { function getFeedCategory(feed) {
try { try {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree && tree.model) if (tree && tree.model)
return tree.getFeedCategory(feed); return tree.getFeedCategory(feed);
@ -367,7 +365,7 @@ function getFeedCategory(feed) {
} }
function hideOrShowFeeds(hide) { function hideOrShowFeeds(hide) {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree) if (tree)
return tree.hideRead(hide, getInitParam("hide_read_shows_special")); return tree.hideRead(hide, getInitParam("hide_read_shows_special"));
@ -377,7 +375,7 @@ function getFeedName(feed, is_cat) {
if (isNaN(feed)) return feed; // it's a tag if (isNaN(feed)) return feed; // it's a tag
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree && tree.model) if (tree && tree.model)
return tree.model.getFeedValue(feed, is_cat, 'name'); return tree.model.getFeedValue(feed, is_cat, 'name');
@ -385,7 +383,7 @@ function getFeedName(feed, is_cat) {
function getFeedValue(feed, is_cat, key) { function getFeedValue(feed, is_cat, key) {
try { try {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree && tree.model) if (tree && tree.model)
return tree.model.getFeedValue(feed, is_cat, key); return tree.model.getFeedValue(feed, is_cat, key);
@ -397,7 +395,7 @@ function getFeedValue(feed, is_cat, key) {
} }
function setFeedUnread(feed, is_cat, unread) { function setFeedUnread(feed, is_cat, unread) {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree && tree.model) if (tree && tree.model)
return tree.model.setFeedUnread(feed, is_cat, unread); return tree.model.setFeedUnread(feed, is_cat, unread);
@ -405,7 +403,7 @@ function setFeedUnread(feed, is_cat, unread) {
function setFeedValue(feed, is_cat, key, value) { function setFeedValue(feed, is_cat, key, value) {
try { try {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree && tree.model) if (tree && tree.model)
return tree.model.setFeedValue(feed, is_cat, key, value); return tree.model.setFeedValue(feed, is_cat, key, value);
@ -416,19 +414,19 @@ function setFeedValue(feed, is_cat, key, value) {
} }
function selectFeed(feed, is_cat) { function selectFeed(feed, is_cat) {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree) return tree.selectFeed(feed, is_cat); if (tree) return tree.selectFeed(feed, is_cat);
} }
function setFeedIcon(feed, is_cat, src) { function setFeedIcon(feed, is_cat, src) {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree) return tree.setFeedIcon(feed, is_cat, src); if (tree) return tree.setFeedIcon(feed, is_cat, src);
} }
function setFeedExpandoIcon(feed, is_cat, src) { function setFeedExpandoIcon(feed, is_cat, src) {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree) return tree.setFeedExpandoIcon(feed, is_cat, src); if (tree) return tree.setFeedExpandoIcon(feed, is_cat, src);
@ -436,8 +434,8 @@ function setFeedExpandoIcon(feed, is_cat, src) {
} }
function getNextUnreadFeed(feed, is_cat) { function getNextUnreadFeed(feed, is_cat) {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
var nuf = tree.model.getNextUnreadFeed(feed, is_cat); const nuf = tree.model.getNextUnreadFeed(feed, is_cat);
if (nuf) if (nuf)
return tree.model.store.getValue(nuf, 'bare_id'); return tree.model.store.getValue(nuf, 'bare_id');
@ -448,13 +446,13 @@ function catchupCurrentFeed(mode) {
} }
function catchupFeedInGroup(id) { function catchupFeedInGroup(id) {
var title = getFeedName(id); const title = getFeedName(id);
var str = __("Mark all articles in %s as read?").replace("%s", title); const str = __("Mark all articles in %s as read?").replace("%s", title);
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
var rows = $$("#headlines-frame > div[id*=RROW][data-orig-feed-id='"+id+"']"); const rows = $$("#headlines-frame > div[id*=RROW][data-orig-feed-id='"+id+"']");
if (rows.length > 0) { if (rows.length > 0) {
@ -467,9 +465,9 @@ function catchupFeedInGroup(id) {
}); });
var feedTitles = $$("#headlines-frame > div[class='cdmFeedTitle']"); const feedTitles = $$("#headlines-frame > div[class='cdmFeedTitle']");
for (var i = 0; i < feedTitles.length; i++) { for (let i = 0; i < feedTitles.length; i++) {
if (feedTitles[i].getAttribute("data-feed-id") == id) { if (feedTitles[i].getAttribute("data-feed-id") == id) {
if (i < feedTitles.length - 1) { if (i < feedTitles.length - 1) {
@ -483,7 +481,7 @@ function catchupFeedInGroup(id) {
updateFloatingTitle(true); updateFloatingTitle(true);
} }
var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" + const catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
id + "&is_cat=false"; id + "&is_cat=false";
console.log(catchup_query); console.log(catchup_query);
@ -504,7 +502,7 @@ function catchupFeedInGroup(id) {
function catchupFeed(feed, is_cat, mode) { function catchupFeed(feed, is_cat, mode) {
if (is_cat == undefined) is_cat = false; if (is_cat == undefined) is_cat = false;
var str = false; let str = false;
switch (mode) { switch (mode) {
case "1day": case "1day":
@ -520,8 +518,8 @@ function catchupFeed(feed, is_cat, mode) {
str = __("Mark %w in %s as read?"); str = __("Mark %w in %s as read?");
} }
var mark_what = last_search_query && last_search_query[0] ? __("search results") : __("all articles"); const mark_what = last_search_query && last_search_query[0] ? __("search results") : __("all articles");
var fn = getFeedName(feed, is_cat); const fn = getFeedName(feed, is_cat);
str = str.replace("%s", fn) str = str.replace("%s", fn)
.replace("%w", mark_what); .replace("%w", mark_what);
@ -530,7 +528,7 @@ function catchupFeed(feed, is_cat, mode) {
return; return;
} }
var catchup_query = {op: 'rpc', method: 'catchupFeed', feed_id: feed, const catchup_query = {op: 'rpc', method: 'catchupFeed', feed_id: feed,
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]};
@ -543,19 +541,17 @@ function catchupFeed(feed, is_cat, mode) {
onComplete: function(transport) { onComplete: function(transport) {
handle_rpc_json(transport); handle_rpc_json(transport);
var 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) {
var 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 { } else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
viewCurrentFeed(); viewCurrentFeed();
} }
}
notify(""); notify("");
} }); } });
@ -563,7 +559,7 @@ function catchupFeed(feed, is_cat, mode) {
} }
function decrementFeedCounter(feed, is_cat) { function decrementFeedCounter(feed, is_cat) {
var ctr = getFeedUnread(feed, is_cat); let ctr = getFeedUnread(feed, is_cat);
if (ctr > 0) { if (ctr > 0) {
setFeedUnread(feed, is_cat, ctr - 1); setFeedUnread(feed, is_cat, ctr - 1);
@ -571,7 +567,7 @@ function decrementFeedCounter(feed, is_cat) {
updateTitle(); updateTitle();
if (!is_cat) { if (!is_cat) {
var cat = parseInt(getFeedCategory(feed)); const cat = parseInt(getFeedCategory(feed));
if (!isNaN(cat)) { if (!isNaN(cat)) {
ctr = getFeedUnread(cat, true); ctr = getFeedUnread(cat, true);

View File

@ -25,12 +25,11 @@ Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
/* add method to remove element from array */ /* add method to remove element from array */
Array.prototype.remove = function(s) { Array.prototype.remove = function(s) {
for (var i=0; i < this.length; i++) { for (let i=0; i < this.length; i++) {
if (s == this[i]) this.splice(i, 1); if (s == this[i]) this.splice(i, 1);
} }
}; };
function report_error(message, filename, lineno, colno, error) { function report_error(message, filename, lineno, colno, error) {
exception_error(error, null, filename, lineno); exception_error(error, null, filename, lineno);
} }
@ -42,7 +41,7 @@ function exception_error(e, e_compat, filename, lineno, colno) {
try { try {
console.error(e); console.error(e);
var msg = e.toString(); const msg = e.toString();
try { try {
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -58,7 +57,7 @@ function exception_error(e, e_compat, filename, lineno, colno) {
console.error("Exception while trying to log the error.", e); console.error("Exception while trying to log the error.", e);
} }
var content = "<div class='fatalError'><p>" + msg + "</p>"; let content = "<div class='fatalError'><p>" + msg + "</p>";
if (e.stack) { if (e.stack) {
content += "<div><b>Stack trace:</b></div>" + content += "<div><b>Stack trace:</b></div>" +
@ -77,7 +76,7 @@ function exception_error(e, e_compat, filename, lineno, colno) {
if (dijit.byId("exceptionDlg")) if (dijit.byId("exceptionDlg"))
dijit.byId("exceptionDlg").destroyRecursive(); dijit.byId("exceptionDlg").destroyRecursive();
var dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
id: "exceptionDlg", id: "exceptionDlg",
title: "Unhandled exception", title: "Unhandled exception",
style: "width: 600px", style: "width: 600px",
@ -101,7 +100,7 @@ function param_escape(arg) {
function notify_real(msg, no_hide, n_type) { function notify_real(msg, no_hide, n_type) {
var n = $("notify"); const n = $("notify");
if (!n) return; if (!n) return;
@ -183,7 +182,7 @@ function notify_info(msg, no_hide) {
function setCookie(name, value, lifetime, path, domain, secure) { function setCookie(name, value, lifetime, path, domain, secure) {
var d = false; let d = false;
if (lifetime) { if (lifetime) {
d = new Date(); d = new Date();
@ -216,9 +215,9 @@ function delCookie(name, path, domain) {
function getCookie(name) { function getCookie(name) {
var dc = document.cookie; const dc = document.cookie;
var prefix = name + "="; const prefix = name + "=";
var begin = dc.indexOf("; " + prefix); let begin = dc.indexOf("; " + prefix);
if (begin == -1) { if (begin == -1) {
begin = dc.indexOf(prefix); begin = dc.indexOf(prefix);
if (begin != 0) return null; if (begin != 0) return null;
@ -226,7 +225,7 @@ function getCookie(name) {
else { else {
begin += 2; begin += 2;
} }
var end = document.cookie.indexOf(";", begin); let end = document.cookie.indexOf(";", begin);
if (end == -1) { if (end == -1) {
end = dc.length; end = dc.length;
} }
@ -246,13 +245,13 @@ function gotoMain() {
} }
function toggleSelectRowById(sender, id) { function toggleSelectRowById(sender, id) {
var row = $(id); const row = $(id);
return toggleSelectRow(sender, row); return toggleSelectRow(sender, row);
} }
/* this is for dijit Checkbox */ /* this is for dijit Checkbox */
function toggleSelectListRow2(sender) { function toggleSelectListRow2(sender) {
var row = sender.domNode.parentNode; const row = sender.domNode.parentNode;
return toggleSelectRow(sender, row); return toggleSelectRow(sender, row);
} }
@ -301,7 +300,7 @@ function getURLParam(param){
} }
function closeInfoBox() { function closeInfoBox() {
var dialog = dijit.byId("infoBox"); const dialog = dijit.byId("infoBox");
if (dialog) dialog.hide(); if (dialog) dialog.hide();
@ -313,7 +312,7 @@ function displayDlg(title, id, param, callback) {
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
var query = "?op=dlg&method=" + const query = "?op=dlg&method=" +
param_escape(id) + "&param=" + param_escape(param); param_escape(id) + "&param=" + param_escape(param);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -327,7 +326,7 @@ function displayDlg(title, id, param, callback) {
} }
function infobox_callback2(transport, title) { function infobox_callback2(transport, title) {
var dialog = false; let dialog = false;
if (dijit.byId("infoBox")) { if (dijit.byId("infoBox")) {
dialog = dijit.byId("infoBox"); dialog = dijit.byId("infoBox");
@ -336,7 +335,7 @@ function infobox_callback2(transport, title) {
//console.log("infobox_callback2"); //console.log("infobox_callback2");
notify(''); notify('');
var content = transport.responseText; const content = transport.responseText;
if (!dialog) { if (!dialog) {
dialog = new dijit.Dialog({ dialog = new dijit.Dialog({
@ -390,7 +389,7 @@ function fatalError(code, msg, ext_info) {
msg = ERRORS[code]; msg = ERRORS[code];
} }
var content = "<div><b>Error code:</b> " + code + "</div>" + let content = "<div><b>Error code:</b> " + code + "</div>" +
"<p>" + msg + "</p>"; "<p>" + msg + "</p>";
if (ext_info) { if (ext_info) {
@ -399,7 +398,7 @@ function fatalError(code, msg, ext_info) {
ext_info + "</textarea>"; ext_info + "</textarea>";
} }
var dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
title: "Fatal error", title: "Fatal error",
style: "width: 600px", style: "width: 600px",
content: content}); content: content});
@ -413,9 +412,9 @@ function fatalError(code, msg, ext_info) {
} }
function filterDlgCheckAction(sender) { function filterDlgCheckAction(sender) {
var action = sender.value; const action = sender.value;
var action_param = $("filterDlg_paramBox"); const action_param = $("filterDlg_paramBox");
if (!action_param) { if (!action_param) {
console.log("filterDlgCheckAction: can't find action param box!"); console.log("filterDlgCheckAction: can't find action param box!");
@ -474,8 +473,8 @@ function strip_tags(s) {
function hotkey_prefix_timeout() { function hotkey_prefix_timeout() {
var date = new Date(); const date = new Date();
var ts = Math.round(date.getTime() / 1000); const ts = Math.round(date.getTime() / 1000);
if (hotkey_prefix_pressed && ts - hotkey_prefix_pressed >= 5) { if (hotkey_prefix_pressed && ts - hotkey_prefix_pressed >= 5) {
console.log("hotkey_prefix seems to be stuck, aborting"); console.log("hotkey_prefix seems to be stuck, aborting");
@ -509,7 +508,7 @@ function uploadIconHandler(rc) {
function removeFeedIcon(id) { function removeFeedIcon(id) {
if (confirm(__("Remove stored feed icon?"))) { if (confirm(__("Remove stored feed icon?"))) {
var query = "backend.php?op=pref-feeds&method=removeicon&feed_id=" + param_escape(id); const query = "backend.php?op=pref-feeds&method=removeicon&feed_id=" + param_escape(id);
console.log(query); console.log(query);
@ -531,23 +530,21 @@ function removeFeedIcon(id) {
} }
function uploadFeedIcon() { function uploadFeedIcon() {
var file = $("icon_file"); const file = $("icon_file");
if (file.value.length == 0) { if (file.value.length == 0) {
alert(__("Please select an image file to upload.")); alert(__("Please select an image file to upload."));
} else { } else if (confirm(__("Upload new icon for this feed?"))) {
if (confirm(__("Upload new icon for this feed?"))) {
notify_progress("Uploading, please wait...", true); notify_progress("Uploading, please wait...", true);
return true; return true;
} }
}
return false; return false;
} }
function addLabel(select, callback) { function addLabel(select, callback) {
var caption = prompt(__("Please enter label caption:"), ""); const caption = prompt(__("Please enter label caption:"), "");
if (caption != undefined) { if (caption != undefined) {
@ -556,7 +553,7 @@ function addLabel(select, callback) {
return false; return false;
} }
var query = "?op=pref-labels&method=add&caption=" + let query = "?op=pref-labels&method=add&caption=" +
param_escape(caption); param_escape(caption);
if (select) if (select)
@ -581,7 +578,7 @@ function addLabel(select, callback) {
} }
function quickAddFeed() { function quickAddFeed() {
var query = "backend.php?op=feeds&method=quickAddFeed"; const query = "backend.php?op=feeds&method=quickAddFeed";
// overlapping widgets // overlapping widgets
if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive(); if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
@ -592,7 +589,7 @@ function quickAddFeed() {
title: __("Subscribe to Feed"), title: __("Subscribe to Feed"),
style: "width: 600px", style: "width: 600px",
show_error: function(msg) { show_error: function(msg) {
var elem = $("fadd_error_message"); const elem = $("fadd_error_message");
elem.innerHTML = msg; elem.innerHTML = msg;
@ -604,7 +601,7 @@ function quickAddFeed() {
if (this.validate()) { if (this.validate()) {
console.log(dojo.objectToQuery(this.attr('value'))); console.log(dojo.objectToQuery(this.attr('value')));
var feed_url = this.attr('value').feed; const feed_url = this.attr('value').feed;
Element.show("feed_add_spinner"); Element.show("feed_add_spinner");
Element.hide("fadd_error_message"); Element.hide("fadd_error_message");
@ -623,7 +620,7 @@ function quickAddFeed() {
return; return;
} }
var rc = reply['result']; const rc = reply['result'];
notify(''); notify('');
Element.hide("feed_add_spinner"); Element.hide("feed_add_spinner");
@ -656,7 +653,7 @@ function quickAddFeed() {
select.addOption({value: '', label: __("Expand to select feed")}); select.addOption({value: '', label: __("Expand to select feed")});
var count = 0; var count = 0;
for (var feedUrl in feeds) { for (const feedUrl in feeds) {
select.addOption({value: feedUrl, label: feeds[feedUrl]}); select.addOption({value: feedUrl, label: feeds[feedUrl]});
count++; count++;
} }
@ -692,11 +689,11 @@ function quickAddFeed() {
} }
function createNewRuleElement(parentNode, replaceNode) { function createNewRuleElement(parentNode, replaceNode) {
var form = document.forms["filter_new_rule_form"]; const form = document.forms["filter_new_rule_form"];
//form.reg_exp.value = form.reg_exp.value.replace(/(<([^>]+)>)/ig,""); //form.reg_exp.value = form.reg_exp.value.replace(/(<([^>]+)>)/ig,"");
var query = "backend.php?op=pref-filters&method=printrulename&rule="+ const query = "backend.php?op=pref-filters&method=printrulename&rule="+
param_escape(dojo.formToJson(form)); param_escape(dojo.formToJson(form));
console.log(query); console.log(query);
@ -705,9 +702,9 @@ function createNewRuleElement(parentNode, replaceNode) {
parameters: query, parameters: query,
onComplete: function (transport) { onComplete: function (transport) {
try { try {
var li = dojo.create("li"); const li = dojo.create("li");
var cb = dojo.create("input", { type: "checkbox" }, li); const cb = dojo.create("input", { type: "checkbox" }, li);
new dijit.form.CheckBox({ new dijit.form.CheckBox({
onChange: function() { onChange: function() {
@ -736,7 +733,7 @@ function createNewRuleElement(parentNode, replaceNode) {
} }
function createNewActionElement(parentNode, replaceNode) { function createNewActionElement(parentNode, replaceNode) {
var form = document.forms["filter_new_action_form"]; const form = document.forms["filter_new_action_form"];
if (form.action_id.value == 7) { if (form.action_id.value == 7) {
form.action_param.value = form.action_param_label.value; form.action_param.value = form.action_param_label.value;
@ -744,7 +741,7 @@ function createNewActionElement(parentNode, replaceNode) {
form.action_param.value = form.action_param_plugin.value; form.action_param.value = form.action_param_plugin.value;
} }
var query = "backend.php?op=pref-filters&method=printactionname&action="+ const query = "backend.php?op=pref-filters&method=printactionname&action="+
param_escape(dojo.formToJson(form)); param_escape(dojo.formToJson(form));
console.log(query); console.log(query);
@ -753,9 +750,9 @@ function createNewActionElement(parentNode, replaceNode) {
parameters: query, parameters: query,
onComplete: function (transport) { onComplete: function (transport) {
try { try {
var li = dojo.create("li"); const li = dojo.create("li");
var cb = dojo.create("input", { type: "checkbox" }, li); const cb = dojo.create("input", { type: "checkbox" }, li);
new dijit.form.CheckBox({ new dijit.form.CheckBox({
onChange: function() { onChange: function() {
@ -789,10 +786,10 @@ function addFilterRule(replaceNode, ruleStr) {
if (dijit.byId("filterNewRuleDlg")) if (dijit.byId("filterNewRuleDlg"))
dijit.byId("filterNewRuleDlg").destroyRecursive(); dijit.byId("filterNewRuleDlg").destroyRecursive();
var query = "backend.php?op=pref-filters&method=newrule&rule=" + const query = "backend.php?op=pref-filters&method=newrule&rule=" +
param_escape(ruleStr); param_escape(ruleStr);
var rule_dlg = new dijit.Dialog({ const rule_dlg = new dijit.Dialog({
id: "filterNewRuleDlg", id: "filterNewRuleDlg",
title: ruleStr ? __("Edit rule") : __("Add rule"), title: ruleStr ? __("Edit rule") : __("Add rule"),
style: "width: 600px", style: "width: 600px",
@ -811,10 +808,10 @@ function addFilterAction(replaceNode, actionStr) {
if (dijit.byId("filterNewActionDlg")) if (dijit.byId("filterNewActionDlg"))
dijit.byId("filterNewActionDlg").destroyRecursive(); dijit.byId("filterNewActionDlg").destroyRecursive();
var query = "backend.php?op=pref-filters&method=newaction&action=" + const query = "backend.php?op=pref-filters&method=newaction&action=" +
param_escape(actionStr); param_escape(actionStr);
var rule_dlg = new dijit.Dialog({ const rule_dlg = new dijit.Dialog({
id: "filterNewActionDlg", id: "filterNewActionDlg",
title: actionStr ? __("Edit action") : __("Add action"), title: actionStr ? __("Edit action") : __("Add action"),
style: "width: 600px", style: "width: 600px",
@ -842,7 +839,7 @@ function editFilterTest(query) {
limit: 100, limit: 100,
max_offset: 10000, max_offset: 10000,
getTestResults: function(query, offset) { getTestResults: function(query, offset) {
var updquery = query + "&offset=" + offset + "&limit=" + test_dlg.limit; const updquery = query + "&offset=" + offset + "&limit=" + test_dlg.limit;
console.log("getTestResults:" + offset); console.log("getTestResults:" + offset);
@ -850,7 +847,7 @@ function editFilterTest(query) {
parameters: updquery, parameters: updquery,
onComplete: function (transport) { onComplete: function (transport) {
try { try {
var result = JSON.parse(transport.responseText); const result = JSON.parse(transport.responseText);
if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) { if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) {
test_dlg.results += result.size(); test_dlg.results += result.size();
@ -863,8 +860,8 @@ function editFilterTest(query) {
console.log(offset + " " + test_dlg.max_offset); console.log(offset + " " + test_dlg.max_offset);
for (var i = 0; i < result.size(); i++) { for (let i = 0; i < result.size(); i++) {
var tmp = new Element("table"); const tmp = new Element("table");
tmp.innerHTML = result[i]; tmp.innerHTML = result[i];
dojo.parser.parse(tmp); dojo.parser.parse(tmp);
@ -920,7 +917,7 @@ function editFilterTest(query) {
} }
function quickAddFilter() { function quickAddFilter() {
var query = ""; let query = "";
if (!inPreferences()) { if (!inPreferences()) {
query = "backend.php?op=pref-filters&method=newfilter&feed=" + query = "backend.php?op=pref-filters&method=newfilter&feed=" +
param_escape(getActiveFeedId()) + "&is_cat=" + param_escape(getActiveFeedId()) + "&is_cat=" +
@ -942,7 +939,7 @@ function quickAddFilter() {
title: __("Create Filter"), title: __("Create Filter"),
style: "width: 600px", style: "width: 600px",
test: function() { test: function() {
var query = "backend.php?" + dojo.formToQuery("filter_new_form") + "&savemode=test"; const query = "backend.php?" + dojo.formToQuery("filter_new_form") + "&savemode=test";
editFilterTest(query); editFilterTest(query);
}, },
@ -967,13 +964,13 @@ function quickAddFilter() {
}); });
}, },
editRule: function(e) { editRule: function(e) {
var li = e.parentNode; const li = e.parentNode;
var rule = li.getElementsByTagName("INPUT")[1].value; const rule = li.getElementsByTagName("INPUT")[1].value;
addFilterRule(li, rule); addFilterRule(li, rule);
}, },
editAction: function(e) { editAction: function(e) {
var li = e.parentNode; const li = e.parentNode;
var action = li.getElementsByTagName("INPUT")[1].value; const action = li.getElementsByTagName("INPUT")[1].value;
addFilterAction(li, action); addFilterAction(li, action);
}, },
addAction: function() { addFilterAction(); }, addAction: function() { addFilterAction(); },
@ -987,7 +984,7 @@ function quickAddFilter() {
execute: function() { execute: function() {
if (this.validate()) { if (this.validate()) {
var query = dojo.formToQuery("filter_new_form"); const query = dojo.formToQuery("filter_new_form");
console.log(query); console.log(query);
@ -1005,30 +1002,30 @@ function quickAddFilter() {
href: query}); href: query});
if (!inPreferences()) { if (!inPreferences()) {
var selectedText = getSelectionText(); const selectedText = getSelectionText();
var lh = dojo.connect(dialog, "onLoad", function(){ var lh = dojo.connect(dialog, "onLoad", function(){
dojo.disconnect(lh); dojo.disconnect(lh);
if (selectedText != "") { if (selectedText != "") {
var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : const feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
getActiveFeedId(); getActiveFeedId();
var rule = { reg_exp: selectedText, feed_id: [feed_id], filter_type: 1 }; const rule = { reg_exp: selectedText, feed_id: [feed_id], filter_type: 1 };
addFilterRule(null, dojo.toJson(rule)); addFilterRule(null, dojo.toJson(rule));
} else { } else {
var query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId(); const query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId();
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
var reply = JSON.parse(transport.responseText); const reply = JSON.parse(transport.responseText);
var title = false; let title = false;
if (reply && reply.title) title = reply.title; if (reply && reply.title) title = reply.title;
@ -1036,10 +1033,10 @@ function quickAddFilter() {
console.log(title + " " + getActiveFeedId()); console.log(title + " " + getActiveFeedId());
var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : const feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
getActiveFeedId(); getActiveFeedId();
var rule = { reg_exp: title, feed_id: [feed_id], filter_type: 1 }; const rule = { reg_exp: title, feed_id: [feed_id], filter_type: 1 };
addFilterRule(null, dojo.toJson(rule)); addFilterRule(null, dojo.toJson(rule));
} }
@ -1057,12 +1054,12 @@ function quickAddFilter() {
function unsubscribeFeed(feed_id, title) { function unsubscribeFeed(feed_id, title) {
var msg = __("Unsubscribe from %s?").replace("%s", title); const msg = __("Unsubscribe from %s?").replace("%s", title);
if (title == undefined || confirm(msg)) { if (title == undefined || confirm(msg)) {
notify_progress("Removing feed..."); notify_progress("Removing feed...");
var query = "?op=pref-feeds&quiet=1&method=remove&ids=" + feed_id; const query = "?op=pref-feeds&quiet=1&method=remove&ids=" + feed_id;
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
@ -1095,14 +1092,14 @@ function backend_sanity_check_callback(transport) {
return; return;
} }
var reply = JSON.parse(transport.responseText); const reply = JSON.parse(transport.responseText);
if (!reply) { if (!reply) {
fatalError(3, "Sanity check: invalid RPC reply", transport.responseText); fatalError(3, "Sanity check: invalid RPC reply", transport.responseText);
return; return;
} }
var error_code = reply['error']['code']; const error_code = reply['error']['code'];
if (error_code && error_code != 0) { if (error_code && error_code != 0) {
return fatalError(error_code, reply['error']['message']); return fatalError(error_code, reply['error']['message']);
@ -1110,12 +1107,12 @@ function backend_sanity_check_callback(transport) {
console.log("sanity check ok"); console.log("sanity check ok");
var params = reply['init-params']; const params = reply['init-params'];
if (params) { if (params) {
console.log('reading init-params...'); console.log('reading init-params...');
for (var k in params) { for (const k in params) {
console.log("IP: " + k + " => " + JSON.stringify(params[k])); console.log("IP: " + k + " => " + JSON.stringify(params[k]));
if (k == "label_base_index") _label_base_index = parseInt(params[k]); if (k == "label_base_index") _label_base_index = parseInt(params[k]);
} }
@ -1133,22 +1130,22 @@ function backend_sanity_check_callback(transport) {
} }
function genUrlChangeKey(feed, is_cat) { function genUrlChangeKey(feed, is_cat) {
var ok = confirm(__("Generate new syndication address for this feed?")); const ok = confirm(__("Generate new syndication address for this feed?"));
if (ok) { if (ok) {
notify_progress("Trying to change address...", true); notify_progress("Trying to change address...", true);
var query = "?op=pref-feeds&method=regenFeedKey&id=" + param_escape(feed) + const query = "?op=pref-feeds&method=regenFeedKey&id=" + param_escape(feed) +
"&is_cat=" + param_escape(is_cat); "&is_cat=" + param_escape(is_cat);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
var reply = JSON.parse(transport.responseText); const reply = JSON.parse(transport.responseText);
var new_link = reply.link; const new_link = reply.link;
var e = $('gen_feed_url'); const e = $('gen_feed_url');
if (new_link) { if (new_link) {
@ -1172,19 +1169,19 @@ function genUrlChangeKey(feed, is_cat) {
// mode = all, none, invert // mode = all, none, invert
function selectTableRows(id, mode) { function selectTableRows(id, mode) {
var rows = $(id).rows; const rows = $(id).rows;
for (var i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
var row = rows[i]; const row = rows[i];
var cb = false; let cb = false;
var dcb = false; let dcb = false;
if (row.id && row.className) { if (row.id && row.className) {
var bare_id = row.id.replace(/^[A-Z]*?-/, ""); const bare_id = row.id.replace(/^[A-Z]*?-/, "");
var inputs = rows[i].getElementsByTagName("input"); const inputs = rows[i].getElementsByTagName("input");
for (var j = 0; j < inputs.length; j++) { for (let j = 0; j < inputs.length; j++) {
var input = inputs[j]; const input = inputs[j];
if (input.getAttribute("type") == "checkbox" && if (input.getAttribute("type") == "checkbox" &&
input.id.match(bare_id)) { input.id.match(bare_id)) {
@ -1196,7 +1193,7 @@ function selectTableRows(id, mode) {
} }
if (cb || dcb) { if (cb || dcb) {
var issel = row.hasClassName("Selected"); const issel = row.hasClassName("Selected");
if (mode == "all" && !issel) { if (mode == "all" && !issel) {
row.addClassName("Selected"); row.addClassName("Selected");
@ -1226,13 +1223,13 @@ function selectTableRows(id, mode) {
} }
function getSelectedTableRowIds(id) { function getSelectedTableRowIds(id) {
var rows = []; const rows = [];
var elem_rows = $(id).rows; const elem_rows = $(id).rows;
for (var i = 0; i < elem_rows.length; i++) { for (let i = 0; i < elem_rows.length; i++) {
if (elem_rows[i].hasClassName("Selected")) { if (elem_rows[i].hasClassName("Selected")) {
var bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, ""); const bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, "");
rows.push(bare_id); rows.push(bare_id);
} }
} }
@ -1244,7 +1241,7 @@ function editFeed(feed) {
if (feed <= 0) if (feed <= 0)
return alert(__("You can't edit this kind of feed.")); return alert(__("You can't edit this kind of feed."));
var query = "backend.php?op=pref-feeds&method=editfeed&id=" + const query = "backend.php?op=pref-feeds&method=editfeed&id=" +
param_escape(feed); param_escape(feed);
console.log(query); console.log(query);
@ -1280,7 +1277,7 @@ function editFeed(feed) {
} }
function feedBrowser() { function feedBrowser() {
var query = "backend.php?op=feeds&method=feedBrowser"; const query = "backend.php?op=feeds&method=feedBrowser";
if (dijit.byId("feedAddDlg")) if (dijit.byId("feedAddDlg"))
dijit.byId("feedAddDlg").hide(); dijit.byId("feedAddDlg").hide();
@ -1293,11 +1290,11 @@ function feedBrowser() {
title: __("More Feeds"), title: __("More Feeds"),
style: "width: 600px", style: "width: 600px",
getSelectedFeedIds: function () { getSelectedFeedIds: function () {
var list = $$("#browseFeedList li[id*=FBROW]"); const list = $$("#browseFeedList li[id*=FBROW]");
var selected = new Array(); const selected = new Array();
list.each(function (child) { list.each(function (child) {
var id = child.id.replace("FBROW-", ""); const id = child.id.replace("FBROW-", "");
if (child.hasClassName('Selected')) { if (child.hasClassName('Selected')) {
selected.push(id); selected.push(id);
@ -1307,12 +1304,12 @@ function feedBrowser() {
return selected; return selected;
}, },
getSelectedFeeds: function () { getSelectedFeeds: function () {
var list = $$("#browseFeedList li.Selected"); const list = $$("#browseFeedList li.Selected");
var selected = new Array(); const selected = new Array();
list.each(function (child) { list.each(function (child) {
var title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML; const title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML;
var url = child.getElementsBySelector("a.fb_feedUrl")[0].href; const url = child.getElementsBySelector("a.fb_feedUrl")[0].href;
selected.push([title, url]); selected.push([title, url]);
@ -1322,8 +1319,8 @@ function feedBrowser() {
}, },
subscribe: function () { subscribe: function () {
var mode = this.attr('value').mode; const mode = this.attr('value').mode;
var selected = []; let selected = [];
if (mode == "1") if (mode == "1")
selected = this.getSelectedFeeds(); selected = this.getSelectedFeeds();
@ -1338,7 +1335,7 @@ function feedBrowser() {
// we use dojo.toJson instead of JSON.stringify because // we use dojo.toJson instead of JSON.stringify because
// it somehow escapes everything TWICE, at least in Chrome 9 // it somehow escapes everything TWICE, at least in Chrome 9
var query = "?op=rpc&method=massSubscribe&payload=" + const query = "?op=rpc&method=massSubscribe&payload=" +
param_escape(dojo.toJson(selected)) + "&mode=" + param_escape(mode); param_escape(dojo.toJson(selected)) + "&mode=" + param_escape(mode);
console.log(query); console.log(query);
@ -1357,7 +1354,7 @@ function feedBrowser() {
}, },
update: function () { update: function () {
var query = dojo.objectToQuery(dialog.attr('value')); const query = dojo.objectToQuery(dialog.attr('value'));
Element.show('feed_browser_spinner'); Element.show('feed_browser_spinner');
@ -1368,12 +1365,12 @@ function feedBrowser() {
Element.hide('feed_browser_spinner'); Element.hide('feed_browser_spinner');
var c = $("browseFeedList"); const c = $("browseFeedList");
var reply = JSON.parse(transport.responseText); const reply = JSON.parse(transport.responseText);
var r = reply['content']; const r = reply['content'];
var mode = reply['mode']; const mode = reply['mode'];
if (c && r) { if (c && r) {
c.innerHTML = r; c.innerHTML = r;
@ -1391,18 +1388,18 @@ function feedBrowser() {
}); });
}, },
removeFromArchive: function () { removeFromArchive: function () {
var selected = this.getSelectedFeedIds(); const selected = this.getSelectedFeedIds();
if (selected.length > 0) { if (selected.length > 0) {
var pr = __("Remove selected feeds from the archive? Feeds with stored articles will not be removed."); const pr = __("Remove selected feeds from the archive? Feeds with stored articles will not be removed.");
if (confirm(pr)) { if (confirm(pr)) {
Element.show('feed_browser_spinner'); Element.show('feed_browser_spinner');
var query = "?op=rpc&method=remarchive&ids=" + const query = "?op=rpc&method=remarchive&ids=" +
param_escape(selected.toString()); param_escape(selected.toString());
;
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
@ -1425,7 +1422,7 @@ function feedBrowser() {
} }
function showFeedsWithErrors() { function showFeedsWithErrors() {
var query = "backend.php?op=pref-feeds&method=feedsWithErrors"; const query = "backend.php?op=pref-feeds&method=feedsWithErrors";
if (dijit.byId("errorFeedsDlg")) if (dijit.byId("errorFeedsDlg"))
dijit.byId("errorFeedsDlg").destroyRecursive(); dijit.byId("errorFeedsDlg").destroyRecursive();
@ -1438,17 +1435,17 @@ function showFeedsWithErrors() {
return getSelectedTableRowIds("prefErrorFeedList"); return getSelectedTableRowIds("prefErrorFeedList");
}, },
removeSelected: function() { removeSelected: function() {
var sel_rows = this.getSelectedFeeds(); const sel_rows = this.getSelectedFeeds();
console.log(sel_rows); console.log(sel_rows);
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected feeds?")); const ok = confirm(__("Remove selected feeds?"));
if (ok) { if (ok) {
notify_progress("Removing selected feeds...", true); notify_progress("Removing selected feeds...", true);
var query = "?op=pref-feeds&method=remove&ids="+ const query = "?op=pref-feeds&method=remove&ids="+
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1474,17 +1471,17 @@ function showFeedsWithErrors() {
} }
function get_timestamp() { function get_timestamp() {
var date = new Date(); const date = new Date();
return Math.round(date.getTime() / 1000); return Math.round(date.getTime() / 1000);
} }
function helpDialog(topic) { function helpDialog(topic) {
var query = "backend.php?op=backend&method=help&topic=" + param_escape(topic); const query = "backend.php?op=backend&method=help&topic=" + param_escape(topic);
if (dijit.byId("helpDlg")) if (dijit.byId("helpDlg"))
dijit.byId("helpDlg").destroyRecursive(); dijit.byId("helpDlg").destroyRecursive();
var dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
id: "helpDlg", id: "helpDlg",
title: __("Help"), title: __("Help"),
style: "width: 600px", style: "width: 600px",
@ -1514,14 +1511,14 @@ function htmlspecialchars_decode (string, quote_style) {
// * returns 1: '<p>this -> &quot;</p>' // * returns 1: '<p>this -> &quot;</p>'
// * example 2: htmlspecialchars_decode("&amp;quot;"); // * example 2: htmlspecialchars_decode("&amp;quot;");
// * returns 2: '&quot;' // * returns 2: '&quot;'
var optTemp = 0, let optTemp = 0,
i = 0, i = 0,
noquotes = false; noquotes = false;
if (typeof quote_style === 'undefined') { if (typeof quote_style === 'undefined') {
quote_style = 2; quote_style = 2;
} }
string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>'); string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
var OPTS = { const OPTS = {
'ENT_NOQUOTES': 0, 'ENT_NOQUOTES': 0,
'ENT_HTML_QUOTE_SINGLE': 1, 'ENT_HTML_QUOTE_SINGLE': 1,
'ENT_HTML_QUOTE_DOUBLE': 2, 'ENT_HTML_QUOTE_DOUBLE': 2,
@ -1569,13 +1566,13 @@ function feed_to_label_id(feed) {
// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac // http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac
function getSelectionText() { function getSelectionText() {
var text = ""; let text = "";
if (typeof window.getSelection != "undefined") { if (typeof window.getSelection != "undefined") {
var sel = window.getSelection(); const sel = window.getSelection();
if (sel.rangeCount) { if (sel.rangeCount) {
var container = document.createElement("div"); const container = document.createElement("div");
for (var i = 0, len = sel.rangeCount; i < len; ++i) { for (let i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents()); container.appendChild(sel.getRangeAt(i).cloneContents());
} }
text = container.innerHTML; text = container.innerHTML;
@ -1590,13 +1587,13 @@ function getSelectionText() {
} }
function openUrlPopup(url) { function openUrlPopup(url) {
var w = window.open(""); const w = window.open("");
w.opener = null; w.opener = null;
w.location = url; w.location = url;
} }
function openArticlePopup(id) { function openArticlePopup(id) {
var w = window.open("", const w = window.open("",
"ttrss_article_popup", "ttrss_article_popup",
"height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no"); "height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no");

View File

@ -11,8 +11,8 @@ function notify_callback2(transport, sticky) {
function updateFeedList() { function updateFeedList() {
var user_search = $("feed_search"); const user_search = $("feed_search");
var search = ""; let search = "";
if (user_search) { search = user_search.value; } if (user_search) { search = user_search.value; }
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -36,14 +36,14 @@ function checkInactiveFeeds() {
} }
function updateUsersList(sort_key) { function updateUsersList(sort_key) {
var user_search = $("user_search"); const user_search = $("user_search");
var search = ""; let search = "";
if (user_search) { if (user_search) {
search = user_search.value; search = user_search.value;
} }
var query = "?op=pref-users&sort=" const query = "?op=pref-users&sort=" +
+ param_escape(sort_key) + param_escape(sort_key) +
"&search=" + param_escape(search); "&search=" + param_escape(search);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -57,7 +57,7 @@ function updateUsersList(sort_key) {
} }
function addUser() { function addUser() {
var login = prompt(__("Please enter login:"), ""); const login = prompt(__("Please enter login:"), "");
if (login == null) { if (login == null) {
return false; return false;
@ -70,7 +70,7 @@ function addUser() {
notify_progress("Adding user..."); notify_progress("Adding user...");
var query = "?op=pref-users&method=add&login=" + const query = "?op=pref-users&method=add&login=" +
param_escape(login); param_escape(login);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -85,7 +85,7 @@ function addUser() {
function editUser(id) { function editUser(id) {
var query = "backend.php?op=pref-users&method=edit&id=" + const query = "backend.php?op=pref-users&method=edit&id=" +
param_escape(id); param_escape(id);
if (dijit.byId("userEditDlg")) if (dijit.byId("userEditDlg"))
@ -99,7 +99,7 @@ function editUser(id) {
if (this.validate()) { if (this.validate()) {
notify_progress("Saving data...", true); notify_progress("Saving data...", true);
var query = dojo.formToQuery("user_edit_form"); const query = dojo.formToQuery("user_edit_form");
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
@ -118,7 +118,7 @@ function editUser(id) {
function editFilter(id) { function editFilter(id) {
var query = "backend.php?op=pref-filters&method=edit&id=" + param_escape(id); const query = "backend.php?op=pref-filters&method=edit&id=" + param_escape(id);
if (dijit.byId("feedEditDlg")) if (dijit.byId("feedEditDlg"))
dijit.byId("feedEditDlg").destroyRecursive(); dijit.byId("feedEditDlg").destroyRecursive();
@ -132,7 +132,7 @@ function editFilter(id) {
style: "width: 600px", style: "width: 600px",
test: function () { test: function () {
var query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test"; const query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test";
editFilterTest(query); editFilterTest(query);
}, },
@ -157,26 +157,26 @@ function editFilter(id) {
}); });
}, },
editRule: function (e) { editRule: function (e) {
var li = e.parentNode; const li = e.parentNode;
var rule = li.getElementsByTagName("INPUT")[1].value; const rule = li.getElementsByTagName("INPUT")[1].value;
addFilterRule(li, rule); addFilterRule(li, rule);
}, },
editAction: function (e) { editAction: function (e) {
var li = e.parentNode; const li = e.parentNode;
var action = li.getElementsByTagName("INPUT")[1].value; const action = li.getElementsByTagName("INPUT")[1].value;
addFilterAction(li, action); addFilterAction(li, action);
}, },
removeFilter: function () { removeFilter: function () {
var msg = __("Remove filter?"); const msg = __("Remove filter?");
if (confirm(msg)) { if (confirm(msg)) {
this.hide(); this.hide();
notify_progress("Removing filter..."); notify_progress("Removing filter...");
var id = this.attr('value').id; const id = this.attr('value').id;
var query = "?op=pref-filters&method=remove&ids=" + const query = "?op=pref-filters&method=remove&ids=" +
param_escape(id); param_escape(id);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -208,7 +208,7 @@ function editFilter(id) {
notify_progress("Saving data...", true); notify_progress("Saving data...", true);
var query = dojo.formToQuery("filter_edit_form"); const query = dojo.formToQuery("filter_edit_form");
console.log(query); console.log(query);
@ -229,9 +229,9 @@ function editFilter(id) {
function getSelectedLabels() { function getSelectedLabels() {
var tree = dijit.byId("labelTree"); const tree = dijit.byId("labelTree");
var items = tree.model.getCheckedItems(); const items = tree.model.getCheckedItems();
var rv = []; const rv = [];
items.each(function(item) { items.each(function(item) {
rv.push(tree.model.store.getValue(item, 'bare_id')); rv.push(tree.model.store.getValue(item, 'bare_id'));
@ -245,9 +245,9 @@ function getSelectedUsers() {
} }
function getSelectedFeeds() { function getSelectedFeeds() {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
var items = tree.model.getCheckedItems(); const items = tree.model.getCheckedItems();
var rv = []; const rv = [];
items.each(function(item) { items.each(function(item) {
if (item.id[0].match("FEED:")) if (item.id[0].match("FEED:"))
@ -258,9 +258,9 @@ function getSelectedFeeds() {
} }
function getSelectedCategories() { function getSelectedCategories() {
var tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
var items = tree.model.getCheckedItems(); const items = tree.model.getCheckedItems();
var rv = []; const rv = [];
items.each(function(item) { items.each(function(item) {
if (item.id[0].match("CAT:")) if (item.id[0].match("CAT:"))
@ -271,9 +271,9 @@ function getSelectedCategories() {
} }
function getSelectedFilters() { function getSelectedFilters() {
var tree = dijit.byId("filterTree"); const tree = dijit.byId("filterTree");
var items = tree.model.getCheckedItems(); const items = tree.model.getCheckedItems();
var rv = []; const rv = [];
items.each(function(item) { items.each(function(item) {
rv.push(tree.model.store.getValue(item, 'bare_id')); rv.push(tree.model.store.getValue(item, 'bare_id'));
@ -285,16 +285,16 @@ function getSelectedFilters() {
function removeSelectedLabels() { function removeSelectedLabels() {
var sel_rows = getSelectedLabels(); const sel_rows = getSelectedLabels();
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected labels?")); const ok = confirm(__("Remove selected labels?"));
if (ok) { if (ok) {
notify_progress("Removing selected labels..."); notify_progress("Removing selected labels...");
var query = "?op=pref-labels&method=remove&ids="+ const query = "?op=pref-labels&method=remove&ids="+
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -313,16 +313,16 @@ function removeSelectedLabels() {
function removeSelectedUsers() { function removeSelectedUsers() {
var sel_rows = getSelectedUsers(); const sel_rows = getSelectedUsers();
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed.")); const ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed."));
if (ok) { if (ok) {
notify_progress("Removing selected users..."); notify_progress("Removing selected users...");
var query = "?op=pref-users&method=remove&ids=" + const query = "?op=pref-users&method=remove&ids=" +
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -343,16 +343,16 @@ function removeSelectedUsers() {
function removeSelectedFilters() { function removeSelectedFilters() {
var sel_rows = getSelectedFilters(); const sel_rows = getSelectedFilters();
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected filters?")); const ok = confirm(__("Remove selected filters?"));
if (ok) { if (ok) {
notify_progress("Removing selected filters..."); notify_progress("Removing selected filters...");
var query = "?op=pref-filters&method=remove&ids=" + const query = "?op=pref-filters&method=remove&ids=" +
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -371,17 +371,17 @@ function removeSelectedFilters() {
function removeSelectedFeeds() { function removeSelectedFeeds() {
var sel_rows = getSelectedFeeds(); const sel_rows = getSelectedFeeds();
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
var ok = confirm(__("Unsubscribe from selected feeds?")); const ok = confirm(__("Unsubscribe from selected feeds?"));
if (ok) { if (ok) {
notify_progress("Unsubscribing from selected feeds...", true); notify_progress("Unsubscribing from selected feeds...", true);
var query = "?op=pref-feeds&method=remove&ids=" + const query = "?op=pref-feeds&method=remove&ids=" +
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
console.log(query); console.log(query);
@ -402,7 +402,7 @@ function removeSelectedFeeds() {
} }
function editSelectedUser() { function editSelectedUser() {
var rows = getSelectedUsers(); const rows = getSelectedUsers();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No users are selected.")); alert(__("No users are selected."));
@ -421,7 +421,7 @@ function editSelectedUser() {
function resetSelectedUserPass() { function resetSelectedUserPass() {
var rows = getSelectedUsers(); const rows = getSelectedUsers();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No users are selected.")); alert(__("No users are selected."));
@ -433,14 +433,14 @@ function resetSelectedUserPass() {
return; return;
} }
var ok = confirm(__("Reset password of selected user?")); const ok = confirm(__("Reset password of selected user?"));
if (ok) { if (ok) {
notify_progress("Resetting password for selected user..."); notify_progress("Resetting password for selected user...");
var id = rows[0]; const id = rows[0];
var query = "?op=pref-users&method=resetPass&id=" + const query = "?op=pref-users&method=resetPass&id=" +
param_escape(id); param_escape(id);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -455,7 +455,7 @@ function resetSelectedUserPass() {
function selectedUserDetails() { function selectedUserDetails() {
var rows = getSelectedUsers(); const rows = getSelectedUsers();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No users are selected.")); alert(__("No users are selected."));
@ -467,9 +467,9 @@ function selectedUserDetails() {
return; return;
} }
var id = rows[0]; const id = rows[0];
var query = "backend.php?op=pref-users&method=userdetails&id=" + id; const query = "backend.php?op=pref-users&method=userdetails&id=" + id;
if (dijit.byId("userDetailsDlg")) if (dijit.byId("userDetailsDlg"))
dijit.byId("userDetailsDlg").destroyRecursive(); dijit.byId("userDetailsDlg").destroyRecursive();
@ -489,7 +489,7 @@ function selectedUserDetails() {
function editSelectedFilter() { function editSelectedFilter() {
var rows = getSelectedFilters(); const rows = getSelectedFilters();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No filters are selected.")); alert(__("No filters are selected."));
@ -508,19 +508,19 @@ function editSelectedFilter() {
} }
function joinSelectedFilters() { function joinSelectedFilters() {
var rows = getSelectedFilters(); const rows = getSelectedFilters();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No filters are selected.")); alert(__("No filters are selected."));
return; return;
} }
var ok = confirm(__("Combine selected filters?")); const ok = confirm(__("Combine selected filters?"));
if (ok) { if (ok) {
notify_progress("Joining filters..."); notify_progress("Joining filters...");
var query = "?op=pref-filters&method=join&ids="+ const query = "?op=pref-filters&method=join&ids="+
param_escape(rows.toString()); param_escape(rows.toString());
console.log(query); console.log(query);
@ -534,7 +534,7 @@ function joinSelectedFilters() {
} }
function editSelectedFeed() { function editSelectedFeed() {
var rows = getSelectedFeeds(); const rows = getSelectedFeeds();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No feeds are selected.")); alert(__("No feeds are selected."));
@ -552,7 +552,7 @@ function editSelectedFeed() {
} }
function editSelectedFeeds() { function editSelectedFeeds() {
var rows = getSelectedFeeds(); const rows = getSelectedFeeds();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No feeds are selected.")); alert(__("No feeds are selected."));
@ -561,7 +561,7 @@ function editSelectedFeeds() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
var query = "backend.php?op=pref-feeds&method=editfeeds&ids=" + const query = "backend.php?op=pref-feeds&method=editfeeds&ids=" +
param_escape(rows.toString()); param_escape(rows.toString());
console.log(query); console.log(query);
@ -580,7 +580,7 @@ function editSelectedFeeds() {
title: __("Edit Multiple Feeds"), title: __("Edit Multiple Feeds"),
style: "width: 600px", style: "width: 600px",
getChildByName: function (name) { getChildByName: function (name) {
var rv = null; let rv = null;
this.getChildren().each( this.getChildren().each(
function (child) { function (child) {
if (child.name == name) { if (child.name == name) {
@ -602,7 +602,7 @@ function editSelectedFeeds() {
}, },
execute: function () { execute: function () {
if (this.validate() && confirm(__("Save changes to selected feeds?"))) { if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
var query = dojo.objectToQuery(this.attr('value')); let query = dojo.objectToQuery(this.attr('value'));
/* Form.serialize ignores unchecked checkboxes */ /* Form.serialize ignores unchecked checkboxes */
@ -674,9 +674,9 @@ function opmlImportComplete(iframe) {
if (dijit.byId('opmlImportDlg')) if (dijit.byId('opmlImportDlg'))
dijit.byId('opmlImportDlg').destroyRecursive(); dijit.byId('opmlImportDlg').destroyRecursive();
var content = iframe.contentDocument.body.innerHTML; const content = iframe.contentDocument.body.innerHTML;
var dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
id: "opmlImportDlg", id: "opmlImportDlg",
title: __("OPML Import"), title: __("OPML Import"),
style: "width: 600px", style: "width: 600px",
@ -694,7 +694,7 @@ function opmlImportComplete(iframe) {
function opmlImport() { function opmlImport() {
var opml_file = $("opml_file"); const opml_file = $("opml_file");
if (opml_file.value.length == 0) { if (opml_file.value.length == 0) {
alert(__("Please choose an OPML file first.")); alert(__("Please choose an OPML file first."));
@ -710,8 +710,8 @@ function opmlImport() {
function updateFilterList() { function updateFilterList() {
var user_search = $("filter_search"); const user_search = $("filter_search");
var search = ""; let search = "";
if (user_search) { search = user_search.value; } if (user_search) { search = user_search.value; }
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -767,7 +767,7 @@ function selectTab(id, noupdate) {
updateSystemList(); updateSystemList();
} }
var tab = dijit.byId(id + "Tab"); const tab = dijit.byId(id + "Tab");
dijit.byId("pref-tabs").selectChild(tab); dijit.byId("pref-tabs").selectChild(tab);
} }
@ -778,17 +778,17 @@ function init_second_stage() {
loading_set_progress(50); loading_set_progress(50);
notify(""); notify("");
var tab = getURLParam('tab'); let tab = getURLParam('tab');
if (tab) { if (tab) {
tab = dijit.byId(tab + "Tab"); tab = dijit.byId(tab + "Tab");
if (tab) dijit.byId("pref-tabs").selectChild(tab); if (tab) dijit.byId("pref-tabs").selectChild(tab);
} }
var method = getURLParam('method'); const method = getURLParam('method');
if (method == 'editFeed') { if (method == 'editFeed') {
var param = getURLParam('methodparam'); const param = getURLParam('methodparam');
window.setTimeout(function() { editFeed(param) }, 100); window.setTimeout(function() { editFeed(param) }, 100);
} }
@ -846,7 +846,7 @@ function init() {
loading_set_progress(50); loading_set_progress(50);
var clientTzOffset = new Date().getTimezoneOffset() * 60; const clientTzOffset = new Date().getTimezoneOffset() * 60;
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: { parameters: {
@ -866,11 +866,11 @@ function init() {
function validatePrefsReset() { function validatePrefsReset() {
var ok = confirm(__("Reset to defaults?")); const ok = confirm(__("Reset to defaults?"));
if (ok) { if (ok) {
var query = "?op=pref-prefs&method=resetconfig"; const query = "?op=pref-prefs&method=resetconfig";
console.log(query); console.log(query);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -890,10 +890,10 @@ function pref_hotkey_handler(e) {
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return; if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
var keycode = false; let keycode = false;
var shift_key = false; let shift_key = false;
var cmdline = $('cmdline'); const cmdline = $('cmdline');
try { try {
shift_key = e.shiftKey; shift_key = e.shiftKey;
@ -907,7 +907,7 @@ function pref_hotkey_handler(e) {
keycode = e.which; keycode = e.which;
} }
var keychar = String.fromCharCode(keycode); let keychar = String.fromCharCode(keycode);
if (keycode == 27) { // escape if (keycode == 27) { // escape
hotkey_prefix = false; hotkey_prefix = false;
@ -922,8 +922,8 @@ function pref_hotkey_handler(e) {
if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) { if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
var date = new Date(); const date = new Date();
var ts = Math.round(date.getTime() / 1000); const ts = Math.round(date.getTime() / 1000);
hotkey_prefix = keychar; hotkey_prefix = keychar;
hotkey_prefix_pressed = ts; hotkey_prefix_pressed = ts;
@ -936,14 +936,14 @@ function pref_hotkey_handler(e) {
Element.hide(cmdline); Element.hide(cmdline);
var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")"; let hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey; hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
hotkey_prefix = false; hotkey_prefix = false;
var hotkey_action = false; let hotkey_action = false;
var hotkeys = getInitParam("hotkeys"); var hotkeys = getInitParam("hotkeys");
for (var sequence in hotkeys[1]) { for (const sequence in hotkeys[1]) {
if (sequence == hotkey) { if (sequence == hotkey) {
hotkey_action = hotkeys[1][sequence]; hotkey_action = hotkeys[1][sequence];
break; break;
@ -970,10 +970,10 @@ function pref_hotkey_handler(e) {
function removeCategory(id, item) { function removeCategory(id, item) {
var ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name)); const ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name));
if (ok) { if (ok) {
var query = "?op=pref-feeds&method=removeCat&ids=" + const query = "?op=pref-feeds&method=removeCat&ids=" +
param_escape(id); param_escape(id);
notify_progress("Removing category..."); notify_progress("Removing category...");
@ -990,16 +990,16 @@ function removeCategory(id, item) {
function removeSelectedCategories() { function removeSelectedCategories() {
var sel_rows = getSelectedCategories(); const sel_rows = getSelectedCategories();
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected categories?")); const ok = confirm(__("Remove selected categories?"));
if (ok) { if (ok) {
notify_progress("Removing selected categories..."); notify_progress("Removing selected categories...");
var query = "?op=pref-feeds&method=removeCat&ids="+ const query = "?op=pref-feeds&method=removeCat&ids="+
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1017,13 +1017,13 @@ function removeSelectedCategories() {
} }
function createCategory() { function createCategory() {
var title = prompt(__("Category title:")); const title = prompt(__("Category title:"));
if (title) { if (title) {
notify_progress("Creating category..."); notify_progress("Creating category...");
var query = "?op=pref-feeds&method=addCat&cat=" + const query = "?op=pref-feeds&method=addCat&cat=" +
param_escape(title); param_escape(title);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1037,7 +1037,7 @@ function createCategory() {
} }
function showInactiveFeeds() { function showInactiveFeeds() {
var query = "backend.php?op=pref-feeds&method=inactiveFeeds"; const query = "backend.php?op=pref-feeds&method=inactiveFeeds";
if (dijit.byId("inactiveFeedsDlg")) if (dijit.byId("inactiveFeedsDlg"))
dijit.byId("inactiveFeedsDlg").destroyRecursive(); dijit.byId("inactiveFeedsDlg").destroyRecursive();
@ -1050,17 +1050,17 @@ function showInactiveFeeds() {
return getSelectedTableRowIds("prefInactiveFeedList"); return getSelectedTableRowIds("prefInactiveFeedList");
}, },
removeSelected: function () { removeSelected: function () {
var sel_rows = this.getSelectedFeeds(); const sel_rows = this.getSelectedFeeds();
console.log(sel_rows); console.log(sel_rows);
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected feeds?")); const ok = confirm(__("Remove selected feeds?"));
if (ok) { if (ok) {
notify_progress("Removing selected feeds...", true); notify_progress("Removing selected feeds...", true);
var query = "?op=pref-feeds&method=remove&ids=" + const query = "?op=pref-feeds&method=remove&ids=" +
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1088,22 +1088,22 @@ function showInactiveFeeds() {
} }
function opmlRegenKey() { function opmlRegenKey() {
var ok = confirm(__("Replace current OPML publishing address with a new one?")); const ok = confirm(__("Replace current OPML publishing address with a new one?"));
if (ok) { if (ok) {
notify_progress("Trying to change address...", true); notify_progress("Trying to change address...", true);
var query = "?op=pref-feeds&method=regenOPMLKey"; const query = "?op=pref-feeds&method=regenOPMLKey";
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function (transport) { onComplete: function (transport) {
var reply = JSON.parse(transport.responseText); const reply = JSON.parse(transport.responseText);
var new_link = reply.link; const new_link = reply.link;
var e = $('pub_opml_url'); const e = $('pub_opml_url');
if (new_link) { if (new_link) {
e.href = new_link; e.href = new_link;
@ -1123,13 +1123,13 @@ function opmlRegenKey() {
} }
function labelColorReset() { function labelColorReset() {
var labels = getSelectedLabels(); const labels = getSelectedLabels();
if (labels.length > 0) { if (labels.length > 0) {
var ok = confirm(__("Reset selected labels to default colors?")); const ok = confirm(__("Reset selected labels to default colors?"));
if (ok) { if (ok) {
var query = "?op=pref-labels&method=colorreset&ids=" + const query = "?op=pref-labels&method=colorreset&ids=" +
param_escape(labels.toString()); param_escape(labels.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1154,7 +1154,7 @@ function editProfiles() {
if (dijit.byId("profileEditDlg")) if (dijit.byId("profileEditDlg"))
dijit.byId("profileEditDlg").destroyRecursive(); dijit.byId("profileEditDlg").destroyRecursive();
var query = "backend.php?op=pref-prefs&method=editPrefProfiles"; const query = "backend.php?op=pref-prefs&method=editPrefProfiles";
var dialog = new dijit.Dialog({ var dialog = new dijit.Dialog({
id: "profileEditDlg", id: "profileEditDlg",
@ -1164,15 +1164,15 @@ function editProfiles() {
return getSelectedTableRowIds("prefFeedProfileList"); return getSelectedTableRowIds("prefFeedProfileList");
}, },
removeSelected: function () { removeSelected: function () {
var sel_rows = this.getSelectedProfiles(); const sel_rows = this.getSelectedProfiles();
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
var ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed.")); const ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed."));
if (ok) { if (ok) {
notify_progress("Removing selected profiles...", true); notify_progress("Removing selected profiles...", true);
var query = "?op=rpc&method=remprofiles&ids=" + const query = "?op=rpc&method=remprofiles&ids=" +
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1190,16 +1190,16 @@ function editProfiles() {
} }
}, },
activateProfile: function () { activateProfile: function () {
var sel_rows = this.getSelectedProfiles(); const sel_rows = this.getSelectedProfiles();
if (sel_rows.length == 1) { if (sel_rows.length == 1) {
var ok = confirm(__("Activate selected profile?")); const ok = confirm(__("Activate selected profile?"));
if (ok) { if (ok) {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
var query = "?op=rpc&method=setprofile&id=" + const query = "?op=rpc&method=setprofile&id=" +
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1218,7 +1218,7 @@ function editProfiles() {
if (this.validate()) { if (this.validate()) {
notify_progress("Creating profile...", true); notify_progress("Creating profile...", true);
var query = "?op=rpc&method=addprofile&title=" + const query = "?op=rpc&method=addprofile&title=" +
param_escape(dialog.attr('value').newprofile); param_escape(dialog.attr('value').newprofile);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1243,16 +1243,16 @@ function editProfiles() {
function activatePrefProfile() { function activatePrefProfile() {
var sel_rows = getSelectedFeedCats(); const sel_rows = getSelectedFeedCats();
if (sel_rows.length == 1) { if (sel_rows.length == 1) {
var ok = confirm(__("Activate selected profile?")); const ok = confirm(__("Activate selected profile?"));
if (ok) { if (ok) {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
var query = "?op=rpc&method=setprofile&id="+ const query = "?op=rpc&method=setprofile&id="+
param_escape(sel_rows.toString()); param_escape(sel_rows.toString());
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -1271,12 +1271,12 @@ function activatePrefProfile() {
function clearFeedAccessKeys() { function clearFeedAccessKeys() {
var ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?")); const ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?"));
if (ok) { if (ok) {
notify_progress("Clearing URLs..."); notify_progress("Clearing URLs...");
var query = "?op=pref-feeds&method=clearKeys"; const query = "?op=pref-feeds&method=clearKeys";
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
@ -1300,7 +1300,6 @@ function resetFilterOrder() {
} }
function resetFeedOrder() { function resetFeedOrder() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
@ -1324,7 +1323,7 @@ function resetCatOrder() {
} }
function editCat(id, item) { function editCat(id, item) {
var new_name = prompt(__('Rename category to:'), item.name); const new_name = prompt(__('Rename category to:'), item.name);
if (new_name && new_name != item.name) { if (new_name && new_name != item.name) {
@ -1345,20 +1344,20 @@ function editCat(id, item) {
} }
function editLabel(id) { function editLabel(id) {
var query = "backend.php?op=pref-labels&method=edit&id=" + const query = "backend.php?op=pref-labels&method=edit&id=" +
param_escape(id); param_escape(id);
if (dijit.byId("labelEditDlg")) if (dijit.byId("labelEditDlg"))
dijit.byId("labelEditDlg").destroyRecursive(); dijit.byId("labelEditDlg").destroyRecursive();
var dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
id: "labelEditDlg", id: "labelEditDlg",
title: __("Label Editor"), title: __("Label Editor"),
style: "width: 600px", style: "width: 600px",
setLabelColor: function (id, fg, bg) { setLabelColor: function (id, fg, bg) {
var kind = ''; let kind = '';
var color = ''; let color = '';
if (fg && bg) { if (fg && bg) {
kind = 'both'; kind = 'both';
@ -1370,13 +1369,13 @@ function editLabel(id) {
color = bg; color = bg;
} }
var query = "?op=pref-labels&method=colorset&kind=" + kind + const query = "?op=pref-labels&method=colorset&kind=" + kind +
"&ids=" + param_escape(id) + "&fg=" + param_escape(fg) + "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) +
"&bg=" + param_escape(bg) + "&color=" + param_escape(color); "&bg=" + param_escape(bg) + "&color=" + param_escape(color);
// console.log(query); // console.log(query);
var e = $("LICID-" + id); const e = $("LICID-" + id);
if (e) { if (e) {
if (fg) e.style.color = fg; if (fg) e.style.color = fg;
@ -1389,10 +1388,10 @@ function editLabel(id) {
}, },
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
var caption = this.attr('value').caption; const caption = this.attr('value').caption;
var fg_color = this.attr('value').fg_color; const fg_color = this.attr('value').fg_color;
var bg_color = this.attr('value').bg_color; const bg_color = this.attr('value').bg_color;
var query = dojo.objectToQuery(this.attr('value')); const query = dojo.objectToQuery(this.attr('value'));
dijit.byId('labelTree').setNameById(id, caption); dijit.byId('labelTree').setNameById(id, caption);
this.setLabelColor(id, fg_color, bg_color); this.setLabelColor(id, fg_color, bg_color);
@ -1414,12 +1413,12 @@ function editLabel(id) {
function customizeCSS() { function customizeCSS() {
var query = "backend.php?op=pref-prefs&method=customizeCSS"; const query = "backend.php?op=pref-prefs&method=customizeCSS";
if (dijit.byId("cssEditDlg")) if (dijit.byId("cssEditDlg"))
dijit.byId("cssEditDlg").destroyRecursive(); dijit.byId("cssEditDlg").destroyRecursive();
var dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
id: "cssEditDlg", id: "cssEditDlg",
title: __("Customize stylesheet"), title: __("Customize stylesheet"),
style: "width: 600px", style: "width: 600px",
@ -1445,13 +1444,13 @@ function insertSSLserial(value) {
} }
function gotoExportOpml(filename, settings) { function gotoExportOpml(filename, settings) {
var tmp = settings ? 1 : 0; const tmp = settings ? 1 : 0;
document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp; document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp;
} }
function batchSubscribe() { function batchSubscribe() {
var query = "backend.php?op=pref-feeds&method=batchSubscribe"; const query = "backend.php?op=pref-feeds&method=batchSubscribe";
// overlapping widgets // overlapping widgets
if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive(); if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
@ -1501,7 +1500,7 @@ function clearSqlLog() {
if (confirm(__("Clear all messages in the error log?"))) { if (confirm(__("Clear all messages in the error log?"))) {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
var query = "?op=pref-system&method=clearLog"; const query = "?op=pref-system&method=clearLog";
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,

View File

@ -50,11 +50,11 @@ function updateFeedList() {
dijit.byId("feedTree").destroyRecursive(); dijit.byId("feedTree").destroyRecursive();
} }
var store = new dojo.data.ItemFileWriteStore({ const store = new dojo.data.ItemFileWriteStore({
url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2" url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2"
}); });
var treeModel = new fox.FeedStoreModel({ const treeModel = new fox.FeedStoreModel({
store: store, store: store,
query: { query: {
"type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed" "type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
@ -64,12 +64,12 @@ function updateFeedList() {
childrenAttrs: ["items"] childrenAttrs: ["items"]
}); });
var tree = new fox.FeedTree({ const tree = new fox.FeedTree({
model: treeModel, model: treeModel,
onClick: function (item, node) { onClick: function (item, node) {
var id = String(item.id); const id = String(item.id);
var is_cat = id.match("^CAT:"); const is_cat = id.match("^CAT:");
var feed = id.substr(id.indexOf(":") + 1); const feed = id.substr(id.indexOf(":") + 1);
viewfeed({feed: feed, is_cat: is_cat}); viewfeed({feed: feed, is_cat: is_cat});
return false; return false;
}, },
@ -115,11 +115,11 @@ function updateFeedList() {
function catchupAllFeeds() { function catchupAllFeeds() {
var str = __("Mark all articles as read?"); const str = __("Mark all articles as read?");
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
var query_str = "backend.php?op=feeds&method=catchupAll"; const query_str = "backend.php?op=feeds&method=catchupAll";
notify_progress("Marking all feeds as read..."); notify_progress("Marking all feeds as read...");
@ -154,13 +154,13 @@ function timeout() {
} }
function search() { function search() {
var query = "backend.php?op=feeds&method=search&param=" + const query = "backend.php?op=feeds&method=search&param=" +
param_escape(getActiveFeedId() + ":" + activeFeedIsCat()); param_escape(getActiveFeedId() + ":" + activeFeedIsCat());
if (dijit.byId("searchDlg")) if (dijit.byId("searchDlg"))
dijit.byId("searchDlg").destroyRecursive(); dijit.byId("searchDlg").destroyRecursive();
var dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
id: "searchDlg", id: "searchDlg",
title: __("Search"), title: __("Search"),
style: "width: 600px", style: "width: 600px",
@ -177,20 +177,12 @@ function search() {
} }
function updateTitle() { function updateTitle() {
var tmp = "Tiny Tiny RSS"; let tmp = "Tiny Tiny RSS";
if (global_unread > 0) { if (global_unread > 0) {
tmp = "(" + global_unread + ") " + tmp; tmp = "(" + global_unread + ") " + tmp;
} }
if (window.fluid) {
if (global_unread > 0) {
window.fluid.dockBadge = global_unread;
} else {
window.fluid.dockBadge = "";
}
}
document.title = tmp; document.title = tmp;
} }
@ -258,12 +250,12 @@ function init() {
loading_set_progress(30); loading_set_progress(30);
var a = document.createElement('audio'); const a = document.createElement('audio');
var hasAudio = !!a.canPlayType; const hasAudio = !!a.canPlayType;
var hasSandbox = "sandbox" in document.createElement("iframe"); const hasSandbox = "sandbox" in document.createElement("iframe");
var hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, '')); const hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
var clientTzOffset = new Date().getTimezoneOffset() * 60; const clientTzOffset = new Date().getTimezoneOffset() * 60;
init_hotkey_actions(); init_hotkey_actions();
@ -290,13 +282,13 @@ function init() {
function init_hotkey_actions() { function init_hotkey_actions() {
hotkey_actions["next_feed"] = function() { hotkey_actions["next_feed"] = function() {
var rv = dijit.byId("feedTree").getNextFeed( const rv = dijit.byId("feedTree").getNextFeed(
getActiveFeedId(), activeFeedIsCat()); getActiveFeedId(), activeFeedIsCat());
if (rv) viewfeed({feed: rv[0], is_cat: rv[1], can_wait: true}) if (rv) viewfeed({feed: rv[0], is_cat: rv[1], can_wait: true})
}; };
hotkey_actions["prev_feed"] = function() { hotkey_actions["prev_feed"] = function() {
var rv = dijit.byId("feedTree").getPreviousFeed( const rv = dijit.byId("feedTree").getPreviousFeed(
getActiveFeedId(), activeFeedIsCat()); getActiveFeedId(), activeFeedIsCat());
if (rv) viewfeed({feed: rv[0], is_cat: rv[1], can_wait: true}) if (rv) viewfeed({feed: rv[0], is_cat: rv[1], can_wait: true})
@ -320,8 +312,8 @@ function init_hotkey_actions() {
moveToPost('prev', true, true); moveToPost('prev', true, true);
}; };
hotkey_actions["collapse_article"] = function() { hotkey_actions["collapse_article"] = function() {
var id = getActiveArticleId(); const id = getActiveArticleId();
var elem = $("CICD-"+id); const elem = $("CICD-"+id);
if (elem) { if (elem) {
if (elem.visible()) { if (elem.visible()) {
@ -333,8 +325,8 @@ function init_hotkey_actions() {
} }
}; };
hotkey_actions["toggle_expand"] = function() { hotkey_actions["toggle_expand"] = function() {
var id = getActiveArticleId(); const id = getActiveArticleId();
var elem = $("CICD-"+id); const elem = $("CICD-"+id);
if (elem) { if (elem) {
if (elem.visible()) { if (elem.visible()) {
@ -358,10 +350,10 @@ function init_hotkey_actions() {
selectionToggleUnread(undefined, false, true); selectionToggleUnread(undefined, false, true);
}; };
hotkey_actions["edit_tags"] = function() { hotkey_actions["edit_tags"] = function() {
var id = getActiveArticleId(); const id = getActiveArticleId();
if (id) { if (id) {
editArticleTags(id); editArticleTags(id);
}; }
} }
hotkey_actions["open_in_new_window"] = function() { hotkey_actions["open_in_new_window"] = function() {
if (getActiveArticleId()) { if (getActiveArticleId()) {
@ -457,7 +449,7 @@ function init_hotkey_actions() {
reverseHeadlineOrder(); reverseHeadlineOrder();
}; };
hotkey_actions["feed_toggle_vgroup"] = function() { hotkey_actions["feed_toggle_vgroup"] = function() {
var query_str = "?op=rpc&method=togglepref&key=VFEED_GROUP_BY_FEED"; const query_str = "?op=rpc&method=togglepref&key=VFEED_GROUP_BY_FEED";
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query_str, parameters: query_str,
@ -494,12 +486,12 @@ function init_hotkey_actions() {
gotoPreferences(); gotoPreferences();
}; };
hotkey_actions["select_article_cursor"] = function() { hotkey_actions["select_article_cursor"] = function() {
var id = getArticleUnderPointer(); const id = getArticleUnderPointer();
if (id) { if (id) {
var row = $("RROW-" + id); const row = $("RROW-" + id);
if (row) { if (row) {
var cb = dijit.getEnclosingWidget( const cb = dijit.getEnclosingWidget(
row.getElementsByClassName("rchk")[0]); row.getElementsByClassName("rchk")[0]);
if (cb) { if (cb) {
@ -546,8 +538,8 @@ function init_hotkey_actions() {
hotkey_actions["toggle_combined_mode"] = function() { hotkey_actions["toggle_combined_mode"] = function() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
var value = isCdmMode() ? "false" : "true"; const value = isCdmMode() ? "false" : "true";
var query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value; const query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value;
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
@ -563,8 +555,8 @@ function init_hotkey_actions() {
hotkey_actions["toggle_cdm_expanded"] = function() { hotkey_actions["toggle_cdm_expanded"] = function() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
var value = getInitParam("cdm_expanded") ? "false" : "true"; const value = getInitParam("cdm_expanded") ? "false" : "true";
var query = "?op=rpc&method=setpref&key=CDM_EXPANDED&value=" + value; const query = "?op=rpc&method=setpref&key=CDM_EXPANDED&value=" + value;
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
@ -603,7 +595,7 @@ function init_second_stage() {
delCookie("ttrss_test"); delCookie("ttrss_test");
var toolbar = document.forms["main_toolbar_form"]; const toolbar = document.forms["main_toolbar_form"];
dijit.getEnclosingWidget(toolbar.view_mode).attr('value', dijit.getEnclosingWidget(toolbar.view_mode).attr('value',
getInitParam("default_view_mode")); getInitParam("default_view_mode"));
@ -611,10 +603,10 @@ function init_second_stage() {
dijit.getEnclosingWidget(toolbar.order_by).attr('value', dijit.getEnclosingWidget(toolbar.order_by).attr('value',
getInitParam("default_view_order_by")); getInitParam("default_view_order_by"));
var feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1; const feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
var hash_feed_id = hash_get('f'); const hash_feed_id = hash_get('f');
var hash_feed_is_cat = hash_get('c') == "1"; const hash_feed_is_cat = hash_get('c') == "1";
if (hash_feed_id != undefined) { if (hash_feed_id != undefined) {
setActiveFeedId(hash_feed_id, hash_feed_is_cat); setActiveFeedId(hash_feed_id, hash_feed_is_cat);
@ -626,11 +618,11 @@ function init_second_stage() {
if ('sessionStorage' in window && window['sessionStorage'] !== null) if ('sessionStorage' in window && window['sessionStorage'] !== null)
sessionStorage.clear(); sessionStorage.clear();
var hotkeys = getInitParam("hotkeys"); const hotkeys = getInitParam("hotkeys");
var tmp = []; const tmp = [];
for (var sequence in hotkeys[1]) { for (const sequence in hotkeys[1]) {
var filtered = sequence.replace(/\|.*$/, ""); const filtered = sequence.replace(/\|.*$/, "");
tmp[filtered] = hotkeys[1][sequence]; tmp[filtered] = hotkeys[1][sequence];
} }
@ -733,11 +725,11 @@ function quickMenuGo(opid) {
function toggleDispRead() { function toggleDispRead() {
var hide = !(getInitParam("hide_read_feeds") == "1"); const hide = !(getInitParam("hide_read_feeds") == "1");
hideOrShowFeeds(hide); hideOrShowFeeds(hide);
var query = "?op=rpc&method=setpref&key=HIDE_READ_FEEDS&value=" + const query = "?op=rpc&method=setpref&key=HIDE_READ_FEEDS&value=" +
param_escape(hide); param_escape(hide);
setInitParam("hide_read_feeds", hide); setInitParam("hide_read_feeds", hide);
@ -753,8 +745,8 @@ function parse_runtime_info(data) {
//console.log("parsing runtime info..."); //console.log("parsing runtime info...");
for (var k in data) { for (const k in data) {
var v = data[k]; const v = data[k];
// console.log("RI: " + k + " => " + v); // console.log("RI: " + k + " => " + v);
@ -770,7 +762,7 @@ function parse_runtime_info(data) {
} }
if (k == "update_result") { if (k == "update_result") {
var updatesIcon = dijit.byId("updatesIcon").domNode; const updatesIcon = dijit.byId("updatesIcon").domNode;
if (v) { if (v) {
Element.show(updatesIcon); Element.show(updatesIcon);
@ -801,7 +793,7 @@ function parse_runtime_info(data) {
function collapse_feedlist() { function collapse_feedlist() {
Element.toggle("feeds-holder"); Element.toggle("feeds-holder");
var splitter = $("feeds-holder_splitter"); const splitter = $("feeds-holder_splitter");
Element.visible("feeds-holder") ? splitter.show() : splitter.hide(); Element.visible("feeds-holder") ? splitter.show() : splitter.hide();
@ -815,7 +807,7 @@ function viewModeChanged() {
function rescoreCurrentFeed() { function rescoreCurrentFeed() {
var actid = getActiveFeedId(); const actid = getActiveFeedId();
if (activeFeedIsCat() || actid < 0) { if (activeFeedIsCat() || actid < 0) {
alert(__("You can't rescore this kind of feed.")); alert(__("You can't rescore this kind of feed."));
@ -827,13 +819,13 @@ function rescoreCurrentFeed() {
return; return;
} }
var fn = getFeedName(actid); const fn = getFeedName(actid);
var pr = __("Rescore articles in %s?").replace("%s", fn); const pr = __("Rescore articles in %s?").replace("%s", fn);
if (confirm(pr)) { if (confirm(pr)) {
notify_progress("Rescoring articles..."); notify_progress("Rescoring articles...");
var query = "?op=pref-feeds&method=rescore&quiet=1&ids=" + actid; const query = "?op=pref-feeds&method=rescore&quiet=1&ids=" + actid;
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
@ -847,9 +839,9 @@ function hotkey_handler(e) {
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return; if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
var keycode = false; let keycode = false;
var cmdline = $('cmdline'); const cmdline = $('cmdline');
if (window.event) { if (window.event) {
keycode = window.event.keyCode; keycode = window.event.keyCode;
@ -865,12 +857,12 @@ function hotkey_handler(e) {
if (keycode == 17) return; // ignore lone ctrl if (keycode == 17) return; // ignore lone ctrl
var hotkeys = getInitParam("hotkeys"); var hotkeys = getInitParam("hotkeys");
var keychar = String.fromCharCode(keycode).toLowerCase(); const keychar = String.fromCharCode(keycode).toLowerCase();
if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) { if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
var date = new Date(); const date = new Date();
var ts = Math.round(date.getTime() / 1000); const ts = Math.round(date.getTime() / 1000);
hotkey_prefix = keychar; hotkey_prefix = keychar;
hotkey_prefix_pressed = ts; hotkey_prefix_pressed = ts;
@ -886,7 +878,7 @@ function hotkey_handler(e) {
Element.hide(cmdline); Element.hide(cmdline);
var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")"; let hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
// ensure ^*char notation // ensure ^*char notation
if (e.shiftKey) hotkey = "*" + hotkey; if (e.shiftKey) hotkey = "*" + hotkey;
@ -897,17 +889,17 @@ function hotkey_handler(e) {
hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey; hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
hotkey_prefix = false; hotkey_prefix = false;
var hotkey_action = false; let hotkey_action = false;
var hotkeys = getInitParam("hotkeys"); var hotkeys = getInitParam("hotkeys");
for (var sequence in hotkeys[1]) { for (const sequence in hotkeys[1]) {
if (sequence == hotkey) { if (sequence == hotkey) {
hotkey_action = hotkeys[1][sequence]; hotkey_action = hotkeys[1][sequence];
break; break;
} }
} }
var action = hotkey_actions[hotkey_action]; const action = hotkey_actions[hotkey_action];
if (action != null) { if (action != null) {
action(); action();
@ -922,10 +914,10 @@ function inPreferences() {
function reverseHeadlineOrder() { function reverseHeadlineOrder() {
var toolbar = document.forms["main_toolbar_form"]; const toolbar = document.forms["main_toolbar_form"];
var order_by = dijit.getEnclosingWidget(toolbar.order_by); const order_by = dijit.getEnclosingWidget(toolbar.order_by);
var value = order_by.attr('value'); let value = order_by.attr('value');
if (value == "date_reverse") if (value == "date_reverse")
value = "default"; value = "default";
@ -940,21 +932,21 @@ function reverseHeadlineOrder() {
function handle_rpc_json(transport, scheduled_call) { function handle_rpc_json(transport, scheduled_call) {
var netalert_dijit = dijit.byId("net-alert"); const netalert_dijit = dijit.byId("net-alert");
var netalert = false; let netalert = false;
if (netalert_dijit) netalert = netalert_dijit.domNode; if (netalert_dijit) netalert = netalert_dijit.domNode;
try { try {
var reply = JSON.parse(transport.responseText); const reply = JSON.parse(transport.responseText);
if (reply) { if (reply) {
var error = reply['error']; const error = reply['error'];
if (error) { if (error) {
var code = error['code']; const code = error['code'];
var msg = error['msg']; const msg = error['msg'];
console.warn("[handle_rpc_json] received fatal error " + code + "/" + msg); console.warn("[handle_rpc_json] received fatal error " + code + "/" + msg);
@ -964,7 +956,7 @@ function handle_rpc_json(transport, scheduled_call) {
} }
} }
var seq = reply['seq']; const seq = reply['seq'];
if (seq) { if (seq) {
if (get_seq() != seq) { if (get_seq() != seq) {
@ -974,7 +966,7 @@ function handle_rpc_json(transport, scheduled_call) {
} }
} }
var message = reply['message']; const message = reply['message'];
if (message) { if (message) {
if (message == "UPDATE_COUNTERS") { if (message == "UPDATE_COUNTERS") {
@ -984,24 +976,22 @@ function handle_rpc_json(transport, scheduled_call) {
} }
} }
var counters = reply['counters']; const counters = reply['counters'];
if (counters) if (counters)
parse_counters(counters, scheduled_call); parse_counters(counters, scheduled_call);
var runtime_info = reply['runtime-info']; const runtime_info = reply['runtime-info'];
if (runtime_info) if (runtime_info)
parse_runtime_info(runtime_info); parse_runtime_info(runtime_info);
if (netalert) netalert.hide(); if (netalert) netalert.hide();
} else { } else if (netalert)
if (netalert)
netalert.show(); netalert.show();
else else
notify_error("Communication problem with server."); notify_error("Communication problem with server.");
}
} catch (e) { } catch (e) {
if (netalert) if (netalert)
@ -1018,7 +1008,7 @@ function handle_rpc_json(transport, scheduled_call) {
function switchPanelMode(wide) { function switchPanelMode(wide) {
if (isCdmMode()) return; if (isCdmMode()) return;
var article_id = getActiveArticleId(); const article_id = getActiveArticleId();
if (wide) { if (wide) {
dijit.byId("headlines-wrap-inner").attr("design", 'sidebar'); dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
@ -1077,11 +1067,11 @@ function update_random_feed() {
} }
function hash_get(key) { function hash_get(key) {
var kv = window.location.hash.substring(1).toQueryParams(); const kv = window.location.hash.substring(1).toQueryParams();
return kv[key]; return kv[key];
} }
function hash_set(key, value) { function hash_set(key, value) {
var kv = window.location.hash.substring(1).toQueryParams(); const kv = window.location.hash.substring(1).toQueryParams();
kv[key] = value; kv[key] = value;
window.location.hash = $H(kv).toQueryString(); window.location.hash = $H(kv).toQueryString();
} }

File diff suppressed because it is too large Load Diff