replace 4 space indents with tabs

master
Andrew Dolgov 6 years ago
parent 50052fb78a
commit 02ec3984bd

@ -103,7 +103,7 @@ function viewfeed(params) {
Form.enable("main_toolbar_form"); Form.enable("main_toolbar_form");
let query = Object.assign({op: "feeds", method: "view", feed: feed}, let query = Object.assign({op: "feeds", method: "view", feed: feed},
dojo.formToObject("main_toolbar_form")); dojo.formToObject("main_toolbar_form"));
if (method) query.m = method; if (method) query.m = method;
@ -156,13 +156,13 @@ function viewfeed(params) {
_viewfeed_timeout = setTimeout(() => { _viewfeed_timeout = setTimeout(() => {
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
try { try {
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif'); setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
headlines_callback2(transport, offset, background, infscroll_req); headlines_callback2(transport, offset, background, infscroll_req);
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]); PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
} catch (e) { } catch (e) {
exception_error(e); exception_error(e);
} }
}); });
}, timeout_ms); // Wait 250ms }, timeout_ms); // Wait 250ms
@ -209,11 +209,11 @@ function feedlist_init() {
} }
// bw_limit disables timeout() so we request initial counters separately // bw_limit disables timeout() so we request initial counters separately
if (getInitParam("bw_limit") == "1") { if (getInitParam("bw_limit") == "1") {
request_counters(true); request_counters(true);
} else { } else {
setTimeout(timeout, 250); setTimeout(timeout, 250);
} }
} }
@ -232,7 +232,7 @@ function request_counters(force) {
query.last_article_id = getInitParam("last_article_id"); query.last_article_id = getInitParam("last_article_id");
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
}); });
} else { } else {
@ -471,7 +471,7 @@ function catchupFeedInGroup(id) {
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
xhrPost("backend.php", { op: "rpc", method: "catchupFeed", feed_id: id, is_cat: false}, (transport) => { xhrPost("backend.php", { op: "rpc", method: "catchupFeed", feed_id: id, is_cat: false}, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
}); });
} }
} }
@ -512,21 +512,21 @@ function catchupFeed(feed, is_cat, mode) {
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
xhrPost("backend.php", catchup_query, (transport) => { xhrPost("backend.php", catchup_query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
const show_next_feed = getInitParam("on_catchup_show_next_feed") == "1"; const show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
if (show_next_feed) { if (show_next_feed) {
const nuf = getNextUnreadFeed(feed, is_cat); const nuf = getNextUnreadFeed(feed, is_cat);
if (nuf) { if (nuf) {
viewfeed({feed: nuf, is_cat: is_cat}); viewfeed({feed: nuf, is_cat: is_cat});
} }
} else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) { } else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
viewCurrentFeed(); viewCurrentFeed();
} }
notify(""); notify("");
}); });
} }

