WIP reshuffling of JS global context into separate logical objects

This commit is contained in:
Andrew Dolgov 2018-12-01 17:05:28 +03:00
parent 78780c9c08
commit 049a37aa0e
15 changed files with 1151 additions and 1269 deletions

View File

@ -877,7 +877,7 @@ class Article extends Handler_Protected {
$tags_str = ""; $tags_str = "";
for ($i = 0; $i < $maxtags; $i++) { for ($i = 0; $i < $maxtags; $i++) {
$tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"viewfeed({feed:'".$tags[$i]."'})\">" . $tags[$i] . "</a>, "; $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.viewfeed({feed:'".$tags[$i]."'})\">" . $tags[$i] . "</a>, ";
} }
$tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2);

View File

@ -139,7 +139,7 @@ class Dlg extends Handler_Protected {
$key_escaped = str_replace("'", "\\'", $key); $key_escaped = str_replace("'", "\\'", $key);
echo "<a href=\"javascript:viewfeed({feed:'$key_escaped'}) \" style=\"font-size: " . echo "<a href=\"#\" onclick=\"Feeds.viewfeed({feed:'$key_escaped'}) \" style=\"font-size: " .
$size . "px\" title=\"$value articles tagged with " . $size . "px\" title=\"$value articles tagged with " .
$key . '">' . $key . '</a> '; $key . '">' . $key . '</a> ';
} }

View File

