function loadMoreHeadlines() {
console.log("loadMoreHeadlines");
- var offset = 0;
+ let offset = 0;
- var view_mode = document.forms["main_toolbar_form"].view_mode.value;
- var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
- var num_all = $$("#headlines-frame > div[id*=RROW]").length;
- var num_unread = getFeedUnread(getActiveFeedId(), activeFeedIsCat());
+ const view_mode = document.forms["main_toolbar_form"].view_mode.value;
+ const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
+ const num_all = $$("#headlines-frame > div[id*=RROW]").length;
+ const num_unread = getFeedUnread(getActiveFeedId(), activeFeedIsCat());
// TODO implement marked & published
}
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) {
dojo.destroy(d.domNode);
}
function viewfeed(params) {
- var feed = params.feed;
- var is_cat = params.is_cat;
- var offset = params.offset;
- var background = params.background;
- var infscroll_req = params.infscroll_req;
- var can_wait = params.can_wait;
- var viewfeed_debug = params.viewfeed_debug;
- var method = params.method;
+ const feed = params.feed;
+ let is_cat = params.is_cat;
+ let offset = params.offset;
+ let background = params.background;
+ let infscroll_req = params.infscroll_req;
+ const can_wait = params.can_wait;
+ const viewfeed_debug = params.viewfeed_debug;
+ const method = params.method;
if (is_cat == undefined)
is_cat = false;
}
if (infscroll_req) {
- var timestamp = get_timestamp();
+ const timestamp = get_timestamp();
if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) {
//console.log("infscroll request in progress, aborting");
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;
if (method) query += "&m=" + param_escape(method);
if (vgroup_last_feed) {
query = query + "&vgrlf=" + param_escape(vgroup_last_feed);
}
- } else {
- if (!is_cat && feed == getActiveFeedId() && !params.method) {
+ } else if (!is_cat && feed == getActiveFeedId() && !params.method) {
query = query + "&m=ForceUpdate";
}
- }
Form.enable("main_toolbar_form");
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() {
new Ajax.Request("backend.php", {
if (getInitParam("is_default_pw")) {
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"),
href: "backend.php?op=dlg&method=defaultpasswordwarning",
id: 'infoBox',
function request_counters(force) {
- var date = new Date();
- var timestamp = Math.round(date.getTime() / 1000);
+ const date = new Date();
+ const timestamp = Math.round(date.getTime() / 1000);
if (force || timestamp - counters_last_request > 5) {
console.log("scheduling request of counters...");
counters_last_request = timestamp;
- var query = "?op=rpc&method=getAllCounters&seq=" + next_seq();
+ let query = "?op=rpc&method=getAllCounters&seq=" + next_seq();
if (!force)
query = query + "&last_article_id=" + getInitParam("last_article_id");
// http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html
function counter_is_equal(a, b) {
// Create arrays of property names
- var aProps = Object.getOwnPropertyNames(a);
- var bProps = Object.getOwnPropertyNames(b);
+ const aProps = Object.getOwnPropertyNames(a);
+ const bProps = Object.getOwnPropertyNames(b);
// If number of properties is different,
// objects are not equivalent
return false;
}
- for (var i = 0; i < aProps.length; i++) {
- var propName = aProps[i];
+ for (let i = 0; i < aProps.length; i++) {
+ const propName = aProps[i];
// If values of same property are not equal,
// objects are not equivalent
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])) {
continue;
}
- var id = elems[l].id;
- var kind = elems[l].kind;
- var ctr = parseInt(elems[l].counter);
- var error = elems[l].error;
- var has_img = elems[l].has_img;
- var updated = elems[l].updated;
- var auxctr = parseInt(elems[l].auxcounter);
+ const id = elems[l].id;
+ const kind = elems[l].kind;
+ const ctr = parseInt(elems[l].counter);
+ const error = elems[l].error;
+ const has_img = elems[l].has_img;
+ const updated = elems[l].updated;
+ const auxctr = parseInt(elems[l].auxcounter);
if (id == "global-unread") {
global_unread = ctr;
function getFeedUnread(feed, is_cat) {
try {
- var tree = dijit.byId("feedTree");
+ const tree = dijit.byId("feedTree");
if (tree && tree.model)
return tree.model.getFeedUnread(feed, is_cat);
function getFeedCategory(feed) {
try {
- var tree = dijit.byId("feedTree");
+ const tree = dijit.byId("feedTree");
if (tree && tree.model)
return tree.getFeedCategory(feed);
}
function hideOrShowFeeds(hide) {
- var tree = dijit.byId("feedTree");
+ const tree = dijit.byId("feedTree");
if (tree)
return tree.hideRead(hide, getInitParam("hide_read_shows_special"));
if (isNaN(feed)) return feed; // it's a tag
- var tree = dijit.byId("feedTree");
+ const tree = dijit.byId("feedTree");
if (tree && tree.model)
return tree.model.getFeedValue(feed, is_cat, 'name');
function getFeedValue(feed, is_cat, key) {
try {
- var tree = dijit.byId("feedTree");
+ const tree = dijit.byId("feedTree");
if (tree && tree.model)
return tree.model.getFeedValue(feed, is_cat, key);
}
function setFeedUnread(feed, is_cat, unread) {
- var tree = dijit.byId("feedTree");
+ const tree = dijit.byId("feedTree");
if (tree && tree.model)
return tree.model.setFeedUnread(feed, is_cat, unread);
function setFeedValue(feed, is_cat, key, value) {
try {
- var tree = dijit.byId("feedTree");
+ const tree = dijit.byId("feedTree");
if (tree && tree.model)
return tree.model.setFeedValue(feed, is_cat, key, value);
}
function selectFeed(feed, is_cat) {
- var tree = dijit.byId("feedTree");
+ const tree = dijit.byId("feedTree");
if (tree) return tree.selectFeed(feed, is_cat);
}
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);
}
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);
}
function getNextUnreadFeed(feed, is_cat) {
- var tree = dijit.byId("feedTree");
- var nuf = tree.model.getNextUnreadFeed(feed, is_cat);
+ const tree = dijit.byId("feedTree");
+ const nuf = tree.model.getNextUnreadFeed(feed, is_cat);
if (nuf)
return tree.model.store.getValue(nuf, 'bare_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)) {
- 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) {
});
- 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 (i < feedTitles.length - 1) {
updateFloatingTitle(true);
}
- var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
+ const catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
id + "&is_cat=false";
console.log(catchup_query);
function catchupFeed(feed, is_cat, mode) {
if (is_cat == undefined) is_cat = false;
- var str = false;
+ let str = false;
switch (mode) {
case "1day":
str = __("Mark %w in %s as read?");
}
- var mark_what = last_search_query && last_search_query[0] ? __("search results") : __("all articles");
- var fn = getFeedName(feed, is_cat);
+ const mark_what = last_search_query && last_search_query[0] ? __("search results") : __("all articles");
+ const fn = getFeedName(feed, is_cat);
str = str.replace("%s", fn)
.replace("%w", mark_what);
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],
search_lang: last_search_query[1]};
onComplete: function(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) {
- var nuf = getNextUnreadFeed(feed, is_cat);
+ const nuf = getNextUnreadFeed(feed, is_cat);
if (nuf) {
viewfeed({feed: nuf, is_cat: is_cat});
}
- } else {
- if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
+ } else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
viewCurrentFeed();
}
- }
notify("");
} });
}
function decrementFeedCounter(feed, is_cat) {
- var ctr = getFeedUnread(feed, is_cat);
+ let ctr = getFeedUnread(feed, is_cat);
if (ctr > 0) {
setFeedUnread(feed, is_cat, ctr - 1);
updateTitle();
if (!is_cat) {
- var cat = parseInt(getFeedCategory(feed));
+ const cat = parseInt(getFeedCategory(feed));
if (!isNaN(cat)) {
ctr = getFeedUnread(cat, true);
/* add method to remove element from array */
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);
}
};
-
function report_error(message, filename, lineno, colno, error) {
exception_error(error, null, filename, lineno);
}
try {
console.error(e);
- var msg = e.toString();
+ const msg = e.toString();
try {
new Ajax.Request("backend.php", {
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) {
content += "<div><b>Stack trace:</b></div>" +
if (dijit.byId("exceptionDlg"))
dijit.byId("exceptionDlg").destroyRecursive();
- var dialog = new dijit.Dialog({
+ const dialog = new dijit.Dialog({
id: "exceptionDlg",
title: "Unhandled exception",
style: "width: 600px",
function notify_real(msg, no_hide, n_type) {
- var n = $("notify");
+ const n = $("notify");
if (!n) return;
function setCookie(name, value, lifetime, path, domain, secure) {
- var d = false;
+ let d = false;
if (lifetime) {
d = new Date();
function getCookie(name) {
- var dc = document.cookie;
- var prefix = name + "=";
- var begin = dc.indexOf("; " + prefix);
+ const dc = document.cookie;
+ const prefix = name + "=";
+ let begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
else {
begin += 2;
}
- var end = document.cookie.indexOf(";", begin);
+ let end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
}
function toggleSelectRowById(sender, id) {
- var row = $(id);
+ const row = $(id);
return toggleSelectRow(sender, row);
}
/* this is for dijit Checkbox */
function toggleSelectListRow2(sender) {
- var row = sender.domNode.parentNode;
+ const row = sender.domNode.parentNode;
return toggleSelectRow(sender, row);
}
}
function closeInfoBox() {
- var dialog = dijit.byId("infoBox");
+ const dialog = dijit.byId("infoBox");
if (dialog) dialog.hide();
notify_progress("Loading, please wait...", true);
- var query = "?op=dlg&method=" +
+ const query = "?op=dlg&method=" +
param_escape(id) + "¶m=" + param_escape(param);
new Ajax.Request("backend.php", {
}
function infobox_callback2(transport, title) {
- var dialog = false;
+ let dialog = false;
if (dijit.byId("infoBox")) {
dialog = dijit.byId("infoBox");
//console.log("infobox_callback2");
notify('');
- var content = transport.responseText;
+ const content = transport.responseText;
if (!dialog) {
dialog = new dijit.Dialog({
msg = ERRORS[code];
}
- var content = "<div><b>Error code:</b> " + code + "</div>" +
+ let content = "<div><b>Error code:</b> " + code + "</div>" +
"<p>" + msg + "</p>";
if (ext_info) {
ext_info + "</textarea>";
}
- var dialog = new dijit.Dialog({
+ const dialog = new dijit.Dialog({
title: "Fatal error",
style: "width: 600px",
content: content});
}
function filterDlgCheckAction(sender) {
- var action = sender.value;
+ const action = sender.value;
- var action_param = $("filterDlg_paramBox");
+ const action_param = $("filterDlg_paramBox");
if (!action_param) {
console.log("filterDlgCheckAction: can't find action param box!");
function hotkey_prefix_timeout() {
- var date = new Date();
- var ts = Math.round(date.getTime() / 1000);
+ const date = new Date();
+ const ts = Math.round(date.getTime() / 1000);
if (hotkey_prefix_pressed && ts - hotkey_prefix_pressed >= 5) {
console.log("hotkey_prefix seems to be stuck, aborting");
function removeFeedIcon(id) {
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);
}
function uploadFeedIcon() {
- var file = $("icon_file");
+ const file = $("icon_file");
if (file.value.length == 0) {
alert(__("Please select an image file to upload."));
- } else {
- if (confirm(__("Upload new icon for this feed?"))) {
+ } else if (confirm(__("Upload new icon for this feed?"))) {
notify_progress("Uploading, please wait...", true);
return true;
}
- }
return false;
}
function addLabel(select, callback) {
- var caption = prompt(__("Please enter label caption:"), "");
+ const caption = prompt(__("Please enter label caption:"), "");
if (caption != undefined) {
return false;
}
- var query = "?op=pref-labels&method=add&caption=" +
+ let query = "?op=pref-labels&method=add&caption=" +
param_escape(caption);
if (select)
}
function quickAddFeed() {
- var query = "backend.php?op=feeds&method=quickAddFeed";
+ const query = "backend.php?op=feeds&method=quickAddFeed";
// overlapping widgets
if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
title: __("Subscribe to Feed"),
style: "width: 600px",
show_error: function(msg) {
- var elem = $("fadd_error_message");
+ const elem = $("fadd_error_message");
elem.innerHTML = msg;
if (this.validate()) {
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.hide("fadd_error_message");
return;
}
- var rc = reply['result'];
+ const rc = reply['result'];
notify('');
Element.hide("feed_add_spinner");
select.addOption({value: '', label: __("Expand to select feed")});
var count = 0;
- for (var feedUrl in feeds) {
+ for (const feedUrl in feeds) {
select.addOption({value: feedUrl, label: feeds[feedUrl]});
count++;
}
}
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,"");
- 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));
console.log(query);
parameters: query,
onComplete: function (transport) {
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({
onChange: function() {
}
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) {
form.action_param.value = form.action_param_label.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));
console.log(query);
parameters: query,
onComplete: function (transport) {
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({
onChange: function() {
if (dijit.byId("filterNewRuleDlg"))
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);
- var rule_dlg = new dijit.Dialog({
+ const rule_dlg = new dijit.Dialog({
id: "filterNewRuleDlg",
title: ruleStr ? __("Edit rule") : __("Add rule"),
style: "width: 600px",
if (dijit.byId("filterNewActionDlg"))
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);
- var rule_dlg = new dijit.Dialog({
+ const rule_dlg = new dijit.Dialog({
id: "filterNewActionDlg",
title: actionStr ? __("Edit action") : __("Add action"),
style: "width: 600px",
limit: 100,
max_offset: 10000,
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);
parameters: updquery,
onComplete: function (transport) {
try {
- var result = JSON.parse(transport.responseText);
+ const result = JSON.parse(transport.responseText);
if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) {
test_dlg.results += result.size();
console.log(offset + " " + test_dlg.max_offset);
- for (var i = 0; i < result.size(); i++) {
- var tmp = new Element("table");
+ for (let i = 0; i < result.size(); i++) {
+ const tmp = new Element("table");
tmp.innerHTML = result[i];
dojo.parser.parse(tmp);
}
function quickAddFilter() {
- var query = "";
+ let query = "";
if (!inPreferences()) {
query = "backend.php?op=pref-filters&method=newfilter&feed=" +
param_escape(getActiveFeedId()) + "&is_cat=" +
title: __("Create Filter"),
style: "width: 600px",
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);
},
});
},
editRule: function(e) {
- var li = e.parentNode;
- var rule = li.getElementsByTagName("INPUT")[1].value;
+ const li = e.parentNode;
+ const rule = li.getElementsByTagName("INPUT")[1].value;
addFilterRule(li, rule);
},
editAction: function(e) {
- var li = e.parentNode;
- var action = li.getElementsByTagName("INPUT")[1].value;
+ const li = e.parentNode;
+ const action = li.getElementsByTagName("INPUT")[1].value;
addFilterAction(li, action);
},
addAction: function() { addFilterAction(); },
execute: function() {
if (this.validate()) {
- var query = dojo.formToQuery("filter_new_form");
+ const query = dojo.formToQuery("filter_new_form");
console.log(query);
href: query});
if (!inPreferences()) {
- var selectedText = getSelectionText();
+ const selectedText = getSelectionText();
var lh = dojo.connect(dialog, "onLoad", function(){
dojo.disconnect(lh);
if (selectedText != "") {
- var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
+ const feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(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));
} else {
- var query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId();
+ const query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId();
new Ajax.Request("backend.php", {
parameters: query,
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;
console.log(title + " " + getActiveFeedId());
- var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
+ const feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(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));
}
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)) {
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", {
parameters: query,
return;
}
- var reply = JSON.parse(transport.responseText);
+ const reply = JSON.parse(transport.responseText);
if (!reply) {
fatalError(3, "Sanity check: invalid RPC reply", transport.responseText);
return;
}
- var error_code = reply['error']['code'];
+ const error_code = reply['error']['code'];
if (error_code && error_code != 0) {
return fatalError(error_code, reply['error']['message']);
console.log("sanity check ok");
- var params = reply['init-params'];
+ const params = reply['init-params'];
if (params) {
console.log('reading init-params...');
- for (var k in params) {
+ for (const k in params) {
console.log("IP: " + k + " => " + JSON.stringify(params[k]));
if (k == "label_base_index") _label_base_index = parseInt(params[k]);
}
}
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) {
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);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
- var reply = JSON.parse(transport.responseText);
- var new_link = reply.link;
+ const reply = JSON.parse(transport.responseText);
+ const new_link = reply.link;
- var e = $('gen_feed_url');
+ const e = $('gen_feed_url');
if (new_link) {
// mode = all, none, invert
function selectTableRows(id, mode) {
- var rows = $(id).rows;
+ const rows = $(id).rows;
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i];
- var cb = false;
- var dcb = false;
+ for (let i = 0; i < rows.length; i++) {
+ const row = rows[i];
+ let cb = false;
+ let dcb = false;
if (row.id && row.className) {
- var bare_id = row.id.replace(/^[A-Z]*?-/, "");
- var inputs = rows[i].getElementsByTagName("input");
+ const bare_id = row.id.replace(/^[A-Z]*?-/, "");
+ const inputs = rows[i].getElementsByTagName("input");
- for (var j = 0; j < inputs.length; j++) {
- var input = inputs[j];
+ for (let j = 0; j < inputs.length; j++) {
+ const input = inputs[j];
if (input.getAttribute("type") == "checkbox" &&
input.id.match(bare_id)) {
}
if (cb || dcb) {
- var issel = row.hasClassName("Selected");
+ const issel = row.hasClassName("Selected");
if (mode == "all" && !issel) {
row.addClassName("Selected");
}
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")) {
- var bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, "");
+ const bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, "");
rows.push(bare_id);
}
}
if (feed <= 0)
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);
console.log(query);
}
function feedBrowser() {
- var query = "backend.php?op=feeds&method=feedBrowser";
+ const query = "backend.php?op=feeds&method=feedBrowser";
if (dijit.byId("feedAddDlg"))
dijit.byId("feedAddDlg").hide();
title: __("More Feeds"),
style: "width: 600px",
getSelectedFeedIds: function () {
- var list = $$("#browseFeedList li[id*=FBROW]");
- var selected = new Array();
+ const list = $$("#browseFeedList li[id*=FBROW]");
+ const selected = new Array();
list.each(function (child) {
- var id = child.id.replace("FBROW-", "");
+ const id = child.id.replace("FBROW-", "");
if (child.hasClassName('Selected')) {
selected.push(id);
return selected;
},
getSelectedFeeds: function () {
- var list = $$("#browseFeedList li.Selected");
- var selected = new Array();
+ const list = $$("#browseFeedList li.Selected");
+ const selected = new Array();
list.each(function (child) {
- var title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML;
- var url = child.getElementsBySelector("a.fb_feedUrl")[0].href;
+ const title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML;
+ const url = child.getElementsBySelector("a.fb_feedUrl")[0].href;
selected.push([title, url]);
},
subscribe: function () {
- var mode = this.attr('value').mode;
- var selected = [];
+ const mode = this.attr('value').mode;
+ let selected = [];
if (mode == "1")
selected = this.getSelectedFeeds();
// we use dojo.toJson instead of JSON.stringify because
// 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);
console.log(query);
},
update: function () {
- var query = dojo.objectToQuery(dialog.attr('value'));
+ const query = dojo.objectToQuery(dialog.attr('value'));
Element.show('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'];
- var mode = reply['mode'];
+ const r = reply['content'];
+ const mode = reply['mode'];
if (c && r) {
c.innerHTML = r;
});
},
removeFromArchive: function () {
- var selected = this.getSelectedFeedIds();
+ const selected = this.getSelectedFeedIds();
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)) {
Element.show('feed_browser_spinner');
- var query = "?op=rpc&method=remarchive&ids=" +
+ const query = "?op=rpc&method=remarchive&ids=" +
param_escape(selected.toString());
- ;
+
new Ajax.Request("backend.php", {
parameters: query,
}
function showFeedsWithErrors() {
- var query = "backend.php?op=pref-feeds&method=feedsWithErrors";
+ const query = "backend.php?op=pref-feeds&method=feedsWithErrors";
if (dijit.byId("errorFeedsDlg"))
dijit.byId("errorFeedsDlg").destroyRecursive();
return getSelectedTableRowIds("prefErrorFeedList");
},
removeSelected: function() {
- var sel_rows = this.getSelectedFeeds();
+ const sel_rows = this.getSelectedFeeds();
console.log(sel_rows);
if (sel_rows.length > 0) {
- var ok = confirm(__("Remove selected feeds?"));
+ const ok = confirm(__("Remove selected feeds?"));
if (ok) {
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());
new Ajax.Request("backend.php", {
}
function get_timestamp() {
- var date = new Date();
+ const date = new Date();
return Math.round(date.getTime() / 1000);
}
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"))
dijit.byId("helpDlg").destroyRecursive();
- var dialog = new dijit.Dialog({
+ const dialog = new dijit.Dialog({
id: "helpDlg",
title: __("Help"),
style: "width: 600px",
// * returns 1: '<p>this -> "</p>'
// * example 2: htmlspecialchars_decode("&quot;");
// * returns 2: '"'
- var optTemp = 0,
+ let optTemp = 0,
i = 0,
noquotes = false;
if (typeof quote_style === 'undefined') {
quote_style = 2;
}
string = string.toString().replace(/</g, '<').replace(/>/g, '>');
- var OPTS = {
+ const OPTS = {
'ENT_NOQUOTES': 0,
'ENT_HTML_QUOTE_SINGLE': 1,
'ENT_HTML_QUOTE_DOUBLE': 2,
// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac
function getSelectionText() {
- var text = "";
+ let text = "";
if (typeof window.getSelection != "undefined") {
- var sel = window.getSelection();
+ const sel = window.getSelection();
if (sel.rangeCount) {
- var container = document.createElement("div");
- for (var i = 0, len = sel.rangeCount; i < len; ++i) {
+ const container = document.createElement("div");
+ for (let i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents());
}
text = container.innerHTML;
}
function openUrlPopup(url) {
- var w = window.open("");
+ const w = window.open("");
w.opener = null;
w.location = url;
}
function openArticlePopup(id) {
- var w = window.open("",
+ const w = window.open("",
"ttrss_article_popup",
"height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no");
function updateFeedList() {
- var user_search = $("feed_search");
- var search = "";
+ const user_search = $("feed_search");
+ let search = "";
if (user_search) { search = user_search.value; }
new Ajax.Request("backend.php", {
}
function updateUsersList(sort_key) {
- var user_search = $("user_search");
- var search = "";
+ const user_search = $("user_search");
+ let search = "";
if (user_search) {
search = user_search.value;
}
- var query = "?op=pref-users&sort="
- + param_escape(sort_key) +
+ const query = "?op=pref-users&sort=" +
+ param_escape(sort_key) +
"&search=" + param_escape(search);
new Ajax.Request("backend.php", {
}
function addUser() {
- var login = prompt(__("Please enter login:"), "");
+ const login = prompt(__("Please enter login:"), "");
if (login == null) {
return false;
notify_progress("Adding user...");
- var query = "?op=pref-users&method=add&login=" +
+ const query = "?op=pref-users&method=add&login=" +
param_escape(login);
new Ajax.Request("backend.php", {
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);
if (dijit.byId("userEditDlg"))
if (this.validate()) {
notify_progress("Saving data...", true);
- var query = dojo.formToQuery("user_edit_form");
+ const query = dojo.formToQuery("user_edit_form");
new Ajax.Request("backend.php", {
parameters: query,
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"))
dijit.byId("feedEditDlg").destroyRecursive();
style: "width: 600px",
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);
},
});
},
editRule: function (e) {
- var li = e.parentNode;
- var rule = li.getElementsByTagName("INPUT")[1].value;
+ const li = e.parentNode;
+ const rule = li.getElementsByTagName("INPUT")[1].value;
addFilterRule(li, rule);
},
editAction: function (e) {
- var li = e.parentNode;
- var action = li.getElementsByTagName("INPUT")[1].value;
+ const li = e.parentNode;
+ const action = li.getElementsByTagName("INPUT")[1].value;
addFilterAction(li, action);
},
removeFilter: function () {
- var msg = __("Remove filter?");
+ const msg = __("Remove filter?");
if (confirm(msg)) {
this.hide();
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);
new Ajax.Request("backend.php", {
notify_progress("Saving data...", true);
- var query = dojo.formToQuery("filter_edit_form");
+ const query = dojo.formToQuery("filter_edit_form");
console.log(query);
function getSelectedLabels() {
- var tree = dijit.byId("labelTree");
- var items = tree.model.getCheckedItems();
- var rv = [];
+ const tree = dijit.byId("labelTree");
+ const items = tree.model.getCheckedItems();
+ const rv = [];
items.each(function(item) {
rv.push(tree.model.store.getValue(item, 'bare_id'));
}
function getSelectedFeeds() {
- var tree = dijit.byId("feedTree");
- var items = tree.model.getCheckedItems();
- var rv = [];
+ const tree = dijit.byId("feedTree");
+ const items = tree.model.getCheckedItems();
+ const rv = [];
items.each(function(item) {
if (item.id[0].match("FEED:"))
}
function getSelectedCategories() {
- var tree = dijit.byId("feedTree");
- var items = tree.model.getCheckedItems();
- var rv = [];
+ const tree = dijit.byId("feedTree");
+ const items = tree.model.getCheckedItems();
+ const rv = [];
items.each(function(item) {
if (item.id[0].match("CAT:"))
}
function getSelectedFilters() {
- var tree = dijit.byId("filterTree");
- var items = tree.model.getCheckedItems();
- var rv = [];
+ const tree = dijit.byId("filterTree");
+ const items = tree.model.getCheckedItems();
+ const rv = [];
items.each(function(item) {
rv.push(tree.model.store.getValue(item, 'bare_id'));
function removeSelectedLabels() {
- var sel_rows = getSelectedLabels();
+ const sel_rows = getSelectedLabels();
if (sel_rows.length > 0) {
- var ok = confirm(__("Remove selected labels?"));
+ const ok = confirm(__("Remove selected labels?"));
if (ok) {
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());
new Ajax.Request("backend.php", {
function removeSelectedUsers() {
- var sel_rows = getSelectedUsers();
+ const sel_rows = getSelectedUsers();
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) {
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());
new Ajax.Request("backend.php", {
function removeSelectedFilters() {
- var sel_rows = getSelectedFilters();
+ const sel_rows = getSelectedFilters();
if (sel_rows.length > 0) {
- var ok = confirm(__("Remove selected filters?"));
+ const ok = confirm(__("Remove selected filters?"));
if (ok) {
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());
new Ajax.Request("backend.php", {
function removeSelectedFeeds() {
- var sel_rows = getSelectedFeeds();
+ const sel_rows = getSelectedFeeds();
if (sel_rows.length > 0) {
- var ok = confirm(__("Unsubscribe from selected feeds?"));
+ const ok = confirm(__("Unsubscribe from selected feeds?"));
if (ok) {
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());
console.log(query);
}
function editSelectedUser() {
- var rows = getSelectedUsers();
+ const rows = getSelectedUsers();
if (rows.length == 0) {
alert(__("No users are selected."));
function resetSelectedUserPass() {
- var rows = getSelectedUsers();
+ const rows = getSelectedUsers();
if (rows.length == 0) {
alert(__("No users are selected."));
return;
}
- var ok = confirm(__("Reset password of selected user?"));
+ const ok = confirm(__("Reset password of selected user?"));
if (ok) {
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);
new Ajax.Request("backend.php", {
function selectedUserDetails() {
- var rows = getSelectedUsers();
+ const rows = getSelectedUsers();
if (rows.length == 0) {
alert(__("No users are selected."));
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"))
dijit.byId("userDetailsDlg").destroyRecursive();
function editSelectedFilter() {
- var rows = getSelectedFilters();
+ const rows = getSelectedFilters();
if (rows.length == 0) {
alert(__("No filters are selected."));
}
function joinSelectedFilters() {
- var rows = getSelectedFilters();
+ const rows = getSelectedFilters();
if (rows.length == 0) {
alert(__("No filters are selected."));
return;
}
- var ok = confirm(__("Combine selected filters?"));
+ const ok = confirm(__("Combine selected filters?"));
if (ok) {
notify_progress("Joining filters...");
- var query = "?op=pref-filters&method=join&ids="+
+ const query = "?op=pref-filters&method=join&ids="+
param_escape(rows.toString());
console.log(query);
}
function editSelectedFeed() {
- var rows = getSelectedFeeds();
+ const rows = getSelectedFeeds();
if (rows.length == 0) {
alert(__("No feeds are selected."));
}
function editSelectedFeeds() {
- var rows = getSelectedFeeds();
+ const rows = getSelectedFeeds();
if (rows.length == 0) {
alert(__("No feeds are selected."));
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());
console.log(query);
title: __("Edit Multiple Feeds"),
style: "width: 600px",
getChildByName: function (name) {
- var rv = null;
+ let rv = null;
this.getChildren().each(
function (child) {
if (child.name == name) {
},
execute: function () {
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 */
if (dijit.byId('opmlImportDlg'))
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",
title: __("OPML Import"),
style: "width: 600px",
function opmlImport() {
- var opml_file = $("opml_file");
+ const opml_file = $("opml_file");
if (opml_file.value.length == 0) {
alert(__("Please choose an OPML file first."));
function updateFilterList() {
- var user_search = $("filter_search");
- var search = "";
+ const user_search = $("filter_search");
+ let search = "";
if (user_search) { search = user_search.value; }
new Ajax.Request("backend.php", {
updateSystemList();
}
- var tab = dijit.byId(id + "Tab");
+ const tab = dijit.byId(id + "Tab");
dijit.byId("pref-tabs").selectChild(tab);
}
loading_set_progress(50);
notify("");
- var tab = getURLParam('tab');
+ let tab = getURLParam('tab');
if (tab) {
tab = dijit.byId(tab + "Tab");
if (tab) dijit.byId("pref-tabs").selectChild(tab);
}
- var method = getURLParam('method');
+ const method = getURLParam('method');
if (method == 'editFeed') {
- var param = getURLParam('methodparam');
+ const param = getURLParam('methodparam');
window.setTimeout(function() { editFeed(param) }, 100);
}
loading_set_progress(50);
- var clientTzOffset = new Date().getTimezoneOffset() * 60;
+ const clientTzOffset = new Date().getTimezoneOffset() * 60;
new Ajax.Request("backend.php", {
parameters: {
function validatePrefsReset() {
- var ok = confirm(__("Reset to defaults?"));
+ const ok = confirm(__("Reset to defaults?"));
if (ok) {
- var query = "?op=pref-prefs&method=resetconfig";
+ const query = "?op=pref-prefs&method=resetconfig";
console.log(query);
new Ajax.Request("backend.php", {
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
- var keycode = false;
- var shift_key = false;
+ let keycode = false;
+ let shift_key = false;
- var cmdline = $('cmdline');
+ const cmdline = $('cmdline');
try {
shift_key = e.shiftKey;
keycode = e.which;
}
- var keychar = String.fromCharCode(keycode);
+ let keychar = String.fromCharCode(keycode);
if (keycode == 27) { // escape
hotkey_prefix = false;
if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
- var date = new Date();
- var ts = Math.round(date.getTime() / 1000);
+ const date = new Date();
+ const ts = Math.round(date.getTime() / 1000);
hotkey_prefix = keychar;
hotkey_prefix_pressed = ts;
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_prefix = false;
- var hotkey_action = false;
+ let hotkey_action = false;
var hotkeys = getInitParam("hotkeys");
- for (var sequence in hotkeys[1]) {
+ for (const sequence in hotkeys[1]) {
if (sequence == hotkey) {
hotkey_action = hotkeys[1][sequence];
break;
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) {
- var query = "?op=pref-feeds&method=removeCat&ids=" +
+ const query = "?op=pref-feeds&method=removeCat&ids=" +
param_escape(id);
notify_progress("Removing category...");
function removeSelectedCategories() {
- var sel_rows = getSelectedCategories();
+ const sel_rows = getSelectedCategories();
if (sel_rows.length > 0) {
- var ok = confirm(__("Remove selected categories?"));
+ const ok = confirm(__("Remove selected categories?"));
if (ok) {
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());
new Ajax.Request("backend.php", {
}
function createCategory() {
- var title = prompt(__("Category title:"));
+ const title = prompt(__("Category title:"));
if (title) {
notify_progress("Creating category...");
- var query = "?op=pref-feeds&method=addCat&cat=" +
+ const query = "?op=pref-feeds&method=addCat&cat=" +
param_escape(title);
new Ajax.Request("backend.php", {
}
function showInactiveFeeds() {
- var query = "backend.php?op=pref-feeds&method=inactiveFeeds";
+ const query = "backend.php?op=pref-feeds&method=inactiveFeeds";
if (dijit.byId("inactiveFeedsDlg"))
dijit.byId("inactiveFeedsDlg").destroyRecursive();
return getSelectedTableRowIds("prefInactiveFeedList");
},
removeSelected: function () {
- var sel_rows = this.getSelectedFeeds();
+ const sel_rows = this.getSelectedFeeds();
console.log(sel_rows);
if (sel_rows.length > 0) {
- var ok = confirm(__("Remove selected feeds?"));
+ const ok = confirm(__("Remove selected feeds?"));
if (ok) {
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());
new Ajax.Request("backend.php", {
}
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) {
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", {
parameters: query,
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) {
e.href = new_link;
}
function labelColorReset() {
- var labels = getSelectedLabels();
+ const labels = getSelectedLabels();
if (labels.length > 0) {
- var ok = confirm(__("Reset selected labels to default colors?"));
+ const ok = confirm(__("Reset selected labels to default colors?"));
if (ok) {
- var query = "?op=pref-labels&method=colorreset&ids=" +
+ const query = "?op=pref-labels&method=colorreset&ids=" +
param_escape(labels.toString());
new Ajax.Request("backend.php", {
if (dijit.byId("profileEditDlg"))
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({
id: "profileEditDlg",
return getSelectedTableRowIds("prefFeedProfileList");
},
removeSelected: function () {
- var sel_rows = this.getSelectedProfiles();
+ const sel_rows = this.getSelectedProfiles();
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) {
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());
new Ajax.Request("backend.php", {
}
},
activateProfile: function () {
- var sel_rows = this.getSelectedProfiles();
+ const sel_rows = this.getSelectedProfiles();
if (sel_rows.length == 1) {
- var ok = confirm(__("Activate selected profile?"));
+ const ok = confirm(__("Activate selected profile?"));
if (ok) {
notify_progress("Loading, please wait...");
- var query = "?op=rpc&method=setprofile&id=" +
+ const query = "?op=rpc&method=setprofile&id=" +
param_escape(sel_rows.toString());
new Ajax.Request("backend.php", {
if (this.validate()) {
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);
new Ajax.Request("backend.php", {
function activatePrefProfile() {
- var sel_rows = getSelectedFeedCats();
+ const sel_rows = getSelectedFeedCats();
if (sel_rows.length == 1) {
- var ok = confirm(__("Activate selected profile?"));
+ const ok = confirm(__("Activate selected profile?"));
if (ok) {
notify_progress("Loading, please wait...");
- var query = "?op=rpc&method=setprofile&id="+
+ const query = "?op=rpc&method=setprofile&id="+
param_escape(sel_rows.toString());
new Ajax.Request("backend.php", {
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) {
notify_progress("Clearing URLs...");
- var query = "?op=pref-feeds&method=clearKeys";
+ const query = "?op=pref-feeds&method=clearKeys";
new Ajax.Request("backend.php", {
parameters: query,
}
-
function resetFeedOrder() {
notify_progress("Loading, please wait...");
}
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) {
}
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);
if (dijit.byId("labelEditDlg"))
dijit.byId("labelEditDlg").destroyRecursive();
- var dialog = new dijit.Dialog({
+ const dialog = new dijit.Dialog({
id: "labelEditDlg",
title: __("Label Editor"),
style: "width: 600px",
setLabelColor: function (id, fg, bg) {
- var kind = '';
- var color = '';
+ let kind = '';
+ let color = '';
if (fg && bg) {
kind = 'both';
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) +
"&bg=" + param_escape(bg) + "&color=" + param_escape(color);
// console.log(query);
- var e = $("LICID-" + id);
+ const e = $("LICID-" + id);
if (e) {
if (fg) e.style.color = fg;
},
execute: function () {
if (this.validate()) {
- var caption = this.attr('value').caption;
- var fg_color = this.attr('value').fg_color;
- var bg_color = this.attr('value').bg_color;
- var query = dojo.objectToQuery(this.attr('value'));
+ const caption = this.attr('value').caption;
+ const fg_color = this.attr('value').fg_color;
+ const bg_color = this.attr('value').bg_color;
+ const query = dojo.objectToQuery(this.attr('value'));
dijit.byId('labelTree').setNameById(id, caption);
this.setLabelColor(id, fg_color, bg_color);
function customizeCSS() {
- var query = "backend.php?op=pref-prefs&method=customizeCSS";
+ const query = "backend.php?op=pref-prefs&method=customizeCSS";
if (dijit.byId("cssEditDlg"))
dijit.byId("cssEditDlg").destroyRecursive();
- var dialog = new dijit.Dialog({
+ const dialog = new dijit.Dialog({
id: "cssEditDlg",
title: __("Customize stylesheet"),
style: "width: 600px",
}
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;
}
function batchSubscribe() {
- var query = "backend.php?op=pref-feeds&method=batchSubscribe";
+ const query = "backend.php?op=pref-feeds&method=batchSubscribe";
// overlapping widgets
if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
if (confirm(__("Clear all messages in the error log?"))) {
notify_progress("Loading, please wait...");
- var query = "?op=pref-system&method=clearLog";
+ const query = "?op=pref-system&method=clearLog";
new Ajax.Request("backend.php", {
parameters: query,
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"
});
- var treeModel = new fox.FeedStoreModel({
+ const treeModel = new fox.FeedStoreModel({
store: store,
query: {
"type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
childrenAttrs: ["items"]
});
- var tree = new fox.FeedTree({
+ const tree = new fox.FeedTree({
model: treeModel,
onClick: function (item, node) {
- var id = String(item.id);
- var is_cat = id.match("^CAT:");
- var feed = id.substr(id.indexOf(":") + 1);
+ const id = String(item.id);
+ const is_cat = id.match("^CAT:");
+ const feed = id.substr(id.indexOf(":") + 1);
viewfeed({feed: feed, is_cat: is_cat});
return false;
},
function catchupAllFeeds() {
- var str = __("Mark all articles as read?");
+ const str = __("Mark all articles as read?");
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...");
}
function search() {
- var query = "backend.php?op=feeds&method=search¶m=" +
+ const query = "backend.php?op=feeds&method=search¶m=" +
param_escape(getActiveFeedId() + ":" + activeFeedIsCat());
if (dijit.byId("searchDlg"))
dijit.byId("searchDlg").destroyRecursive();
- var dialog = new dijit.Dialog({
+ const dialog = new dijit.Dialog({
id: "searchDlg",
title: __("Search"),
style: "width: 600px",
}
function updateTitle() {
- var tmp = "Tiny Tiny RSS";
+ let tmp = "Tiny Tiny RSS";
if (global_unread > 0) {
tmp = "(" + global_unread + ") " + tmp;
}
- if (window.fluid) {
- if (global_unread > 0) {
- window.fluid.dockBadge = global_unread;
- } else {
- window.fluid.dockBadge = "";
- }
- }
-
document.title = tmp;
}
loading_set_progress(30);
- var a = document.createElement('audio');
+ const a = document.createElement('audio');
- var hasAudio = !!a.canPlayType;
- var hasSandbox = "sandbox" in document.createElement("iframe");
- var hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
- var clientTzOffset = new Date().getTimezoneOffset() * 60;
+ const hasAudio = !!a.canPlayType;
+ const hasSandbox = "sandbox" in document.createElement("iframe");
+ const hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
+ const clientTzOffset = new Date().getTimezoneOffset() * 60;
init_hotkey_actions();
function init_hotkey_actions() {
hotkey_actions["next_feed"] = function() {
- var rv = dijit.byId("feedTree").getNextFeed(
+ const rv = dijit.byId("feedTree").getNextFeed(
getActiveFeedId(), activeFeedIsCat());
if (rv) viewfeed({feed: rv[0], is_cat: rv[1], can_wait: true})
};
hotkey_actions["prev_feed"] = function() {
- var rv = dijit.byId("feedTree").getPreviousFeed(
+ const rv = dijit.byId("feedTree").getPreviousFeed(
getActiveFeedId(), activeFeedIsCat());
if (rv) viewfeed({feed: rv[0], is_cat: rv[1], can_wait: true})
moveToPost('prev', true, true);
};
hotkey_actions["collapse_article"] = function() {
- var id = getActiveArticleId();
- var elem = $("CICD-"+id);
+ const id = getActiveArticleId();
+ const elem = $("CICD-"+id);
if (elem) {
if (elem.visible()) {
}
};
hotkey_actions["toggle_expand"] = function() {
- var id = getActiveArticleId();
- var elem = $("CICD-"+id);
+ const id = getActiveArticleId();
+ const elem = $("CICD-"+id);
if (elem) {
if (elem.visible()) {
selectionToggleUnread(undefined, false, true);
};
hotkey_actions["edit_tags"] = function() {
- var id = getActiveArticleId();
+ const id = getActiveArticleId();
if (id) {
editArticleTags(id);
- };
+ }
}
hotkey_actions["open_in_new_window"] = function() {
if (getActiveArticleId()) {
reverseHeadlineOrder();
};
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", {
parameters: query_str,
gotoPreferences();
};
hotkey_actions["select_article_cursor"] = function() {
- var id = getArticleUnderPointer();
+ const id = getArticleUnderPointer();
if (id) {
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (row) {
- var cb = dijit.getEnclosingWidget(
+ const cb = dijit.getEnclosingWidget(
row.getElementsByClassName("rchk")[0]);
if (cb) {
hotkey_actions["toggle_combined_mode"] = function() {
notify_progress("Loading, please wait...");
- var value = isCdmMode() ? "false" : "true";
- var query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value;
+ const value = isCdmMode() ? "false" : "true";
+ const query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value;
new Ajax.Request("backend.php", {
parameters: query,
hotkey_actions["toggle_cdm_expanded"] = function() {
notify_progress("Loading, please wait...");
- var value = getInitParam("cdm_expanded") ? "false" : "true";
- var query = "?op=rpc&method=setpref&key=CDM_EXPANDED&value=" + value;
+ const value = getInitParam("cdm_expanded") ? "false" : "true";
+ const query = "?op=rpc&method=setpref&key=CDM_EXPANDED&value=" + value;
new Ajax.Request("backend.php", {
parameters: query,
delCookie("ttrss_test");
- var toolbar = document.forms["main_toolbar_form"];
+ const toolbar = document.forms["main_toolbar_form"];
dijit.getEnclosingWidget(toolbar.view_mode).attr('value',
getInitParam("default_view_mode"));
dijit.getEnclosingWidget(toolbar.order_by).attr('value',
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');
- var hash_feed_is_cat = hash_get('c') == "1";
+ const hash_feed_id = hash_get('f');
+ const hash_feed_is_cat = hash_get('c') == "1";
if (hash_feed_id != undefined) {
setActiveFeedId(hash_feed_id, hash_feed_is_cat);
if ('sessionStorage' in window && window['sessionStorage'] !== null)
sessionStorage.clear();
- var hotkeys = getInitParam("hotkeys");
- var tmp = [];
+ const hotkeys = getInitParam("hotkeys");
+ const tmp = [];
- for (var sequence in hotkeys[1]) {
- var filtered = sequence.replace(/\|.*$/, "");
+ for (const sequence in hotkeys[1]) {
+ const filtered = sequence.replace(/\|.*$/, "");
tmp[filtered] = hotkeys[1][sequence];
}
function toggleDispRead() {
- var hide = !(getInitParam("hide_read_feeds") == "1");
+ const hide = !(getInitParam("hide_read_feeds") == "1");
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);
setInitParam("hide_read_feeds", hide);
//console.log("parsing runtime info...");
- for (var k in data) {
- var v = data[k];
+ for (const k in data) {
+ const v = data[k];
// console.log("RI: " + k + " => " + v);
}
if (k == "update_result") {
- var updatesIcon = dijit.byId("updatesIcon").domNode;
+ const updatesIcon = dijit.byId("updatesIcon").domNode;
if (v) {
Element.show(updatesIcon);
function collapse_feedlist() {
Element.toggle("feeds-holder");
- var splitter = $("feeds-holder_splitter");
+ const splitter = $("feeds-holder_splitter");
Element.visible("feeds-holder") ? splitter.show() : splitter.hide();
function rescoreCurrentFeed() {
- var actid = getActiveFeedId();
+ const actid = getActiveFeedId();
if (activeFeedIsCat() || actid < 0) {
alert(__("You can't rescore this kind of feed."));
return;
}
- var fn = getFeedName(actid);
- var pr = __("Rescore articles in %s?").replace("%s", fn);
+ const fn = getFeedName(actid);
+ const pr = __("Rescore articles in %s?").replace("%s", fn);
if (confirm(pr)) {
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", {
parameters: query,
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) {
keycode = window.event.keyCode;
if (keycode == 17) return; // ignore lone ctrl
var hotkeys = getInitParam("hotkeys");
- var keychar = String.fromCharCode(keycode).toLowerCase();
+ const keychar = String.fromCharCode(keycode).toLowerCase();
if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
- var date = new Date();
- var ts = Math.round(date.getTime() / 1000);
+ const date = new Date();
+ const ts = Math.round(date.getTime() / 1000);
hotkey_prefix = keychar;
hotkey_prefix_pressed = ts;
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
if (e.shiftKey) hotkey = "*" + hotkey;
hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
hotkey_prefix = false;
- var hotkey_action = false;
+ let hotkey_action = false;
var hotkeys = getInitParam("hotkeys");
- for (var sequence in hotkeys[1]) {
+ for (const sequence in hotkeys[1]) {
if (sequence == hotkey) {
hotkey_action = hotkeys[1][sequence];
break;
}
}
- var action = hotkey_actions[hotkey_action];
+ const action = hotkey_actions[hotkey_action];
if (action != null) {
action();
function reverseHeadlineOrder() {
- var toolbar = document.forms["main_toolbar_form"];
- var order_by = dijit.getEnclosingWidget(toolbar.order_by);
+ const toolbar = document.forms["main_toolbar_form"];
+ const order_by = dijit.getEnclosingWidget(toolbar.order_by);
- var value = order_by.attr('value');
+ let value = order_by.attr('value');
if (value == "date_reverse")
value = "default";
function handle_rpc_json(transport, scheduled_call) {
- var netalert_dijit = dijit.byId("net-alert");
- var netalert = false;
+ const netalert_dijit = dijit.byId("net-alert");
+ let netalert = false;
if (netalert_dijit) netalert = netalert_dijit.domNode;
try {
- var reply = JSON.parse(transport.responseText);
+ const reply = JSON.parse(transport.responseText);
if (reply) {
- var error = reply['error'];
+ const error = reply['error'];
if (error) {
- var code = error['code'];
- var msg = error['msg'];
+ const code = error['code'];
+ const msg = error['msg'];
console.warn("[handle_rpc_json] received fatal error " + code + "/" + msg);
}
}
- var seq = reply['seq'];
+ const seq = reply['seq'];
if (seq) {
if (get_seq() != seq) {
}
}
- var message = reply['message'];
+ const message = reply['message'];
if (message) {
if (message == "UPDATE_COUNTERS") {
}
}
- var counters = reply['counters'];
+ const counters = reply['counters'];
if (counters)
parse_counters(counters, scheduled_call);
- var runtime_info = reply['runtime-info'];
+ const runtime_info = reply['runtime-info'];
if (runtime_info)
parse_runtime_info(runtime_info);
if (netalert) netalert.hide();
- } else {
- if (netalert)
+ } else if (netalert)
netalert.show();
else
notify_error("Communication problem with server.");
- }
} catch (e) {
if (netalert)
function switchPanelMode(wide) {
if (isCdmMode()) return;
- var article_id = getActiveArticleId();
+ const article_id = getActiveArticleId();
if (wide) {
dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
}
function hash_get(key) {
- var kv = window.location.hash.substring(1).toQueryParams();
+ const kv = window.location.hash.substring(1).toQueryParams();
return kv[key];
}
function hash_set(key, value) {
- var kv = window.location.hash.substring(1).toQueryParams();
+ const kv = window.location.hash.substring(1).toQueryParams();
kv[key] = value;
window.location.hash = $H(kv).toQueryString();
}
console.log("headlines_callback2 [offset=" + offset + "] B:" + background + " I:" + infscroll_req);
- var is_cat = false;
- var feed_id = false;
+ let is_cat = false;
+ let feed_id = false;
- var reply = false;
+ let reply = false;
try {
reply = JSON.parse(transport.responseText);
last_search_query = reply['headlines']['search_query'];
if (background) {
- var content = reply['headlines']['content'];
+ let content = reply['headlines']['content'];
content = content + "<div id='headlines-spacer'></div>";
return;
$("floatingTitle").setAttribute("data-article-id", 0);
$("floatingTitle").innerHTML = "";
}
- } catch (e) { };
+ } catch (e) { }
$("headlines-frame").removeClassName("cdm");
$("headlines-frame").removeClassName("normal");
$("headlines-frame").addClassName(isCdmMode() ? "cdm" : "normal");
- var headlines_count = reply['headlines-info']['count'];
+ const headlines_count = reply['headlines-info']['count'];
vgroup_last_feed = reply['headlines-info']['vgroup_last_feed'];
}
current_first_id = reply['headlines']['first_id'];
- var counters = reply['counters'];
- var articles = reply['articles'];
+ const counters = reply['counters'];
+ const articles = reply['articles'];
//var runtime_info = reply['runtime-info'];
if (infscroll_req == false) {
"</span>";
}
- } else {
-
- if (headlines_count > 0 && feed_id == getActiveFeedId() && is_cat == activeFeedIsCat()) {
+ } else if (headlines_count > 0 && feed_id == getActiveFeedId() && is_cat == activeFeedIsCat()) {
console.log("adding some more headlines: " + headlines_count);
- var c = dijit.byId("headlines-frame");
- var ids = getSelectedArticleIds2();
+ const c = dijit.byId("headlines-frame");
+ const ids = getSelectedArticleIds2();
var hsp = $("headlines-spacer");
} else {
console.log("no new headlines received");
- var first_id_changed = reply['headlines']['first_id_changed'];
+ const first_id_changed = reply['headlines']['first_id_changed'];
console.log("first id changed:" + first_id_changed);
var hsp = $("headlines-spacer");
}
}
- }
if (articles) {
for (var i = 0; i < articles.length; i++) {
- var a_id = articles[i]['id'];
+ const a_id = articles[i]['id'];
cache_set("article:" + a_id, articles[i]['content']);
}
} else {
dijit.byId("headlines-wrap-inner").addChild(
dijit.byId("content-insert"));
- var c = dijit.byId("content-insert");
+ const c = dijit.byId("content-insert");
try {
c.domNode.scrollTop = 0;
- } catch (e) { };
+ } catch (e) { }
c.attr('content', article);
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, c.domNode);
try {
c.focus();
- } catch (e) { };
+ } catch (e) { }
}
function showArticleInHeadlines(id, noexpand) {
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (!row) return;
if (!noexpand)
handle_rpc_json(transport);
- var reply = false;
+ let reply = false;
try {
reply = JSON.parse(transport.responseText);
__('Could not display article (invalid object received - see error console for details)') + "</div>");
}
- var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
+ const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
request_counters(unread_in_buffer == 0);
notify("");
}
function view(id, activefeed, noexpand) {
- var oldrow = $("RROW-" + getActiveArticleId());
+ const oldrow = $("RROW-" + getActiveArticleId());
if (oldrow) oldrow.removeClassName("active");
- var crow = $("RROW-" + id);
+ const crow = $("RROW-" + id);
if (!crow) return;
if (noexpand) {
console.log("loading article: " + id);
- var cached_article = cache_get("article:" + id);
+ const cached_article = cache_get("article:" + id);
console.log("cache check result: " + (cached_article != false));
- var query = "?op=article&method=view&id=" + param_escape(id);
+ let query = "?op=article&method=view&id=" + param_escape(id);
- var neighbor_ids = getRelativePostIds(id);
+ const neighbor_ids = getRelativePostIds(id);
/* only request uncached articles */
- var cids_to_request = [];
+ const cids_to_request = [];
- for (var i = 0; i < neighbor_ids.length; i++) {
+ for (let i = 0; i < neighbor_ids.length; i++) {
if (cids_requested.indexOf(neighbor_ids[i]) == -1)
if (!cache_get("article:" + neighbor_ids[i])) {
cids_to_request.push(neighbor_ids[i]);
query = query + "&cids=" + cids_to_request.toString();
- var article_is_unread = crow.hasClassName("Unread");
+ const article_is_unread = crow.hasClassName("Unread");
setActiveArticleId(id);
showArticleInHeadlines(id);
}
function toggleMark(id, client_only) {
- var query = "?op=rpc&id=" + id + "&method=mark";
+ let query = "?op=rpc&id=" + id + "&method=mark";
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (!row) return;
- var imgs = [];
+ const imgs = [];
- var row_imgs = row.getElementsByClassName("markedPic");
+ const row_imgs = row.getElementsByClassName("markedPic");
for (var i = 0; i < row_imgs.length; i++)
imgs.push(row_imgs[i]);
- var ft = $("floatingTitle");
+ const ft = $("floatingTitle");
if (ft && ft.getAttribute("data-article-id") == id) {
- var fte = ft.getElementsByClassName("markedPic");
+ const fte = ft.getElementsByClassName("markedPic");
for (var i = 0; i < fte.length; i++)
imgs.push(fte[i]);
}
for (i = 0; i < imgs.length; i++) {
- var img = imgs[i];
+ const img = imgs[i];
if (!row.hasClassName("marked")) {
img.src = img.src.replace("mark_unset", "mark_set");
}
function togglePub(id, client_only, no_effects, note) {
- var query = "?op=rpc&id=" + id + "&method=publ";
+ let query = "?op=rpc&id=" + id + "&method=publ";
if (note != undefined) {
query = query + "¬e=" + param_escape(note);
query = query + "¬e=undefined";
}
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (!row) return;
- var imgs = [];
+ const imgs = [];
- var row_imgs = row.getElementsByClassName("pubPic");
+ const row_imgs = row.getElementsByClassName("pubPic");
for (var i = 0; i < row_imgs.length; i++)
imgs.push(row_imgs[i]);
- var ft = $("floatingTitle");
+ const ft = $("floatingTitle");
if (ft && ft.getAttribute("data-article-id") == id) {
- var fte = ft.getElementsByClassName("pubPic");
+ const fte = ft.getElementsByClassName("pubPic");
for (var i = 0; i < fte.length; i++)
imgs.push(fte[i]);
}
for (var i = 0; i < imgs.length; i++) {
- var img = imgs[i];
+ const img = imgs[i];
if (!row.hasClassName("published") || note != undefined) {
img.src = img.src.replace("pub_unset", "pub_set");
}
function moveToPost(mode, noscroll, noexpand) {
- var rows = getLoadedArticleIds();
+ const rows = getLoadedArticleIds();
- var prev_id = false;
- var next_id = false;
+ let prev_id = false;
+ let next_id = false;
if (!$('RROW-' + getActiveArticleId())) {
setActiveArticleId(0);
next_id = rows[0];
prev_id = rows[rows.length-1]
} else {
- for (var i = 0; i < rows.length; i++) {
+ for (let i = 0; i < rows.length; i++) {
if (rows[i] == getActiveArticleId()) {
// Account for adjacent identical article ids.
if (i > 0) prev_id = rows[i-1];
- for (var j = i+1; j < rows.length; j++) {
+ for (let j = i+1; j < rows.length; j++) {
if (rows[j] != getActiveArticleId()) {
next_id = rows[j];
break;
if (isCdmMode()) {
var article = $("RROW-" + getActiveArticleId());
- var prev_article = $("RROW-" + prev_id);
+ const prev_article = $("RROW-" + prev_id);
var ctr = $("headlines-frame");
if (!getInitParam("cdm_expanded")) {
cdmExpandArticle(prev_id, noexpand);
cdmScrollToArticleId(prev_id, true);
}
- } else {
-
- if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
+ } else if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
scrollArticle(-ctr.offsetHeight/3);
} else if (!noscroll && prev_article &&
prev_article.offsetTop < ctr.scrollTop) {
cdmExpandArticle(prev_id, noexpand);
cdmScrollToArticleId(prev_id, noscroll);
}
- }
} else if (prev_id) {
correctHeadlinesOffset(prev_id);
}
function toggleSelected(id, force_on) {
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (row) {
- var cb = dijit.getEnclosingWidget(
+ const cb = dijit.getEnclosingWidget(
row.getElementsByClassName("rchk")[0]);
if (row.hasClassName('Selected') && !force_on) {
}
function updateSelectedPrompt() {
- var count = getSelectedArticleIds2().size();
- var elem = $("selected_prompt");
+ const count = getSelectedArticleIds2().size();
+ const elem = $("selected_prompt");
if (elem) {
elem.innerHTML = ngettext("%d article selected",
}
function toggleUnread(id, cmode, effect) {
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (row) {
- var tmpClassName = row.className;
+ const tmpClassName = row.className;
if (cmode == undefined || cmode == 2) {
if (row.hasClassName("Unread")) {
if (cmode == undefined) cmode = 2;
- var query = "?op=rpc&method=catchupSelected" +
+ const query = "?op=rpc&method=catchupSelected" +
"&cmode=" + param_escape(cmode) + "&ids=" + param_escape(id);
// notify_progress("Loading, please wait...");
return;
}
- var query = "?op=article&method=removeFromLabel&ids=" +
+ const query = "?op=article&method=removeFromLabel&ids=" +
param_escape(ids.toString()) + "&lid=" + param_escape(id);
console.log(query);
return;
}
- var query = "?op=article&method=assignToLabel&ids=" +
+ const query = "?op=article&method=assignToLabel&ids=" +
param_escape(ids.toString()) + "&lid=" + param_escape(id);
console.log(query);
}
function selectionToggleUnread(set_state, callback, no_error, ids) {
- var rows = ids ? ids : getSelectedArticleIds2();
+ const rows = ids ? ids : getSelectedArticleIds2();
if (rows.length == 0 && !no_error) {
alert(__("No articles are selected."));
return;
}
- for (var i = 0; i < rows.length; i++) {
- var row = $("RROW-" + rows[i]);
+ for (let i = 0; i < rows.length; i++) {
+ const row = $("RROW-" + rows[i]);
if (row) {
if (set_state == undefined) {
if (row.hasClassName("Unread")) {
if (rows.length > 0) {
- var cmode = "";
+ let cmode = "";
if (set_state == undefined) {
cmode = "2";
cmode = "0";
}
- var query = "?op=rpc&method=catchupSelected" +
+ const query = "?op=rpc&method=catchupSelected" +
"&cmode=" + cmode + "&ids=" + param_escape(rows.toString());
notify_progress("Loading, please wait...");
// sel_state ignored
function selectionToggleMarked(sel_state, callback, no_error, ids) {
- var rows = ids ? ids : getSelectedArticleIds2();
+ const rows = ids ? ids : getSelectedArticleIds2();
if (rows.length == 0 && !no_error) {
alert(__("No articles are selected."));
return;
}
- for (var i = 0; i < rows.length; i++) {
+ for (let i = 0; i < rows.length; i++) {
toggleMark(rows[i], true, true);
}
if (rows.length > 0) {
- var query = "?op=rpc&method=markSelected&ids=" +
+ const query = "?op=rpc&method=markSelected&ids=" +
param_escape(rows.toString()) + "&cmode=2";
new Ajax.Request("backend.php", {
// sel_state ignored
function selectionTogglePublished(sel_state, callback, no_error, ids) {
- var rows = ids ? ids : getSelectedArticleIds2();
+ const rows = ids ? ids : getSelectedArticleIds2();
if (rows.length == 0 && !no_error) {
alert(__("No articles are selected."));
return;
}
- for (var i = 0; i < rows.length; i++) {
+ for (let i = 0; i < rows.length; i++) {
togglePub(rows[i], true, true);
}
if (rows.length > 0) {
- var query = "?op=rpc&method=publishSelected&ids=" +
+ const query = "?op=rpc&method=publishSelected&ids=" +
param_escape(rows.toString()) + "&cmode=2";
new Ajax.Request("backend.php", {
function getSelectedArticleIds2() {
- var rv = [];
+ const rv = [];
$$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
function(child) {
}
function getLoadedArticleIds() {
- var rv = [];
+ const rv = [];
- var children = $$("#headlines-frame > div[id*=RROW-]");
+ const children = $$("#headlines-frame > div[id*=RROW-]");
children.each(function(child) {
if (Element.visible(child)) {
function selectArticles(mode, query) {
if (!query) query = "#headlines-frame > div[id*=RROW]";
- var children = $$(query);
+ const children = $$(query);
children.each(function(child) {
- var id = child.getAttribute("data-article-id");
+ const id = child.getAttribute("data-article-id");
- var cb = dijit.getEnclosingWidget(
+ const cb = dijit.getEnclosingWidget(
child.getElementsByClassName("rchk")[0]);
if (mode == "all") {
function deleteSelection() {
- var rows = getSelectedArticleIds2();
+ const rows = getSelectedArticleIds2();
if (rows.length == 0) {
alert(__("No articles are selected."));
return;
}
- var fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
- var str;
+ const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
+ let str;
if (getActiveFeedId() != 0) {
str = ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?", rows.length);
return;
}
- var query = "?op=rpc&method=delete&ids=" + param_escape(rows);
+ const query = "?op=rpc&method=delete&ids=" + param_escape(rows);
console.log(query);
function archiveSelection() {
- var rows = getSelectedArticleIds2();
+ const rows = getSelectedArticleIds2();
if (rows.length == 0) {
alert(__("No articles are selected."));
return;
}
- var fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
- var str;
- var op;
+ const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
+ let str;
+ let op;
if (getActiveFeedId() != 0) {
str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length);
return;
}
- var query = "?op=rpc&method="+op+"&ids=" + param_escape(rows);
+ const query = "?op=rpc&method="+op+"&ids=" + param_escape(rows);
console.log(query);
- for (var i = 0; i < rows.length; i++) {
+ for (let i = 0; i < rows.length; i++) {
cache_delete("article:" + rows[i]);
}
function catchupSelection() {
- var rows = getSelectedArticleIds2();
+ const rows = getSelectedArticleIds2();
if (rows.length == 0) {
alert(__("No articles are selected."));
return;
}
- var fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
+ const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
- var str = ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows.length);
+ let str = ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows.length);
str = str.replace("%d", rows.length);
str = str.replace("%s", fn);
}
function editArticleTags(id) {
- var query = "backend.php?op=article&method=editArticleTags¶m=" + param_escape(id);
+ const query = "backend.php?op=article&method=editArticleTags¶m=" + param_escape(id);
if (dijit.byId("editTagsDlg"))
dijit.byId("editTagsDlg").destroyRecursive();
style: "width: 600px",
execute: function() {
if (this.validate()) {
- var query = dojo.objectToQuery(this.attr('value'));
+ const query = dojo.objectToQuery(this.attr('value'));
notify_progress("Saving article tags...", true);
notify('');
dialog.hide();
- var data = JSON.parse(transport.responseText);
+ const data = JSON.parse(transport.responseText);
if (data) {
- var id = data.id;
+ const id = data.id;
console.log(id);
- var tags = $("ATSTR-" + id);
- var tooltip = dijit.byId("ATSTRTIP-" + id);
+ const tags = $("ATSTR-" + id);
+ const tooltip = dijit.byId("ATSTRTIP-" + id);
if (tags) tags.innerHTML = data.content;
if (tooltip) tooltip.attr('label', data.content_full);
}
function cdmScrollToArticleId(id, force) {
- var ctr = $("headlines-frame");
- var e = $("RROW-" + id);
+ const ctr = $("headlines-frame");
+ const e = $("RROW-" + id);
if (!e || !ctr) return;
$$("#headlines-frame span.cencw[id]").each(
function (child) {
- var row = $("RROW-" + child.id.replace("CENCW-", ""));
+ const row = $("RROW-" + child.id.replace("CENCW-", ""));
if (row && row.offsetTop <= $("headlines-frame").scrollTop +
$("headlines-frame").offsetHeight) {
_headlines_scroll_offset = e.scrollTop;
- var hsp = $("headlines-spacer");
+ const hsp = $("headlines-spacer");
unpackVisibleHeadlines();
getSelectedArticleIds2().length <= 1 &&
getInitParam("cdm_expanded")) {
- var rows = $$("#headlines-frame > div[id*=RROW]");
+ const rows = $$("#headlines-frame > div[id*=RROW]");
- for (var i = 0; i < rows.length; i++) {
+ for (let i = 0; i < rows.length; i++) {
var child = rows[i];
if ($("headlines-frame").scrollTop <= child.offsetTop &&
child.getAttribute("data-article-id") != _active_article_id) {
if (_active_article_id) {
- var row = $("RROW-" + _active_article_id);
+ const row = $("RROW-" + _active_article_id);
if (row) row.removeClassName("active");
}
if (getInitParam("cdm_auto_catchup") == 1) {
// let's get DOM some time to settle down
- var ts = new Date().getTime();
+ const ts = new Date().getTime();
if (ts - _last_headlines_update < 100) return;
$$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
if (child.hasClassName("Unread") && $("headlines-frame").scrollTop >
(child.offsetTop + child.offsetHeight/2)) {
- var id = child.getAttribute("data-article-id")
+ const id = child.getAttribute("data-article-id")
if (catchup_id_batch.indexOf(id) == -1)
catchup_id_batch.push(id);
}
function openNextUnreadFeed() {
- var is_cat = activeFeedIsCat();
- var nuf = getNextUnreadFeed(getActiveFeedId(), is_cat);
+ const is_cat = activeFeedIsCat();
+ const nuf = getNextUnreadFeed(getActiveFeedId(), is_cat);
if (nuf) viewfeed({feed: nuf, is_cat: is_cat});
}
console.log("catchupBatchedArticles: working");
// make a copy of the array
- var batch = catchup_id_batch.slice();
- var query = "?op=rpc&method=catchupSelected" +
+ const batch = catchup_id_batch.slice();
+ const query = "?op=rpc&method=catchupSelected" +
"&cmode=0&ids=" + param_escape(batch.toString());
console.log(query);
_catchup_request_sent = false;
- var reply = JSON.parse(transport.responseText);
- var batch = reply.ids;
+ const reply = JSON.parse(transport.responseText);
+ const batch = reply.ids;
batch.each(function (id) {
console.log(id);
- var elem = $("RROW-" + id);
+ const elem = $("RROW-" + id);
if (elem) elem.removeClassName("Unread");
catchup_id_batch.remove(id);
});
return;
}
- var visible_ids = getLoadedArticleIds();
+ const visible_ids = getLoadedArticleIds();
- var ids_to_mark = new Array();
+ const ids_to_mark = new Array();
if (!below) {
for (var i = 0; i < visible_ids.length; i++) {
if (ids_to_mark.length == 0) {
alert(__("No articles found to mark"));
} else {
- var msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length);
+ const msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length);
if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) {
e.removeClassName("Unread");
}
- var query = "?op=rpc&method=catchupSelected" +
+ const query = "?op=rpc&method=catchupSelected" +
"&cmode=0" + "&ids=" + param_escape(ids_to_mark.toString());
new Ajax.Request("backend.php", {
function cdmCollapseArticle(event, id, unmark) {
if (unmark == undefined) unmark = true;
- var row = $("RROW-" + id);
- var elem = $("CICD-" + id);
+ const row = $("RROW-" + id);
+ const elem = $("CICD-" + id);
if (elem && row) {
- var collapse = row.select("span[class='collapseBtn']")[0];
+ const collapse = row.select("span[class='collapseBtn']")[0];
Element.hide(elem);
Element.show("CEXC-" + id);
function cdmExpandArticle(id, noexpand) {
console.log("cdmExpandArticle " + id);
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (!row) return false;
- var oldrow = $("RROW-" + getActiveArticleId());
+ const oldrow = $("RROW-" + getActiveArticleId());
- var elem = $("CICD-" + getActiveArticleId());
+ let elem = $("CICD-" + getActiveArticleId());
if (id == getActiveArticleId() && Element.visible(elem))
return true;
selectArticles("none");
- var old_offset = row.offsetTop;
+ const old_offset = row.offsetTop;
if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) {
var collapse = oldrow.select("span[class='collapseBtn']")[0];
var collapse = row.select("span[class='collapseBtn']")[0];
- var cencw = $("CENCW-" + id);
+ const cencw = $("CENCW-" + id);
if (!Element.visible(elem) && !noexpand) {
if (cencw) {
Element.show(collapse);
}
- var new_offset = row.offsetTop;
+ const new_offset = row.offsetTop;
if (old_offset > new_offset)
$("headlines-frame").scrollTop -= (old_offset - new_offset);
function scrollArticle(offset) {
if (!isCdmMode()) {
- var ci = $("content-insert");
+ const ci = $("content-insert");
if (ci) {
ci.scrollTop += offset;
}
} else {
- var hi = $("headlines-frame");
+ const hi = $("headlines-frame");
if (hi) {
hi.scrollTop += offset;
}
}
function show_labels_in_headlines(transport) {
- var data = JSON.parse(transport.responseText);
+ const data = JSON.parse(transport.responseText);
if (data) {
data['info-for-headlines'].each(function (elem) {
updateFloatingTitle(true);
}
- var query = "?op=rpc&method=catchupSelected" +
+ const query = "?op=rpc&method=catchupSelected" +
"&cmode=0&ids=" + param_escape(id);
new Ajax.Request("backend.php", {
return true;
}
- var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
+ const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
request_counters(unread_in_buffer == 0);
return false;
function openArticleInNewWindow(id) {
toggleUnread(id, 0, false);
- var w = window.open("");
+ const w = window.open("");
w.opener = null;
w.location = "backend.php?op=article&method=redirect&id=" + id;
}
function markHeadline(id, marked) {
if (marked == undefined) marked = true;
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (row) {
- var check = dijit.getEnclosingWidget(
+ const check = dijit.getEnclosingWidget(
row.getElementsByClassName("rchk")[0]);
if (check) {
function getRelativePostIds(id, limit) {
- var tmp = [];
+ const tmp = [];
if (!limit) limit = 6; //3
- var ids = getLoadedArticleIds();
+ const ids = getLoadedArticleIds();
- for (var i = 0; i < ids.length; i++) {
+ for (let i = 0; i < ids.length; i++) {
if (ids[i] == id) {
- for (var k = 1; k <= limit; k++) {
+ for (let k = 1; k <= limit; k++) {
//if (i > k-1) tmp.push(ids[i-k]);
if (i < ids.length - k) tmp.push(ids[i + k]);
}
function correctHeadlinesOffset(id) {
- var container = $("headlines-frame");
- var row = $("RROW-" + id);
+ const container = $("headlines-frame");
+ const row = $("RROW-" + id);
if (!container || !row) return;
- var viewport = container.offsetHeight;
+ const viewport = container.offsetHeight;
- var rel_offset_top = row.offsetTop - container.scrollTop;
- var rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;
+ const rel_offset_top = row.offsetTop - container.scrollTop;
+ const rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;
//console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
//console.log("Vport: " + viewport);
function initFloatingMenu() {
if (!dijit.byId("floatingMenu")) {
- var menu = new dijit.Menu({
+ const menu = new dijit.Menu({
id: "floatingMenu",
targetNodeIds: ["floatingTitle"]
});
label: __("Toggle unread"),
onClick: function (event) {
- var ids = getSelectedArticleIds2();
+ let ids = getSelectedArticleIds2();
// cast to string
- var id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
+ const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
selectionToggleUnread(undefined, false, true, ids);
menu.addChild(new dijit.MenuItem({
label: __("Toggle starred"),
onClick: function (event) {
- var ids = getSelectedArticleIds2();
+ let ids = getSelectedArticleIds2();
// cast to string
- var id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
+ const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
selectionToggleMarked(undefined, false, true, ids);
menu.addChild(new dijit.MenuItem({
label: __("Toggle published"),
onClick: function (event) {
- var ids = getSelectedArticleIds2();
+ let ids = getSelectedArticleIds2();
// cast to string
- var id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
+ const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
selectionTogglePublished(undefined, false, true, ids);
}));
- var labels = getInitParam("labels");
+ const labels = getInitParam("labels");
if (labels && labels.length) {
menu.addChild(new dijit.MenuSeparator());
- var labelAddMenu = new dijit.Menu({ownerMenu: menu});
- var labelDelMenu = new dijit.Menu({ownerMenu: menu});
+ const labelAddMenu = new dijit.Menu({ownerMenu: menu});
+ const labelDelMenu = new dijit.Menu({ownerMenu: menu});
labels.each(function (label) {
- var bare_id = label.id;
- var name = label.caption;
+ const bare_id = label.id;
+ const name = label.caption;
labelAddMenu.addChild(new dijit.MenuItem({
label: name,
labelId: bare_id,
onClick: function (event) {
- var ids = getSelectedArticleIds2();
+ let ids = getSelectedArticleIds2();
// cast to string
- var id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
+ const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
label: name,
labelId: bare_id,
onClick: function (event) {
- var ids = getSelectedArticleIds2();
+ let ids = getSelectedArticleIds2();
// cast to string
- var id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
+ const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
}
function setSelectionScore() {
- var ids = getSelectedArticleIds2();
+ const ids = getSelectedArticleIds2();
if (ids.length > 0) {
console.log(ids);
var score = prompt(__("Please enter new score for selected articles:"), score);
if (score != undefined) {
- var query = "op=article&method=setScore&id=" + param_escape(ids.toString()) +
+ const query = "op=article&method=setScore&id=" + param_escape(ids.toString()) +
"&score=" + param_escape(score);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
- var reply = JSON.parse(transport.responseText);
+ const reply = JSON.parse(transport.responseText);
if (reply) {
console.log(ids);
ids.each(function (id) {
- var row = $("RROW-" + id);
+ const row = $("RROW-" + id);
if (row) {
- var pic = row.getElementsByClassName("hlScorePic")[0];
+ const pic = row.getElementsByClassName("hlScorePic")[0];
if (pic) {
pic.src = pic.src.replace(/score_.*?\.png/,
}
function updateScore(id) {
- var pic = $$("#RROW-" + id + " .hlScorePic")[0];
+ const pic = $$("#RROW-" + id + " .hlScorePic")[0];
if (pic) {
- var query = "op=article&method=getScore&id=" + param_escape(id);
+ const query = "op=article&method=getScore&id=" + param_escape(id);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
console.log(transport.responseText);
- var reply = JSON.parse(transport.responseText);
+ const reply = JSON.parse(transport.responseText);
if (reply) {
pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
}
function changeScore(id, pic) {
- var score = pic.getAttribute("score");
+ const score = pic.getAttribute("score");
- var new_score = prompt(__("Please enter new score for this article:"), score);
+ const new_score = prompt(__("Please enter new score for this article:"), score);
if (new_score != undefined) {
- var query = "op=article&method=setScore&id=" + param_escape(id) +
+ const query = "op=article&method=setScore&id=" + param_escape(id) +
"&score=" + param_escape(new_score);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
- var reply = JSON.parse(transport.responseText);
+ const reply = JSON.parse(transport.responseText);
if (reply) {
pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
}
function displayArticleUrl(id) {
- var query = "op=rpc&method=getlinktitlebyid&id=" + param_escape(id);
+ const query = "op=rpc&method=getlinktitlebyid&id=" + param_escape(id);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function (transport) {
- var reply = JSON.parse(transport.responseText);
+ const reply = JSON.parse(transport.responseText);
if (reply && reply.link) {
prompt(__("Article URL:"), reply.link);
}
function scrollToRowId(id) {
- var row = $(id);
+ const row = $(id);
if (row)
$("headlines-frame").scrollTop = row.offsetTop - 4;
function updateFloatingTitle(unread_only) {
if (!isCdmMode()) return;
- var hf = $("headlines-frame");
+ const hf = $("headlines-frame");
- var elems = $$("#headlines-frame > div[id*=RROW]");
+ const elems = $$("#headlines-frame > div[id*=RROW]");
- for (var i = 0; i < elems.length; i++) {
+ for (let i = 0; i < elems.length; i++) {
- var child = elems[i];
+ const child = elems[i];
if (child && child.offsetTop + child.offsetHeight > hf.scrollTop) {
- var header = child.getElementsByClassName("cdmHeader")[0];
+ const header = child.getElementsByClassName("cdmHeader")[0];
if (unread_only || child.getAttribute("data-article-id") != $("floatingTitle").getAttribute("data-article-id")) {
if (child.getAttribute("data-article-id") != $("floatingTitle").getAttribute("data-article-id")) {
initFloatingMenu();
- var cb = $$("#floatingTitle .dijitCheckBox")[0];
+ const cb = $$("#floatingTitle .dijitCheckBox")[0];
if (cb)
cb.parentNode.removeChild(cb);