@ -30,23 +30,23 @@ Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
function xhrPost(url, params, complete) { function xhrPost(url, params, complete) {
console.log("xhrPost:", params); console.log("xhrPost:", params);
return new Ajax.Request(url, { return new Ajax.Request(url, {
parameters: params, parameters: params,
onComplete: complete onComplete: complete
}); });
} }
function xhrJson(url, params, complete) { function xhrJson(url, params, complete) {
return xhrPost(url, params, (reply) => { return xhrPost(url, params, (reply) => {
try { try {
const obj = JSON.parse(reply.responseText); const obj = JSON.parse(reply.responseText);
complete(obj); complete(obj);
} catch (e) { } catch (e) {
console.error("xhrJson", e, reply); console.error("xhrJson", e, reply);
complete(null); complete(null);
} }
}) })
} }
/* add method to remove element from array */ /* add method to remove element from array */
@ -246,15 +246,15 @@ function getCookie(name) {
const prefix = name + "="; const prefix = name + "=";
let 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;
} }
else { else {
begin += 2; begin += 2;
} }
let end = document.cookie.indexOf(";", begin); let end = document.cookie.indexOf(";", begin);
if (end == -1) { if (end == -1) {
end = dc.length; end = dc.length;
} }
return unescape(dc.substring(begin + prefix.length, end)); return unescape(dc.substring(begin + prefix.length, end));
} }
@ -342,8 +342,8 @@ function displayDlg(title, id, param, callback) {
const query = { op: "dlg", method: id, param: param }; const query = { op: "dlg", method: id, param: param };
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
infobox_callback2(transport, title); infobox_callback2(transport, title);
if (callback) callback(transport); if (callback) callback(transport);
}); });
return false; return false;
@ -527,16 +527,16 @@ function removeFeedIcon(id) {
notify_progress("Removing feed icon...", true); notify_progress("Removing feed icon...", true);
const query = { op: "pref-feeds", method: "removeicon", feed_id: id }; const query = { op: "pref-feeds", method: "removeicon", feed_id: id };
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
notify_info("Feed icon removed."); notify_info("Feed icon removed.");
if (inPreferences()) { if (inPreferences()) {
updateFeedList(); updateFeedList();
} else { } else {
setTimeout('updateFeedList(false, false)', 50); setTimeout('updateFeedList(false, false)', 50);
} }
}); });
} }
return false; return false;
@ -574,14 +574,14 @@ function addLabel(select, callback) {
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
if (callback) { if (callback) {
callback(transport); callback(transport);
} else if (inPreferences()) { } else if (inPreferences()) {
updateLabelList(); updateLabelList();
} else { } else {
updateFeedList(); updateFeedList();
} }
}); });
} }
} }
@ -616,75 +616,75 @@ function quickAddFeed() {
Element.hide("fadd_error_message"); Element.hide("fadd_error_message");
xhrPost("backend.php", this.attr('value'), (transport) => { xhrPost("backend.php", this.attr('value'), (transport) => {
try { try {
try { try {
var reply = JSON.parse(transport.responseText); var reply = JSON.parse(transport.responseText);
} catch (e) { } catch (e) {
Element.hide("feed_add_spinner"); Element.hide("feed_add_spinner");
alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console."));
console.log('quickAddFeed, backend returned:' + transport.responseText); console.log('quickAddFeed, backend returned:' + transport.responseText);
return; return;
} }
const rc = reply['result']; const rc = reply['result'];
notify(''); notify('');
Element.hide("feed_add_spinner"); Element.hide("feed_add_spinner");
console.log(rc); console.log(rc);
switch (parseInt(rc['code'])) { switch (parseInt(rc['code'])) {
case 1: case 1:
dialog.hide(); dialog.hide();
notify_info(__("Subscribed to %s").replace("%s", feed_url)); notify_info(__("Subscribed to %s").replace("%s", feed_url));
updateFeedList(); updateFeedList();
break; break;
case 2: case 2:
dialog.show_error(__("Specified URL seems to be invalid.")); dialog.show_error(__("Specified URL seems to be invalid."));
break; break;
case 3: case 3:
dialog.show_error(__("Specified URL doesn't seem to contain any feeds.")); dialog.show_error(__("Specified URL doesn't seem to contain any feeds."));
break; break;
case 4: case 4:
const feeds = rc['feeds']; const feeds = rc['feeds'];
Element.show("fadd_multiple_notify"); Element.show("fadd_multiple_notify");
const select = dijit.byId("feedDlg_feedContainerSelect"); const select = dijit.byId("feedDlg_feedContainerSelect");
while (select.getOptions().length > 0) while (select.getOptions().length > 0)
select.removeOption(0); select.removeOption(0);
select.addOption({value: '', label: __("Expand to select feed")}); select.addOption({value: '', label: __("Expand to select feed")});
let count = 0; let count = 0;
for (const feedUrl in feeds) { for (const feedUrl in feeds) {
select.addOption({value: feedUrl, label: feeds[feedUrl]}); select.addOption({value: feedUrl, label: feeds[feedUrl]});
count++; count++;
} }
Effect.Appear('feedDlg_feedsContainer', {duration : 0.5}); Effect.Appear('feedDlg_feedsContainer', {duration : 0.5});
break; break;
case 5: case 5:
dialog.show_error(__("Couldn't download the specified URL: %s"). dialog.show_error(__("Couldn't download the specified URL: %s").
replace("%s", rc['message'])); replace("%s", rc['message']));
break; break;
case 6: case 6:
dialog.show_error(__("XML validation failed: %s"). dialog.show_error(__("XML validation failed: %s").
replace("%s", rc['message'])); replace("%s", rc['message']));
break; break;
case 0: case 0:
dialog.show_error(__("You are already subscribed to this feed.")); dialog.show_error(__("You are already subscribed to this feed."));
break; break;
} }
} catch (e) { } catch (e) {
console.error(transport.responseText); console.error(transport.responseText);
exception_error(e); exception_error(e);
} }
}); });
} }
}, },
@ -1089,23 +1089,23 @@ function backend_sanity_check_callback(transport) {
for (const k in params) { for (const k in params) {
switch (k) { switch (k) {
case "label_base_index": case "label_base_index":
_label_base_index = parseInt(params[k]) _label_base_index = parseInt(params[k])
break; break;
case "hotkeys": case "hotkeys":
// filter mnemonic definitions (used for help panel) from hotkeys map // filter mnemonic definitions (used for help panel) from hotkeys map
// i.e. *(191)|Ctrl-/ -> *(191) // i.e. *(191)|Ctrl-/ -> *(191)
const tmp = []; const tmp = [];
for (const sequence in params[k][1]) { for (const sequence in params[k][1]) {
const filtered = sequence.replace(/\|.*$/, ""); const filtered = sequence.replace(/\|.*$/, "");
tmp[filtered] = params[k][1][sequence]; tmp[filtered] = params[k][1][sequence];
} }
params[k][1] = tmp; params[k][1] = tmp;
break; break;
} }
console.log("IP:", k, "=>", params[k]); console.log("IP:", k, "=>", params[k]);
} }
init_params = params; init_params = params;
@ -1398,10 +1398,10 @@ function showFeedsWithErrors() {
ids: sel_rows.toString() }; ids: sel_rows.toString() };
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
notify(''); notify('');
dialog.hide(); dialog.hide();
updateFeedList(); updateFeedList();
}); });
} }
} else { } else {
@ -1424,19 +1424,19 @@ function get_timestamp() {
} }
function helpDialog(topic) { function helpDialog(topic) {
const 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();
const dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
id: "helpDlg", id: "helpDlg",
title: __("Help"), title: __("Help"),
style: "width: 600px", style: "width: 600px",
href: query, href: query,
}); });
dialog.show(); dialog.show();
} }
function label_to_feed_id(label) { function label_to_feed_id(label) {
@ -1487,55 +1487,55 @@ function openArticlePopup(id) {
function keyevent_to_action(e) { function keyevent_to_action(e) {
const hotkeys_map = getInitParam("hotkeys"); const hotkeys_map = getInitParam("hotkeys");
const keycode = e.which; const keycode = e.which;
const keychar = String.fromCharCode(keycode).toLowerCase(); const keychar = String.fromCharCode(keycode).toLowerCase();
if (keycode == 27) { // escape and drop prefix if (keycode == 27) { // escape and drop prefix
hotkey_prefix = false; hotkey_prefix = false;
} }
if (keycode == 16 || keycode == 17) return; // ignore lone shift / ctrl if (keycode == 16 || keycode == 17) return; // ignore lone shift / ctrl
if (!hotkey_prefix && hotkeys_map[0].indexOf(keychar) != -1) { if (!hotkey_prefix && hotkeys_map[0].indexOf(keychar) != -1) {
const date = new Date(); const date = new Date();
const 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;
$("cmdline").innerHTML = keychar; $("cmdline").innerHTML = keychar;
Element.show("cmdline"); Element.show("cmdline");
e.stopPropagation(); e.stopPropagation();
return false; return false;
} }
Element.hide("cmdline"); Element.hide("cmdline");
let hotkey_name = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")"; let hotkey_name = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
// ensure ^*char notation // ensure ^*char notation
if (e.shiftKey) hotkey_name = "*" + hotkey_name; if (e.shiftKey) hotkey_name = "*" + hotkey_name;
if (e.ctrlKey) hotkey_name = "^" + hotkey_name; if (e.ctrlKey) hotkey_name = "^" + hotkey_name;
if (e.altKey) hotkey_name = "+" + hotkey_name; if (e.altKey) hotkey_name = "+" + hotkey_name;
if (e.metaKey) hotkey_name = "%" + hotkey_name; if (e.metaKey) hotkey_name = "%" + hotkey_name;
const hotkey_full = hotkey_prefix ? hotkey_prefix + " " + hotkey_name : hotkey_name; const hotkey_full = hotkey_prefix ? hotkey_prefix + " " + hotkey_name : hotkey_name;
hotkey_prefix = false; hotkey_prefix = false;
let action_name = false; let action_name = false;
for (const sequence in hotkeys_map[1]) { for (const sequence in hotkeys_map[1]) {
if (sequence == hotkey_full) { if (sequence == hotkey_full) {
action_name = hotkeys_map[1][sequence]; action_name = hotkeys_map[1][sequence];
break; break;
} }
} }
console.log('keyevent_to_action', hotkey_full, '=>', action_name); console.log('keyevent_to_action', hotkey_full, '=>', action_name);
return action_name; return action_name;
} }

@ -55,9 +55,9 @@ function addUser() {
notify_progress("Adding user..."); notify_progress("Adding user...");
xhrPost("backend.php", { op: "pref-users", method: "add", login: login }, (transport) => { xhrPost("backend.php", { op: "pref-users", method: "add", login: login }, (transport) => {
notify_callback2(transport); notify_callback2(transport);
updateUsersList(); updateUsersList();
}); });
} }
@ -78,9 +78,9 @@ function editUser(id) {
notify_progress("Saving data...", true); notify_progress("Saving data...", true);
xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => { xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => {
dialog.hide(); dialog.hide();
updateUsersList(); updateUsersList();
}); });
} }
}, },
href: query href: query
@ -552,7 +552,7 @@ function opmlImportComplete(iframe) {
title: __("OPML Import"), title: __("OPML Import"),
style: "width: 600px", style: "width: 600px",
onCancel: function () { onCancel: function () {
window.location.reload(); window.location.reload();
}, },
execute: function () { execute: function () {
window.location.reload(); window.location.reload();
@ -586,30 +586,30 @@ function updateFilterList() {
if (user_search) { search = user_search.value; } if (user_search) { search = user_search.value; }
xhrPost("backend.php", { op: "pref-filters", search: search }, (transport) => { xhrPost("backend.php", { op: "pref-filters", search: search }, (transport) => {
dijit.byId('filterConfigTab').attr('content', transport.responseText); dijit.byId('filterConfigTab').attr('content', transport.responseText);
notify(""); notify("");
}); });
} }
function updateLabelList() { function updateLabelList() {
xhrPost("backend.php", { op: "pref-labels" }, (transport) => { xhrPost("backend.php", { op: "pref-labels" }, (transport) => {
dijit.byId('labelConfigTab').attr('content', transport.responseText); dijit.byId('labelConfigTab').attr('content', transport.responseText);
notify(""); notify("");
}); });
} }
function updatePrefsList() { function updatePrefsList() {
xhrPost("backend.php", { op: "pref-prefs" }, (transport) => { xhrPost("backend.php", { op: "pref-prefs" }, (transport) => {
dijit.byId('genConfigTab').attr('content', transport.responseText); dijit.byId('genConfigTab').attr('content', transport.responseText);
notify(""); notify("");
}); });
} }
function updateSystemList() { function updateSystemList() {
xhrPost("backend.php", { op: "pref-system" }, (transport) => { xhrPost("backend.php", { op: "pref-system" }, (transport) => {
dijit.byId('systemConfigTab').attr('content', transport.responseText); dijit.byId('systemConfigTab').attr('content', transport.responseText);
notify(""); notify("");
}); });
} }
function selectTab(id, noupdate) { function selectTab(id, noupdate) {
@ -618,22 +618,22 @@ function selectTab(id, noupdate) {
switch (id) { switch (id) {
case "feedConfig": case "feedConfig":
updateFeedList(); updateFeedList();
break; break;
case "filterConfig": case "filterConfig":
updateFilterList(); updateFilterList();
break; break;
case "labelConfig": case "labelConfig":
updateLabelList(); updateLabelList();
break; break;
case "genConfig": case "genConfig":
updatePrefsList(); updatePrefsList();
break; break;
case "userConfig": case "userConfig":
updateUsersList(); updateUsersList();
break; break;
case "systemConfig": case "systemConfig":
updateSystemList(); updateSystemList();
break; break;
default: default:
console.warn("unknown tab", id); console.warn("unknown tab", id);
@ -684,7 +684,7 @@ function init() {
"dijit/form/CheckBox", "dijit/form/CheckBox",
"dijit/form/DropDownButton", "dijit/form/DropDownButton",
"dijit/form/FilteringSelect", "dijit/form/FilteringSelect",
"dijit/form/MultiSelect", "dijit/form/MultiSelect",
"dijit/form/Form", "dijit/form/Form",
"dijit/form/RadioButton", "dijit/form/RadioButton",
"dijit/form/ComboButton", "dijit/form/ComboButton",
@ -739,36 +739,36 @@ function validatePrefsReset() {
const query = "?op=pref-prefs&method=resetconfig"; const query = "?op=pref-prefs&method=resetconfig";
xhrPost("backend.php", { op: "pref-prefs", method: "resetconfig" }, (transport) => { xhrPost("backend.php", { op: "pref-prefs", method: "resetconfig" }, (transport) => {
updatePrefsList(); updatePrefsList();
notify_info(transport.responseText); notify_info(transport.responseText);
}); });
} }
return false; return false;
} }
function pref_hotkey_handler(e) { 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;
const action_name = keyevent_to_action(e); const action_name = keyevent_to_action(e);
if (action_name) { if (action_name) {
switch (action_name) { switch (action_name) {
case "feed_subscribe": case "feed_subscribe":
quickAddFeed(); quickAddFeed();
return false; return false;
case "create_label": case "create_label":
addLabel(); addLabel();
return false; return false;
case "create_filter": case "create_filter":
quickAddFilter(); quickAddFilter();
return false; return false;
case "help_dialog": case "help_dialog":
helpDialog("main"); helpDialog("main");
return false; return false;
default: default:
console.log("unhandled action: " + action_name + "; keycode: " + e.which); console.log("unhandled action: " + action_name + "; keycode: " + e.which);
} }
} }
} }
@ -777,13 +777,13 @@ function removeCategory(id, item) {
if (confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name))) { if (confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name))) {
notify_progress("Removing category..."); notify_progress("Removing category...");
const query = { op: "pref-feeds", method: "removeCat", const query = { op: "pref-feeds", method: "removeCat",
ids: id }; ids: id };
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
notify(''); notify('');
updateFeedList(); updateFeedList();
}); });
} }
} }
@ -798,8 +798,8 @@ function removeSelectedCategories() {
ids: sel_rows.toString() }; ids: sel_rows.toString() };
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
updateFeedList(); updateFeedList();
}); });
} }
} else { } else {
alert(__("No categories are selected.")); alert(__("No categories are selected."));
@ -815,9 +815,9 @@ function createCategory() {
notify_progress("Creating category..."); notify_progress("Creating category...");
xhrPost("backend.php", { op: "pref-feeds", method: "addCat", cat: title }, () => { xhrPost("backend.php", { op: "pref-feeds", method: "addCat", cat: title }, () => {
notify(''); notify('');
updateFeedList(); updateFeedList();
}); });
} }
} }
@ -845,10 +845,10 @@ function showInactiveFeeds() {
ids: sel_rows.toString() }; ids: sel_rows.toString() };
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
notify(''); notify('');
dialog.hide(); dialog.hide();
updateFeedList(); updateFeedList();
}); });
} }
} else { } else {
@ -870,23 +870,23 @@ function opmlRegenKey() {
notify_progress("Trying to change address...", true); notify_progress("Trying to change address...", true);
xhrJson("backend.php", { op: "pref-feeds", method: "regenOPMLKey" }, (reply) => { xhrJson("backend.php", { op: "pref-feeds", method: "regenOPMLKey" }, (reply) => {
if (reply) { if (reply) {
const new_link = reply.link; const new_link = reply.link;
const e = $('pub_opml_url'); const e = $('pub_opml_url');
if (new_link) { if (new_link) {
e.href = new_link; e.href = new_link;
e.innerHTML = new_link; e.innerHTML = new_link;
new Effect.Highlight(e); new Effect.Highlight(e);
notify(''); notify('');
} else { } else {
notify_error("Could not change feed URL."); notify_error("Could not change feed URL.");
} }
} }
}); });
} }
return false; return false;
} }
@ -901,8 +901,8 @@ function labelColorReset() {
ids: labels.toString() }; ids: labels.toString() };
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
updateLabelList(); updateLabelList();
}); });
} }
} else { } else {
@ -955,9 +955,9 @@ function editProfiles() {
if (confirm(__("Activate selected profile?"))) { if (confirm(__("Activate selected profile?"))) {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
xhrPost("backend.php", { op: "rpc", method: "setprofile", id: sel_rows.toString() }, () => { xhrPost("backend.php", { op: "rpc", method: "setprofile", id: sel_rows.toString() }, () => {
window.location.reload(); window.location.reload();
}); });
} }
} else { } else {
@ -1017,8 +1017,8 @@ function clearFeedAccessKeys() {
notify_progress("Clearing URLs..."); notify_progress("Clearing URLs...");
xhrPost("backend.php", { op: "pref-feeds", method: "clearKeys" }, () => { xhrPost("backend.php", { op: "pref-feeds", method: "clearKeys" }, () => {
notify_info("Generated URLs cleared."); notify_info("Generated URLs cleared.");
}); });
} }
return false; return false;
@ -1027,18 +1027,18 @@ function clearFeedAccessKeys() {
function resetFilterOrder() { function resetFilterOrder() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
xhrPost("backend.php", { op: "pref-filters", method: "filtersortreset" }, () => { xhrPost("backend.php", { op: "pref-filters", method: "filtersortreset" }, () => {
updateFilterList(); updateFilterList();
}); });
} }
function resetFeedOrder() { function resetFeedOrder() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
xhrPost("backend.php", { op: "pref-feeds", method: "feedsortreset" }, () => { xhrPost("backend.php", { op: "pref-feeds", method: "feedsortreset" }, () => {
updateFeedList(); updateFeedList();
}); });
} }
function resetCatOrder() { function resetCatOrder() {
@ -1095,11 +1095,11 @@ function editLabel(id) {
if (bg) e.style.backgroundColor = bg; if (bg) e.style.backgroundColor = bg;
} }
const query = { op: "pref-labels", method: "colorset", kind: kind, const query = { op: "pref-labels", method: "colorset", kind: kind,
ids: id, fg: fg, bg: bg, color: color }; ids: id, fg: fg, bg: bg, color: color };
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
updateFilterList(); // maybe there's labels in there updateFilterList(); // maybe there's labels in there
}); });
}, },
@ -1114,7 +1114,7 @@ function editLabel(id) {
this.hide(); this.hide();
xhrPost("backend.php", this.attr('value'), () => { xhrPost("backend.php", this.attr('value'), () => {
updateFilterList(); // maybe there's labels in there updateFilterList(); // maybe there's labels in there
}); });
} }
}, },
@ -1164,7 +1164,7 @@ function batchSubscribe() {
// overlapping widgets // overlapping widgets
if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive(); if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive(); if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
const dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
id: "batchSubDlg", id: "batchSubDlg",

@ -206,7 +206,7 @@ function init() {
"dijit/form/Form", "dijit/form/Form",
"dijit/form/RadioButton", "dijit/form/RadioButton",
"dijit/form/Select", "dijit/form/Select",
"dijit/form/MultiSelect", "dijit/form/MultiSelect",
"dijit/form/SimpleTextarea", "dijit/form/SimpleTextarea",
"dijit/form/TextBox", "dijit/form/TextBox",
"dijit/form/ComboBox", "dijit/form/ComboBox",
@ -237,25 +237,25 @@ function init() {
loading_set_progress(30); loading_set_progress(30);
init_hotkey_actions(); init_hotkey_actions();
const a = document.createElement('audio'); const a = document.createElement('audio');
const hasAudio = !!a.canPlayType; const hasAudio = !!a.canPlayType;
const hasSandbox = "sandbox" in document.createElement("iframe"); const hasSandbox = "sandbox" in document.createElement("iframe");
const hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, '')); const hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
const clientTzOffset = new Date().getTimezoneOffset() * 60; const clientTzOffset = new Date().getTimezoneOffset() * 60;
const params = { const params = {
op: "rpc", method: "sanityCheck", hasAudio: hasAudio, op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
hasMp3: hasMp3, hasMp3: hasMp3,
clientTzOffset: clientTzOffset, clientTzOffset: clientTzOffset,
hasSandbox: hasSandbox hasSandbox: hasSandbox
}; };
xhrPost("backend.php", params, (transport) => { xhrPost("backend.php", params, (transport) => {
try { try {
backend_sanity_check_callback(transport); backend_sanity_check_callback(transport);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
}); });
} catch (e) { } catch (e) {
@ -492,11 +492,11 @@ function init_hotkey_actions() {
const value = isCdmMode() ? "false" : "true"; const value = isCdmMode() ? "false" : "true";
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => { xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => {
setInitParam("combined_display_mode", setInitParam("combined_display_mode",
!getInitParam("combined_display_mode")); !getInitParam("combined_display_mode"));
closeArticlePanel(); closeArticlePanel();
viewCurrentFeed(); viewCurrentFeed();
}) })
}; };
} }
@ -651,8 +651,8 @@ function toggleDispRead() {
const hide = !(getInitParam("hide_read_feeds") == "1"); const hide = !(getInitParam("hide_read_feeds") == "1");
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => { xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => {
hideOrShowFeeds(hide); hideOrShowFeeds(hide);
setInitParam("hide_read_feeds", hide); setInitParam("hide_read_feeds", hide);
}); });
} }
@ -723,16 +723,16 @@ function viewModeChanged() {
function hotkey_handler(e) { function hotkey_handler(e) {
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return; if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
const action_name = keyevent_to_action(e); const action_name = keyevent_to_action(e);
if (action_name) { if (action_name) {
const action_func = hotkey_actions[action_name]; const action_func = hotkey_actions[action_name];
if (action_func != null) { if (action_func != null) {
action_func(); action_func();
e.stopPropagation(); e.stopPropagation();
return false; return false;
} }
} }
} }
@ -815,11 +815,11 @@ function handle_rpc_json(transport, scheduled_call) {
return reply; return reply;
} 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)