@ -51,7 +51,7 @@ class Feeds extends Handler_Protected {
$reply .= "<span class='r'> $reply .= "<span class='r'>
<a href=\"#\" <a href=\"#\"
title=\"".__("View as RSS feed")."\" title=\"".__("View as RSS feed")."\"
onclick=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\"> onclick=\"Utils.displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">
<img class=\"noborder\" src=\"images/pub_set.png\"></a>"; <img class=\"noborder\" src=\"images/pub_set.png\"></a>";
@ -137,7 +137,7 @@ class Feeds extends Handler_Protected {
//$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>"; //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>";
$reply .= "<option value=\"displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>"; $reply .= "<option value=\"Utils.displayDlg('".__("View as RSS")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">".__('View as RSS')."</option>";
$reply .= "</select>"; $reply .= "</select>";
@ -392,7 +392,7 @@ class Feeds extends Handler_Protected {
$reply['content'] .= "<div data-feed-id='$feed_id' class='feed-titl'>". $reply['content'] .= "<div data-feed-id='$feed_id' class='feed-titl'>".
"<div style='float : right'>$feed_icon_img</div>". "<div style='float : right'>$feed_icon_img</div>".
"<a class='title' href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">". "<a class='title' href=\"#\" onclick=\"Feeds.viewfeed({feed:$feed_id})\">".
$line["feed_title"]."</a> $line["feed_title"]."</a>
$vf_catchup_link</div>"; $vf_catchup_link</div>";
@ -434,7 +434,7 @@ class Feeds extends Handler_Protected {
if (@$line["feed_title"]) { if (@$line["feed_title"]) {
$rgba = @$rgba_cache[$feed_id]; $rgba = @$rgba_cache[$feed_id];
$reply['content'] .= "<span class=\"feed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"viewfeed({feed:$feed_id})\">". $reply['content'] .= "<span class=\"feed\"><a style=\"background : rgba($rgba, 0.3)\" href=\"#\" onclick=\"Feeds.viewfeed({feed:$feed_id})\">".
truncate_string($line["feed_title"],30)."</a></span>"; truncate_string($line["feed_title"],30)."</a></span>";
} }
} }
@ -451,7 +451,7 @@ class Feeds extends Handler_Protected {
if ($line["feed_title"] && !$vfeed_group_enabled) { if ($line["feed_title"] && !$vfeed_group_enabled) {
$reply['content'] .= "<span onclick=\"viewfeed({feed:$feed_id})\" $reply['content'] .= "<span onclick=\"Feeds.viewfeed({feed:$feed_id})\"
style=\"cursor : pointer\" style=\"cursor : pointer\"
title=\"".htmlspecialchars($line['feed_title'])."\"> title=\"".htmlspecialchars($line['feed_title'])."\">
$feed_icon_img</span>"; $feed_icon_img</span>";
@ -488,7 +488,7 @@ class Feeds extends Handler_Protected {
$reply['content'] .= "<div data-feed-id='$feed_id' class='feed-title'>". $reply['content'] .= "<div data-feed-id='$feed_id' class='feed-title'>".
"<div style=\"float : right\">$feed_icon_img</div>". "<div style=\"float : right\">$feed_icon_img</div>".
"<a href=\"#\" class='title' onclick=\"viewfeed({feed:$feed_id})\">". "<a href=\"#\" class='title' onclick=\"Feeds.viewfeed({feed:$feed_id})\">".
$line["feed_title"]."</a> $vf_catchup_link</div>"; $line["feed_title"]."</a> $vf_catchup_link</div>";
} }
@ -547,7 +547,7 @@ class Feeds extends Handler_Protected {
$tmp_content .= "<div class=\"feed\"> $tmp_content .= "<div class=\"feed\">
<a href=\"#\" style=\"background-color: rgba($rgba,0.3)\" <a href=\"#\" style=\"background-color: rgba($rgba,0.3)\"
onclick=\"viewfeed({feed:$feed_id})\">". onclick=\"Feeds.viewfeed({feed:$feed_id})\">".
truncate_string($line["feed_title"],30)."</a> truncate_string($line["feed_title"],30)."</a>
</div>"; </div>";
} }
@ -561,7 +561,7 @@ class Feeds extends Handler_Protected {
if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) { if (!get_pref("VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
$tmp_content .= "<span style=\"cursor : pointer\" $tmp_content .= "<span style=\"cursor : pointer\"
title=\"".htmlspecialchars($line["feed_title"])."\" title=\"".htmlspecialchars($line["feed_title"])."\"
onclick=\"viewfeed({feed:$feed_id})\">$feed_icon_img</span>"; onclick=\"Feeds.viewfeed({feed:$feed_id})\">$feed_icon_img</span>";
} }
$tmp_content .= "</div>"; //score wrapper2 $tmp_content .= "</div>"; //score wrapper2

View File

@ -1174,7 +1174,7 @@ class Pref_Feeds extends Handler_Protected {
print "<div style='float : right; padding-right : 4px;'> print "<div style='float : right; padding-right : 4px;'>
<input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\" <input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\"
value=\"$feed_search\"> value=\"$feed_search\">
<button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">". <button dojoType=\"dijit.form.Button\" onclick=\"Feeds.reload()\">".
__('Search')."</button> __('Search')."</button>
</div>"; </div>";
@ -1306,7 +1306,7 @@ class Pref_Feeds extends Handler_Protected {
print_warning("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds."); print_warning("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.");
print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">". print "<button dojoType=\"dijit.form.Button\" onclick=\"return Utils.displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">".
__('Display published OPML URL')."</button> "; __('Display published OPML URL')."</button> ";
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
@ -1323,7 +1323,7 @@ class Pref_Feeds extends Handler_Protected {
print "<p>"; print "<p>";
print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('".__("View as RSS")."','generatedFeed', '$rss_url')\">". print "<button dojoType=\"dijit.form.Button\" onclick=\"return Utils.displayDlg('".__("View as RSS")."','generatedFeed', '$rss_url')\">".
__('Display URL')."</button> "; __('Display URL')."</button> ";
print "<button class=\"warning\" dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">". print "<button class=\"warning\" dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">".

View File

@ -97,7 +97,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Mark all feeds as read"), label: __("Mark all feeds as read"),
onClick: function() { onClick: function() {
catchupAllFeeds(); Feeds.catchupAllFeeds();
}})); }}));
menu.bindDomNode(tnode.domNode); menu.bindDomNode(tnode.domNode);

View File

@ -1,302 +1,430 @@
let infscroll_in_progress = 0;
let infscroll_disabled = 0;
let _infscroll_timeout = false;
let _search_query = false;
let _viewfeed_wait_timeout = false;
let counters_last_request = 0; let counters_last_request = 0;
let _counters_prev = [];
function resetCounterCache() { const Counters = {
_counters_prev = []; };
}
function loadMoreHeadlines() { const Feeds = {
const view_mode = document.forms["main_toolbar_form"].view_mode.value; _active_feed_id: 0,
const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length; _active_feed_is_cat: false,
const num_all = $$("#headlines-frame > div[id*=RROW]").length; infscroll_in_progress: 0,
const num_unread = getFeedUnread(getActiveFeedId(), activeFeedIsCat()); infscroll_disabled: 0,
_infscroll_timeout: false,
_search_query: false,
_viewfeed_wait_timeout: false,
_counters_prev: [],
// NOTE: this implementation is incomplete
// for general objects but good enough for counters
// http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html
counterEquals: function(a, b) {
// Create arrays of property names
const aProps = Object.getOwnPropertyNames(a);
const bProps = Object.getOwnPropertyNames(b);
// TODO implement marked & published // If number of properties is different,
// objects are not equivalent
let offset = num_all; if (aProps.length != bProps.length) {
return false;
switch (view_mode) {
case "marked":
case "published":
console.warn("loadMoreHeadlines: ", view_mode, "not implemented");
break;
case "unread":
offset = unread_in_buffer;
break;
case "adaptive":
if (!(getActiveFeedId() == -1 && !activeFeedIsCat()))
offset = num_unread > 0 ? unread_in_buffer : num_all;
break;
}
console.log("loadMoreHeadlines, offset=", offset);
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), offset: offset, infscroll_req: true});
}
function cleanup_memory(root) {
const dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode);
dijits.each(function (d) {
dojo.destroy(d.domNode);
});
$$("#" + root + " *").each(function (i) {
i.parentNode ? i.parentNode.removeChild(i) : true;
});
}
function viewfeed(params) {
const feed = params.feed;
const is_cat = !!params.is_cat || false;
const offset = params.offset || 0;
const viewfeed_debug = params.viewfeed_debug;
const method = params.method;
// this is used to quickly switch between feeds, sets active but xhr is on a timeout
const delayed = params.delayed || false;
if (feed != getActiveFeedId() || activeFeedIsCat() != is_cat) {
_search_query = false;
}
if (offset != 0) {
if (infscroll_in_progress)
return;
infscroll_in_progress = 1;
window.clearTimeout(_infscroll_timeout);
_infscroll_timeout = window.setTimeout(() => {
console.log('infscroll request timed out, aborting');
infscroll_in_progress = 0;
// call scroll handler to maybe repeat infscroll request
headlinesScrollHandler();
}, 10 * 1000);
}
Form.enable("main_toolbar_form");
let query = Object.assign({op: "feeds", method: "view", feed: feed},
dojo.formToObject("main_toolbar_form"));
if (method) query.m = method;
if (offset > 0) {
if (current_first_id) {
query.fid = current_first_id;
}
}
if (_search_query) {
query = Object.assign(query, _search_query);
}
if (offset != 0) {
query.skip = offset;
// to prevent duplicate feed titles when showing grouped vfeeds
if (vgroup_last_feed) {
query.vgrlf = vgroup_last_feed;
}
} else if (!is_cat && feed == getActiveFeedId() && !params.method) {
query.m = "ForceUpdate";
} }
Form.enable("main_toolbar_form"); for (let i = 0; i < aProps.length; i++) {
const propName = aProps[i];
if (!delayed) // If values of same property are not equal,
if (!setFeedExpandoIcon(feed, is_cat, // objects are not equivalent
(is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif')) if (a[propName] !== b[propName]) {
notify_progress("Loading, please wait...", true); return false;
}
}
query.cat = is_cat; // If we made it this far, objects
// are considered equivalent
return true;
},
resetCounters: function () {
this._counters_prev = [];
},
parseCounters: function (elems) {
for (let l = 0; l < elems.length; l++) {
setActiveFeedId(feed, is_cat); if (this._counters_prev[l] && this.counterEquals(elems[l], this._counters_prev[l])) {
continue;
}
if (viewfeed_debug) { const id = elems[l].id;
window.open("backend.php?" + const kind = elems[l].kind;
dojo.objectToQuery( const ctr = parseInt(elems[l].counter);
Object.assign({debug: 1, csrf_token: getInitParam("csrf_token")}, query) const error = elems[l].error;
)); const has_img = elems[l].has_img;
} const updated = elems[l].updated;
const auxctr = parseInt(elems[l].auxcounter);
if (id == "global-unread") {
App.global_unread = ctr;
App.updateTitle();
continue;
}
if (id == "subscribed-feeds") {
/* feeds_found = ctr; */
continue;
}
/*if (getFeedUnread(id, (kind == "cat")) != ctr ||
(kind == "cat")) {
}*/
setFeedUnread(id, (kind == "cat"), ctr);
setFeedValue(id, (kind == "cat"), 'auxcounter', auxctr);
if (kind != "cat") {
setFeedValue(id, false, 'error', error);
setFeedValue(id, false, 'updated', updated);
if (id > 0) {
if (has_img) {
setFeedIcon(id, false,
getInitParam("icons_url") + "/" + id + ".ico?" + has_img);
} else {
setFeedIcon(id, false, 'images/blank_icon.gif');
}
}
}
}
this.hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
this._counters_prev = elems;
},
viewCurrentFeed: function(method) {
console.log("viewCurrentFeed: " + method);
if (this.getActiveFeedId() != undefined) {
this.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat(), method: method});
}
return false; // block unneeded form submits
},
openNextUnreadFeed: function() {
const is_cat = Feeds.activeFeedIsCat();
const nuf = getNextUnreadFeed(Feeds.getActiveFeedId(), is_cat);
if (nuf) this.viewfeed({feed: nuf, is_cat: is_cat});
},
collapseFeedlist: function() {
Element.toggle("feeds-holder");
const splitter = $("feeds-holder_splitter");
Element.visible("feeds-holder") ? splitter.show() : splitter.hide();
dijit.byId("main").resize();
},
cancelSearch: function() {
this._search_query = "";
Feeds.viewCurrentFeed();
},
requestCounters: function(force) {
const date = new Date();
const timestamp = Math.round(date.getTime() / 1000);
if (force || timestamp - counters_last_request > 5) {
console.log("scheduling request of counters...");
counters_last_request = timestamp;
let query = {op: "rpc", method: "getAllCounters", seq: App.next_seq()};
if (!force)
query.last_article_id = getInitParam("last_article_id");
window.clearTimeout(_viewfeed_wait_timeout);
_viewfeed_wait_timeout = window.setTimeout(() => {
catchupBatchedArticles(() => {
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
App.handleRpcJson(transport);
});
} else {
console.log("request_counters: rate limit reached: " + (timestamp - counters_last_request));
}
},
reload: function() {
try {
Element.show("feedlistLoading");
this.resetCounters();
if (dijit.byId("feedTree")) {
dijit.byId("feedTree").destroyRecursive();
}
const store = new dojo.data.ItemFileWriteStore({
url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2"
});
const treeModel = new fox.FeedStoreModel({
store: store,
query: {
"type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
},
rootId: "root",
rootLabel: "Feeds",
childrenAttrs: ["items"]
});
const tree = new fox.FeedTree({
model: treeModel,
onClick: function (item, node) {
const id = String(item.id);
const is_cat = id.match("^CAT:");
const feed = id.substr(id.indexOf(":") + 1);
Feeds.viewfeed({feed: feed, is_cat: is_cat});
return false;
},
openOnClick: false,
showRoot: false,
persist: true,
id: "feedTree",
}, "feedTree");
const tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) {
console.log(dijit.getEnclosingWidget(event.target));
dojo.disconnect(tmph);
});
$("feeds-holder").appendChild(tree.domNode);
const tmph2 = dojo.connect(tree, 'onLoad', function () {
dojo.disconnect(tmph2);
Element.hide("feedlistLoading");
try { try {
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif'); Feeds.init();
headlines_callback2(transport, offset); setLoadingProgress(25);
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
} catch (e) { } catch (e) {
exception_error(e); exception_error(e);
} }
}); });
tree.startup();
} catch (e) {
exception_error(e);
}
},
init: function() {
console.log("in feedlist init");
setLoadingProgress(50);
document.onkeydown = App.hotkeyHandler;
setInterval(hotkeyPrefixTimeout, 3 * 1000);
setInterval(catchupBatchedArticles, 10 * 1000);
if (!this.getActiveFeedId()) {
this.viewfeed({feed: -3});
} else {
this.viewfeed({feed: this.getActiveFeedId(), is_cat: this.activeFeedIsCat()});
}
this.hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
if (getInitParam("is_default_pw")) {
console.warn("user password is at default value");
const dialog = new dijit.Dialog({
title: __("Your password is at default value"),
href: "backend.php?op=dlg&method=defaultpasswordwarning",
id: 'infoBox',
style: "width: 600px",
onCancel: function () {
return true;
},
onExecute: function () {
return true;
},
onClose: function () {
return true;
}
});
dialog.show();
}
// bw_limit disables timeout() so we request initial counters separately
if (getInitParam("bw_limit") == "1") {
this.requestCounters(true);
} else {
setTimeout(() => {
this.requestCounters(true);
setInterval(() => {
this.requestCounters();
}, 60 * 1000)
}, 250);
}
},
activeFeedIsCat: function() {
return !!this._active_feed_is_cat;
},
getActiveFeedId: function() {
return this._active_feed_id;
},
setActiveFeedId: function(id, is_cat) {
hash_set('f', id);
hash_set('c', is_cat ? 1 : 0);
this._active_feed_id = id;
this._active_feed_is_cat = is_cat;
$("headlines-frame").setAttribute("feed-id", id);
$("headlines-frame").setAttribute("is-cat", is_cat ? 1 : 0);
this.selectFeed(id, is_cat);
PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, _active_article_id);
},
selectFeed: function(feed, is_cat) {
const tree = dijit.byId("feedTree");
if (tree) return tree.selectFeed(feed, is_cat);
},
toggleDispRead: function() {
const hide = !(getInitParam("hide_read_feeds") == "1");
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => {
this.hideOrShowFeeds(hide);
setInitParam("hide_read_feeds", hide);
}); });
}, delayed ? 250 : 0); },
} hideOrShowFeeds: function(hide) {
const tree = dijit.byId("feedTree");
function feedlist_init() { if (tree)
console.log("in feedlist init"); return tree.hideRead(hide, getInitParam("hide_read_shows_special"));
},
viewfeed: function(params) {
const feed = params.feed;
const is_cat = !!params.is_cat || false;
const offset = params.offset || 0;
const viewfeed_debug = params.viewfeed_debug;
const method = params.method;
// this is used to quickly switch between feeds, sets active but xhr is on a timeout
const delayed = params.delayed || false;
setLoadingProgress(50); if (feed != Feeds.getActiveFeedId() || Feeds.activeFeedIsCat() != is_cat) {
this._search_query = false;
setActiveArticleId(0);
}
document.onkeydown = hotkey_handler; if (offset != 0) {
setInterval(hotkeyPrefixTimeout, 3*1000); if (this.infscroll_in_progress)
setInterval(catchupBatchedArticles, 10*1000); return;
if (!getActiveFeedId()) { this.infscroll_in_progress = 1;
viewfeed({feed: -3});
} else {
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat()});
}
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); window.clearTimeout(this._infscroll_timeout);
this._infscroll_timeout = window.setTimeout(() => {
console.log('infscroll request timed out, aborting');
this.infscroll_in_progress = 0;
if (getInitParam("is_default_pw")) { // call scroll handler to maybe repeat infscroll request
console.warn("user password is at default value"); Headlines.scrollHandler();
}, 10 * 1000);
}
const dialog = new dijit.Dialog({ Form.enable("main_toolbar_form");
title: __("Your password is at default value"),
href: "backend.php?op=dlg&method=defaultpasswordwarning", let query = Object.assign({op: "feeds", method: "view", feed: feed},
id: 'infoBox', dojo.formToObject("main_toolbar_form"));
style: "width: 600px",
onCancel: function() { if (method) query.m = method;
return true;
}, if (offset > 0) {
onExecute: function() { if (current_first_id) {
return true; query.fid = current_first_id;
},
onClose: function() {
return true;
} }
});
dialog.show();
}
// bw_limit disables timeout() so we request initial counters separately
if (getInitParam("bw_limit") == "1") {
request_counters(true);
} else {
setTimeout(timeout, 250);
}
}
function request_counters(force) {
const date = new Date();
const timestamp = Math.round(date.getTime() / 1000);
if (force || timestamp - counters_last_request > 5) {
console.log("scheduling request of counters...");
counters_last_request = timestamp;
let query = {op: "rpc", method: "getAllCounters", seq: next_seq()};
if (!force)
query.last_article_id = getInitParam("last_article_id");
xhrPost("backend.php", query, (transport) => {
handle_rpc_json(transport);
});
} else {
console.log("request_counters: rate limit reached: " + (timestamp - counters_last_request));
}
}
// NOTE: this implementation is incomplete
// for general objects but good enough for counters
// http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html
function counter_is_equal(a, b) {
// Create arrays of property names
const aProps = Object.getOwnPropertyNames(a);
const bProps = Object.getOwnPropertyNames(b);
// If number of properties is different,
// objects are not equivalent
if (aProps.length != bProps.length) {
return false;
}
for (let i = 0; i < aProps.length; i++) {
const propName = aProps[i];
// If values of same property are not equal,
// objects are not equivalent
if (a[propName] !== b[propName]) {
return false;
}
}
// If we made it this far, objects
// are considered equivalent
return true;
}
function parse_counters(elems) {
for (let l = 0; l < elems.length; l++) {
if (_counters_prev[l] && counter_is_equal(elems[l], _counters_prev[l])) {
continue;
} }
const id = elems[l].id; if (this._search_query) {
const kind = elems[l].kind; query = Object.assign(query, this._search_query);
const ctr = parseInt(elems[l].counter);
const error = elems[l].error;
const has_img = elems[l].has_img;
const updated = elems[l].updated;
const auxctr = parseInt(elems[l].auxcounter);
if (id == "global-unread") {
global_unread = ctr;
updateTitle();
continue;
} }
if (id == "subscribed-feeds") { if (offset != 0) {
/* feeds_found = ctr; */ query.skip = offset;
continue;
// to prevent duplicate feed titles when showing grouped vfeeds
if (vgroup_last_feed) {
query.vgrlf = vgroup_last_feed;
}
} else if (!is_cat && feed == Feeds.getActiveFeedId() && !params.method) {
query.m = "ForceUpdate";
} }
/*if (getFeedUnread(id, (kind == "cat")) != ctr || Form.enable("main_toolbar_form");
(kind == "cat")) {
}*/
setFeedUnread(id, (kind == "cat"), ctr); if (!delayed)
setFeedValue(id, (kind == "cat"), 'auxcounter', auxctr); if (!setFeedExpandoIcon(feed, is_cat,
(is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif'))
notify_progress("Loading, please wait...", true);
if (kind != "cat") { query.cat = is_cat;
setFeedValue(id, false, 'error', error);
setFeedValue(id, false, 'updated', updated);
if (id > 0) { Feeds.setActiveFeedId(feed, is_cat);
if (has_img) {
setFeedIcon(id, false, if (viewfeed_debug) {
getInitParam("icons_url") + "/" + id + ".ico?" + has_img); window.open("backend.php?" +
} else { dojo.objectToQuery(
setFeedIcon(id, false, 'images/blank_icon.gif'); Object.assign({debug: 1, csrf_token: getInitParam("csrf_token")}, query)
));
}
window.clearTimeout(this._viewfeed_wait_timeout);
this._viewfeed_wait_timeout = window.setTimeout(() => {
catchupBatchedArticles(() => {
xhrPost("backend.php", query, (transport) => {
try {
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
Headlines.onLoaded(transport, offset);
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
} catch (e) {
exception_error(e);
}
});
});
}, delayed ? 250 : 0);
},
catchupAllFeeds: function() {
const str = __("Mark all articles as read?");
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
notify_progress("Marking all feeds as read...");
xhrPost("backend.php", {op: "feeds", method: "catchupAll"}, () => {
this.requestCounters(true);
this.viewCurrentFeed();
});
App.global_unread = 0;
App.updateTitle();
}
},
decrementFeedCounter: function(feed, is_cat) {
let ctr = getFeedUnread(feed, is_cat);
if (ctr > 0) {
setFeedUnread(feed, is_cat, ctr - 1);
App.global_unread -= 1;
App.updateTitle();
if (!is_cat) {
const cat = parseInt(getFeedCategory(feed));
if (!isNaN(cat)) {
ctr = getFeedUnread(cat, true);
if (ctr > 0) {
setFeedUnread(cat, true, ctr - 1);
}
} }
} }
} }
} }
};
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
_counters_prev = elems;
}
function getFeedUnread(feed, is_cat) { function getFeedUnread(feed, is_cat) {
try { try {
@ -326,13 +454,6 @@ function getFeedCategory(feed) {
return false; return false;
} }
function hideOrShowFeeds(hide) {
const tree = dijit.byId("feedTree");
if (tree)
return tree.hideRead(hide, getInitParam("hide_read_shows_special"));
}
function getFeedName(feed, is_cat) { function getFeedName(feed, is_cat) {
if (isNaN(feed)) return feed; // it's a tag if (isNaN(feed)) return feed; // it's a tag
@ -375,12 +496,6 @@ function setFeedValue(feed, is_cat, key, value) {
} }
} }
function selectFeed(feed, is_cat) {
const tree = dijit.byId("feedTree");
if (tree) return tree.selectFeed(feed, is_cat);
}
function setFeedIcon(feed, is_cat, src) { function setFeedIcon(feed, is_cat, src) {
const tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
@ -404,7 +519,7 @@ function getNextUnreadFeed(feed, is_cat) {
} }
function catchupCurrentFeed(mode) { function catchupCurrentFeed(mode) {
catchupFeed(getActiveFeedId(), activeFeedIsCat(), mode); catchupFeed(Feeds.getActiveFeedId(), Feeds.activeFeedIsCat(), mode);
} }
function catchupFeedInGroup(id) { function catchupFeedInGroup(id) {
@ -440,13 +555,13 @@ function catchupFeedInGroup(id) {
} }
} }
updateFloatingTitle(true); Headlines.updateFloatingTitle(true);
} }
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
xhrPost("backend.php", { op: "rpc", method: "catchupFeed", feed_id: id, is_cat: false}, (transport) => { xhrPost("backend.php", { op: "rpc", method: "catchupFeed", feed_id: id, is_cat: false}, (transport) => {
handle_rpc_json(transport); App.handleRpcJson(transport);
}); });
} }
} }
@ -487,7 +602,7 @@ function catchupFeed(feed, is_cat, mode) {
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
xhrPost("backend.php", catchup_query, (transport) => { xhrPost("backend.php", catchup_query, (transport) => {
handle_rpc_json(transport); App.handleRpcJson(transport);
const show_next_feed = getInitParam("on_catchup_show_next_feed") == "1"; const show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
@ -495,37 +610,15 @@ function catchupFeed(feed, is_cat, mode) {
const nuf = getNextUnreadFeed(feed, is_cat); const nuf = getNextUnreadFeed(feed, is_cat);
if (nuf) { if (nuf) {
viewfeed({feed: nuf, is_cat: is_cat}); Feeds.viewfeed({feed: nuf, is_cat: is_cat});
} }
} else if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) { } else if (feed == Feeds.getActiveFeedId() && is_cat == Feeds.activeFeedIsCat()) {
viewCurrentFeed(); Feeds.viewCurrentFeed();
} }
notify(""); notify("");
}); });
} }
function decrementFeedCounter(feed, is_cat) {
let ctr = getFeedUnread(feed, is_cat);
if (ctr > 0) {
setFeedUnread(feed, is_cat, ctr - 1);
global_unread = global_unread - 1;
updateTitle();
if (!is_cat) {
const cat = parseInt(getFeedCategory(feed));
if (!isNaN(cat)) {
ctr = getFeedUnread(cat, true);
if (ctr > 0) {
setFeedUnread(cat, true, ctr - 1);
}
}
}
}
}

