mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 15:05:56 +00:00
WIP reshuffling of JS global context into separate logical objects
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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> ';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -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()\">".
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
633
js/feedlist.js
633
js/feedlist.js
@@ -1,224 +1,21 @@
|
|||||||
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,
|
||||||
// TODO implement marked & published
|
_search_query: false,
|
||||||
|
_viewfeed_wait_timeout: false,
|
||||||
let offset = num_all;
|
_counters_prev: [],
|
||||||
|
// NOTE: this implementation is incomplete
|
||||||
switch (view_mode) {
|
// for general objects but good enough for counters
|
||||||
case "marked":
|
// http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html
|
||||||
case "published":
|
counterEquals: function(a, b) {
|
||||||
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");
|
|
||||||
|
|
||||||
if (!delayed)
|
|
||||||
if (!setFeedExpandoIcon(feed, is_cat,
|
|
||||||
(is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif'))
|
|
||||||
notify_progress("Loading, please wait...", true);
|
|
||||||
|
|
||||||
query.cat = is_cat;
|
|
||||||
|
|
||||||
setActiveFeedId(feed, is_cat);
|
|
||||||
|
|
||||||
if (viewfeed_debug) {
|
|
||||||
window.open("backend.php?" +
|
|
||||||
dojo.objectToQuery(
|
|
||||||
Object.assign({debug: 1, csrf_token: getInitParam("csrf_token")}, query)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
window.clearTimeout(_viewfeed_wait_timeout);
|
|
||||||
_viewfeed_wait_timeout = window.setTimeout(() => {
|
|
||||||
catchupBatchedArticles(() => {
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
|
||||||
try {
|
|
||||||
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
|
|
||||||
headlines_callback2(transport, offset);
|
|
||||||
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
|
|
||||||
} catch (e) {
|
|
||||||
exception_error(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, delayed ? 250 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
function feedlist_init() {
|
|
||||||
console.log("in feedlist init");
|
|
||||||
|
|
||||||
setLoadingProgress(50);
|
|
||||||
|
|
||||||
document.onkeydown = hotkey_handler;
|
|
||||||
setInterval(hotkeyPrefixTimeout, 3*1000);
|
|
||||||
setInterval(catchupBatchedArticles, 10*1000);
|
|
||||||
|
|
||||||
if (!getActiveFeedId()) {
|
|
||||||
viewfeed({feed: -3});
|
|
||||||
} else {
|
|
||||||
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat()});
|
|
||||||
}
|
|
||||||
|
|
||||||
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") {
|
|
||||||
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
|
// Create arrays of property names
|
||||||
const aProps = Object.getOwnPropertyNames(a);
|
const aProps = Object.getOwnPropertyNames(a);
|
||||||
const bProps = Object.getOwnPropertyNames(b);
|
const bProps = Object.getOwnPropertyNames(b);
|
||||||
@@ -242,13 +39,14 @@ function counter_is_equal(a, b) {
|
|||||||
// If we made it this far, objects
|
// If we made it this far, objects
|
||||||
// are considered equivalent
|
// are considered equivalent
|
||||||
return true;
|
return true;
|
||||||
}
|
},
|
||||||
|
resetCounters: function () {
|
||||||
|
this._counters_prev = [];
|
||||||
function parse_counters(elems) {
|
},
|
||||||
|
parseCounters: function (elems) {
|
||||||
for (let l = 0; l < elems.length; l++) {
|
for (let l = 0; l < elems.length; l++) {
|
||||||
|
|
||||||
if (_counters_prev[l] && counter_is_equal(elems[l], _counters_prev[l])) {
|
if (this._counters_prev[l] && this.counterEquals(elems[l], this._counters_prev[l])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,8 +59,8 @@ function parse_counters(elems) {
|
|||||||
const auxctr = parseInt(elems[l].auxcounter);
|
const auxctr = parseInt(elems[l].auxcounter);
|
||||||
|
|
||||||
if (id == "global-unread") {
|
if (id == "global-unread") {
|
||||||
global_unread = ctr;
|
App.global_unread = ctr;
|
||||||
updateTitle();
|
App.updateTitle();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,10 +91,340 @@ function parse_counters(elems) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
|
this.hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
|
||||||
|
this._counters_prev = elems;
|
||||||
|
},
|
||||||
|
viewCurrentFeed: function(method) {
|
||||||
|
console.log("viewCurrentFeed: " + method);
|
||||||
|
|
||||||
_counters_prev = elems;
|
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");
|
||||||
|
|
||||||
|
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 {
|
||||||
|
Feeds.init();
|
||||||
|
setLoadingProgress(25);
|
||||||
|
} catch (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);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
hideOrShowFeeds: function(hide) {
|
||||||
|
const tree = dijit.byId("feedTree");
|
||||||
|
|
||||||
|
if (tree)
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (feed != Feeds.getActiveFeedId() || Feeds.activeFeedIsCat() != is_cat) {
|
||||||
|
this._search_query = false;
|
||||||
|
setActiveArticleId(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset != 0) {
|
||||||
|
if (this.infscroll_in_progress)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.infscroll_in_progress = 1;
|
||||||
|
|
||||||
|
window.clearTimeout(this._infscroll_timeout);
|
||||||
|
this._infscroll_timeout = window.setTimeout(() => {
|
||||||
|
console.log('infscroll request timed out, aborting');
|
||||||
|
this.infscroll_in_progress = 0;
|
||||||
|
|
||||||
|
// call scroll handler to maybe repeat infscroll request
|
||||||
|
Headlines.scrollHandler();
|
||||||
|
}, 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 (this._search_query) {
|
||||||
|
query = Object.assign(query, this._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 == Feeds.getActiveFeedId() && !params.method) {
|
||||||
|
query.m = "ForceUpdate";
|
||||||
|
}
|
||||||
|
|
||||||
|
Form.enable("main_toolbar_form");
|
||||||
|
|
||||||
|
if (!delayed)
|
||||||
|
if (!setFeedExpandoIcon(feed, is_cat,
|
||||||
|
(is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif'))
|
||||||
|
notify_progress("Loading, please wait...", true);
|
||||||
|
|
||||||
|
query.cat = is_cat;
|
||||||
|
|
||||||
|
Feeds.setActiveFeedId(feed, is_cat);
|
||||||
|
|
||||||
|
if (viewfeed_debug) {
|
||||||
|
window.open("backend.php?" +
|
||||||
|
dojo.objectToQuery(
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
178
js/functions.js
178
js/functions.js
@@ -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);
|
||||||
|
|||||||
26
js/prefs.js
26
js/prefs.js
@@ -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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
655
js/tt-rss.js
655
js/tt-rss.js
@@ -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"
|
|
||||||
});
|
|
||||||
|
|
||||||
const treeModel = new fox.FeedStoreModel({
|
|
||||||
store: store,
|
|
||||||
query: {
|
|
||||||
"type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
|
|
||||||
},
|
},
|
||||||
rootId: "root",
|
isCombinedMode: function() {
|
||||||
rootLabel: "Feeds",
|
return getInitParam("combined_display_mode");
|
||||||
childrenAttrs: ["items"]
|
},
|
||||||
});
|
hotkeyHandler(event) {
|
||||||
|
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
|
||||||
|
|
||||||
|
const action_name = keyeventToAction(event);
|
||||||
|
|
||||||
|
if (action_name) {
|
||||||
|
const action_func = hotkey_actions[action_name];
|
||||||
|
|
||||||
|
if (action_func != null) {
|
||||||
|
action_func();
|
||||||
|
event.stopPropagation();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
switchPanelMode: function(wide) {
|
||||||
|
if (App.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");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
tree.startup();
|
|
||||||
} catch (e) {
|
|
||||||
exception_error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function catchupAllFeeds() {
|
|
||||||
|
|
||||||
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"}, () => {
|
|
||||||
request_counters(true);
|
|
||||||
viewCurrentFeed();
|
|
||||||
});
|
|
||||||
|
|
||||||
global_unread = 0;
|
|
||||||
updateTitle("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function viewCurrentFeed(method) {
|
|
||||||
console.log("viewCurrentFeed: " + method);
|
|
||||||
|
|
||||||
if (getActiveFeedId() != undefined) {
|
|
||||||
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), method: method});
|
|
||||||
}
|
|
||||||
return false; // block unneeded form submits
|
|
||||||
}
|
|
||||||
|
|
||||||
function timeout() {
|
|
||||||
if (getInitParam("bw_limit") != "1") {
|
|
||||||
request_counters(true);
|
|
||||||
setTimeout(timeout, 60*1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
const query = "backend.php?op=feeds&method=search¶m=" +
|
const query = "backend.php?op=feeds&method=search¶m=" +
|
||||||
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
654
js/viewfeed.js
654
js/viewfeed.js
@@ -15,10 +15,242 @@ let last_search_query;
|
|||||||
|
|
||||||
let has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
|
let has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
|
||||||
|
|
||||||
function headlines_callback2(transport, offset) {
|
const Article = {
|
||||||
const reply = handle_rpc_json(transport);
|
closeArticlePanel: function () {
|
||||||
|
if (dijit.byId("content-insert"))
|
||||||
|
dijit.byId("headlines-wrap-inner").removeChild(
|
||||||
|
dijit.byId("content-insert"));
|
||||||
|
},
|
||||||
|
displayArticleUrl: function (id) {
|
||||||
|
const query = {op: "rpc", method: "getlinktitlebyid", id: id};
|
||||||
|
|
||||||
console.log("headlines_callback2, offset=", offset);
|
xhrJson("backend.php", query, (reply) => {
|
||||||
|
if (reply && reply.link) {
|
||||||
|
prompt(__("Article URL:"), reply.link);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
openArticleInNewWindow: function (id) {
|
||||||
|
const w = window.open("");
|
||||||
|
w.opener = null;
|
||||||
|
w.location = "backend.php?op=article&method=redirect&id=" + id;
|
||||||
|
},
|
||||||
|
renderArticle: function (article) {
|
||||||
|
Utils.cleanupMemory("content-insert");
|
||||||
|
|
||||||
|
dijit.byId("headlines-wrap-inner").addChild(
|
||||||
|
dijit.byId("content-insert"));
|
||||||
|
|
||||||
|
const c = dijit.byId("content-insert");
|
||||||
|
|
||||||
|
try {
|
||||||
|
c.domNode.scrollTop = 0;
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
c.attr('content', article);
|
||||||
|
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, c.domNode);
|
||||||
|
|
||||||
|
correctHeadlinesOffset(getActiveArticleId());
|
||||||
|
|
||||||
|
try {
|
||||||
|
c.focus();
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const Headlines = {
|
||||||
|
_headlines_scroll_timeout: 0,
|
||||||
|
initScrollHandler: function() {
|
||||||
|
$("headlines-frame").onscroll = (event) => {
|
||||||
|
clearTimeout(this._headlines_scroll_timeout);
|
||||||
|
this._headlines_scroll_timeout = window.setTimeout(function() {
|
||||||
|
//console.log('done scrolling', event);
|
||||||
|
Headlines.scrollHandler();
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
loadMoreHeadlines: function() {
|
||||||
|
const view_mode = document.forms["main_toolbar_form"].view_mode.value;
|
||||||
|
const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
|
||||||
|
const num_all = $$("#headlines-frame > div[id*=RROW]").length;
|
||||||
|
const num_unread = getFeedUnread(Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
|
||||||
|
|
||||||
|
// TODO implement marked & published
|
||||||
|
|
||||||
|
let offset = num_all;
|
||||||
|
|
||||||
|
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 (!(Feeds.getActiveFeedId() == -1 && !Feeds.activeFeedIsCat()))
|
||||||
|
offset = num_unread > 0 ? unread_in_buffer : num_all;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("loadMoreHeadlines, offset=", offset);
|
||||||
|
|
||||||
|
Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat(), offset: offset});
|
||||||
|
},
|
||||||
|
scrollHandler: function() {
|
||||||
|
try {
|
||||||
|
Headlines.unpackVisibleArticles();
|
||||||
|
|
||||||
|
if (App.isCombinedMode()) {
|
||||||
|
Headlines.updateFloatingTitle();
|
||||||
|
|
||||||
|
// set topmost child in the buffer as active
|
||||||
|
if (getInitParam("cdm_expanded") && getInitParam("cdm_auto_catchup") == 1) {
|
||||||
|
|
||||||
|
const rows = $$("#headlines-frame > div[id*=RROW]");
|
||||||
|
|
||||||
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
const row = rows[i];
|
||||||
|
|
||||||
|
if ($("headlines-frame").scrollTop <= row.offsetTop &&
|
||||||
|
row.offsetTop - $("headlines-frame").scrollTop < 100 &&
|
||||||
|
row.getAttribute("data-article-id") != getActiveArticleId()) {
|
||||||
|
|
||||||
|
setActiveArticleId(row.getAttribute("data-article-id"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Feeds.infscroll_disabled) {
|
||||||
|
const hsp = $("headlines-spacer");
|
||||||
|
const container = $("headlines-frame");
|
||||||
|
|
||||||
|
if (hsp && hsp.offsetTop - 250 <= container.scrollTop + container.offsetHeight) {
|
||||||
|
|
||||||
|
hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
|
||||||
|
__("Loading, please wait...") + "</span>";
|
||||||
|
|
||||||
|
Headlines.loadMoreHeadlines();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getInitParam("cdm_auto_catchup") == 1) {
|
||||||
|
|
||||||
|
let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]");
|
||||||
|
|
||||||
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
const row = rows[i];
|
||||||
|
|
||||||
|
if ($("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight / 2)) {
|
||||||
|
const id = row.getAttribute("data-article-id")
|
||||||
|
|
||||||
|
if (catchup_id_batch.indexOf(id) == -1)
|
||||||
|
catchup_id_batch.push(id);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Feeds.infscroll_disabled) {
|
||||||
|
const row = $$("#headlines-frame div[id*=RROW]").last();
|
||||||
|
|
||||||
|
if (row && $("headlines-frame").scrollTop >
|
||||||
|
(row.offsetTop + row.offsetHeight - 50)) {
|
||||||
|
|
||||||
|
console.log("we seem to be at an end");
|
||||||
|
|
||||||
|
if (getInitParam("on_catchup_show_next_feed") == "1") {
|
||||||
|
Feeds.openNextUnreadFeed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("scrollHandler", e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updateFloatingTitle: function(unread_only) {
|
||||||
|
if (!App.isCombinedMode()/* || !getInitParam("cdm_expanded")*/) return;
|
||||||
|
|
||||||
|
const hf = $("headlines-frame");
|
||||||
|
const elems = $$("#headlines-frame > div[id*=RROW]");
|
||||||
|
const ft = $("floatingTitle");
|
||||||
|
|
||||||
|
for (let i = 0; i < elems.length; i++) {
|
||||||
|
const row = elems[i];
|
||||||
|
|
||||||
|
if (row && row.offsetTop + row.offsetHeight > hf.scrollTop) {
|
||||||
|
|
||||||
|
const header = row.select(".header")[0];
|
||||||
|
const id = row.getAttribute("data-article-id");
|
||||||
|
|
||||||
|
if (unread_only || id != ft.getAttribute("data-article-id")) {
|
||||||
|
if (id != ft.getAttribute("data-article-id")) {
|
||||||
|
|
||||||
|
ft.setAttribute("data-article-id", id);
|
||||||
|
ft.innerHTML = header.innerHTML;
|
||||||
|
ft.firstChild.innerHTML = "<img class='anchor marked-pic' src='images/page_white_go.png' " +
|
||||||
|
"onclick=\"cdmScrollToArticleId(" + id + ", true)\">" + ft.firstChild.innerHTML;
|
||||||
|
|
||||||
|
initFloatingMenu();
|
||||||
|
|
||||||
|
const cb = ft.select(".rchk")[0];
|
||||||
|
|
||||||
|
if (cb)
|
||||||
|
cb.parentNode.removeChild(cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row.hasClassName("Unread"))
|
||||||
|
ft.addClassName("Unread");
|
||||||
|
else
|
||||||
|
ft.removeClassName("Unread");
|
||||||
|
|
||||||
|
PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
ft.style.marginRight = hf.offsetWidth - row.offsetWidth + "px";
|
||||||
|
|
||||||
|
if (header.offsetTop + header.offsetHeight < hf.scrollTop + ft.offsetHeight - 5 &&
|
||||||
|
row.offsetTop + row.offsetHeight >= hf.scrollTop + ft.offsetHeight - 5)
|
||||||
|
new Effect.Appear(ft, {duration: 0.3});
|
||||||
|
else
|
||||||
|
Element.hide(ft);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
unpackVisibleArticles: function() {
|
||||||
|
if (!App.isCombinedMode() || !getInitParam("cdm_expanded")) return;
|
||||||
|
|
||||||
|
const rows = $$("#headlines-frame div[id*=RROW][data-content]");
|
||||||
|
const threshold = $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight + 600;
|
||||||
|
|
||||||
|
for (let i = 0; i < rows.length; i++) {
|
||||||
|
const row = rows[i];
|
||||||
|
|
||||||
|
if (row.offsetTop <= threshold) {
|
||||||
|
console.log("unpacking: " + row.id);
|
||||||
|
|
||||||
|
row.select(".content-inner")[0].innerHTML = row.getAttribute("data-content");
|
||||||
|
row.removeAttribute("data-content");
|
||||||
|
|
||||||
|
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoaded: function(transport, offset) {
|
||||||
|
const reply = App.handleRpcJson(transport);
|
||||||
|
|
||||||
|
console.log("Headlines.onLoaded: offset=", offset);
|
||||||
|
|
||||||
let is_cat = false;
|
let is_cat = false;
|
||||||
let feed_id = false;
|
let feed_id = false;
|
||||||
@@ -29,7 +261,7 @@ function headlines_callback2(transport, offset) {
|
|||||||
feed_id = reply['headlines']['id'];
|
feed_id = reply['headlines']['id'];
|
||||||
last_search_query = reply['headlines']['search_query'];
|
last_search_query = reply['headlines']['search_query'];
|
||||||
|
|
||||||
if (feed_id != -7 && (feed_id != getActiveFeedId() || is_cat != activeFeedIsCat()))
|
if (feed_id != -7 && (feed_id != Feeds.getActiveFeedId() || is_cat != Feeds.activeFeedIsCat()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -40,17 +272,18 @@ function headlines_callback2(transport, offset) {
|
|||||||
$("floatingTitle").setAttribute("data-article-id", 0);
|
$("floatingTitle").setAttribute("data-article-id", 0);
|
||||||
$("floatingTitle").innerHTML = "";
|
$("floatingTitle").innerHTML = "";
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
$("headlines-frame").removeClassName("cdm");
|
$("headlines-frame").removeClassName("cdm");
|
||||||
$("headlines-frame").removeClassName("normal");
|
$("headlines-frame").removeClassName("normal");
|
||||||
|
|
||||||
$("headlines-frame").addClassName(isCombinedMode() ? "cdm" : "normal");
|
$("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal");
|
||||||
|
|
||||||
const headlines_count = reply['headlines-info']['count'];
|
const headlines_count = reply['headlines-info']['count'];
|
||||||
infscroll_disabled = parseInt(headlines_count) != 30;
|
Feeds.infscroll_disabled = parseInt(headlines_count) != 30;
|
||||||
|
|
||||||
console.log('received', headlines_count, 'headlines, infscroll disabled=', infscroll_disabled);
|
console.log('received', headlines_count, 'headlines, infscroll disabled=', Feeds.infscroll_disabled);
|
||||||
|
|
||||||
vgroup_last_feed = reply['headlines-info']['vgroup_last_feed'];
|
vgroup_last_feed = reply['headlines-info']['vgroup_last_feed'];
|
||||||
current_first_id = reply['headlines']['first_id'];
|
current_first_id = reply['headlines']['first_id'];
|
||||||
@@ -84,17 +317,17 @@ function headlines_callback2(transport, offset) {
|
|||||||
|
|
||||||
initHeadlinesMenu();
|
initHeadlinesMenu();
|
||||||
|
|
||||||
if (infscroll_disabled)
|
if (Feeds.infscroll_disabled)
|
||||||
hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
|
hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnreadFeed()'>" +
|
||||||
__("Click to open next unread feed.") + "</a>";
|
__("Click to open next unread feed.") + "</a>";
|
||||||
|
|
||||||
if (_search_query) {
|
if (Feeds._search_query) {
|
||||||
$("feed_title").innerHTML += "<span id='cancel_search'>" +
|
$("feed_title").innerHTML += "<span id='cancel_search'>" +
|
||||||
" (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
|
" (<a href='#' onclick='Feeds.cancelSearch()'>" + __("Cancel search") + "</a>)" +
|
||||||
"</span>";
|
"</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (headlines_count > 0 && feed_id == getActiveFeedId() && is_cat == activeFeedIsCat()) {
|
} else if (headlines_count > 0 && feed_id == Feeds.getActiveFeedId() && is_cat == Feeds.activeFeedIsCat()) {
|
||||||
const c = dijit.byId("headlines-frame");
|
const c = dijit.byId("headlines-frame");
|
||||||
//const ids = getSelectedArticleIds2();
|
//const ids = getSelectedArticleIds2();
|
||||||
|
|
||||||
@@ -120,8 +353,6 @@ function headlines_callback2(transport, offset) {
|
|||||||
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
|
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
|
||||||
c.domNode.appendChild(hsp);
|
c.domNode.appendChild(hsp);
|
||||||
|
|
||||||
if (headlines_count < 30) infscroll_disabled = true;
|
|
||||||
|
|
||||||
/* console.log("restore selected ids: " + ids);
|
/* console.log("restore selected ids: " + ids);
|
||||||
|
|
||||||
for (let i = 0; i < ids.length; i++) {
|
for (let i = 0; i < ids.length; i++) {
|
||||||
@@ -130,8 +361,8 @@ function headlines_callback2(transport, offset) {
|
|||||||
|
|
||||||
initHeadlinesMenu();
|
initHeadlinesMenu();
|
||||||
|
|
||||||
if (infscroll_disabled) {
|
if (Feeds.infscroll_disabled) {
|
||||||
hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
|
hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnreadFeed()'>" +
|
||||||
__("Click to open next unread feed.") + "</a>";
|
__("Click to open next unread feed.") + "</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,10 +376,10 @@ function headlines_callback2(transport, offset) {
|
|||||||
|
|
||||||
if (hsp) {
|
if (hsp) {
|
||||||
if (first_id_changed) {
|
if (first_id_changed) {
|
||||||
hsp.innerHTML = "<a href='#' onclick='viewCurrentFeed()'>" +
|
hsp.innerHTML = "<a href='#' onclick='Feeds.viewCurrentFeed()'>" +
|
||||||
__("New articles found, reload feed to continue.") + "</a>";
|
__("New articles found, reload feed to continue.") + "</a>";
|
||||||
} else {
|
} else {
|
||||||
hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
|
hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnreadFeed()'>" +
|
||||||
__("Click to open next unread feed.") + "</a>";
|
__("Click to open next unread feed.") + "</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,45 +392,24 @@ function headlines_callback2(transport, offset) {
|
|||||||
"</div>");
|
"</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
infscroll_in_progress = 0;
|
Feeds.infscroll_in_progress = 0;
|
||||||
|
|
||||||
// this is used to auto-catchup articles if needed after infscroll request has finished,
|
// this is used to auto-catchup articles if needed after infscroll request has finished,
|
||||||
// unpack visible articles, etc
|
// unpack visible articles, etc
|
||||||
headlinesScrollHandler();
|
this.scrollHandler();
|
||||||
|
|
||||||
// if we have some more space in the buffer, why not try to fill it
|
// if we have some more space in the buffer, why not try to fill it
|
||||||
if (!infscroll_disabled && $("headlines-spacer") &&
|
if (!Feeds.infscroll_disabled && $("headlines-spacer") &&
|
||||||
$("headlines-spacer").offsetTop < $("headlines-frame").offsetHeight) {
|
$("headlines-spacer").offsetTop < $("headlines-frame").offsetHeight) {
|
||||||
|
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function () {
|
||||||
loadMoreHeadlines();
|
this.loadMoreHeadlines();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
notify("");
|
notify("");
|
||||||
}
|
},
|
||||||
|
};
|
||||||
function render_article(article) {
|
|
||||||
cleanup_memory("content-insert");
|
|
||||||
|
|
||||||
dijit.byId("headlines-wrap-inner").addChild(
|
|
||||||
dijit.byId("content-insert"));
|
|
||||||
|
|
||||||
const c = dijit.byId("content-insert");
|
|
||||||
|
|
||||||
try {
|
|
||||||
c.domNode.scrollTop = 0;
|
|
||||||
} catch (e) { }
|
|
||||||
|
|
||||||
c.attr('content', article);
|
|
||||||
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, c.domNode);
|
|
||||||
|
|
||||||
correctHeadlinesOffset(getActiveArticleId());
|
|
||||||
|
|
||||||
try {
|
|
||||||
c.focus();
|
|
||||||
} catch (e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
function view(id, noexpand) {
|
function view(id, noexpand) {
|
||||||
setActiveArticleId(id);
|
setActiveArticleId(id);
|
||||||
@@ -220,19 +430,19 @@ function view(id, noexpand) {
|
|||||||
|
|
||||||
if (cached_article) {
|
if (cached_article) {
|
||||||
console.log('rendering cached', id);
|
console.log('rendering cached', id);
|
||||||
render_article(cached_article);
|
Article.renderArticle(cached_article);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
xhrPost("backend.php", {op: "article", method: "view", id: id, cids: cids.toString()}, (transport) => {
|
xhrPost("backend.php", {op: "article", method: "view", id: id, cids: cids.toString()}, (transport) => {
|
||||||
try {
|
try {
|
||||||
const reply = handle_rpc_json(transport);
|
const reply = App.handleRpcJson(transport);
|
||||||
|
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
|
||||||
reply.each(function(article) {
|
reply.each(function(article) {
|
||||||
if (getActiveArticleId() == article['id']) {
|
if (getActiveArticleId() == article['id']) {
|
||||||
render_article(article['content']);
|
Article.renderArticle(article['content']);
|
||||||
}
|
}
|
||||||
//cids_requested.remove(article['id']);
|
//cids_requested.remove(article['id']);
|
||||||
|
|
||||||
@@ -242,7 +452,7 @@ function view(id, noexpand) {
|
|||||||
} else {
|
} else {
|
||||||
console.error("Invalid object received: " + transport.responseText);
|
console.error("Invalid object received: " + transport.responseText);
|
||||||
|
|
||||||
render_article("<div class='whiteBox'>" +
|
Article.renderArticle("<div class='whiteBox'>" +
|
||||||
__('Could not display article (invalid object received - see error console for details)') + "</div>");
|
__('Could not display article (invalid object received - see error console for details)') + "</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +491,7 @@ function toggleMark(id, client_only) {
|
|||||||
|
|
||||||
if (!client_only)
|
if (!client_only)
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,7 +518,7 @@ function togglePub(id, client_only) {
|
|||||||
|
|
||||||
if (!client_only)
|
if (!client_only)
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -349,7 +559,7 @@ function moveToPost(mode, noscroll, noexpand) {
|
|||||||
|
|
||||||
if (mode == "next") {
|
if (mode == "next") {
|
||||||
if (next_id || getActiveArticleId()) {
|
if (next_id || getActiveArticleId()) {
|
||||||
if (isCombinedMode()) {
|
if (App.isCombinedMode()) {
|
||||||
|
|
||||||
const article = $("RROW-" + getActiveArticleId());
|
const article = $("RROW-" + getActiveArticleId());
|
||||||
const ctr = $("headlines-frame");
|
const ctr = $("headlines-frame");
|
||||||
@@ -373,7 +583,7 @@ function moveToPost(mode, noscroll, noexpand) {
|
|||||||
|
|
||||||
if (mode == "prev") {
|
if (mode == "prev") {
|
||||||
if (prev_id || getActiveArticleId()) {
|
if (prev_id || getActiveArticleId()) {
|
||||||
if (isCombinedMode()) {
|
if (App.isCombinedMode()) {
|
||||||
|
|
||||||
const article = $("RROW-" + getActiveArticleId());
|
const article = $("RROW-" + getActiveArticleId());
|
||||||
const prev_article = $("RROW-" + prev_id);
|
const prev_article = $("RROW-" + prev_id);
|
||||||
@@ -432,7 +642,7 @@ function toggleUnread(id, cmode) {
|
|||||||
if (row.className != origClassName)
|
if (row.className != origClassName)
|
||||||
xhrPost("backend.php",
|
xhrPost("backend.php",
|
||||||
{op: "rpc", method: "catchupSelected", cmode: cmode, ids: id},(transport) => {
|
{op: "rpc", method: "catchupSelected", cmode: cmode, ids: id},(transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -449,7 +659,7 @@ function selectionRemoveLabel(id, ids) {
|
|||||||
ids: ids.toString(), lid: id };
|
ids: ids.toString(), lid: id };
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
updateHeadlineLabels(transport);
|
updateHeadlineLabels(transport);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -466,7 +676,7 @@ function selectionAssignLabel(id, ids) {
|
|||||||
ids: ids.toString(), lid: id };
|
ids: ids.toString(), lid: id };
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
updateHeadlineLabels(transport);
|
updateHeadlineLabels(transport);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -509,7 +719,7 @@ function selectionToggleUnread(params) {
|
|||||||
notify_progress("Loading, please wait...");
|
notify_progress("Loading, please wait...");
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
if (callback) callback(transport);
|
if (callback) callback(transport);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -530,7 +740,7 @@ function selectionToggleMarked(ids) {
|
|||||||
ids: rows.toString(), cmode: 2 };
|
ids: rows.toString(), cmode: 2 };
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,7 +762,7 @@ function selectionTogglePublished(ids) {
|
|||||||
ids: rows.toString(), cmode: 2 };
|
ids: rows.toString(), cmode: 2 };
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -652,10 +862,10 @@ function deleteSelection() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
|
const fn = getFeedName(Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
|
||||||
let str;
|
let str;
|
||||||
|
|
||||||
if (getActiveFeedId() != 0) {
|
if (Feeds.getActiveFeedId() != 0) {
|
||||||
str = ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?", rows.length);
|
str = ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?", rows.length);
|
||||||
} else {
|
} else {
|
||||||
str = ngettext("Delete %d selected article?", "Delete %d selected articles?", rows.length);
|
str = ngettext("Delete %d selected article?", "Delete %d selected articles?", rows.length);
|
||||||
@@ -671,8 +881,8 @@ function deleteSelection() {
|
|||||||
const query = { op: "rpc", method: "delete", ids: rows.toString() };
|
const query = { op: "rpc", method: "delete", ids: rows.toString() };
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
viewCurrentFeed();
|
Feeds.viewCurrentFeed();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,11 +896,11 @@ function archiveSelection() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
|
const fn = getFeedName(Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
|
||||||
let str;
|
let str;
|
||||||
let op;
|
let op;
|
||||||
|
|
||||||
if (getActiveFeedId() != 0) {
|
if (Feeds.getActiveFeedId() != 0) {
|
||||||
str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length);
|
str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length);
|
||||||
op = "archive";
|
op = "archive";
|
||||||
} else {
|
} else {
|
||||||
@@ -714,8 +924,8 @@ function archiveSelection() {
|
|||||||
const query = {op: "rpc", method: op, ids: rows.toString()};
|
const query = {op: "rpc", method: op, ids: rows.toString()};
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
viewCurrentFeed();
|
Feeds.viewCurrentFeed();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,7 +938,7 @@ function catchupSelection() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
|
const fn = getFeedName(Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
|
||||||
|
|
||||||
let str = ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows.length);
|
let str = ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows.length);
|
||||||
|
|
||||||
@@ -838,9 +1048,9 @@ function setActiveArticleId(id) {
|
|||||||
if (row.hasClassName("Unread")) {
|
if (row.hasClassName("Unread")) {
|
||||||
|
|
||||||
catchupBatchedArticles(() => {
|
catchupBatchedArticles(() => {
|
||||||
decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
|
Feeds.decrementFeedCounter(Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
|
||||||
toggleUnread(id, 0);
|
toggleUnread(id, 0);
|
||||||
updateFloatingTitle(true);
|
Headlines.updateFloatingTitle(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -870,111 +1080,6 @@ function postMouseOut(id) {
|
|||||||
post_under_pointer = false;
|
post_under_pointer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unpackVisibleArticles() {
|
|
||||||
if (!isCombinedMode() || !getInitParam("cdm_expanded")) return;
|
|
||||||
|
|
||||||
const rows = $$("#headlines-frame div[id*=RROW][data-content]");
|
|
||||||
const threshold = $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight + 600;
|
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i++) {
|
|
||||||
const row = rows[i];
|
|
||||||
|
|
||||||
if (row.offsetTop <= threshold) {
|
|
||||||
console.log("unpacking: " + row.id);
|
|
||||||
|
|
||||||
row.select(".content-inner")[0].innerHTML = row.getAttribute("data-content");
|
|
||||||
row.removeAttribute("data-content");
|
|
||||||
|
|
||||||
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function headlinesScrollHandler(/* event */) {
|
|
||||||
try {
|
|
||||||
unpackVisibleArticles();
|
|
||||||
|
|
||||||
if (isCombinedMode()) {
|
|
||||||
updateFloatingTitle();
|
|
||||||
|
|
||||||
// set topmost child in the buffer as active
|
|
||||||
if (getInitParam("cdm_expanded") && getInitParam("cdm_auto_catchup") == 1) {
|
|
||||||
|
|
||||||
const rows = $$("#headlines-frame > div[id*=RROW]");
|
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i++) {
|
|
||||||
const row = rows[i];
|
|
||||||
|
|
||||||
if ($("headlines-frame").scrollTop <= row.offsetTop &&
|
|
||||||
row.offsetTop - $("headlines-frame").scrollTop < 100 &&
|
|
||||||
row.getAttribute("data-article-id") != getActiveArticleId()) {
|
|
||||||
|
|
||||||
setActiveArticleId(row.getAttribute("data-article-id"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!infscroll_disabled) {
|
|
||||||
const hsp = $("headlines-spacer");
|
|
||||||
const container = $("headlines-frame");
|
|
||||||
|
|
||||||
if (hsp && hsp.offsetTop - 250 <= container.scrollTop + container.offsetHeight) {
|
|
||||||
|
|
||||||
hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
|
|
||||||
__("Loading, please wait...") + "</span>";
|
|
||||||
|
|
||||||
loadMoreHeadlines();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getInitParam("cdm_auto_catchup") == 1) {
|
|
||||||
|
|
||||||
let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]");
|
|
||||||
|
|
||||||
for (let i = 0; i < rows.length; i++) {
|
|
||||||
const row = rows[i];
|
|
||||||
|
|
||||||
if ($("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight/2)) {
|
|
||||||
const id = row.getAttribute("data-article-id")
|
|
||||||
|
|
||||||
if (catchup_id_batch.indexOf(id) == -1)
|
|
||||||
catchup_id_batch.push(id);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (infscroll_disabled) {
|
|
||||||
const row = $$("#headlines-frame div[id*=RROW]").last();
|
|
||||||
|
|
||||||
if (row && $("headlines-frame").scrollTop >
|
|
||||||
(row.offsetTop + row.offsetHeight - 50)) {
|
|
||||||
|
|
||||||
console.log("we seem to be at an end");
|
|
||||||
|
|
||||||
if (getInitParam("on_catchup_show_next_feed") == "1") {
|
|
||||||
openNextUnreadFeed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.warn("headlinesScrollHandler", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openNextUnreadFeed() {
|
|
||||||
const is_cat = activeFeedIsCat();
|
|
||||||
const nuf = getNextUnreadFeed(getActiveFeedId(), is_cat);
|
|
||||||
if (nuf) viewfeed({feed: nuf, is_cat: is_cat});
|
|
||||||
}
|
|
||||||
|
|
||||||
function catchupBatchedArticles(callback) {
|
function catchupBatchedArticles(callback) {
|
||||||
console.log("catchupBatchedArticles, size=", catchup_id_batch.length);
|
console.log("catchupBatchedArticles, size=", catchup_id_batch.length);
|
||||||
|
|
||||||
@@ -986,7 +1091,7 @@ function catchupBatchedArticles(callback) {
|
|||||||
cmode: 0, ids: batch.toString() };
|
cmode: 0, ids: batch.toString() };
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
const reply = handle_rpc_json(transport);
|
const reply = App.handleRpcJson(transport);
|
||||||
|
|
||||||
if (reply) {
|
if (reply) {
|
||||||
const batch = reply.ids;
|
const batch = reply.ids;
|
||||||
@@ -998,7 +1103,7 @@ function catchupBatchedArticles(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFloatingTitle(true);
|
Headlines.updateFloatingTitle(true);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
});
|
||||||
@@ -1062,7 +1167,7 @@ function catchupRelativeToArticle(below, id) {
|
|||||||
cmode: 0, ids: ids_to_mark.toString() };
|
cmode: 0, ids: ids_to_mark.toString() };
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
handle_rpc_json(transport);
|
App.handleRpcJson(transport);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1073,7 +1178,7 @@ function getArticleUnderPointer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function scrollArticle(offset) {
|
function scrollArticle(offset) {
|
||||||
if (!isCombinedMode()) {
|
if (!App.isCombinedMode()) {
|
||||||
const ci = $("content-insert");
|
const ci = $("content-insert");
|
||||||
if (ci) {
|
if (ci) {
|
||||||
ci.scrollTop += offset;
|
ci.scrollTop += offset;
|
||||||
@@ -1102,7 +1207,7 @@ function updateHeadlineLabels(transport) {
|
|||||||
function cdmClicked(event, id, in_body) {
|
function cdmClicked(event, id, in_body) {
|
||||||
|
|
||||||
if (!in_body && (event.ctrlKey || id == getActiveArticleId() || getInitParam("cdm_expanded"))) {
|
if (!in_body && (event.ctrlKey || id == getActiveArticleId() || getInitParam("cdm_expanded"))) {
|
||||||
openArticleInNewWindow(id);
|
Article.openArticleInNewWindow(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
setActiveArticleId(id);
|
setActiveArticleId(id);
|
||||||
@@ -1110,115 +1215,20 @@ function cdmClicked(event, id, in_body) {
|
|||||||
if (!getInitParam("cdm_expanded"))
|
if (!getInitParam("cdm_expanded"))
|
||||||
cdmScrollToArticleId(id);
|
cdmScrollToArticleId(id);
|
||||||
|
|
||||||
//var shift_key = event.shiftKey;
|
|
||||||
|
|
||||||
/* if (!event.ctrlKey && !event.metaKey) {
|
|
||||||
|
|
||||||
let elem = $("RROW-" + getActiveArticleId());
|
|
||||||
|
|
||||||
if (elem) elem.removeClassName("active");
|
|
||||||
|
|
||||||
selectArticles("none");
|
|
||||||
toggleSelected(id);
|
|
||||||
|
|
||||||
elem = $("RROW-" + id);
|
|
||||||
const article_is_unread = elem.hasClassName("Unread");
|
|
||||||
|
|
||||||
elem.removeClassName("Unread");
|
|
||||||
elem.addClassName("active");
|
|
||||||
|
|
||||||
setActiveArticleId(id);
|
|
||||||
|
|
||||||
if (article_is_unread) {
|
|
||||||
decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
|
|
||||||
updateFloatingTitle(true);
|
|
||||||
|
|
||||||
const query = {
|
|
||||||
op: "rpc", method: "catchupSelected",
|
|
||||||
cmode: 0, ids: id
|
|
||||||
};
|
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
|
||||||
handle_rpc_json(transport);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return !event.shiftKey;
|
|
||||||
|
|
||||||
} else if (!in_body) {
|
|
||||||
|
|
||||||
toggleSelected(id, true);
|
|
||||||
|
|
||||||
let elem = $("RROW-" + id);
|
|
||||||
const article_is_unread = elem.hasClassName("Unread");
|
|
||||||
|
|
||||||
if (article_is_unread) {
|
|
||||||
decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleUnread(id, 0, false);
|
|
||||||
|
|
||||||
openArticleInNewWindow(id);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
|
|
||||||
request_counters(unread_in_buffer == 0); */
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hlClicked(event, id) {
|
function hlClicked(event, id) {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
openArticleInNewWindow(id);
|
Article.openArticleInNewWindow(id);
|
||||||
setActiveArticleId(id);
|
setActiveArticleId(id);
|
||||||
} else {
|
} else {
|
||||||
view(id);
|
view(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* if (event.which == 2) {
|
|
||||||
view(id);
|
|
||||||
return true;
|
|
||||||
} else if (event.ctrlKey || event.metaKey) {
|
|
||||||
openArticleInNewWindow(id);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
view(id);
|
|
||||||
return false;
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openArticleInNewWindow(id) {
|
|
||||||
const w = window.open("");
|
|
||||||
w.opener = null;
|
|
||||||
w.location = "backend.php?op=article&method=redirect&id=" + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isCombinedMode() {
|
|
||||||
return getInitParam("combined_display_mode");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* function markHeadline(id, marked) {
|
|
||||||
if (marked == undefined) marked = true;
|
|
||||||
|
|
||||||
const row = $("RROW-" + id);
|
|
||||||
if (row) {
|
|
||||||
const check = dijit.getEnclosingWidget(
|
|
||||||
row.getElementsByClassName("rchk")[0]);
|
|
||||||
|
|
||||||
if (check) {
|
|
||||||
check.attr("checked", marked);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (marked)
|
|
||||||
row.addClassName("Selected");
|
|
||||||
else
|
|
||||||
row.removeClassName("Selected");
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
function getRelativePostIds(id, limit) {
|
function getRelativePostIds(id, limit) {
|
||||||
|
|
||||||
@@ -1262,6 +1272,7 @@ function correctHeadlinesOffset(id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// noinspection JSUnusedGlobalSymbols
|
||||||
function headlineActionsChange(elem) {
|
function headlineActionsChange(elem) {
|
||||||
eval(elem.value);
|
eval(elem.value);
|
||||||
elem.attr('value', 'false');
|
elem.attr('value', 'false');
|
||||||
@@ -1286,12 +1297,6 @@ function cdmCollapseActive(event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeArticlePanel() {
|
|
||||||
if (dijit.byId("content-insert"))
|
|
||||||
dijit.byId("headlines-wrap-inner").removeChild(
|
|
||||||
dijit.byId("content-insert"));
|
|
||||||
}
|
|
||||||
|
|
||||||
function initFloatingMenu() {
|
function initFloatingMenu() {
|
||||||
if (!dijit.byId("floatingMenu")) {
|
if (!dijit.byId("floatingMenu")) {
|
||||||
|
|
||||||
@@ -1311,14 +1316,14 @@ function headlinesMenuCommon(menu) {
|
|||||||
menu.addChild(new dijit.MenuItem({
|
menu.addChild(new dijit.MenuItem({
|
||||||
label: __("Open original article"),
|
label: __("Open original article"),
|
||||||
onClick: function (event) {
|
onClick: function (event) {
|
||||||
openArticleInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id"));
|
Article.openArticleInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id"));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
menu.addChild(new dijit.MenuItem({
|
menu.addChild(new dijit.MenuItem({
|
||||||
label: __("Display article URL"),
|
label: __("Display article URL"),
|
||||||
onClick: function (event) {
|
onClick: function (event) {
|
||||||
displayArticleUrl(this.getParent().currentTarget.getAttribute("data-article-id"));
|
Article.displayArticleUrl(this.getParent().currentTarget.getAttribute("data-article-id"));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -1524,11 +1529,7 @@ function cache_delete(id) {
|
|||||||
sessionStorage.removeItem(id);
|
sessionStorage.removeItem(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelSearch() {
|
// noinspection JSUnusedGlobalSymbols
|
||||||
_search_query = "";
|
|
||||||
viewCurrentFeed();
|
|
||||||
}
|
|
||||||
|
|
||||||
function setSelectionScore() {
|
function setSelectionScore() {
|
||||||
const ids = getSelectedArticleIds2();
|
const ids = getSelectedArticleIds2();
|
||||||
|
|
||||||
@@ -1565,6 +1566,7 @@ function setSelectionScore() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// noinspection JSUnusedGlobalSymbols
|
||||||
function changeScore(id, pic) {
|
function changeScore(id, pic) {
|
||||||
const score = pic.getAttribute("score");
|
const score = pic.getAttribute("score");
|
||||||
|
|
||||||
@@ -1583,73 +1585,3 @@ function changeScore(id, pic) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayArticleUrl(id) {
|
|
||||||
const query = { op: "rpc", method: "getlinktitlebyid", id: id };
|
|
||||||
|
|
||||||
xhrJson("backend.php", query, (reply) => {
|
|
||||||
if (reply && reply.link) {
|
|
||||||
prompt(__("Article URL:"), reply.link);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// floatingTitle goto button uses this
|
|
||||||
/* function scrollToRowId(id) {
|
|
||||||
const row = $(id);
|
|
||||||
|
|
||||||
if (row)
|
|
||||||
$("headlines-frame").scrollTop = row.offsetTop - 4;
|
|
||||||
} */
|
|
||||||
|
|
||||||
function updateFloatingTitle(unread_only) {
|
|
||||||
if (!isCombinedMode()/* || !getInitParam("cdm_expanded")*/) return;
|
|
||||||
|
|
||||||
const hf = $("headlines-frame");
|
|
||||||
const elems = $$("#headlines-frame > div[id*=RROW]");
|
|
||||||
const ft = $("floatingTitle");
|
|
||||||
|
|
||||||
for (let i = 0; i < elems.length; i++) {
|
|
||||||
const row = elems[i];
|
|
||||||
|
|
||||||
if (row && row.offsetTop + row.offsetHeight > hf.scrollTop) {
|
|
||||||
|
|
||||||
const header = row.select(".header")[0];
|
|
||||||
var id = row.getAttribute("data-article-id");
|
|
||||||
|
|
||||||
if (unread_only || id != ft.getAttribute("data-article-id")) {
|
|
||||||
if (id != ft.getAttribute("data-article-id")) {
|
|
||||||
|
|
||||||
ft.setAttribute("data-article-id", id);
|
|
||||||
ft.innerHTML = header.innerHTML;
|
|
||||||
ft.firstChild.innerHTML = "<img class='anchor marked-pic' src='images/page_white_go.png' " +
|
|
||||||
"onclick=\"cdmScrollToArticleId("+id + ", true)\">" + ft.firstChild.innerHTML;
|
|
||||||
|
|
||||||
initFloatingMenu();
|
|
||||||
|
|
||||||
const cb = ft.select(".rchk")[0];
|
|
||||||
|
|
||||||
if (cb)
|
|
||||||
cb.parentNode.removeChild(cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (row.hasClassName("Unread"))
|
|
||||||
ft.addClassName("Unread");
|
|
||||||
else
|
|
||||||
ft.removeClassName("Unread");
|
|
||||||
|
|
||||||
PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, row);
|
|
||||||
}
|
|
||||||
|
|
||||||
ft.style.marginRight = hf.offsetWidth - row.offsetWidth + "px";
|
|
||||||
|
|
||||||
if (header.offsetTop + header.offsetHeight < hf.scrollTop + ft.offsetHeight - 5 &&
|
|
||||||
row.offsetTop + row.offsetHeight >= hf.scrollTop + ft.offsetHeight - 5)
|
|
||||||
new Effect.Appear(ft, {duration: 0.3});
|
|
||||||
else
|
|
||||||
Element.hide(ft);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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>";
|
||||||
|
|||||||
@@ -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')."'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user