add AppBase as a shared ancestor for main and prefs app objects

remove event.observe stuff from startup, unneeded
This commit is contained in:
Andrew Dolgov 2018-12-02 21:52:50 +03:00
parent eeb49d375c
commit ac8361e6f6
10 changed files with 728 additions and 728 deletions

View File

@ -135,12 +135,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="referrer" content="no-referrer"/> <meta name="referrer" content="no-referrer"/>
<script type="text/javascript">
Event.observe(window, 'load', function() {
App.init();
});
</script>
</head> </head>
<body class="claro ttrss_main"> <body class="claro ttrss_main">

35
js/AppBase.js Normal file
View File

@ -0,0 +1,35 @@
'use strict'
/* global __, ngettext */
define(["dojo/_base/declare"], function (declare) {
return declare("fox.AppBase", null, {
_initParams: [],
getInitParam: function(k) {
return this._initParams[k];
},
setInitParam: function(k, v) {
this._initParams[k] = v;
},
constructor: function(args) {
//
},
enableCsrfSupport: function() {
Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
function (callOriginal, options) {
if (App.getInitParam("csrf_token") != undefined) {
Object.extend(options, options || { });
if (Object.isString(options.parameters))
options.parameters = options.parameters.toQueryParams();
else if (Object.isHash(options.parameters))
options.parameters = options.parameters.toObject();
options.parameters["csrf_token"] = App.getInitParam("csrf_token");
}
return callOriginal(options);
}
);
}
});
});

View File