View File

@ -50,13 +50,85 @@ function xhrJson(url, params, complete) {
} }
/* add method to remove element from array */ /* add method to remove element from array */
Array.prototype.remove = function(s) { Array.prototype.remove = function(s) {
for (let i=0; i < this.length; i++) { for (let i=0; i < this.length; i++) {
if (s == this[i]) this.splice(i, 1); if (s == this[i]) this.splice(i, 1);
} }
}; };
const Utils = {
cleanupMemory: function(root) {
const dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode);
dijits.each(function (d) {
dojo.destroy(d.domNode);
});
$$("#" + root + " *").each(function (i) {
i.parentNode ? i.parentNode.removeChild(i) : true;
});
},
helpDialog: function(topic) {
const query = "backend.php?op=backend&method=help&topic=" + param_escape(topic);
if (dijit.byId("helpDlg"))
dijit.byId("helpDlg").destroyRecursive();
const dialog = new dijit.Dialog({
id: "helpDlg",
title: __("Help"),
style: "width: 600px",
href: query,
});
dialog.show();
},
displayDlg: function(title, id, param, callback) {
notify_progress("Loading, please wait...", true);
const query = {op: "dlg", method: id, param: param};
xhrPost("backend.php", query, (transport) => {
try {
const content = transport.responseText;
let dialog = dijit.byId("infoBox");
if (!dialog) {
dialog = new dijit.Dialog({
title: title,
id: 'infoBox',
style: "width: 600px",
onCancel: function () {
return true;
},
onExecute: function () {
return true;
},
onClose: function () {
return true;
},
content: content
});
} else {
dialog.attr('title', title);
dialog.attr('content', content);
}
dialog.show();
notify("");
if (callback) callback(transport);
} catch (e) {
exception_error(e);
}
});
return false;
},
};
function report_error(message, filename, lineno, colno, error) { function report_error(message, filename, lineno, colno, error) {
exception_error(error, null, filename, lineno); exception_error(error, null, filename, lineno);
} }
@ -324,51 +396,6 @@ function closeInfoBox() {
return false; return false;
} }
function displayDlg(title, id, param, callback) {
notify_progress("Loading, please wait...", true);
const query = { op: "dlg", method: id, param: param };
xhrPost("backend.php", query, (transport) => {
try {
const content = transport.responseText;
let dialog = dijit.byId("infoBox");
if (!dialog) {
dialog = new dijit.Dialog({
title: title,
id: 'infoBox',
style: "width: 600px",
onCancel: function () {
return true;
},
onExecute: function () {
return true;
},
onClose: function () {
return true;
},
content: content
});
} else {
dialog.attr('title', title);
dialog.attr('content', content);
}
dialog.show();
notify("");
if (callback) callback(transport);
} catch (e) {
exception_error(e);
}
});
return false;
}
function getInitParam(key) { function getInitParam(key) {
return init_params[key]; return init_params[key];
} }
@ -453,7 +480,7 @@ function filterDlgCheckAction(sender) {
function explainError(code) { function explainError(code) {
return displayDlg(__("Error explained"), "explainError", code); return Utils.displayDlg(__("Error explained"), "explainError", code);
} }
function setLoadingProgress(p) { function setLoadingProgress(p) {
@ -489,9 +516,9 @@ function uploadIconHandler(rc) {
case 0: case 0:
notify_info("Upload complete."); notify_info("Upload complete.");
if (inPreferences()) { if (inPreferences()) {
updateFeedList(); Feeds.reload();
} else { } else {
setTimeout('updateFeedList(false, false)', 50); setTimeout('Feeds.reload(false, false)', 50);
} }
break; break;
case 1: case 1:
@ -514,9 +541,9 @@ function removeFeedIcon(id) {
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
notify_info("Feed icon removed."); notify_info("Feed icon removed.");
if (inPreferences()) { if (inPreferences()) {
updateFeedList(); Feeds.reload();
} else { } else {
setTimeout('updateFeedList(false, false)', 50); setTimeout('Feeds.reload(false, false)', 50);
} }
}); });
} }
@ -556,7 +583,7 @@ function addLabel(select, callback) {
} else if (inPreferences()) { } else if (inPreferences()) {
updateLabelList(); updateLabelList();
} else { } else {
updateFeedList(); Feeds.reload();
} }
}); });
} }
@ -616,7 +643,7 @@ function quickAddFeed() {
dialog.hide(); dialog.hide();
notify_info(__("Subscribed to %s").replace("%s", feed_url)); notify_info(__("Subscribed to %s").replace("%s", feed_url));
updateFeedList(); Feeds.reload();
break; break;
case 2: case 2:
dialog.show_error(__("Specified URL seems to be invalid.")); dialog.show_error(__("Specified URL seems to be invalid."));
@ -889,7 +916,7 @@ function quickAddFilter() {
if (!inPreferences()) { if (!inPreferences()) {
query = { op: "pref-filters", method: "newfilter", query = { op: "pref-filters", method: "newfilter",
feed: getActiveFeedId(), is_cat: activeFeedIsCat() }; feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat() };
} else { } else {
query = { op: "pref-filters", method: "newfilter" }; query = { op: "pref-filters", method: "newfilter" };
} }
@ -973,8 +1000,8 @@ function quickAddFilter() {
if (selectedText != "") { if (selectedText != "") {
const feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : const feed_id = Feeds.activeFeedIsCat() ? 'CAT:' + parseInt(Feeds.getActiveFeedId()) :
getActiveFeedId(); Feeds.getActiveFeedId();
const rule = { reg_exp: selectedText, feed_id: [feed_id], filter_type: 1 }; const rule = { reg_exp: selectedText, feed_id: [feed_id], filter_type: 1 };
@ -991,12 +1018,12 @@ function quickAddFilter() {
if (reply && reply.title) title = reply.title; if (reply && reply.title) title = reply.title;
if (title || getActiveFeedId() || activeFeedIsCat()) { if (title || Feeds.getActiveFeedId() || Feeds.activeFeedIsCat()) {
console.log(title + " " + getActiveFeedId()); console.log(title + " " + Feeds.getActiveFeedId());
const feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : const feed_id = Feeds.activeFeedIsCat() ? 'CAT:' + parseInt(Feeds.getActiveFeedId()) :
getActiveFeedId(); Feeds.getActiveFeedId();
const rule = { reg_exp: title, feed_id: [feed_id], filter_type: 1 }; const rule = { reg_exp: title, feed_id: [feed_id], filter_type: 1 };
@ -1024,12 +1051,13 @@ function unsubscribeFeed(feed_id, title) {
if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide(); if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide();
if (inPreferences()) { if (inPreferences()) {
updateFeedList(); Feeds.reload();
} else { } else {
if (feed_id == getActiveFeedId()) if (feed_id == Feeds.getActiveFeedId())
setTimeout(function() { viewfeed({feed:-5}) }, 100); setTimeout(() => { Feeds.viewfeed({feed:-5}) },
100);
if (feed_id < 0) updateFeedList(); if (feed_id < 0) Feeds.reload();
} }
}); });
} }
@ -1219,7 +1247,7 @@ function editFeed(feed) {
xhrPost("backend.php", dialog.attr('value'), () => { xhrPost("backend.php", dialog.attr('value'), () => {
dialog.hide(); dialog.hide();
notify(''); notify('');
updateFeedList(); Feeds.reload();
}); });
} }
}, },
@ -1290,7 +1318,7 @@ function feedBrowser() {
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
notify(''); notify('');
updateFeedList(); Feeds.reload();
}); });
} else { } else {
@ -1375,7 +1403,7 @@ function showFeedsWithErrors() {
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
notify(''); notify('');
dialog.hide(); dialog.hide();
updateFeedList(); Feeds.reload();
}); });
} }
@ -1399,22 +1427,6 @@ function get_timestamp() {
return Math.round(date.getTime() / 1000); return Math.round(date.getTime() / 1000);
} }
function helpDialog(topic) {
const query = "backend.php?op=backend&method=help&topic=" + param_escape(topic);
if (dijit.byId("helpDlg"))
dijit.byId("helpDlg").destroyRecursive();
const dialog = new dijit.Dialog({
id: "helpDlg",
title: __("Help"),
style: "width: 600px",
href: query,
});
dialog.show();
}
// noinspection JSUnusedGlobalSymbols // noinspection JSUnusedGlobalSymbols
function label_to_feed_id(label) { function label_to_feed_id(label) {
return _label_base_index - 1 - Math.abs(label); return _label_base_index - 1 - Math.abs(label);

View File

@ -6,7 +6,7 @@ function notify_callback2(transport, sticky) {
notify_info(transport.responseText, sticky); notify_info(transport.responseText, sticky);
} }
function updateFeedList() { function Feeds.reload() {
const user_search = $("feed_search"); const user_search = $("feed_search");
let search = ""; let search = "";
@ -324,7 +324,7 @@ function removeSelectedFeeds() {
ids: sel_rows.toString() }; ids: sel_rows.toString() };
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
updateFeedList(); Feeds.reload();
}); });
} }
@ -524,7 +524,7 @@ function editSelectedFeeds() {
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
dialog.hide(); dialog.hide();
updateFeedList(); Feeds.reload();
}); });
} }
}, },
@ -618,7 +618,7 @@ function selectTab(id, noupdate) {
switch (id) { switch (id) {
case "feedConfig": case "feedConfig":
updateFeedList(); Feeds.reload();
break; break;
case "filterConfig": case "filterConfig":
updateFilterList(); updateFilterList();
@ -764,7 +764,7 @@ function pref_hotkey_handler(e) {
quickAddFilter(); quickAddFilter();
return false; return false;
case "help_dialog": case "help_dialog":
helpDialog("main"); Utils.helpDialog("main");
return false; return false;
default: default:
console.log("unhandled action: " + action_name + "; keycode: " + e.which); console.log("unhandled action: " + action_name + "; keycode: " + e.which);
@ -782,7 +782,7 @@ function removeCategory(id, item) {
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
notify(''); notify('');
updateFeedList(); Feeds.reload();
}); });
} }
} }
@ -798,7 +798,7 @@ function removeSelectedCategories() {
ids: sel_rows.toString() }; ids: sel_rows.toString() };
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
updateFeedList(); Feeds.reload();
}); });
} }
} else { } else {
@ -816,7 +816,7 @@ function createCategory() {
xhrPost("backend.php", { op: "pref-feeds", method: "addCat", cat: title }, () => { xhrPost("backend.php", { op: "pref-feeds", method: "addCat", cat: title }, () => {
notify(''); notify('');
updateFeedList(); Feeds.reload();
}); });
} }
} }
@ -847,7 +847,7 @@ function showInactiveFeeds() {
xhrPost("backend.php", query, () => { xhrPost("backend.php", query, () => {
notify(''); notify('');
dialog.hide(); dialog.hide();
updateFeedList(); Feeds.reload();
}); });
} }
@ -1037,7 +1037,7 @@ function resetFeedOrder() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
xhrPost("backend.php", { op: "pref-feeds", method: "feedsortreset" }, () => { xhrPost("backend.php", { op: "pref-feeds", method: "feedsortreset" }, () => {
updateFeedList(); Feeds.reload();
}); });
} }
@ -1045,7 +1045,7 @@ function resetCatOrder() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
xhrPost("backend.php", { op: "pref-feeds", method: "catsortreset" }, () => { xhrPost("backend.php", { op: "pref-feeds", method: "catsortreset" }, () => {
updateFeedList(); Feeds.reload();
}); });
} }
@ -1057,7 +1057,7 @@ function editCat(id, item) {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
xhrPost("backend.php", { op: 'pref-feeds', method: 'renamecat', id: id, title: new_name }, () => { xhrPost("backend.php", { op: 'pref-feeds', method: 'renamecat', id: id, title: new_name }, () => {
updateFeedList(); Feeds.reload();
}); });
} }
} }
@ -1176,7 +1176,7 @@ function batchSubscribe() {
xhrPost("backend.php", this.attr('value'), () => { xhrPost("backend.php", this.attr('value'), () => {
notify(""); notify("");
updateFeedList(); Feeds.reload();
dialog.hide(); dialog.hide();
}); });
} }

