add AppBase as a shared ancestor for main and prefs app objects
remove event.observe stuff from startup, unneeded
This commit is contained in:
parent
eeb49d375c
commit
ac8361e6f6
|
@ -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">
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -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);
|
||||||
|
|
30
js/Feeds.js
30
js/Feeds.js
|
@ -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 + "']");
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
||||||
|
|
16
js/Utils.js
16
js/Utils.js
|
@ -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();
|
||||||
|
|
38
js/common.js
38
js/common.js
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
33
js/prefs.js
33
js/prefs.js
|
@ -1,21 +1,18 @@
|
||||||
'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) {
|
|
||||||
report_error(message, filename, lineno, colno, error);
|
|
||||||
};
|
|
||||||
|
|
||||||
require(["dojo/_base/kernel",
|
|
||||||
"dojo/ready",
|
"dojo/ready",
|
||||||
"dojo/parser",
|
"dojo/parser",
|
||||||
|
"fox/AppBase",
|
||||||
"dojo/_base/loader",
|
"dojo/_base/loader",
|
||||||
"dojo/_base/html",
|
"dojo/_base/html",
|
||||||
"dijit/ColorPalette",
|
"dijit/ColorPalette",
|
||||||
|
@ -55,10 +52,16 @@ const App = {
|
||||||
"fox/PrefFilterStore",
|
"fox/PrefFilterStore",
|
||||||
"fox/PrefFeedTree",
|
"fox/PrefFeedTree",
|
||||||
"fox/PrefFilterTree",
|
"fox/PrefFilterTree",
|
||||||
"fox/PrefLabelTree"], function (dojo, ready, parser) {
|
"fox/PrefLabelTree"], function (dojo, declare, ready, parser, AppBase) {
|
||||||
|
|
||||||
ready(function () {
|
ready(function () {
|
||||||
try {
|
try {
|
||||||
|
const _App = declare("fox.App", AppBase, {
|
||||||
|
constructor: function() {
|
||||||
|
window.onerror = function (message, filename, lineno, colno, error) {
|
||||||
|
report_error(message, filename, lineno, colno, error);
|
||||||
|
};
|
||||||
|
|
||||||
Utils = fox.Utils();
|
Utils = fox.Utils();
|
||||||
CommonDialogs = fox.CommonDialogs();
|
CommonDialogs = fox.CommonDialogs();
|
||||||
Filters = fox.CommonFilters();
|
Filters = fox.CommonFilters();
|
||||||
|
@ -73,14 +76,12 @@ 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) => {
|
||||||
|
try {
|
||||||
Utils.backendSanityCallback(transport);
|
Utils.backendSanityCallback(transport);
|
||||||
});
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
exception_error(e);
|
exception_error(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
initSecondStage: function() {
|
initSecondStage: function() {
|
||||||
document.onkeydown = () => { App.hotkeyHandler(event) };
|
document.onkeydown = () => { App.hotkeyHandler(event) };
|
||||||
|
@ -147,7 +148,15 @@ const App = {
|
||||||
isPrefs: function() {
|
isPrefs: function() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
|
App = new _App();
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function opmlImportComplete(iframe) {
|
function opmlImportComplete(iframe) {
|
||||||
if (!iframe.contentDocument.body.innerHTML) return false;
|
if (!iframe.contentDocument.body.innerHTML) return false;
|
||||||
|
|
79
js/tt-rss.js
79
js/tt-rss.js
|
@ -1,6 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
/* global dijit,__ */
|
/* global dijit,__ */
|
||||||
|
|
||||||
|
let App;
|
||||||
let Utils;
|
let Utils;
|
||||||
let CommonDialogs;
|
let CommonDialogs;
|
||||||
let Filters;
|
let Filters;
|
||||||
|
@ -9,19 +10,11 @@ let Headlines;
|
||||||
let Article;
|
let Article;
|
||||||
let ArticleCache;
|
let ArticleCache;
|
||||||
|
|
||||||
const App = {
|
require(["dojo/_base/kernel",
|
||||||
global_unread: -1,
|
"dojo/_base/declare",
|
||||||
_widescreen_mode: false,
|
|
||||||
hotkey_actions: {},
|
|
||||||
init: function() {
|
|
||||||
|
|
||||||
window.onerror = function (message, filename, lineno, colno, error) {
|
|
||||||
report_error(message, filename, lineno, colno, error);
|
|
||||||
};
|
|
||||||
|
|
||||||
require(["dojo/_base/kernel",
|
|
||||||
"dojo/ready",
|
"dojo/ready",
|
||||||
"dojo/parser",
|
"dojo/parser",
|
||||||
|
"fox/AppBase",
|
||||||
"dojo/_base/loader",
|
"dojo/_base/loader",
|
||||||
"dojo/_base/html",
|
"dojo/_base/html",
|
||||||
"dojo/query",
|
"dojo/query",
|
||||||
|
@ -61,11 +54,19 @@ const App = {
|
||||||
"fox/Article",
|
"fox/Article",
|
||||||
"fox/ArticleCache",
|
"fox/ArticleCache",
|
||||||
"fox/FeedStoreModel",
|
"fox/FeedStoreModel",
|
||||||
"fox/FeedTree"], function (dojo, ready, parser) {
|
"fox/FeedTree"], function (dojo, declare, ready, parser, AppBase) {
|
||||||
|
|
||||||
ready(function () {
|
ready(function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const _App = declare("fox.App", AppBase, {
|
||||||
|
global_unread: -1,
|
||||||
|
_widescreen_mode: false,
|
||||||
|
hotkey_actions: {},
|
||||||
|
constructor: function () {
|
||||||
|
window.onerror = function (message, filename, lineno, colno, error) {
|
||||||
|
report_error(message, filename, lineno, colno, error);
|
||||||
|
};
|
||||||
|
|
||||||
Utils = fox.Utils();
|
Utils = fox.Utils();
|
||||||
CommonDialogs = fox.CommonDialogs();
|
CommonDialogs = fox.CommonDialogs();
|
||||||
Filters = fox.CommonFilters();
|
Filters = fox.CommonFilters();
|
||||||
|
@ -76,11 +77,11 @@ const App = {
|
||||||
|
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
|
||||||
if (!App.genericSanityCheck())
|
if (!this.genericSanityCheck())
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
Utils.setLoadingProgress(30);
|
Utils.setLoadingProgress(30);
|
||||||
App.initHotkeyActions();
|
this.initHotkeyActions();
|
||||||
|
|
||||||
const a = document.createElement('audio');
|
const a = document.createElement('audio');
|
||||||
const hasAudio = !!a.canPlayType;
|
const hasAudio = !!a.canPlayType;
|
||||||
|
@ -98,21 +99,14 @@ const App = {
|
||||||
xhrPost("backend.php", params, (transport) => {
|
xhrPost("backend.php", params, (transport) => {
|
||||||
try {
|
try {
|
||||||
Utils.backendSanityCallback(transport);
|
Utils.backendSanityCallback(transport);
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
exception_error(e);
|
exception_error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
initSecondStage: function () {
|
initSecondStage: function () {
|
||||||
|
this.enableCsrfSupport();
|
||||||
|
|
||||||
Feeds.reload();
|
Feeds.reload();
|
||||||
Article.close();
|
Article.close();
|
||||||
|
|
||||||
|
@ -126,15 +120,15 @@ const App = {
|
||||||
dojo.connect(dijit.byId('feeds-holder'), 'resize',
|
dojo.connect(dijit.byId('feeds-holder'), 'resize',
|
||||||
function (args) {
|
function (args) {
|
||||||
if (args && args.w >= 0) {
|
if (args && args.w >= 0) {
|
||||||
Cookie.set("ttrss_fh_width", args.w, getInitParam("cookie_lifetime"));
|
Cookie.set("ttrss_fh_width", args.w, App.getInitParam("cookie_lifetime"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.connect(dijit.byId('content-insert'), 'resize',
|
dojo.connect(dijit.byId('content-insert'), 'resize',
|
||||||
function (args) {
|
function (args) {
|
||||||
if (args && args.w >= 0 && args.h >= 0) {
|
if (args && args.w >= 0 && args.h >= 0) {
|
||||||
Cookie.set("ttrss_ci_width", args.w, getInitParam("cookie_lifetime"));
|
Cookie.set("ttrss_ci_width", args.w, App.getInitParam("cookie_lifetime"));
|
||||||
Cookie.set("ttrss_ci_height", args.h, getInitParam("cookie_lifetime"));
|
Cookie.set("ttrss_ci_height", args.h, App.getInitParam("cookie_lifetime"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -143,10 +137,10 @@ const App = {
|
||||||
const toolbar = document.forms["main_toolbar_form"];
|
const toolbar = document.forms["main_toolbar_form"];
|
||||||
|
|
||||||
dijit.getEnclosingWidget(toolbar.view_mode).attr('value',
|
dijit.getEnclosingWidget(toolbar.view_mode).attr('value',
|
||||||
getInitParam("default_view_mode"));
|
App.getInitParam("default_view_mode"));
|
||||||
|
|
||||||
dijit.getEnclosingWidget(toolbar.order_by).attr('value',
|
dijit.getEnclosingWidget(toolbar.order_by).attr('value',
|
||||||
getInitParam("default_view_order_by"));
|
App.getInitParam("default_view_order_by"));
|
||||||
|
|
||||||
const hash_feed_id = hash_get('f');
|
const hash_feed_id = hash_get('f');
|
||||||
const hash_feed_is_cat = hash_get('c') == "1";
|
const hash_feed_is_cat = hash_get('c') == "1";
|
||||||
|
@ -159,12 +153,12 @@ const App = {
|
||||||
|
|
||||||
ArticleCache.clear();
|
ArticleCache.clear();
|
||||||
|
|
||||||
this._widescreen_mode = getInitParam("widescreen");
|
this._widescreen_mode = App.getInitParam("widescreen");
|
||||||
this.switchPanelMode(this._widescreen_mode);
|
this.switchPanelMode(this._widescreen_mode);
|
||||||
|
|
||||||
Headlines.initScrollHandler();
|
Headlines.initScrollHandler();
|
||||||
|
|
||||||
if (getInitParam("simple_update")) {
|
if (App.getInitParam("simple_update")) {
|
||||||
console.log("scheduling simple feed updater...");
|
console.log("scheduling simple feed updater...");
|
||||||
window.setInterval(() => { Feeds.updateRandom() }, 30 * 1000);
|
window.setInterval(() => { Feeds.updateRandom() }, 30 * 1000);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +188,7 @@ const App = {
|
||||||
return Feeds.reloadCurrent('');
|
return Feeds.reloadCurrent('');
|
||||||
},
|
},
|
||||||
isCombinedMode: function() {
|
isCombinedMode: function() {
|
||||||
return getInitParam("combined_display_mode");
|
return App.getInitParam("combined_display_mode");
|
||||||
},
|
},
|
||||||
hotkeyHandler(event) {
|
hotkeyHandler(event) {
|
||||||
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
|
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
|
||||||
|
@ -370,7 +364,7 @@ const App = {
|
||||||
this.hotkey_actions["feed_debug_update"] = function () {
|
this.hotkey_actions["feed_debug_update"] = function () {
|
||||||
if (!Feeds.activeIsCat() && parseInt(Feeds.getActive()) > 0) {
|
if (!Feeds.activeIsCat() && parseInt(Feeds.getActive()) > 0) {
|
||||||
window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + Feeds.getActive() +
|
window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + Feeds.getActive() +
|
||||||
"&csrf_token=" + getInitParam("csrf_token"));
|
"&csrf_token=" + App.getInitParam("csrf_token"));
|
||||||
} else {
|
} else {
|
||||||
alert("You can't debug this kind of feed.");
|
alert("You can't debug this kind of feed.");
|
||||||
}
|
}
|
||||||
|
@ -483,8 +477,8 @@ const App = {
|
||||||
const value = App.isCombinedMode() ? "false" : "true";
|
const value = App.isCombinedMode() ? "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",
|
App.setInitParam("combined_display_mode",
|
||||||
!getInitParam("combined_display_mode"));
|
!App.getInitParam("combined_display_mode"));
|
||||||
|
|
||||||
Article.close();
|
Article.close();
|
||||||
Feeds.reloadCurrent();
|
Feeds.reloadCurrent();
|
||||||
|
@ -493,10 +487,10 @@ const App = {
|
||||||
this.hotkey_actions["toggle_cdm_expanded"] = function () {
|
this.hotkey_actions["toggle_cdm_expanded"] = function () {
|
||||||
Notify.progress("Loading, please wait...");
|
Notify.progress("Loading, please wait...");
|
||||||
|
|
||||||
const value = getInitParam("cdm_expanded") ? "false" : "true";
|
const value = App.getInitParam("cdm_expanded") ? "false" : "true";
|
||||||
|
|
||||||
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
|
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
|
||||||
setInitParam("cdm_expanded", !getInitParam("cdm_expanded"));
|
App.setInitParam("cdm_expanded", !App.getInitParam("cdm_expanded"));
|
||||||
Feeds.reloadCurrent();
|
Feeds.reloadCurrent();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -575,7 +569,14 @@ const App = {
|
||||||
isPrefs: function() {
|
isPrefs: function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
|
App = new _App();
|
||||||
|
} catch (e) {
|
||||||
|
exception_error(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function hash_get(key) {
|
function hash_get(key) {
|
||||||
const kv = window.location.hash.substring(1).toQueryParams();
|
const kv = window.location.hash.substring(1).toQueryParams();
|
||||||
|
|
|
@ -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">
|
||||||
|
|
Loading…
Reference in New Issue