@ -123,7 +123,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
postCreate: function() { postCreate: function() {
this.connect(this.model, "onChange", "updateCounter"); this.connect(this.model, "onChange", "updateCounter");
this.connect(this, "_expandNode", function() { this.connect(this, "_expandNode", function() {
this.hideRead(getInitParam("hide_read_feeds"), getInitParam("hide_read_shows_special")); this.hideRead(App.getInitParam("hide_read_feeds"), App.getInitParam("hide_read_shows_special"));
}); });
this.inherited(arguments); this.inherited(arguments);

View File

@ -83,7 +83,7 @@ define(["dojo/_base/declare"], function (declare) {
if (id > 0) { if (id > 0) {
if (has_img) { if (has_img) {
this.setIcon(id, false, this.setIcon(id, false,
getInitParam("icons_url") + "/" + id + ".ico?" + has_img); App.getInitParam("icons_url") + "/" + id + ".ico?" + has_img);
} else { } else {
this.setIcon(id, false, 'images/blank_icon.gif'); this.setIcon(id, false, 'images/blank_icon.gif');
} }
@ -91,7 +91,7 @@ define(["dojo/_base/declare"], function (declare) {
} }
} }
this.hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); this.hideOrShowFeeds(App.getInitParam("hide_read_feeds") == 1);
this._counters_prev = elems; this._counters_prev = elems;
}, },
reloadCurrent: function(method) { reloadCurrent: function(method) {
@ -132,7 +132,7 @@ define(["dojo/_base/declare"], function (declare) {
let query = {op: "rpc", method: "getAllCounters", seq: Utils.next_seq()}; let query = {op: "rpc", method: "getAllCounters", seq: Utils.next_seq()};
if (!force) if (!force)
query.last_article_id = getInitParam("last_article_id"); query.last_article_id = App.getInitParam("last_article_id");
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
Utils.handleRpcJson(transport); Utils.handleRpcJson(transport);
@ -160,7 +160,7 @@ define(["dojo/_base/declare"], function (declare) {
const treeModel = new fox.FeedStoreModel({ const treeModel = new fox.FeedStoreModel({
store: store, store: store,
query: { query: {
"type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed" "type": App.getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
}, },
rootId: "root", rootId: "root",
rootLabel: "Feeds", rootLabel: "Feeds",
@ -221,9 +221,9 @@ define(["dojo/_base/declare"], function (declare) {
this.open({feed: this.getActive(), is_cat: this.activeIsCat()}); this.open({feed: this.getActive(), is_cat: this.activeIsCat()});
} }
this.hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); this.hideOrShowFeeds(App.getInitParam("hide_read_feeds") == 1);
if (getInitParam("is_default_pw")) { if (App.getInitParam("is_default_pw")) {
console.warn("user password is at default value"); console.warn("user password is at default value");
const dialog = new dijit.Dialog({ const dialog = new dijit.Dialog({
@ -246,7 +246,7 @@ define(["dojo/_base/declare"], function (declare) {
} }
// 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 (App.getInitParam("bw_limit") == "1") {
this.requestCounters(true); this.requestCounters(true);
} else { } else {
setTimeout(() => { setTimeout(() => {
@ -281,18 +281,18 @@ define(["dojo/_base/declare"], function (declare) {
if (tree) return tree.selectFeed(feed, is_cat); if (tree) return tree.selectFeed(feed, is_cat);
}, },
toggleUnread: function() { toggleUnread: function() {
const hide = !(getInitParam("hide_read_feeds") == "1"); const hide = !(App.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}, () => {
this.hideOrShowFeeds(hide); this.hideOrShowFeeds(hide);
setInitParam("hide_read_feeds", hide); App.setInitParam("hide_read_feeds", hide);
}); });
}, },
hideOrShowFeeds: function(hide) { hideOrShowFeeds: function(hide) {
const tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
if (tree) if (tree)
return tree.hideRead(hide, getInitParam("hide_read_shows_special")); return tree.hideRead(hide, App.getInitParam("hide_read_shows_special"));
}, },
open: function(params) { open: function(params) {
const feed = params.feed; const feed = params.feed;
@ -366,7 +366,7 @@ define(["dojo/_base/declare"], function (declare) {
if (viewfeed_debug) { if (viewfeed_debug) {
window.open("backend.php?" + window.open("backend.php?" +
dojo.objectToQuery( dojo.objectToQuery(
Object.assign({debug: 1, csrf_token: getInitParam("csrf_token")}, query) Object.assign({debug: 1, csrf_token: App.getInitParam("csrf_token")}, query)
)); ));
} }
@ -389,7 +389,7 @@ define(["dojo/_base/declare"], function (declare) {
catchupAll: function() { catchupAll: function() {
const str = __("Mark all articles as read?"); const str = __("Mark all articles as read?");
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
Notify.progress("Marking all feeds as read..."); Notify.progress("Marking all feeds as read...");
@ -448,7 +448,7 @@ define(["dojo/_base/declare"], function (declare) {
str = str.replace("%s", fn) str = str.replace("%s", fn)
.replace("%w", mark_what); .replace("%w", mark_what);
if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { if (App.getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
return; return;
} }
@ -463,7 +463,7 @@ define(["dojo/_base/declare"], function (declare) {
xhrPost("backend.php", catchup_query, (transport) => { xhrPost("backend.php", catchup_query, (transport) => {
Utils.handleRpcJson(transport); Utils.handleRpcJson(transport);
const show_next_feed = getInitParam("on_catchup_show_next_feed") == "1"; const show_next_feed = App.getInitParam("on_catchup_show_next_feed") == "1";
if (show_next_feed) { if (show_next_feed) {
const nuf = this.getNextUnread(feed, is_cat); const nuf = this.getNextUnread(feed, is_cat);
@ -486,7 +486,7 @@ define(["dojo/_base/declare"], function (declare) {
const str = __("Mark all articles in %s as read?").replace("%s", title); const str = __("Mark all articles in %s as read?").replace("%s", title);
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
const rows = $$("#headlines-frame > div[id*=RROW][data-orig-feed-id='" + id + "']"); const rows = $$("#headlines-frame > div[id*=RROW][data-orig-feed-id='" + id + "']");

View File

@ -12,13 +12,13 @@ define(["dojo/_base/declare"], function (declare) {
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
if (!in_body && (event.ctrlKey || id == Article.getActive() || getInitParam("cdm_expanded"))) { if (!in_body && (event.ctrlKey || id == Article.getActive() || App.getInitParam("cdm_expanded"))) {
Article.openInNewWindow(id); Article.openInNewWindow(id);
} }
Article.setActive(id); Article.setActive(id);
if (!getInitParam("cdm_expanded")) if (!App.getInitParam("cdm_expanded"))
Article.cdmScrollToId(id); Article.cdmScrollToId(id);
return in_body; return in_body;
@ -81,7 +81,7 @@ define(["dojo/_base/declare"], function (declare) {
// set topmost child in the buffer as active, but not if we're at the beginning (to prevent auto marking // set topmost child in the buffer as active, but not if we're at the beginning (to prevent auto marking
// first article as read all the time) // first article as read all the time)
if ($("headlines-frame").scrollTop != 0 && if ($("headlines-frame").scrollTop != 0 &&
getInitParam("cdm_expanded") && getInitParam("cdm_auto_catchup") == 1) { App.getInitParam("cdm_expanded") && App.getInitParam("cdm_auto_catchup") == 1) {
const rows = $$("#headlines-frame > div[id*=RROW]"); const rows = $$("#headlines-frame > div[id*=RROW]");
@ -113,7 +113,7 @@ define(["dojo/_base/declare"], function (declare) {
} }
} }
if (getInitParam("cdm_auto_catchup") == 1) { if (App.getInitParam("cdm_auto_catchup") == 1) {
let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]"); let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]");
@ -139,7 +139,7 @@ define(["dojo/_base/declare"], function (declare) {
console.log("we seem to be at an end"); console.log("we seem to be at an end");
if (getInitParam("on_catchup_show_next_feed") == "1") { if (App.getInitParam("on_catchup_show_next_feed") == "1") {
Feeds.openNextUnread(); Feeds.openNextUnread();
} }
} }
@ -150,7 +150,7 @@ define(["dojo/_base/declare"], function (declare) {
} }
}, },
updateFloatingTitle: function(unread_only) { updateFloatingTitle: function(unread_only) {
if (!App.isCombinedMode()/* || !getInitParam("cdm_expanded")*/) return; if (!App.isCombinedMode()/* || !App.getInitParam("cdm_expanded")*/) return;
const hf = $("headlines-frame"); const hf = $("headlines-frame");
const elems = $$("#headlines-frame > div[id*=RROW]"); const elems = $$("#headlines-frame > div[id*=RROW]");
@ -201,7 +201,7 @@ define(["dojo/_base/declare"], function (declare) {
} }
}, },
unpackVisible: function() { unpackVisible: function() {
if (!App.isCombinedMode() || !getInitParam("cdm_expanded")) return; if (!App.isCombinedMode() || !App.getInitParam("cdm_expanded")) 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 + 600; const threshold = $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight + 600;
@ -714,7 +714,7 @@ define(["dojo/_base/declare"], function (declare) {
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 (App.getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
return; return;
} }
@ -839,7 +839,7 @@ define(["dojo/_base/declare"], function (declare) {
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 (App.getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
return; return;
} }
@ -869,7 +869,7 @@ define(["dojo/_base/declare"], function (declare) {
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 (App.getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
return; return;
} }
@ -952,7 +952,7 @@ define(["dojo/_base/declare"], function (declare) {
} else { } else {
const 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)) { if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) {
for (var i = 0; i < ids_to_mark.length; i++) { for (var i = 0; i < ids_to_mark.length; i++) {
var e = $("RROW-" + ids_to_mark[i]); var e = $("RROW-" + ids_to_mark[i]);
@ -1090,7 +1090,7 @@ define(["dojo/_base/declare"], function (declare) {
})); }));
const labels = getInitParam("labels"); const labels = App.getInitParam("labels");
if (labels && labels.length) { if (labels && labels.length) {

View File

@ -28,7 +28,7 @@ define(["dojo/_base/declare"], function (declare) {
}, },
keyeventToAction: function(event) { keyeventToAction: function(event) {
const hotkeys_map = getInitParam("hotkeys"); const hotkeys_map = App.getInitParam("hotkeys");
const keycode = event.which; const keycode = event.which;
const keychar = String.fromCharCode(keycode).toLowerCase(); const keychar = String.fromCharCode(keycode).toLowerCase();
@ -191,7 +191,7 @@ define(["dojo/_base/declare"], function (declare) {
if (message == "UPDATE_COUNTERS") { if (message == "UPDATE_COUNTERS") {
console.log("need to refresh counters..."); console.log("need to refresh counters...");
setInitParam("last_article_id", -1); App.setInitParam("last_article_id", -1);
Feeds.requestCounters(true); Feeds.requestCounters(true);
} }
@ -228,9 +228,6 @@ define(["dojo/_base/declare"], function (declare) {
return false; return false;
}, },
parseRuntimeInfo: function(data) { parseRuntimeInfo: function(data) {
//console.log("parsing runtime info...");
for (const k in data) { for (const k in data) {
if (data.hasOwnProperty(k)) { if (data.hasOwnProperty(k)) {
const v = data[k]; const v = data[k];
@ -258,13 +255,13 @@ define(["dojo/_base/declare"], function (declare) {
} }
if (k == "max_feed_id" || k == "num_feeds") { if (k == "max_feed_id" || k == "num_feeds") {
if (init_params[k] != v) { if (App.getInitParam(k) != v) {
console.log("feed count changed, need to reload feedlist."); console.log("feed count changed, need to reload feedlist.");
Feeds.reload(); Feeds.reload();
} }
} }
init_params[k] = v; App.setInitParam(k, v);
} }
} }
@ -315,13 +312,12 @@ define(["dojo/_base/declare"], function (declare) {
} }
console.log("IP:", k, "=>", params[k]); console.log("IP:", k, "=>", params[k]);
App.setInitParam(k, params[k]);
} }
} }
init_params = params;
// PluginHost might not be available on non-index pages // PluginHost might not be available on non-index pages
window.PluginHost && PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, init_params); window.PluginHost && PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, App._initParams);
} }
App.initSecondStage(); App.initSecondStage();

View File

@ -1,28 +1,8 @@
'use strict' 'use strict'
/* global dijit, __ */ /* global dijit, __ */
let init_params = {};
let _label_base_index = -1024; let _label_base_index = -1024;
let loading_progress = 0; let loading_progress = 0;
let notify_hide_timerid = false;
Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
function (callOriginal, options) {
if (getInitParam("csrf_token") != undefined) {
Object.extend(options, options || { });
if (Object.isString(options.parameters))
options.parameters = options.parameters.toQueryParams();
else if (Object.isHash(options.parameters))
options.parameters = options.parameters.toObject();
options.parameters["csrf_token"] = getInitParam("csrf_token");
}
return callOriginal(options);
}
);
/* xhr shorthand helpers */ /* xhr shorthand helpers */
@ -239,15 +219,15 @@ const Notify = {
switch (kind) { switch (kind) {
case this.KIND_INFO: case this.KIND_INFO:
notify.addClassName("notify_info") notify.addClassName("notify_info")
icon = getInitParam("icon_information"); icon = App.getInitParam("icon_information");
break; break;
case this.KIND_ERROR: case this.KIND_ERROR:
notify.addClassName("notify_error"); notify.addClassName("notify_error");
icon = getInitParam("icon_alert"); icon = App.getInitParam("icon_alert");
break; break;
case this.KIND_PROGRESS: case this.KIND_PROGRESS:
notify.addClassName("notify_progress"); notify.addClassName("notify_progress");
icon = getInitParam("icon_indicator_white") icon = App.getInitParam("icon_indicator_white")
break; break;
} }
@ -255,7 +235,7 @@ const Notify = {
msgfmt += (" <span><img src=\"%s\" class='close' title=\"" + msgfmt += (" <span><img src=\"%s\" class='close' title=\"" +
__("Click to close") + "\" onclick=\"Notify.close()\"></span>") __("Click to close") + "\" onclick=\"Notify.close()\"></span>")
.replace("%s", getInitParam("icon_cross")); .replace("%s", App.getInitParam("icon_cross"));
notify.innerHTML = msgfmt; notify.innerHTML = msgfmt;
notify.addClassName("visible"); notify.addClassName("visible");
@ -289,14 +269,6 @@ function displayIfChecked(checkbox, elemId) {
} }
} }
function getInitParam(key) {
return init_params[key];
}
function setInitParam(key, value) {
init_params[key] = value;
}
function fatalError(code, msg, ext_info) { function fatalError(code, msg, ext_info) {
if (code == 6) { if (code == 6) {
window.location.href = "index.php"; window.location.href = "index.php";
@ -390,5 +362,5 @@ function popupOpenArticle(id) {
"height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no"); "height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no");
w.opener = null; w.opener = null;
w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + getInitParam("csrf_token"); w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + App.getInitParam("csrf_token");
} }

View File

@ -1,64 +1,67 @@
'use strict' 'use strict'
/* global dijit, __ */ /* global dijit, __ */
let App;
let Utils; let Utils;
let CommonDialogs; let CommonDialogs;
let Filters; let Filters;
let Users; let Users;
let Prefs; let Prefs;
const App = { require(["dojo/_base/kernel",
init: function() { "dojo/_base/declare",
window.onerror = function (message, filename, lineno, colno, error) { "dojo/ready",
report_error(message, filename, lineno, colno, error); "dojo/parser",
}; "fox/AppBase",
"dojo/_base/loader",
"dojo/_base/html",
"dijit/ColorPalette",
"dijit/Dialog",
"dijit/form/Button",
"dijit/form/CheckBox",
"dijit/form/DropDownButton",
"dijit/form/FilteringSelect",
"dijit/form/MultiSelect",
"dijit/form/Form",
"dijit/form/RadioButton",
"dijit/form/ComboButton",
"dijit/form/Select",
"dijit/form/SimpleTextarea",
"dijit/form/TextBox",
"dijit/form/ValidationTextBox",
"dijit/InlineEditBox",
"dijit/layout/AccordionContainer",
"dijit/layout/AccordionPane",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/Menu",
"dijit/ProgressBar",
"dijit/Toolbar",
"dijit/Tree",
"dijit/tree/dndSource",
"dojo/data/ItemFileWriteStore",
"lib/CheckBoxStoreModel",
"lib/CheckBoxTree",
"fox/Utils",
"fox/CommonDialogs",
"fox/CommonFilters",
"fox/PrefUsers",
"fox/PrefHelpers",
"fox/PrefFeedStore",
"fox/PrefFilterStore",
"fox/PrefFeedTree",
"fox/PrefFilterTree",
"fox/PrefLabelTree"], function (dojo, declare, ready, parser, AppBase) {
require(["dojo/_base/kernel", ready(function () {
"dojo/ready", try {
"dojo/parser", const _App = declare("fox.App", AppBase, {
"dojo/_base/loader", constructor: function() {
"dojo/_base/html", window.onerror = function (message, filename, lineno, colno, error) {
"dijit/ColorPalette", report_error(message, filename, lineno, colno, error);
"dijit/Dialog", };
"dijit/form/Button",
"dijit/form/CheckBox",
"dijit/form/DropDownButton",
"dijit/form/FilteringSelect",
"dijit/form/MultiSelect",
"dijit/form/Form",
"dijit/form/RadioButton",
"dijit/form/ComboButton",
"dijit/form/Select",
"dijit/form/SimpleTextarea",
"dijit/form/TextBox",
"dijit/form/ValidationTextBox",
"dijit/InlineEditBox",
"dijit/layout/AccordionContainer",
"dijit/layout/AccordionPane",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/Menu",
"dijit/ProgressBar",
"dijit/Toolbar",
"dijit/Tree",
"dijit/tree/dndSource",
"dojo/data/ItemFileWriteStore",
"lib/CheckBoxStoreModel",
"lib/CheckBoxTree",
"fox/Utils",
"fox/CommonDialogs",
"fox/CommonFilters",
"fox/PrefUsers",
"fox/PrefHelpers",
"fox/PrefFeedStore",
"fox/PrefFilterStore",
"fox/PrefFeedTree",
"fox/PrefFilterTree",
"fox/PrefLabelTree"], function (dojo, ready, parser) {
ready(function () {
try {
Utils = fox.Utils(); Utils = fox.Utils();
CommonDialogs = fox.CommonDialogs(); CommonDialogs = fox.CommonDialogs();
Filters = fox.CommonFilters(); Filters = fox.CommonFilters();
@ -73,81 +76,87 @@ const App = {
const params = {op: "rpc", method: "sanityCheck", clientTzOffset: clientTzOffset}; const params = {op: "rpc", method: "sanityCheck", clientTzOffset: clientTzOffset};
xhrPost("backend.php", params, (transport) => { xhrPost("backend.php", params, (transport) => {
Utils.backendSanityCallback(transport); try {
Utils.backendSanityCallback(transport);
} catch (e) {
exception_error(e);
}
});
},
initSecondStage: function() {
document.onkeydown = () => { App.hotkeyHandler(event) };
Utils.setLoadingProgress(50);
Notify.close();
let tab = Utils.urlParam('tab');
if (tab) {
tab = dijit.byId(tab + "Tab");
if (tab) {
dijit.byId("pref-tabs").selectChild(tab);
switch (Utils.urlParam('method')) {
case "editfeed":
window.setTimeout(function () {
CommonDialogs.editFeed(Utils.urlParam('methodparam'))
}, 100);
break;
default:
console.warn("initSecondStage, unknown method:", Utils.urlParam("method"));
}
}
} else {
let tab = localStorage.getItem("ttrss:prefs-tab");
if (tab) {
tab = dijit.byId(tab);
if (tab) {
dijit.byId("pref-tabs").selectChild(tab);
}
}
}
dojo.connect(dijit.byId("pref-tabs"), "selectChild", function (elem) {
localStorage.setItem("ttrss:prefs-tab", elem.id);
}); });
} catch (e) { },
exception_error(e); hotkeyHandler: function (event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
const action_name = Utils.keyeventToAction(event);
if (action_name) {
switch (action_name) {
case "feed_subscribe":
CommonDialogs.quickAddFeed();
return false;
case "create_label":
CommonDialogs.addLabel();
return false;
case "create_filter":
Filters.quickAddFilter();
return false;
case "help_dialog":
Utils.helpDialog("main");
return false;
default:
console.log("unhandled action: " + action_name + "; keycode: " + event.which);
}
}
},
isPrefs: function() {
return true;
} }
}); });
});
},
initSecondStage: function() {
document.onkeydown = () => { App.hotkeyHandler(event) };
Utils.setLoadingProgress(50);
Notify.close();
let tab = Utils.urlParam('tab'); App = new _App();
if (tab) { } catch (e) {
tab = dijit.byId(tab + "Tab"); exception_error(e);
if (tab) {
dijit.byId("pref-tabs").selectChild(tab);
switch (Utils.urlParam('method')) {
case "editfeed":
window.setTimeout(function () {
CommonDialogs.editFeed(Utils.urlParam('methodparam'))
}, 100);
break;
default:
console.warn("initSecondStage, unknown method:", Utils.urlParam("method"));
}
}
} else {
let tab = localStorage.getItem("ttrss:prefs-tab");
if (tab) {
tab = dijit.byId(tab);
if (tab) {
dijit.byId("pref-tabs").selectChild(tab);
}
}
} }
});
dojo.connect(dijit.byId("pref-tabs"), "selectChild", function (elem) { });
localStorage.setItem("ttrss:prefs-tab", elem.id);
});
},
hotkeyHandler: function (event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
const action_name = Utils.keyeventToAction(event);
if (action_name) {
switch (action_name) {
case "feed_subscribe":
CommonDialogs.quickAddFeed();
return false;
case "create_label":
CommonDialogs.addLabel();
return false;
case "create_filter":
Filters.quickAddFilter();
return false;
case "help_dialog":
Utils.helpDialog("main");
return false;
default:
console.log("unhandled action: " + action_name + "; keycode: " + event.which);
}
}
},
isPrefs: function() {
return true;
}
};
function opmlImportComplete(iframe) { function opmlImportComplete(iframe) {
if (!iframe.contentDocument.body.innerHTML) return false; if (!iframe.contentDocument.body.innerHTML) return false;

File diff suppressed because it is too large Load Diff

View File

@ -100,13 +100,6 @@
</script> </script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
Event.observe(window, 'load', function() {
App.init();
});
</script>
</head> </head>
<body class="claro ttrss_main ttrss_prefs"> <body class="claro ttrss_main ttrss_prefs">