@ -325,7 +325,7 @@ function view(id, activefeed, noexpand) {
query.mode = "prefetch"; query.mode = "prefetch";
render_article(cached_article); render_article(cached_article);
} else if (cached_article) { } else if (cached_article) {
query.mode = "prefetch_old"; query.mode = "prefetch_old";
render_article(cached_article); render_article(cached_article);
// if we don't need to request any relative ids, we might as well skip // if we don't need to request any relative ids, we might as well skip
@ -344,7 +344,7 @@ function view(id, activefeed, noexpand) {
} }
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
article_callback2(transport, id); article_callback2(transport, id);
}) })
return false; return false;
@ -394,7 +394,7 @@ function toggleMark(id, client_only) {
} }
function togglePub(id, client_only, no_effects, note) { function togglePub(id, client_only, no_effects, note) {
const query = { op: "rpc", id: id, method: "publ" }; const query = { op: "rpc", id: id, method: "publ" };
if (note != undefined) { if (note != undefined) {
query.note = note; query.note = note;
@ -583,12 +583,12 @@ function toggleUnread(id, cmode) {
} }
if (tmpClassName != row.className) { if (tmpClassName != row.className) {
if (cmode == undefined) cmode = 2; if (cmode == undefined) cmode = 2;
const query = {op: "rpc", method: "catchupSelected", const query = {op: "rpc", method: "catchupSelected",
cmode: cmode, ids: id}; cmode: cmode, ids: id};
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
}); });
@ -608,8 +608,8 @@ function selectionRemoveLabel(id, ids) {
ids: ids.toString(), lid: id }; ids: ids.toString(), lid: id };
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
show_labels_in_headlines(transport); show_labels_in_headlines(transport);
}); });
} }
@ -624,10 +624,10 @@ function selectionAssignLabel(id, ids) {
const query = { op: "article", method: "assignToLabel", const query = { op: "article", method: "assignToLabel",
ids: ids.toString(), lid: id }; ids: ids.toString(), lid: id };
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
show_labels_in_headlines(transport); show_labels_in_headlines(transport);
}); });
} }
function selectionToggleUnread(set_state, callback, no_error, ids) { function selectionToggleUnread(set_state, callback, no_error, ids) {
@ -678,10 +678,10 @@ function selectionToggleUnread(set_state, callback, no_error, ids) {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
if (callback) callback(transport); if (callback) callback(transport);
}); });
} }
} }
@ -703,10 +703,10 @@ function selectionToggleMarked(sel_state, callback, no_error, ids) {
const query = { op: "rpc", method: "markSelected", const query = { op: "rpc", method: "markSelected",
ids: rows.toString(), cmode: 2 }; ids: rows.toString(), cmode: 2 };
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
if (callback) callback(transport); if (callback) callback(transport);
}); });
} }
} }
@ -724,13 +724,13 @@ function selectionTogglePublished(sel_state, callback, no_error, ids) {
} }
if (rows.length > 0) { if (rows.length > 0) {
const query = { op: "rpc", method: "publishSelected", const query = { op: "rpc", method: "publishSelected",
ids: rows.toString(), cmode: 2 }; ids: rows.toString(), cmode: 2 };
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
if (callback) callback(transport); if (callback) callback(transport);
}); });
} }
} }
@ -847,52 +847,52 @@ function deleteSelection() {
const query = { op: "rpc", method: "delete", ids: rows.toString() }; const query = { op: "rpc", method: "delete", ids: rows.toString() };
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
viewCurrentFeed(); viewCurrentFeed();
}); });
} }
function archiveSelection() { function archiveSelection() {
const rows = getSelectedArticleIds2(); const rows = getSelectedArticleIds2();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
return; return;
} }
const fn = getFeedName(getActiveFeedId(), activeFeedIsCat()); const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
let str; let str;
let op; let op;
if (getActiveFeedId() != 0) { if (getActiveFeedId() != 0) {
str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length); str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length);
op = "archive"; op = "archive";
} else { } else {
str = ngettext("Move %d archived article back?", "Move %d archived articles back?", rows.length); str = ngettext("Move %d archived article back?", "Move %d archived articles back?", rows.length);
str += " " + __("Please note that unstarred articles might get purged on next feed update."); str += " " + __("Please note that unstarred articles might get purged on next feed update.");
op = "unarchive"; op = "unarchive";
} }
str = str.replace("%d", rows.length); str = str.replace("%d", rows.length);
str = str.replace("%s", fn); str = str.replace("%s", fn);
if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
return; return;
} }
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
cache_delete("article:" + rows[i]); cache_delete("article:" + rows[i]);
} }
const query = {op: "rpc", method: op, ids: rows.toString()}; const query = {op: "rpc", method: op, ids: rows.toString()};
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
viewCurrentFeed(); viewCurrentFeed();
}); });
} }
function catchupSelection() { function catchupSelection() {
@ -935,24 +935,24 @@ function editArticleTags(id) {
notify_progress("Saving article tags...", true); notify_progress("Saving article tags...", true);
xhrPost("backend.php", this.attr('value'), (transport) => { xhrPost("backend.php", this.attr('value'), (transport) => {
try { try {
notify(''); notify('');
dialog.hide(); dialog.hide();
const data = JSON.parse(transport.responseText); const data = JSON.parse(transport.responseText);
if (data) { if (data) {
const id = data.id; const id = data.id;
const tags = $("ATSTR-" + id); const tags = $("ATSTR-" + id);
const tooltip = dijit.byId("ATSTRTIP-" + id); const tooltip = dijit.byId("ATSTRTIP-" + id);
if (tags) tags.innerHTML = data.content; if (tags) tags.innerHTML = data.content;
if (tooltip) tooltip.attr('label', data.content_full); if (tooltip) tooltip.attr('label', data.content_full);
} }
} catch (e) { } catch (e) {
exception_error(e); exception_error(e);
} }
}); });
} }
}, },
@ -1007,25 +1007,25 @@ function postMouseOut(id) {
function unpackVisibleHeadlines() { function unpackVisibleHeadlines() {
if (!isCdmMode()) return; if (!isCdmMode()) return;
const rows = $$("#headlines-frame div[id*=RROW][data-content]"); const rows = $$("#headlines-frame div[id*=RROW][data-content]");
const threshold = $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight + 300; const threshold = $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight + 300;
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
const row = rows[i]; const row = rows[i];
if (row.offsetTop <= threshold) { if (row.offsetTop <= threshold) {
console.log("unpacking: " + row.id); console.log("unpacking: " + row.id);
const content = row.getAttribute("data-content"); const content = row.getAttribute("data-content");
row.select(".cdmContentInner")[0].innerHTML = content; row.select(".cdmContentInner")[0].innerHTML = content;
row.removeAttribute("data-content"); row.removeAttribute("data-content");
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row); PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
} else { } else {
break; break;
} }
} }
} }
function headlines_scroll_handler(e) { function headlines_scroll_handler(e) {
@ -1067,7 +1067,7 @@ function headlines_scroll_handler(e) {
} }
if (!_infscroll_disable) { if (!_infscroll_disable) {
const hsp = $("headlines-spacer"); const hsp = $("headlines-spacer");
if (hsp && hsp.offsetTop - 250 <= e.scrollTop + e.offsetHeight) { if (hsp && hsp.offsetTop - 250 <= e.scrollTop + e.offsetHeight) {
@ -1089,20 +1089,20 @@ function headlines_scroll_handler(e) {
let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]"); let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]");
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
const row = rows[i]; const row = rows[i];
if ($("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight/2)) { if ($("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight/2)) {
const id = row.getAttribute("data-article-id") const id = row.getAttribute("data-article-id")
if (catchup_id_batch.indexOf(id) == -1) if (catchup_id_batch.indexOf(id) == -1)
catchup_id_batch.push(id); catchup_id_batch.push(id);
//console.log("auto_catchup_batch: " + catchup_id_batch.toString()); //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
} else { } else {
break; break;
} }
} }
if (_infscroll_disable) { if (_infscroll_disable) {
const row = $$("#headlines-frame div[id*=RROW]").last(); const row = $$("#headlines-frame div[id*=RROW]").last();
@ -1143,21 +1143,21 @@ function catchupBatchedArticles() {
_catchup_request_sent = true; _catchup_request_sent = true;
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
const reply = handle_rpc_json(transport); const reply = handle_rpc_json(transport);
_catchup_request_sent = false; _catchup_request_sent = false;
if (reply) { if (reply) {
const batch = reply.ids; const batch = reply.ids;
batch.each(function (id) { batch.each(function (id) {
const elem = $("RROW-" + id); const elem = $("RROW-" + id);
if (elem) elem.removeClassName("Unread"); if (elem) elem.removeClassName("Unread");
catchup_id_batch.remove(id); catchup_id_batch.remove(id);
}); });
} }
updateFloatingTitle(true); updateFloatingTitle(true);
}); });
} }
} }
@ -1217,7 +1217,7 @@ function catchupRelativeToArticle(below, id) {
cmode: 0, ids: ids_to_mark.toString() }; cmode: 0, ids: ids_to_mark.toString() };
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport); handle_rpc_json(transport);
}); });
} }
} }
@ -1668,20 +1668,20 @@ function setSelectionScore() {
xhrJson("backend.php", query, (reply) => { xhrJson("backend.php", query, (reply) => {
if (reply) { if (reply) {
reply.id.each((id) => { reply.id.each((id) => {
const row = $("RROW-" + id); const row = $("RROW-" + id);
if (row) { if (row) {
const pic = row.getElementsByClassName("hlScorePic")[0]; const pic = row.getElementsByClassName("hlScorePic")[0];
if (pic) { if (pic) {
pic.src = pic.src.replace(/score_.*?\.png/, pic.src = pic.src.replace(/score_.*?\.png/,
reply["score_pic"]); reply["score_pic"]);
pic.setAttribute("score", reply["score"]); pic.setAttribute("score", reply["score"]);
} }
} }
}); });
} }
}); });
} }
@ -1724,11 +1724,11 @@ function changeScore(id, pic) {
const query = { op: "article", method: "setScore", id: id, score: new_score }; const query = { op: "article", method: "setScore", id: id, score: new_score };
xhrJson("backend.php", query, (reply) => { xhrJson("backend.php", query, (reply) => {
if (reply) { if (reply) {
pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]); pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
pic.setAttribute("score", new_score); pic.setAttribute("score", new_score);
pic.setAttribute("title", new_score); pic.setAttribute("title", new_score);
} }
}); });
} }
} }
@ -1737,9 +1737,9 @@ function displayArticleUrl(id) {
const query = { op: "rpc", method: "getlinktitlebyid", id: id }; const query = { op: "rpc", method: "getlinktitlebyid", id: id };
xhrJson("backend.php", query, (reply) => { xhrJson("backend.php", query, (reply) => {
if (reply && reply.link) { if (reply && reply.link) {
prompt(__("Article URL:"), reply.link); prompt(__("Article URL:"), reply.link);
} }
}); });
} }

Loading…
Cancel
Save