replace 4 space indents with tabs

This commit is contained in:
Andrew Dolgov 2018-11-30 15:07:44 +03:00
parent 50052fb78a
commit 02ec3984bd
5 changed files with 430 additions and 430 deletions

View File

@ -103,7 +103,7 @@ function viewfeed(params) {
Form.enable("main_toolbar_form");
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;
@ -156,13 +156,13 @@ function viewfeed(params) {
_viewfeed_timeout = setTimeout(() => {
xhrPost("backend.php", query, (transport) => {
try {
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
headlines_callback2(transport, offset, background, infscroll_req);
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
} catch (e) {
exception_error(e);
}
try {
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
headlines_callback2(transport, offset, background, infscroll_req);
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
} catch (e) {
exception_error(e);
}
});
}, timeout_ms); // Wait 250ms
@ -209,11 +209,11 @@ function feedlist_init() {
}
// bw_limit disables timeout() so we request initial counters separately
if (getInitParam("bw_limit") == "1") {
if (getInitParam("bw_limit") == "1") {
request_counters(true);
} else {
setTimeout(timeout, 250);
}
} else {
setTimeout(timeout, 250);
}
}
@ -232,7 +232,7 @@ function request_counters(force) {
query.last_article_id = getInitParam("last_article_id");
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
handle_rpc_json(transport);
});
} else {
@ -471,7 +471,7 @@ function catchupFeedInGroup(id) {
notify_progress("Loading, please wait...", true);
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);
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) {
const nuf = getNextUnreadFeed(feed, is_cat);
if (show_next_feed) {
const nuf = getNextUnreadFeed(feed, is_cat);
if (nuf) {
viewfeed({feed: nuf, is_cat: is_cat});
}
} else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
viewCurrentFeed();
}
if (nuf) {
viewfeed({feed: nuf, is_cat: is_cat});
}
} else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
viewCurrentFeed();
}
notify("");
notify("");
});
}

View File

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

View File

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

View File

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

View File

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