View File

@ -1,148 +1,215 @@
/* global dijit, __ */ /* global dijit, __ */
let global_unread = -1;
let _widescreen_mode = false; let _widescreen_mode = false;
let _rpc_seq = 0;
let _active_feed_id = 0;
let _active_feed_is_cat = false;
let hotkey_actions = {}; let hotkey_actions = {};
let _headlines_scroll_timeout = false;
function next_seq() { const App = {
_rpc_seq += 1; _rpc_seq: 0,
return _rpc_seq; global_unread: -1,
} next_seq: function() {
this._rpc_seq += 1;
return this._rpc_seq;
},
get_seq: function() {
return this._rpc_seq;
},
updateTitle: function() {
let tmp = "Tiny Tiny RSS";
function get_seq() { if (this.global_unread > 0) {
return _rpc_seq; tmp = "(" + this.global_unread + ") " + tmp;
}
function activeFeedIsCat() {
return !!_active_feed_is_cat;
}
function getActiveFeedId() {
return _active_feed_id;
}
function setActiveFeedId(id, is_cat) {
hash_set('f', id);
hash_set('c', is_cat ? 1 : 0);
_active_feed_id = id;
_active_feed_is_cat = is_cat;
$("headlines-frame").setAttribute("feed-id", id);
$("headlines-frame").setAttribute("is-cat", is_cat ? 1 : 0);
selectFeed(id, is_cat);
PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, _active_article_id);
}
function updateFeedList() {
try {
Element.show("feedlistLoading");
resetCounterCache();
if (dijit.byId("feedTree")) {
dijit.byId("feedTree").destroyRecursive();
} }
const store = new dojo.data.ItemFileWriteStore({ document.title = tmp;
url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2" },
}); isCombinedMode: function() {
return getInitParam("combined_display_mode");
},
hotkeyHandler(event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
const treeModel = new fox.FeedStoreModel({ const action_name = keyeventToAction(event);
store: store,
query: {
"type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
},
rootId: "root",
rootLabel: "Feeds",
childrenAttrs: ["items"]
});
const tree = new fox.FeedTree({ if (action_name) {
model: treeModel, const action_func = hotkey_actions[action_name];
onClick: function (item, node) {
const id = String(item.id); if (action_func != null) {
const is_cat = id.match("^CAT:"); action_func();
const feed = id.substr(id.indexOf(":") + 1); event.stopPropagation();
viewfeed({feed: feed, is_cat: is_cat});
return false; return false;
},
openOnClick: false,
showRoot: false,
persist: true,
id: "feedTree",
}, "feedTree");
var tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) {
console.log(dijit.getEnclosingWidget(event.target));
dojo.disconnect(tmph);
});
$("feeds-holder").appendChild(tree.domNode);
var tmph = dojo.connect(tree, 'onLoad', function () {
dojo.disconnect(tmph);
Element.hide("feedlistLoading");
try {
feedlist_init();
setLoadingProgress(25);
} catch (e) {
exception_error(e);
} }
}); }
},
switchPanelMode: function(wide) {
if (App.isCombinedMode()) return;
tree.startup(); const article_id = getActiveArticleId();
} catch (e) {
exception_error(e);
}
}
function catchupAllFeeds() { if (wide) {
dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
dijit.byId("content-insert").attr("region", "trailing");
const str = __("Mark all articles as read?"); dijit.byId("content-insert").domNode.setStyle({width: '50%',
height: 'auto',
borderTopWidth: '0px' });
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { if (parseInt(getCookie("ttrss_ci_width")) > 0) {
dijit.byId("content-insert").domNode.setStyle(
{width: getCookie("ttrss_ci_width") + "px" });
}
notify_progress("Marking all feeds as read..."); $("headlines-frame").setStyle({ borderBottomWidth: '0px' });
$("headlines-frame").addClassName("wide");
xhrPost("backend.php", {op: "feeds", method: "catchupAll"}, () => { } else {
request_counters(true);
viewCurrentFeed();
});
global_unread = 0; dijit.byId("content-insert").attr("region", "bottom");
updateTitle("");
}
}
function viewCurrentFeed(method) { dijit.byId("content-insert").domNode.setStyle({width: 'auto',
console.log("viewCurrentFeed: " + method); height: '50%',
borderTopWidth: '0px'});
if (getActiveFeedId() != undefined) { if (parseInt(getCookie("ttrss_ci_height")) > 0) {
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), method: method}); dijit.byId("content-insert").domNode.setStyle(
} {height: getCookie("ttrss_ci_height") + "px" });
return false; // block unneeded form submits }
}
function timeout() { $("headlines-frame").setStyle({ borderBottomWidth: '1px' });
if (getInitParam("bw_limit") != "1") { $("headlines-frame").removeClassName("wide");
request_counters(true);
setTimeout(timeout, 60*1000); }
}
} Article.closeArticlePanel();
if (article_id) view(article_id);
xhrPost("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0});
},
parseRuntimeInfo: function(data) {
//console.log("parsing runtime info...");
for (const k in data) {
const v = data[k];
if (k == "dep_ts" && parseInt(getInitParam("dep_ts")) > 0) {
if (parseInt(getInitParam("dep_ts")) < parseInt(v) && getInitParam("reload_on_ts_change")) {
window.location.reload();
}
}
if (k == "daemon_is_running" && v != 1) {
notify_error("<span onclick=\"explainError(1)\">Update daemon is not running.</span>", true);
return;
}
if (k == "update_result") {
const updatesIcon = dijit.byId("updatesIcon").domNode;
if (v) {
Element.show(updatesIcon);
} else {
Element.hide(updatesIcon);
}
}
if (k == "daemon_stamp_ok" && v != 1) {
notify_error("<span onclick=\"explainError(3)\">Update daemon is not updating feeds.</span>", true);
return;
}
if (k == "max_feed_id" || k == "num_feeds") {
if (init_params[k] != v) {
console.log("feed count changed, need to reload feedlist.");
Feeds.reload();
}
}
init_params[k] = v;
notify('');
}
PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data);
},
handleRpcJson: function(transport) {
const netalert_dijit = dijit.byId("net-alert");
let netalert = false;
if (netalert_dijit) netalert = netalert_dijit.domNode;
try {
const reply = JSON.parse(transport.responseText);
if (reply) {
const error = reply['error'];
if (error) {
const code = error['code'];
const msg = error['msg'];
console.warn("[handleRpcJson] received fatal error " + code + "/" + msg);
if (code != 0) {
fatalError(code, msg);
return false;
}
}
const seq = reply['seq'];
if (seq && this.get_seq() != seq) {
console.log("[handleRpcJson] sequence mismatch: " + seq +
" (want: " + this.get_seq() + ")");
return true;
}
const message = reply['message'];
if (message == "UPDATE_COUNTERS") {
console.log("need to refresh counters...");
setInitParam("last_article_id", -1);
Feeds.requestCounters(true);
}
const counters = reply['counters'];
if (counters)
Feeds.parseCounters(counters);
const runtime_info = reply['runtime-info'];
if (runtime_info)
this.parseRuntimeInfo(runtime_info);
if (netalert) netalert.hide();
return reply;
} else {
if (netalert)
netalert.show();
else
notify_error("Communication problem with server.");
}
} catch (e) {
if (netalert)
netalert.show();
else
notify_error("Communication problem with server.");
console.error(e);
}
return false;
},
};
function search() { function search() {
const query = "backend.php?op=feeds&method=search&param=" + const query = "backend.php?op=feeds&method=search&param=" +
param_escape(getActiveFeedId() + ":" + activeFeedIsCat()); param_escape(Feeds.getActiveFeedId() + ":" + Feeds.activeFeedIsCat());
if (dijit.byId("searchDlg")) if (dijit.byId("searchDlg"))
dijit.byId("searchDlg").destroyRecursive(); dijit.byId("searchDlg").destroyRecursive();
@ -153,9 +220,9 @@ function search() {
style: "width: 600px", style: "width: 600px",
execute: function() { execute: function() {
if (this.validate()) { if (this.validate()) {
_search_query = this.attr('value'); Feeds._search_query = this.attr('value');
this.hide(); this.hide();
viewCurrentFeed(); Feeds.viewCurrentFeed();
} }
}, },
href: query}); href: query});
@ -163,16 +230,6 @@ function search() {
dialog.show(); dialog.show();
} }
function updateTitle() {
let tmp = "Tiny Tiny RSS";
if (global_unread > 0) {
tmp = "(" + global_unread + ") " + tmp;
}
document.title = tmp;
}
function genericSanityCheck() { function genericSanityCheck() {
setCookie("ttrss_test", "TEST"); setCookie("ttrss_test", "TEST");
@ -272,15 +329,15 @@ function init() {
function init_hotkey_actions() { function init_hotkey_actions() {
hotkey_actions["next_feed"] = function() { hotkey_actions["next_feed"] = function() {
const rv = dijit.byId("feedTree").getNextFeed( const rv = dijit.byId("feedTree").getNextFeed(
getActiveFeedId(), activeFeedIsCat()); Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
if (rv) viewfeed({feed: rv[0], is_cat: rv[1], delayed: true}) if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true})
}; };
hotkey_actions["prev_feed"] = function() { hotkey_actions["prev_feed"] = function() {
const rv = dijit.byId("feedTree").getPreviousFeed( const rv = dijit.byId("feedTree").getPreviousFeed(
getActiveFeedId(), activeFeedIsCat()); Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
if (rv) viewfeed({feed: rv[0], is_cat: rv[1], delayed: true}) if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true})
}; };
hotkey_actions["next_article"] = function() { hotkey_actions["next_article"] = function() {
moveToPost('next'); moveToPost('next');
@ -320,7 +377,7 @@ function init_hotkey_actions() {
} }
hotkey_actions["open_in_new_window"] = function() { hotkey_actions["open_in_new_window"] = function() {
if (getActiveArticleId()) { if (getActiveArticleId()) {
openArticleInNewWindow(getActiveArticleId()); Article.openArticleInNewWindow(getActiveArticleId());
} }
}; };
hotkey_actions["catchup_below"] = function() { hotkey_actions["catchup_below"] = function() {
@ -336,10 +393,10 @@ function init_hotkey_actions() {
scrollArticle(-40); scrollArticle(-40);
}; };
hotkey_actions["close_article"] = function() { hotkey_actions["close_article"] = function() {
if (isCombinedMode()) { if (App.isCombinedMode()) {
cdmCollapseActive(); cdmCollapseActive();
} else { } else {
closeArticlePanel(); Article.closeArticlePanel();
} }
}; };
hotkey_actions["email_article"] = function() { hotkey_actions["email_article"] = function() {
@ -370,20 +427,20 @@ function init_hotkey_actions() {
selectArticles('none'); selectArticles('none');
}; };
hotkey_actions["feed_refresh"] = function() { hotkey_actions["feed_refresh"] = function() {
if (getActiveFeedId() != undefined) { if (Feeds.getActiveFeedId() != undefined) {
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat()}); Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat()});
return; return;
} }
}; };
hotkey_actions["feed_unhide_read"] = function() { hotkey_actions["feed_unhide_read"] = function() {
toggleDispRead(); Feeds.toggleDispRead();
}; };
hotkey_actions["feed_subscribe"] = function() { hotkey_actions["feed_subscribe"] = function() {
quickAddFeed(); quickAddFeed();
}; };
hotkey_actions["feed_debug_update"] = function() { hotkey_actions["feed_debug_update"] = function() {
if (!activeFeedIsCat() && parseInt(getActiveFeedId()) > 0) { if (!Feeds.activeFeedIsCat() && parseInt(Feeds.getActiveFeedId()) > 0) {
window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + getActiveFeedId() + window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + Feeds.getActiveFeedId() +
"&csrf_token=" + getInitParam("csrf_token")); "&csrf_token=" + getInitParam("csrf_token"));
} else { } else {
alert("You can't debug this kind of feed."); alert("You can't debug this kind of feed.");
@ -391,17 +448,17 @@ function init_hotkey_actions() {
}; };
hotkey_actions["feed_debug_viewfeed"] = function() { hotkey_actions["feed_debug_viewfeed"] = function() {
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), viewfeed_debug: true}); Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat(), viewfeed_debug: true});
}; };
hotkey_actions["feed_edit"] = function() { hotkey_actions["feed_edit"] = function() {
if (activeFeedIsCat()) if (Feeds.activeFeedIsCat())
alert(__("You can't edit this kind of feed.")); alert(__("You can't edit this kind of feed."));
else else
editFeed(getActiveFeedId()); editFeed(Feeds.getActiveFeedId());
}; };
hotkey_actions["feed_catchup"] = function() { hotkey_actions["feed_catchup"] = function() {
if (getActiveFeedId() != undefined) { if (Feeds.getActiveFeedId() != undefined) {
catchupCurrentFeed(); catchupCurrentFeed();
return; return;
} }
@ -411,32 +468,32 @@ function init_hotkey_actions() {
}; };
hotkey_actions["feed_toggle_vgroup"] = function() { hotkey_actions["feed_toggle_vgroup"] = function() {
xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => { xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => {
viewCurrentFeed(); Feeds.viewCurrentFeed();
}) })
}; };
hotkey_actions["catchup_all"] = function() { hotkey_actions["catchup_all"] = function() {
catchupAllFeeds(); Feeds.catchupAllFeeds();
}; };
hotkey_actions["cat_toggle_collapse"] = function() { hotkey_actions["cat_toggle_collapse"] = function() {
if (activeFeedIsCat()) { if (Feeds.activeFeedIsCat()) {
dijit.byId("feedTree").collapseCat(getActiveFeedId()); dijit.byId("feedTree").collapseCat(Feeds.getActiveFeedId());
return; return;
} }
}; };
hotkey_actions["goto_all"] = function() { hotkey_actions["goto_all"] = function() {
viewfeed({feed: -4}); Feeds.viewfeed({feed: -4});
}; };
hotkey_actions["goto_fresh"] = function() { hotkey_actions["goto_fresh"] = function() {
viewfeed({feed: -3}); Feeds.viewfeed({feed: -3});
}; };
hotkey_actions["goto_marked"] = function() { hotkey_actions["goto_marked"] = function() {
viewfeed({feed: -1}); Feeds.viewfeed({feed: -1});
}; };
hotkey_actions["goto_published"] = function() { hotkey_actions["goto_published"] = function() {
viewfeed({feed: -2}); Feeds.viewfeed({feed: -2});
}; };
hotkey_actions["goto_tagcloud"] = function() { hotkey_actions["goto_tagcloud"] = function() {
displayDlg(__("Tag cloud"), "printTagCloud"); Utils.displayDlg(__("Tag cloud"), "printTagCloud");
}; };
hotkey_actions["goto_prefs"] = function() { hotkey_actions["goto_prefs"] = function() {
gotoPreferences(); gotoPreferences();
@ -467,7 +524,7 @@ function init_hotkey_actions() {
quickAddFilter(); quickAddFilter();
}; };
hotkey_actions["collapse_sidebar"] = function() { hotkey_actions["collapse_sidebar"] = function() {
collapse_feedlist(); Feeds.viewCurrentFeed();
}; };
hotkey_actions["toggle_embed_original"] = function() { hotkey_actions["toggle_embed_original"] = function() {
if (typeof embedOriginalArticle != "undefined") { if (typeof embedOriginalArticle != "undefined") {
@ -478,32 +535,32 @@ function init_hotkey_actions() {
} }
}; };
hotkey_actions["toggle_widescreen"] = function() { hotkey_actions["toggle_widescreen"] = function() {
if (!isCombinedMode()) { if (!App.isCombinedMode()) {
_widescreen_mode = !_widescreen_mode; _widescreen_mode = !_widescreen_mode;
// reset stored sizes because geometry changed // reset stored sizes because geometry changed
setCookie("ttrss_ci_width", 0); setCookie("ttrss_ci_width", 0);
setCookie("ttrss_ci_height", 0); setCookie("ttrss_ci_height", 0);
switchPanelMode(_widescreen_mode); App.switchPanelMode(_widescreen_mode);
} else { } else {
alert(__("Widescreen is not available in combined mode.")); alert(__("Widescreen is not available in combined mode."));
} }
}; };
hotkey_actions["help_dialog"] = function() { hotkey_actions["help_dialog"] = function() {
helpDialog("main"); Utils.helpDialog("main");
}; };
hotkey_actions["toggle_combined_mode"] = function() { hotkey_actions["toggle_combined_mode"] = function() {
notify_progress("Loading, please wait..."); notify_progress("Loading, please wait...");
const value = 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", setInitParam("combined_display_mode",
!getInitParam("combined_display_mode")); !getInitParam("combined_display_mode"));
closeArticlePanel(); Article.closeArticlePanel();
viewCurrentFeed(); Feeds.viewCurrentFeed();
}) })
}; };
hotkey_actions["toggle_cdm_expanded"] = function() { hotkey_actions["toggle_cdm_expanded"] = function() {
@ -513,15 +570,15 @@ function init_hotkey_actions() {
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")); setInitParam("cdm_expanded", !getInitParam("cdm_expanded"));
viewCurrentFeed(); Feeds.viewCurrentFeed();
}); });
}; };
} }
function init_second_stage() { function init_second_stage() {
updateFeedList(); Feeds.reload();
closeArticlePanel(); Article.closeArticlePanel();
if (parseInt(getCookie("ttrss_fh_width")) > 0) { if (parseInt(getCookie("ttrss_fh_width")) > 0) {
dijit.byId("feeds-holder").domNode.setStyle( dijit.byId("feeds-holder").domNode.setStyle(
@ -559,7 +616,7 @@ function init_second_stage() {
const hash_feed_is_cat = hash_get('c') == "1"; const hash_feed_is_cat = hash_get('c') == "1";
if (hash_feed_id != undefined) { if (hash_feed_id != undefined) {
setActiveFeedId(hash_feed_id, hash_feed_is_cat); Feeds.setActiveFeedId(hash_feed_id, hash_feed_is_cat);
} }
setLoadingProgress(50); setLoadingProgress(50);
@ -569,15 +626,9 @@ function init_second_stage() {
sessionStorage.clear(); sessionStorage.clear();
_widescreen_mode = getInitParam("widescreen"); _widescreen_mode = getInitParam("widescreen");
switchPanelMode(_widescreen_mode); App.switchPanelMode(_widescreen_mode);
$("headlines-frame").onscroll = (event) => { Headlines.initScrollHandler();
clearTimeout(_headlines_scroll_timeout);
_headlines_scroll_timeout = window.setTimeout(function() {
//console.log('done scrolling', event);
headlinesScrollHandler(event);
}, 50);
}
console.log("second stage ok"); console.log("second stage ok");
@ -596,7 +647,7 @@ function quickMenuGo(opid) {
document.location.href = "backend.php?op=logout"; document.location.href = "backend.php?op=logout";
break; break;
case "qmcTagCloud": case "qmcTagCloud":
displayDlg(__("Tag cloud"), "printTagCloud"); Utils.displayDlg(__("Tag cloud"), "printTagCloud");
break; break;
case "qmcSearch": case "qmcSearch":
search(); search();
@ -608,15 +659,15 @@ function quickMenuGo(opid) {
window.location.href = "backend.php?op=digest"; window.location.href = "backend.php?op=digest";
break; break;
case "qmcEditFeed": case "qmcEditFeed":
if (activeFeedIsCat()) if (Feeds.activeFeedIsCat())
alert(__("You can't edit this kind of feed.")); alert(__("You can't edit this kind of feed."));
else else
editFeed(getActiveFeedId()); editFeed(Feeds.getActiveFeedId());
break; break;
case "qmcRemoveFeed": case "qmcRemoveFeed":
var actid = getActiveFeedId(); var actid = Feeds.getActiveFeedId();
if (activeFeedIsCat()) { if (Feeds.activeFeedIsCat()) {
alert(__("You can't unsubscribe from the category.")); alert(__("You can't unsubscribe from the category."));
return; return;
} }
@ -635,120 +686,35 @@ function quickMenuGo(opid) {
} }
break; break;
case "qmcCatchupAll": case "qmcCatchupAll":
catchupAllFeeds(); Feeds.catchupAllFeeds();
break; break;
case "qmcShowOnlyUnread": case "qmcShowOnlyUnread":
toggleDispRead(); Feeds.toggleDispRead();
break; break;
case "qmcToggleWidescreen": case "qmcToggleWidescreen":
if (!isCombinedMode()) { if (!App.isCombinedMode()) {
_widescreen_mode = !_widescreen_mode; _widescreen_mode = !_widescreen_mode;
// reset stored sizes because geometry changed // reset stored sizes because geometry changed
setCookie("ttrss_ci_width", 0); setCookie("ttrss_ci_width", 0);
setCookie("ttrss_ci_height", 0); setCookie("ttrss_ci_height", 0);
switchPanelMode(_widescreen_mode); App.switchPanelMode(_widescreen_mode);
} else { } else {
alert(__("Widescreen is not available in combined mode.")); alert(__("Widescreen is not available in combined mode."));
} }
break; break;
case "qmcHKhelp": case "qmcHKhelp":
helpDialog("main"); Utils.helpDialog("main");
break; break;
default: default:
console.log("quickMenuGo: unknown action: " + opid); console.log("quickMenuGo: unknown action: " + opid);
} }
} }
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);
});
}
function parse_runtime_info(data) {
//console.log("parsing runtime info...");
for (const k in data) {
const v = data[k];
// console.log("RI: " + k + " => " + v);
if (k == "dep_ts" && parseInt(getInitParam("dep_ts")) > 0) {
if (parseInt(getInitParam("dep_ts")) < parseInt(v) && getInitParam("reload_on_ts_change")) {
window.location.reload();
}
}
if (k == "daemon_is_running" && v != 1) {
notify_error("<span onclick=\"explainError(1)\">Update daemon is not running.</span>", true);
return;
}
if (k == "update_result") {
const updatesIcon = dijit.byId("updatesIcon").domNode;
if (v) {
Element.show(updatesIcon);
} else {
Element.hide(updatesIcon);
}
}
if (k == "daemon_stamp_ok" && v != 1) {
notify_error("<span onclick=\"explainError(3)\">Update daemon is not updating feeds.</span>", true);
return;
}
if (k == "max_feed_id" || k == "num_feeds") {
if (init_params[k] != v) {
console.log("feed count changed, need to reload feedlist.");
updateFeedList();
}
}
init_params[k] = v;
notify('');
}
PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data);
}
function collapse_feedlist() {
Element.toggle("feeds-holder");
const splitter = $("feeds-holder_splitter");
Element.visible("feeds-holder") ? splitter.show() : splitter.hide();
dijit.byId("main").resize();
}
function viewModeChanged() { function viewModeChanged() {
cache_clear(); cache_clear();
return viewCurrentFeed(''); return Feeds.viewCurrentFeed('');
}
function hotkey_handler(e) {
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
const action_name = keyeventToAction(e);
if (action_name) {
const action_func = hotkey_actions[action_name];
if (action_func != null) {
action_func();
e.stopPropagation();
return false;
}
}
} }
function inPreferences() { function inPreferences() {
@ -769,136 +735,15 @@ function reverseHeadlineOrder() {
order_by.attr('value', value); order_by.attr('value', value);
viewCurrentFeed(); Feeds.viewCurrentFeed();
} }
function handle_rpc_json(transport, scheduled_call) {
const netalert_dijit = dijit.byId("net-alert");
let netalert = false;
if (netalert_dijit) netalert = netalert_dijit.domNode;
try {
const reply = JSON.parse(transport.responseText);
if (reply) {
const error = reply['error'];
if (error) {
const code = error['code'];
const msg = error['msg'];
console.warn("[handle_rpc_json] received fatal error " + code + "/" + msg);
if (code != 0) {
fatalError(code, msg);
return false;
}
}
const seq = reply['seq'];
if (seq && get_seq() != seq) {
console.log("[handle_rpc_json] sequence mismatch: " + seq +
" (want: " + get_seq() + ")");
return true;
}
const message = reply['message'];
if (message == "UPDATE_COUNTERS") {
console.log("need to refresh counters...");
setInitParam("last_article_id", -1);
request_counters(true);
}
const counters = reply['counters'];
if (counters)
parse_counters(counters, scheduled_call);
const runtime_info = reply['runtime-info'];
if (runtime_info)
parse_runtime_info(runtime_info);
if (netalert) netalert.hide();
return reply;
} else {
if (netalert)
netalert.show();
else
notify_error("Communication problem with server.");
}
} catch (e) {
if (netalert)
netalert.show();
else
notify_error("Communication problem with server.");
console.error(e);
}
return false;
}
function switchPanelMode(wide) {
if (isCombinedMode()) return;
const article_id = getActiveArticleId();
if (wide) {
dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
dijit.byId("content-insert").attr("region", "trailing");
dijit.byId("content-insert").domNode.setStyle({width: '50%',
height: 'auto',
borderTopWidth: '0px' });
if (parseInt(getCookie("ttrss_ci_width")) > 0) {
dijit.byId("content-insert").domNode.setStyle(
{width: getCookie("ttrss_ci_width") + "px" });
}
$("headlines-frame").setStyle({ borderBottomWidth: '0px' });
$("headlines-frame").addClassName("wide");
} else {
dijit.byId("content-insert").attr("region", "bottom");
dijit.byId("content-insert").domNode.setStyle({width: 'auto',
height: '50%',
borderTopWidth: '0px'});
if (parseInt(getCookie("ttrss_ci_height")) > 0) {
dijit.byId("content-insert").domNode.setStyle(
{height: getCookie("ttrss_ci_height") + "px" });
}
$("headlines-frame").setStyle({ borderBottomWidth: '1px' });
$("headlines-frame").removeClassName("wide");
}
closeArticlePanel();
if (article_id) view(article_id);
xhrPost("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0});
}
function update_random_feed() { function update_random_feed() {
console.log("in update_random_feed"); console.log("in update_random_feed");
xhrPost("backend.php", { op: "rpc", method: "updateRandomFeed" }, (transport) => { xhrPost("backend.php", { op: "rpc", method: "updateRandomFeed" }, (transport) => {
handle_rpc_json(transport, true); App.handleRpcJson(transport, true);
window.setTimeout(update_random_feed, 30*1000); window.setTimeout(update_random_feed, 30*1000);
}); });
} }

File diff suppressed because it is too large Load Diff

View File

@ -93,7 +93,7 @@ class Af_Psql_Trgm extends Plugin {
print " <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"$article_link\">". print " <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"$article_link\">".
$line["title"]."</a>"; $line["title"]."</a>";
print " (<a href=\"#\" onclick=\"viewfeed({feed:".$line["feed_id"]."})\">". print " (<a href=\"#\" onclick=\"Feeds.viewfeed({feed:".$line["feed_id"]."})\">".
htmlspecialchars($line["feed_title"])."</a>)"; htmlspecialchars($line["feed_title"])."</a>)";
print " <span class='insensitive'>($sm)</span>"; print " <span class='insensitive'>($sm)</span>";

View File

@ -21,7 +21,7 @@ class Close_Button extends Plugin {
if (!get_pref("COMBINED_DISPLAY_MODE")) { if (!get_pref("COMBINED_DISPLAY_MODE")) {
$rv = "<img src=\"plugins/close_button/button.png\" $rv = "<img src=\"plugins/close_button/button.png\"
class='tagsPic' style=\"cursor : pointer\" class='tagsPic' style=\"cursor : pointer\"
onclick=\"closeArticlePanel()\" onclick=\"Article.closeArticlePanel()\"
title='".__('Close article')."'>"; title='".__('Close article')."'>";
} }

View File

@ -9,7 +9,7 @@ function embedOriginalArticle(id) {
let c = false; let c = false;
if (isCombinedMode()) { if (App.isCombinedMode()) {
c = $$("div#RROW-" + id + " div[class=content-inner]")[0]; c = $$("div#RROW-" + id + " div[class=content-inner]")[0];
} else if (id == getActiveArticleId()) { } else if (id == getActiveArticleId()) {
c = $$(".post .content")[0]; c = $$(".post .content")[0];
@ -22,7 +22,7 @@ function embedOriginalArticle(id) {
Element.show(c); Element.show(c);
c.parentNode.removeChild(iframe); c.parentNode.removeChild(iframe);
if (isCombinedMode()) { if (App.isCombinedMode()) {
cdmScrollToArticleId(id, true); cdmScrollToArticleId(id, true);
} }
@ -47,7 +47,7 @@ function embedOriginalArticle(id) {
Element.hide(c); Element.hide(c);
c.parentNode.insertBefore(iframe, c); c.parentNode.insertBefore(iframe, c);
if (isCombinedMode()) { if (App.isCombinedMode()) {
cdmScrollToArticleId(id, true); cdmScrollToArticleId(id, true);
} }
} }

View File

@ -1,6 +1,6 @@
require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
ready(function () { ready(function () {
updateTitle = function () { App.updateTitle = function () {
document.title = "Tiny Tiny RSS"; document.title = "Tiny Tiny RSS";
}; };
}); });

View File

@ -18,7 +18,7 @@ class Toggle_Sidebar extends Plugin {
function hook_main_toolbar_button() { function hook_main_toolbar_button() {
?> ?>
<button dojoType="dijit.form.Button" onclick="collapse_feedlist()"> <button dojoType="dijit.form.Button" onclick="Feeds.collapseFeedlist()">
<img src="plugins/toggle_sidebar/application_side_list.png" <img src="plugins/toggle_sidebar/application_side_list.png"
title="<?php echo __('Collapse feedlist') ?>"> title="<?php echo __('Collapse feedlist') ?>">
</button> </button>