2020-06-05 04:54:32 +00:00
|
|
|
/* eslint-disable prefer-rest-params */
|
|
|
|
/* global __, dojo, dijit, define, App, Feeds, CommonDialogs */
|
2020-06-04 20:27:22 +00:00
|
|
|
|
2020-07-08 16:48:23 +00:00
|
|
|
define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/cookie", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct, array, cookie) {
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
return declare("fox.FeedTree", dijit.Tree, {
|
2020-07-08 16:48:23 +00:00
|
|
|
// save state in localStorage instead of cookies
|
|
|
|
// reference: https://stackoverflow.com/a/27968996
|
|
|
|
_saveExpandedNodes: function(){
|
2021-02-12 16:02:09 +00:00
|
|
|
if (this.persist && this.cookieName){
|
|
|
|
const ary = [];
|
|
|
|
for (const id in this._openedNodes){
|
2020-07-08 16:48:23 +00:00
|
|
|
ary.push(id);
|
|
|
|
}
|
|
|
|
// Was:
|
|
|
|
// cookie(this.cookieName, ary.join(","), {expires: 365});
|
|
|
|
localStorage.setItem(this.cookieName, ary.join(","));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
_initState: function(){
|
|
|
|
// summary:
|
|
|
|
// Load in which nodes should be opened automatically
|
|
|
|
this._openedNodes = {};
|
2021-02-12 16:02:09 +00:00
|
|
|
if (this.persist && this.cookieName){
|
2020-07-08 16:48:23 +00:00
|
|
|
// Was:
|
|
|
|
// var oreo = cookie(this.cookieName);
|
2021-02-12 16:02:09 +00:00
|
|
|
let oreo = localStorage.getItem(this.cookieName);
|
2020-07-08 16:48:23 +00:00
|
|
|
// migrate old data if nothing in localStorage
|
2021-02-12 16:02:09 +00:00
|
|
|
if (oreo == null || oreo === '') {
|
2020-07-08 16:48:23 +00:00
|
|
|
oreo = cookie(this.cookieName);
|
|
|
|
cookie(this.cookieName, null, { expires: -1 });
|
|
|
|
}
|
2021-02-12 16:02:09 +00:00
|
|
|
if (oreo){
|
2020-07-08 16:48:23 +00:00
|
|
|
array.forEach(oreo.split(','), function(item){
|
|
|
|
this._openedNodes[item] = true;
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-06-05 04:54:32 +00:00
|
|
|
_onContainerKeydown: function(/* Event */ /* e */) {
|
2019-04-07 10:21:52 +00:00
|
|
|
return; // Stop dijit.Tree from interpreting keystrokes
|
|
|
|
},
|
2020-06-05 04:54:32 +00:00
|
|
|
_onContainerKeypress: function(/* Event */ /* e */) {
|
2016-08-10 10:40:24 +00:00
|
|
|
return; // Stop dijit.Tree from interpreting keystrokes
|
|
|
|
},
|
|
|
|
_createTreeNode: function(args) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const tnode = new dijit._TreeNode(args);
|
2010-11-17 19:51:44 +00:00
|
|
|
|
2018-12-05 17:26:27 +00:00
|
|
|
const iconName = args.item.icon ? String(args.item.icon[0]) : null;
|
|
|
|
let iconNode;
|
|
|
|
|
|
|
|
if (iconName) {
|
|
|
|
if (iconName.indexOf("/") == -1) {
|
2020-02-20 11:14:45 +00:00
|
|
|
iconNode = dojo.create("i", { className: "material-icons icon icon-" + iconName, innerHTML: iconName });
|
2018-12-05 17:26:27 +00:00
|
|
|
} else {
|
2020-02-20 11:14:45 +00:00
|
|
|
iconNode = dojo.create('img', { className: 'icon' });
|
2018-12-05 17:26:27 +00:00
|
|
|
if (args.item.icon && args.item.icon[0]) {
|
|
|
|
iconNode.src = args.item.icon[0];
|
|
|
|
} else {
|
|
|
|
iconNode.src = 'images/blank_icon.gif';
|
|
|
|
}
|
|
|
|
}
|
2017-01-20 17:29:59 +00:00
|
|
|
}
|
2018-12-05 17:26:27 +00:00
|
|
|
|
|
|
|
if (iconNode)
|
|
|
|
domConstruct.place(iconNode, tnode.iconNode, 'only');
|
2010-11-19 17:18:20 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const id = args.item.id[0];
|
|
|
|
const bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
2010-11-21 13:11:14 +00:00
|
|
|
|
2020-06-05 04:44:57 +00:00
|
|
|
if (bare_id < App.LABEL_BASE_INDEX) {
|
2020-02-20 11:14:45 +00:00
|
|
|
const label = dojo.create('i', { className: "material-icons icon icon-label", innerHTML: "label" });
|
|
|
|
|
2018-12-06 05:26:52 +00:00
|
|
|
//const fg_color = args.item.fg_color[0];
|
2018-11-29 18:21:06 +00:00
|
|
|
const bg_color = args.item.bg_color[0];
|
2010-11-21 13:11:14 +00:00
|
|
|
|
2018-12-06 05:26:52 +00:00
|
|
|
label.setStyle({
|
|
|
|
color: bg_color,
|
|
|
|
});
|
2010-11-21 13:11:14 +00:00
|
|
|
|
2018-12-06 05:26:52 +00:00
|
|
|
domConstruct.place(label, tnode.iconNode, 'only');
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
2010-11-19 17:18:20 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (id.match("FEED:")) {
|
2021-03-09 15:55:28 +00:00
|
|
|
tnode.rowNode.setAttribute('data-feed-id', bare_id);
|
|
|
|
tnode.rowNode.setAttribute('data-is-cat', "false");
|
|
|
|
|
2020-06-05 04:54:32 +00:00
|
|
|
const menu = new dijit.Menu();
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.row_id = bare_id;
|
2011-11-11 11:28:11 +00:00
|
|
|
|
2012-09-10 18:51:53 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
2016-08-10 10:40:24 +00:00
|
|
|
label: __("Mark as read"),
|
2012-09-10 18:51:53 +00:00
|
|
|
onClick: function() {
|
2018-12-01 14:21:26 +00:00
|
|
|
Feeds.catchupFeed(this.getParent().row_id);
|
2012-09-10 18:51:53 +00:00
|
|
|
}}));
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (bare_id > 0) {
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Edit feed"),
|
|
|
|
onClick: function() {
|
2018-12-01 19:39:29 +00:00
|
|
|
CommonDialogs.editFeed(this.getParent().row_id, false);
|
2016-08-10 10:40:24 +00:00
|
|
|
}}));
|
|
|
|
|
2019-04-08 12:51:05 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Debug feed"),
|
|
|
|
onClick: function() {
|
2020-09-15 13:12:53 +00:00
|
|
|
/* global __csrf_token */
|
2021-02-15 13:51:35 +00:00
|
|
|
App.postOpenWindow("backend.php", {op: "feeds", method: "updatedebugger",
|
2020-09-15 13:12:53 +00:00
|
|
|
feed_id: this.getParent().row_id, csrf_token: __csrf_token});
|
2019-04-08 12:51:05 +00:00
|
|
|
}}));
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id.match("CAT:") && bare_id >= 0) {
|
2020-06-05 04:54:32 +00:00
|
|
|
const menu = new dijit.Menu();
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.row_id = bare_id;
|
|
|
|
|
2016-11-11 11:14:31 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
2016-11-22 06:11:13 +00:00
|
|
|
label: __("Mark as read"),
|
2016-11-11 11:14:31 +00:00
|
|
|
onClick: function() {
|
2018-12-01 14:21:26 +00:00
|
|
|
Feeds.catchupFeed(this.getParent().row_id, true);
|
2016-11-11 11:14:31 +00:00
|
|
|
}}));
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
2016-11-22 06:11:13 +00:00
|
|
|
label: __("(Un)collapse"),
|
2012-09-10 18:51:53 +00:00
|
|
|
onClick: function() {
|
2016-11-22 06:11:13 +00:00
|
|
|
dijit.byId("feedTree").collapseCat(this.getParent().row_id);
|
2016-08-10 10:40:24 +00:00
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
2012-09-10 18:51:53 +00:00
|
|
|
}
|
2010-11-19 17:18:20 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (id.match("CAT:")) {
|
2021-03-09 15:55:28 +00:00
|
|
|
tnode.rowNode.setAttribute('data-feed-id', bare_id);
|
|
|
|
tnode.rowNode.setAttribute('data-is-cat', "true");
|
|
|
|
|
2021-03-22 13:18:59 +00:00
|
|
|
tnode.loadingNode = dojo.create('img', { className: 'loadingNode', src: App.getInitParam('icon_blank')});
|
2020-02-20 11:14:45 +00:00
|
|
|
domConstruct.place(tnode.loadingNode, tnode.labelNode, 'after');
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
2013-05-15 21:08:04 +00:00
|
|
|
|
2021-03-16 17:50:18 +00:00
|
|
|
if (id.match("FEED:")) {
|
2021-03-22 13:18:59 +00:00
|
|
|
tnode.loadingNode = dojo.create('img', { className: 'loadingNode', src: App.getInitParam('icon_blank')});
|
2021-03-16 17:50:18 +00:00
|
|
|
domConstruct.place(tnode.loadingNode, tnode.expandoNode, 'only');
|
|
|
|
}
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (id.match("CAT:") && bare_id == -1) {
|
2020-06-05 04:54:32 +00:00
|
|
|
const menu = new dijit.Menu();
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.row_id = bare_id;
|
2013-05-15 21:08:04 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Mark all feeds as read"),
|
|
|
|
onClick: function() {
|
2019-01-31 09:16:56 +00:00
|
|
|
Feeds.catchupAll();
|
2016-08-10 10:40:24 +00:00
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
2013-05-07 12:28:49 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
tnode.markedCounterNode = dojo.create('span', { className: 'counterNode marked', innerHTML: args.item.markedcounter });
|
|
|
|
domConstruct.place(tnode.markedCounterNode, tnode.rowNode, 'first');
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
tnode.auxCounterNode = dojo.create('span', { className: 'counterNode aux', innerHTML: args.item.auxcounter });
|
|
|
|
domConstruct.place(tnode.auxCounterNode, tnode.rowNode, 'first');
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
tnode.unreadCounterNode = dojo.create('span', { className: 'counterNode unread', innerHTML: args.item.unread });
|
|
|
|
domConstruct.place(tnode.unreadCounterNode, tnode.rowNode, 'first');
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
return tnode;
|
|
|
|
},
|
|
|
|
postCreate: function() {
|
|
|
|
this.connect(this.model, "onChange", "updateCounter");
|
|
|
|
this.inherited(arguments);
|
|
|
|
},
|
|
|
|
updateCounter: function (item) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const tree = this;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
//console.log("updateCounter: " + item.id[0] + " " + item.unread + " " + tree);
|
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeNode = tree._itemNodesMap[item.id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
treeNode.unreadCounterNode.innerHTML = item.unread;
|
|
|
|
treeNode.auxCounterNode.innerHTML = item.auxcounter;
|
|
|
|
treeNode.markedCounterNode.innerHTML = item.markedcounter;
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
getTooltip: function (item) {
|
2020-06-05 04:54:32 +00:00
|
|
|
return [item.updated, item.error].filter((x) => x && x != "").join(" - ");
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
getIconClass: function (item, opened) {
|
2020-06-05 04:54:32 +00:00
|
|
|
// eslint-disable-next-line no-nested-ternary
|
2018-12-05 17:26:27 +00:00
|
|
|
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon";
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
2020-06-05 04:54:32 +00:00
|
|
|
getLabelClass: function (item/* , opened */) {
|
2019-05-06 06:32:08 +00:00
|
|
|
return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
2020-06-05 04:54:32 +00:00
|
|
|
getRowClass: function (item/*, opened */) {
|
2021-03-22 11:46:23 +00:00
|
|
|
let rc = "dijitTreeRow dijitTreeRowFlex";
|
2020-02-21 11:06:21 +00:00
|
|
|
|
|
|
|
const is_cat = String(item.id).indexOf('CAT:') != -1;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2021-03-16 17:50:18 +00:00
|
|
|
if (is_cat)
|
|
|
|
rc += " Is_Cat";
|
|
|
|
else
|
|
|
|
rc += " Is_Feed";
|
|
|
|
|
2020-02-21 11:06:21 +00:00
|
|
|
if (!is_cat && item.error != '') rc += " Error";
|
2016-08-10 10:40:24 +00:00
|
|
|
if (item.unread > 0) rc += " Unread";
|
2020-02-20 11:14:45 +00:00
|
|
|
if (item.auxcounter > 0) rc += " Has_Aux";
|
2020-01-24 11:35:10 +00:00
|
|
|
if (item.markedcounter > 0) rc += " Has_Marked";
|
2018-02-08 10:54:06 +00:00
|
|
|
if (item.updates_disabled > 0) rc += " UpdatesDisabled";
|
2020-06-05 04:44:57 +00:00
|
|
|
if (item.bare_id >= App.LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id == 0 && !is_cat) rc += " Special";
|
2020-02-21 11:06:21 +00:00
|
|
|
if (item.bare_id == -1 && is_cat) rc += " AlwaysVisible";
|
2020-06-05 04:44:57 +00:00
|
|
|
if (item.bare_id < App.LABEL_BASE_INDEX) rc += " Label";
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
},
|
|
|
|
getLabel: function(item) {
|
2018-11-29 18:21:06 +00:00
|
|
|
let name = String(item.name);
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
/* Horrible */
|
|
|
|
name = name.replace(/"/g, "\"");
|
|
|
|
name = name.replace(/&/g, "&");
|
|
|
|
name = name.replace(/—/g, "-");
|
|
|
|
name = name.replace(/</g, "<");
|
|
|
|
name = name.replace(/>/g, ">");
|
|
|
|
|
|
|
|
return name;
|
|
|
|
},
|
|
|
|
expandParentNodes: function(feed, is_cat, list) {
|
|
|
|
try {
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
const id = String(list[i].id);
|
|
|
|
let item = this._itemNodesMap[id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (item) {
|
|
|
|
item = item[0];
|
|
|
|
this._expandNode(item);
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
} catch (e) {
|
2018-12-03 10:38:13 +00:00
|
|
|
App.Error.report(e);
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
findNodeParentsAndExpandThem: function(feed, is_cat, root, parents) {
|
|
|
|
// expands all parents of specified feed to properly mark it as active
|
|
|
|
// my fav thing about frameworks is doing everything myself
|
|
|
|
try {
|
2018-11-29 18:21:06 +00:00
|
|
|
const test_id = is_cat ? 'CAT:' + feed : 'FEED:' + feed;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (!root) {
|
|
|
|
if (!this.model || !this.model.store) return false;
|
2013-03-26 12:31:36 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const items = this.model.store._arrayOfTopLevelItems;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < items.length; i++) {
|
2016-08-10 10:40:24 +00:00
|
|
|
if (String(items[i].id) == test_id) {
|
2013-03-26 12:31:36 +00:00
|
|
|
this.expandParentNodes(feed, is_cat, parents);
|
|
|
|
} else {
|
2016-08-10 10:40:24 +00:00
|
|
|
this.findNodeParentsAndExpandThem(feed, is_cat, items[i], []);
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-29 18:21:06 +00:00
|
|
|
} else if (root.items) {
|
2016-08-10 10:40:24 +00:00
|
|
|
parents.push(root);
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < root.items.length; i++) {
|
2016-08-10 10:40:24 +00:00
|
|
|
if (String(root.items[i].id) == test_id) {
|
|
|
|
this.expandParentNodes(feed, is_cat, parents);
|
|
|
|
} else {
|
|
|
|
this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents.slice(0));
|
|
|
|
}
|
|
|
|
}
|
2018-11-29 18:21:06 +00:00
|
|
|
} else if (String(root.id) == test_id) {
|
2016-08-10 10:40:24 +00:00
|
|
|
this.expandParentNodes(feed, is_cat, parents.slice(0));
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2018-12-03 10:38:13 +00:00
|
|
|
App.Error.report(e);
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
selectFeed: function(feed, is_cat) {
|
|
|
|
this.findNodeParentsAndExpandThem(feed, is_cat, false, false);
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeNode;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (is_cat)
|
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
|
|
|
|
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
|
|
|
if (!is_cat) this._expandNode(treeNode);
|
|
|
|
this.set("selectedNodes", [treeNode]);
|
2017-05-05 07:35:10 +00:00
|
|
|
this.focusNode(treeNode);
|
2017-05-12 05:05:35 +00:00
|
|
|
|
|
|
|
// focus headlines to route key events there
|
2019-01-27 20:31:00 +00:00
|
|
|
setTimeout(() => {
|
2021-02-18 18:51:18 +00:00
|
|
|
App.byId("headlines-frame").focus();
|
2019-01-27 20:31:00 +00:00
|
|
|
|
2019-01-28 15:49:58 +00:00
|
|
|
if (treeNode) {
|
|
|
|
const node = treeNode.rowNode;
|
|
|
|
const tree = this.domNode;
|
|
|
|
|
|
|
|
if (node && tree) {
|
|
|
|
// scroll tree to selection if needed
|
|
|
|
if (node.offsetTop < tree.scrollTop || node.offsetTop > tree.scrollTop + tree.clientHeight) {
|
2021-02-18 18:51:18 +00:00
|
|
|
App.byId("feedTree").scrollTop = node.offsetTop;
|
2019-01-28 15:49:58 +00:00
|
|
|
}
|
2019-01-28 15:48:56 +00:00
|
|
|
}
|
2019-01-27 20:31:00 +00:00
|
|
|
}
|
|
|
|
|
2017-05-12 05:05:35 +00:00
|
|
|
}, 0);
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
2021-03-16 17:50:18 +00:00
|
|
|
setIcon: function(feed, is_cat, src) {
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeNode;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (is_cat)
|
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
2021-03-16 17:50:18 +00:00
|
|
|
|
|
|
|
// could be <i material>
|
|
|
|
const icon = treeNode.iconNode.querySelector('img.icon');
|
|
|
|
|
|
|
|
if (icon) {
|
|
|
|
icon.src = src;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2021-03-16 17:50:18 +00:00
|
|
|
showLoading: function(feed, is_cat, show) {
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeNode;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (is_cat)
|
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
2021-03-16 17:50:18 +00:00
|
|
|
|
|
|
|
if (show)
|
|
|
|
treeNode.loadingNode.addClassName("visible");
|
|
|
|
else
|
|
|
|
treeNode.loadingNode.removeClassName("visible");
|
|
|
|
|
|
|
|
return true
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
hasCats: function() {
|
|
|
|
return this.model.hasCats();
|
|
|
|
},
|
|
|
|
collapseCat: function(id) {
|
|
|
|
if (!this.model.hasCats()) return;
|
2010-12-27 12:39:40 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const tree = this;
|
2010-12-27 12:39:40 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const node = tree._itemNodesMap['CAT:' + id][0];
|
|
|
|
const item = tree.model.store._itemsByIdentity['CAT:' + id];
|
2010-12-27 12:39:40 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (node && item) {
|
|
|
|
if (!node.isExpanded)
|
|
|
|
tree._expandNode(node);
|
|
|
|
else
|
|
|
|
tree._collapseNode(node);
|
2010-12-27 12:39:40 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
2021-03-19 11:06:23 +00:00
|
|
|
getNextUnread: function(feed, is_cat) {
|
|
|
|
return this.getNextFeed(feed, is_cat, true);
|
|
|
|
},
|
|
|
|
getNextFeed: function (feed, is_cat, unread_only = false) {
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeItem;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (is_cat) {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
|
|
|
|
} else {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
}
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const items = this.model.store._arrayOfAllItems;
|
2021-03-22 04:39:31 +00:00
|
|
|
let item = false;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < items.length; i++) {
|
2016-08-10 10:40:24 +00:00
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let j = i+1; j < items.length; j++) {
|
|
|
|
const id = String(items[j].id);
|
|
|
|
const box = this._itemNodesMap[id];
|
2021-03-19 11:06:23 +00:00
|
|
|
const unread = parseInt(items[j].unread);
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2021-03-19 11:06:23 +00:00
|
|
|
if (box && (!unread_only || unread > 0)) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const row = box[0].rowNode;
|
|
|
|
const cat = box[0].rowNode.parentNode.parentNode;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (Element.visible(cat) && Element.visible(row)) {
|
|
|
|
item = items[j];
|
|
|
|
break;
|
|
|
|
}
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
break;
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (item) {
|
|
|
|
return [this.model.store.getValue(item, 'bare_id'),
|
|
|
|
!this.model.store.getValue(item, 'id').match('FEED:')];
|
|
|
|
} else {
|
2021-03-22 04:39:31 +00:00
|
|
|
return [false, false];
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getPreviousFeed: function (feed, is_cat) {
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeItem;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (is_cat) {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
|
|
|
|
} else {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
}
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const items = this.model.store._arrayOfAllItems;
|
2021-03-22 04:50:56 +00:00
|
|
|
let item = false;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < items.length; i++) {
|
2016-08-10 10:40:24 +00:00
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let j = i-1; j > 0; j--) {
|
|
|
|
const id = String(items[j].id);
|
|
|
|
const box = this._itemNodesMap[id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (box) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const row = box[0].rowNode;
|
|
|
|
const cat = box[0].rowNode.parentNode.parentNode;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (Element.visible(cat) && Element.visible(row)) {
|
|
|
|
item = items[j];
|
|
|
|
break;
|
|
|
|
}
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (item) {
|
|
|
|
return [this.model.store.getValue(item, 'bare_id'),
|
|
|
|
!this.model.store.getValue(item, 'id').match('FEED:')];
|
|
|
|
} else {
|
2021-03-22 04:50:56 +00:00
|
|
|
return [false, false];
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
2011-01-18 09:40:19 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
getFeedCategory: function(feed) {
|
|
|
|
try {
|
|
|
|
return this.getNodesByItem(this.model.store.
|
2012-04-04 11:34:06 +00:00
|
|
|
_itemsByIdentity["FEED:" + feed])[0].
|
2016-08-10 10:40:24 +00:00
|
|
|
getParent().item.bare_id[0];
|
2011-01-18 09:40:19 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
2010-11-17 19:51:44 +00:00
|
|
|
});
|
2016-08-10 10:40:24 +00:00
|
|
|
|