eslint-related fixes; move a few things from global context to App
This commit is contained in:
parent
88027d7a39
commit
d01ad09800
|
@ -91,7 +91,7 @@ module.exports = {
|
||||||
"max-statements-per-line": [ "warn", { "max" : 2 } ],
|
"max-statements-per-line": [ "warn", { "max" : 2 } ],
|
||||||
"multiline-comment-style": "off",
|
"multiline-comment-style": "off",
|
||||||
"multiline-ternary": "off",
|
"multiline-ternary": "off",
|
||||||
"new-cap": "error",
|
"new-cap": "warn",
|
||||||
"new-parens": "error",
|
"new-parens": "error",
|
||||||
"newline-after-var": "off",
|
"newline-after-var": "off",
|
||||||
"newline-before-return": "off",
|
"newline-before-return": "off",
|
||||||
|
@ -150,7 +150,7 @@ module.exports = {
|
||||||
"no-negated-condition": "off",
|
"no-negated-condition": "off",
|
||||||
"no-negated-in-lhs": "error",
|
"no-negated-in-lhs": "error",
|
||||||
"no-nested-ternary": "error",
|
"no-nested-ternary": "error",
|
||||||
"no-new": "error",
|
"no-new": "warn",
|
||||||
"no-new-func": "error",
|
"no-new-func": "error",
|
||||||
"no-new-object": "off",
|
"no-new-object": "off",
|
||||||
"no-new-require": "error",
|
"no-new-require": "error",
|
||||||
|
@ -162,7 +162,7 @@ module.exports = {
|
||||||
"no-process-env": "error",
|
"no-process-env": "error",
|
||||||
"no-process-exit": "error",
|
"no-process-exit": "error",
|
||||||
"no-proto": "error",
|
"no-proto": "error",
|
||||||
"no-prototype-builtins": "error",
|
"no-prototype-builtins": "warn",
|
||||||
"no-restricted-globals": "error",
|
"no-restricted-globals": "error",
|
||||||
"no-restricted-imports": "error",
|
"no-restricted-imports": "error",
|
||||||
"no-restricted-modules": "error",
|
"no-restricted-modules": "error",
|
||||||
|
|
|
@ -393,7 +393,7 @@ class Article extends Handler_Protected {
|
||||||
# $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" .
|
# $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" .
|
||||||
# $filename . " (" . $ctype . ")" . "</a>";
|
# $filename . " (" . $ctype . ")" . "</a>";
|
||||||
|
|
||||||
$entry = "<div onclick=\"popupOpenUrl('".htmlspecialchars($url)."')\"
|
$entry = "<div onclick=\"Article.popupOpenUrl('".htmlspecialchars($url)."')\"
|
||||||
dojoType=\"dijit.MenuItem\">$filename ($ctype)</div>";
|
dojoType=\"dijit.MenuItem\">$filename ($ctype)</div>";
|
||||||
|
|
||||||
array_push($entries_html, $entry);
|
array_push($entries_html, $entry);
|
||||||
|
@ -473,7 +473,7 @@ class Article extends Handler_Protected {
|
||||||
else
|
else
|
||||||
$filename = "";
|
$filename = "";
|
||||||
|
|
||||||
$rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")'
|
$rv .= "<div onclick='Article.popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")'
|
||||||
dojoType=\"dijit.MenuItem\">".$filename . $title."</div>";
|
dojoType=\"dijit.MenuItem\">".$filename . $title."</div>";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -701,7 +701,7 @@ class Feeds extends Handler_Protected {
|
||||||
print "<section>";
|
print "<section>";
|
||||||
print "<label>
|
print "<label>
|
||||||
<label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox' id='feedDlg_loginCheck'
|
<label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox' id='feedDlg_loginCheck'
|
||||||
onclick='displayIfChecked(this, \"feedDlg_loginContainer\")'>
|
onclick='App.displayIfChecked(this, \"feedDlg_loginContainer\")'>
|
||||||
".__('This feed requires authentication.')."</label>";
|
".__('This feed requires authentication.')."</label>";
|
||||||
print "</section>";
|
print "</section>";
|
||||||
|
|
||||||
|
|
|
@ -676,7 +676,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
$auth_checked = $auth_enabled ? 'checked' : '';
|
$auth_checked = $auth_enabled ? 'checked' : '';
|
||||||
print "<label class='checkbox'>
|
print "<label class='checkbox'>
|
||||||
<input type='checkbox' $auth_checked name='need_auth' dojoType='dijit.form.CheckBox' id='feedEditDlg_loginCheck'
|
<input type='checkbox' $auth_checked name='need_auth' dojoType='dijit.form.CheckBox' id='feedEditDlg_loginCheck'
|
||||||
onclick='displayIfChecked(this, \"feedEditDlg_loginContainer\")'>
|
onclick='App.displayIfChecked(this, \"feedEditDlg_loginContainer\")'>
|
||||||
".__('This feed requires authentication.')."</label>";
|
".__('This feed requires authentication.')."</label>";
|
||||||
|
|
||||||
print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Options').'">';
|
print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Options').'">';
|
||||||
|
@ -1672,7 +1672,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
|
|
||||||
print "<fieldset class='narrow'>
|
print "<fieldset class='narrow'>
|
||||||
<label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox'
|
<label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox'
|
||||||
onclick='displayIfChecked(this, \"feedDlg_loginContainer\")'> ".
|
onclick='App.displayIfChecked(this, \"feedDlg_loginContainer\")'> ".
|
||||||
__('Feeds require authentication.')."</label></div>";
|
__('Feeds require authentication.')."</label></div>";
|
||||||
print "</fieldset>";
|
print "</fieldset>";
|
||||||
|
|
||||||
|
|
44
js/App.js
44
js/App.js
|
@ -1,8 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/* global __, ngettext, Article, Headlines, Filters */
|
/* global __, Article, Ajax, Headlines, Filters */
|
||||||
/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds, Cookie */
|
/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds, Cookie */
|
||||||
/* global CommonDialogs, CommonFilters, Plugins */
|
/* global CommonDialogs, Plugins, Effect */
|
||||||
|
|
||||||
const App = {
|
const App = {
|
||||||
_initParams: [],
|
_initParams: [],
|
||||||
|
@ -12,8 +12,10 @@ const App = {
|
||||||
hotkey_prefix_timeout: 0,
|
hotkey_prefix_timeout: 0,
|
||||||
global_unread: -1,
|
global_unread: -1,
|
||||||
_widescreen_mode: false,
|
_widescreen_mode: false,
|
||||||
|
_loading_progress: 0,
|
||||||
hotkey_actions: {},
|
hotkey_actions: {},
|
||||||
is_prefs: false,
|
is_prefs: false,
|
||||||
|
LABEL_BASE_INDEX: -1024,
|
||||||
Scrollable: {
|
Scrollable: {
|
||||||
scrollByPages: function (elem, page_offset) {
|
scrollByPages: function (elem, page_offset) {
|
||||||
if (!elem) return;
|
if (!elem) return;
|
||||||
|
@ -47,6 +49,12 @@ const App = {
|
||||||
elem.offsetTop >= ctr.scrollTop;
|
elem.offsetTop >= ctr.scrollTop;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
label_to_feed_id: function(label) {
|
||||||
|
return this.LABEL_BASE_INDEX - 1 - Math.abs(label);
|
||||||
|
},
|
||||||
|
feed_to_label_id: function(feed) {
|
||||||
|
return this.LABEL_BASE_INDEX - 1 + Math.abs(feed);
|
||||||
|
},
|
||||||
getInitParam: function(k) {
|
getInitParam: function(k) {
|
||||||
return this._initParams[k];
|
return this._initParams[k];
|
||||||
},
|
},
|
||||||
|
@ -130,12 +138,12 @@ const App = {
|
||||||
return this._rpc_seq;
|
return this._rpc_seq;
|
||||||
},
|
},
|
||||||
setLoadingProgress: function(p) {
|
setLoadingProgress: function(p) {
|
||||||
loading_progress += p;
|
this._loading_progress += p;
|
||||||
|
|
||||||
if (dijit.byId("loading_bar"))
|
if (dijit.byId("loading_bar"))
|
||||||
dijit.byId("loading_bar").update({progress: loading_progress});
|
dijit.byId("loading_bar").update({progress: this._loading_progress});
|
||||||
|
|
||||||
if (loading_progress >= 90) {
|
if (this._loading_progress >= 90) {
|
||||||
$("overlay").hide();
|
$("overlay").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +232,25 @@ const App = {
|
||||||
i.parentNode ? i.parentNode.removeChild(i) : true;
|
i.parentNode ? i.parentNode.removeChild(i) : true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// htmlspecialchars()-alike for headlines data-content attribute
|
||||||
|
escapeHtml: function(text) {
|
||||||
|
const map = {
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
"'": '''
|
||||||
|
};
|
||||||
|
|
||||||
|
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
|
||||||
|
},
|
||||||
|
displayIfChecked: function(checkbox, elemId) {
|
||||||
|
if (checkbox.checked) {
|
||||||
|
Effect.Appear(elemId, {duration : 0.5});
|
||||||
|
} else {
|
||||||
|
Effect.Fade(elemId, {duration : 0.5});
|
||||||
|
}
|
||||||
|
},
|
||||||
helpDialog: function(topic) {
|
helpDialog: function(topic) {
|
||||||
const query = "backend.php?op=backend&method=help&topic=" + encodeURIComponent(topic);
|
const query = "backend.php?op=backend&method=help&topic=" + encodeURIComponent(topic);
|
||||||
|
|
||||||
|
@ -418,7 +445,7 @@ const App = {
|
||||||
if (params.hasOwnProperty(k)) {
|
if (params.hasOwnProperty(k)) {
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case "label_base_index":
|
case "label_base_index":
|
||||||
LABEL_BASE_INDEX = parseInt(params[k]);
|
this.LABEL_BASE_INDEX = parseInt(params[k]);
|
||||||
break;
|
break;
|
||||||
case "cdm_auto_catchup":
|
case "cdm_auto_catchup":
|
||||||
if (params[k] == 1) {
|
if (params[k] == 1) {
|
||||||
|
@ -429,7 +456,7 @@ const App = {
|
||||||
case "hotkeys":
|
case "hotkeys":
|
||||||
// filter mnemonic definitions (used for help panel) from hotkeys map
|
// filter mnemonic definitions (used for help panel) from hotkeys map
|
||||||
// i.e. *(191)|Ctrl-/ -> *(191)
|
// i.e. *(191)|Ctrl-/ -> *(191)
|
||||||
|
{
|
||||||
const tmp = [];
|
const tmp = [];
|
||||||
for (const sequence in params[k][1]) {
|
for (const sequence in params[k][1]) {
|
||||||
if (params[k][1].hasOwnProperty(sequence)) {
|
if (params[k][1].hasOwnProperty(sequence)) {
|
||||||
|
@ -439,6 +466,7 @@ const App = {
|
||||||
}
|
}
|
||||||
|
|
||||||
params[k][1] = tmp;
|
params[k][1] = tmp;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,7 +615,7 @@ const App = {
|
||||||
['MutationObserver'].each(function(wf) {
|
['MutationObserver'].each(function(wf) {
|
||||||
if (!(wf in window)) {
|
if (!(wf in window)) {
|
||||||
errorMsg = `Browser feature check failed: <code>window.${wf}</code> not found.`;
|
errorMsg = `Browser feature check failed: <code>window.${wf}</code> not found.`;
|
||||||
throw $break;
|
throw new Error(errorMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, escapeHtml */
|
/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Ajax */
|
||||||
|
|
||||||
const Article = {
|
const Article = {
|
||||||
_scroll_reset_timeout: false,
|
_scroll_reset_timeout: false,
|
||||||
|
@ -86,6 +86,22 @@ const Article = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
popupOpenUrl: function(url) {
|
||||||
|
const w = window.open("");
|
||||||
|
|
||||||
|
w.opener = null;
|
||||||
|
w.location = url;
|
||||||
|
},
|
||||||
|
/* popupOpenArticle: function(id) {
|
||||||
|
const w = window.open("",
|
||||||
|
"ttrss_article_popup",
|
||||||
|
"height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no");
|
||||||
|
|
||||||
|
if (w) {
|
||||||
|
w.opener = null;
|
||||||
|
w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + App.getInitParam("csrf_token");
|
||||||
|
}
|
||||||
|
}, */
|
||||||
cdmUnsetActive: function (event) {
|
cdmUnsetActive: function (event) {
|
||||||
const row = $("RROW-" + Article.getActive());
|
const row = $("RROW-" + Article.getActive());
|
||||||
|
|
||||||
|
@ -157,14 +173,14 @@ const Article = {
|
||||||
comments_msg = hl.num_comments + " " + ngettext("comment", "comments", hl.num_comments)
|
comments_msg = hl.num_comments + " " + ngettext("comment", "comments", hl.num_comments)
|
||||||
}
|
}
|
||||||
|
|
||||||
comments = `<a href="${escapeHtml(hl.comments ? hl.comments : hl.link)}">(${comments_msg})</a>`;
|
comments = `<a href="${App.escapeHtml(hl.comments ? hl.comments : hl.link)}">(${comments_msg})</a>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return comments;
|
return comments;
|
||||||
},
|
},
|
||||||
formatOriginallyFrom: function(hl) {
|
formatOriginallyFrom: function(hl) {
|
||||||
return hl.orig_feed ? `<span>
|
return hl.orig_feed ? `<span>
|
||||||
${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${escapeHtml(hl.orig_feed[1])}">${hl.orig_feed[0]}</a>
|
${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.orig_feed[1])}">${hl.orig_feed[0]}</a>
|
||||||
</span>` : "";
|
</span>` : "";
|
||||||
},
|
},
|
||||||
unpack: function(row) {
|
unpack: function(row) {
|
||||||
|
@ -213,8 +229,8 @@ const Article = {
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="title"><a target="_blank" rel="noopener noreferrer"
|
<div class="title"><a target="_blank" rel="noopener noreferrer"
|
||||||
title="${escapeHtml(hl.title)}"
|
title="${App.escapeHtml(hl.title)}"
|
||||||
href="${escapeHtml(hl.link)}">${hl.title}</a></div>
|
href="${App.escapeHtml(hl.link)}">${hl.title}</a></div>
|
||||||
<div class="date">${hl.updated_long}</div>
|
<div class="date">${hl.updated_long}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
@ -46,6 +46,7 @@ const CommonDialogs = {
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
switch (parseInt(this.responseText)) {
|
switch (parseInt(this.responseText)) {
|
||||||
case 0:
|
case 0:
|
||||||
|
{
|
||||||
Notify.info("Upload complete.");
|
Notify.info("Upload complete.");
|
||||||
|
|
||||||
if (App.isPrefs())
|
if (App.isPrefs())
|
||||||
|
@ -58,6 +59,7 @@ const CommonDialogs = {
|
||||||
if (icon)
|
if (icon)
|
||||||
icon.src = icon.src.replace(/\?[0-9]+$/, "?" + new Date().getTime());
|
icon.src = icon.src.replace(/\?[0-9]+$/, "?" + new Date().getTime());
|
||||||
|
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Notify.error("Upload failed: icon is too big.");
|
Notify.error("Upload failed: icon is too big.");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
/* global __, ngettext, App, Article, Lists */
|
/* global __, App, Article, Lists, Effect */
|
||||||
/* global xhrPost, xhrJson, dojo, dijit, Notify, $$, Feeds */
|
/* global xhrPost, dojo, dijit, Notify, $$, Feeds */
|
||||||
|
|
||||||
const Filters = {
|
const Filters = {
|
||||||
filterDlgCheckAction: function(sender) {
|
filterDlgCheckAction: function(sender) {
|
||||||
|
@ -337,6 +337,7 @@ const Filters = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!App.isPrefs()) {
|
if (!App.isPrefs()) {
|
||||||
|
/* global getSelectionText */
|
||||||
const selectedText = getSelectionText();
|
const selectedText = getSelectionText();
|
||||||
|
|
||||||
const lh = dojo.connect(dialog, "onLoad", function () {
|
const lh = dojo.connect(dialog, "onLoad", function () {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global dojo, dijit, define, App, Feeds, CommonDialogs, LABEL_BASE_INDEX */
|
/* global dojo, dijit, define, App, Feeds, CommonDialogs */
|
||||||
|
|
||||||
define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) {
|
define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) {
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
||||||
const id = args.item.id[0];
|
const id = args.item.id[0];
|
||||||
const bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
const bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
||||||
|
|
||||||
if (bare_id < LABEL_BASE_INDEX) {
|
if (bare_id < App.LABEL_BASE_INDEX) {
|
||||||
const label = dojo.create('i', { className: "material-icons icon icon-label", innerHTML: "label" });
|
const label = dojo.create('i', { className: "material-icons icon icon-label", innerHTML: "label" });
|
||||||
|
|
||||||
//const fg_color = args.item.fg_color[0];
|
//const fg_color = args.item.fg_color[0];
|
||||||
|
@ -164,9 +164,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
||||||
if (item.auxcounter > 0) rc += " Has_Aux";
|
if (item.auxcounter > 0) rc += " Has_Aux";
|
||||||
if (item.markedcounter > 0) rc += " Has_Marked";
|
if (item.markedcounter > 0) rc += " Has_Marked";
|
||||||
if (item.updates_disabled > 0) rc += " UpdatesDisabled";
|
if (item.updates_disabled > 0) rc += " UpdatesDisabled";
|
||||||
if (item.bare_id >= LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id == 0 && !is_cat) rc += " Special";
|
if (item.bare_id >= App.LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id == 0 && !is_cat) rc += " Special";
|
||||||
if (item.bare_id == -1 && is_cat) rc += " AlwaysVisible";
|
if (item.bare_id == -1 && is_cat) rc += " AlwaysVisible";
|
||||||
if (item.bare_id < LABEL_BASE_INDEX) rc += " Label";
|
if (item.bare_id < App.LABEL_BASE_INDEX) rc += " Label";
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/* global __, ngettext, Article, App, escapeHtml */
|
/* global __, ngettext, Article, App */
|
||||||
/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds */
|
/* global xhrPost, dojo, dijit, PluginHost, Notify, $$, Feeds */
|
||||||
/* global CommonDialogs */
|
/* global CommonDialogs */
|
||||||
|
|
||||||
const Headlines = {
|
const Headlines = {
|
||||||
|
@ -402,7 +402,7 @@ const Headlines = {
|
||||||
if (headlines.vfeed_group_enabled) row_class += " vgrlf";
|
if (headlines.vfeed_group_enabled) row_class += " vgrlf";
|
||||||
|
|
||||||
if (headlines.vfeed_group_enabled && hl.feed_title && this.vgroup_last_feed != hl.feed_id) {
|
if (headlines.vfeed_group_enabled && hl.feed_title && this.vgroup_last_feed != hl.feed_id) {
|
||||||
let vgrhdr = `<div data-feed-id='${hl.feed_id}' class='feed-title'>
|
const vgrhdr = `<div data-feed-id='${hl.feed_id}' class='feed-title'>
|
||||||
<div style='float : right'>${hl.feed_icon}</div>
|
<div style='float : right'>${hl.feed_icon}</div>
|
||||||
<a class="title" href="#" onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title}
|
<a class="title" href="#" onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title}
|
||||||
<a class="catchup" title="${__('mark feed as read')}" onclick="Feeds.catchupFeedInGroup(${hl.feed_id})" href="#"><i class="icon-done material-icons">done_all</i></a>
|
<a class="catchup" title="${__('mark feed as read')}" onclick="Feeds.catchupFeedInGroup(${hl.feed_id})" href="#"><i class="icon-done material-icons">done_all</i></a>
|
||||||
|
@ -426,9 +426,9 @@ const Headlines = {
|
||||||
id="RROW-${hl.id}"
|
id="RROW-${hl.id}"
|
||||||
data-article-id="${hl.id}"
|
data-article-id="${hl.id}"
|
||||||
data-orig-feed-id="${hl.feed_id}"
|
data-orig-feed-id="${hl.feed_id}"
|
||||||
data-content="${escapeHtml(hl.content)}"
|
data-content="${App.escapeHtml(hl.content)}"
|
||||||
data-score="${hl.score}"
|
data-score="${hl.score}"
|
||||||
data-article-title="${escapeHtml(hl.title)}"
|
data-article-title="${App.escapeHtml(hl.title)}"
|
||||||
onmouseover="Article.mouseIn(${hl.id})"
|
onmouseover="Article.mouseIn(${hl.id})"
|
||||||
onmouseout="Article.mouseOut(${hl.id})">
|
onmouseout="Article.mouseOut(${hl.id})">
|
||||||
<div class="header-sticky-guard"></div>
|
<div class="header-sticky-guard"></div>
|
||||||
|
@ -440,7 +440,7 @@ const Headlines = {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span onclick="return Headlines.click(event, ${hl.id});" data-article-id="${hl.id}" class="titleWrap hlMenuAttach">
|
<span onclick="return Headlines.click(event, ${hl.id});" data-article-id="${hl.id}" class="titleWrap hlMenuAttach">
|
||||||
<a class="title" title="${escapeHtml(hl.title)}" target="_blank" rel="noopener noreferrer" href="${escapeHtml(hl.link)}">
|
<a class="title" title="${App.escapeHtml(hl.title)}" target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.link)}">
|
||||||
${hl.title}</a>
|
${hl.title}</a>
|
||||||
<span class="author">${hl.author}</span>
|
<span class="author">${hl.author}</span>
|
||||||
${hl.labels}
|
${hl.labels}
|
||||||
|
@ -457,7 +457,7 @@ const Headlines = {
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i>
|
<i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i>
|
||||||
|
|
||||||
<span style="cursor : pointer" title="${escapeHtml(hl.feed_title)}" onclick="Feeds.open({feed:${hl.feed_id}})">
|
<span style="cursor : pointer" title="${App.escapeHtml(hl.feed_title)}" onclick="Feeds.open({feed:${hl.feed_id}})">
|
||||||
${hl.feed_icon}</span>
|
${hl.feed_icon}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ const Headlines = {
|
||||||
data-orig-feed-id="${hl.feed_id}"
|
data-orig-feed-id="${hl.feed_id}"
|
||||||
data-article-id="${hl.id}"
|
data-article-id="${hl.id}"
|
||||||
data-score="${hl.score}"
|
data-score="${hl.score}"
|
||||||
data-article-title="${escapeHtml(hl.title)}"
|
data-article-title="${App.escapeHtml(hl.title)}"
|
||||||
onmouseover="Article.mouseIn(${hl.id})"
|
onmouseover="Article.mouseIn(${hl.id})"
|
||||||
onmouseout="Article.mouseOut(${hl.id})">
|
onmouseout="Article.mouseOut(${hl.id})">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
|
@ -507,7 +507,7 @@ const Headlines = {
|
||||||
</div>
|
</div>
|
||||||
<div onclick="return Headlines.click(event, ${hl.id})" class="title">
|
<div onclick="return Headlines.click(event, ${hl.id})" class="title">
|
||||||
<span data-article-id="${hl.id}" class="hl-content hlMenuAttach">
|
<span data-article-id="${hl.id}" class="hl-content hlMenuAttach">
|
||||||
<a class="title" href="${escapeHtml(hl.link)}">${hl.title} <span class="preview">${hl.content_preview}</span></a>
|
<a class="title" href="${App.escapeHtml(hl.link)}">${hl.title} <span class="preview">${hl.content_preview}</span></a>
|
||||||
<span class="author">${hl.author}</span>
|
<span class="author">${hl.author}</span>
|
||||||
${hl.labels}
|
${hl.labels}
|
||||||
</span>
|
</span>
|
||||||
|
@ -520,7 +520,7 @@ const Headlines = {
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i>
|
<i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i>
|
||||||
<span onclick="Feeds.open({feed:${hl.feed_id}})" style="cursor : pointer" title="${escapeHtml(hl.feed_title)}">${hl.feed_icon}</span>
|
<span onclick="Feeds.open({feed:${hl.feed_id}})" style="cursor : pointer" title="${App.escapeHtml(hl.feed_title)}">${hl.feed_icon}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
@ -685,7 +685,7 @@ const Headlines = {
|
||||||
|
|
||||||
console.log("no headlines received, infscroll_disabled=", Feeds.infscroll_disabled, 'first_id_changed=', first_id_changed);
|
console.log("no headlines received, infscroll_disabled=", Feeds.infscroll_disabled, 'first_id_changed=', first_id_changed);
|
||||||
|
|
||||||
let hsp = $("headlines-spacer");
|
const hsp = $("headlines-spacer");
|
||||||
|
|
||||||
if (hsp) {
|
if (hsp) {
|
||||||
if (first_id_changed) {
|
if (first_id_changed) {
|
||||||
|
@ -1207,6 +1207,7 @@ const Headlines = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onActionChanged: function (elem) {
|
onActionChanged: function (elem) {
|
||||||
|
// eslint-disable-next-line no-eval
|
||||||
eval(elem.value);
|
eval(elem.value);
|
||||||
elem.attr('value', 'false');
|
elem.attr('value', 'false');
|
||||||
},
|
},
|
||||||
|
|
78
js/common.js
78
js/common.js
|
@ -1,21 +1,19 @@
|
||||||
'use strict'
|
'use strict';
|
||||||
/* global dijit, __ */
|
|
||||||
|
|
||||||
let LABEL_BASE_INDEX = -1024; /* not const because it's assigned at least once (by backend) */
|
/* global dijit, __, App, Ajax */
|
||||||
let loading_progress = 0;
|
|
||||||
|
|
||||||
/* error reporting shim */
|
/* error reporting shim */
|
||||||
|
|
||||||
// TODO: deprecated; remove
|
// TODO: deprecated; remove
|
||||||
function exception_error(e, e_compat, filename, lineno, colno) {
|
/* function exception_error(e, e_compat, filename, lineno, colno) {
|
||||||
if (typeof e == "string")
|
if (typeof e == "string")
|
||||||
e = e_compat;
|
e = e_compat;
|
||||||
|
|
||||||
App.Error.report(e, {filename: filename, lineno: lineno, colno: colno});
|
App.Error.report(e, {filename: filename, lineno: lineno, colno: colno});
|
||||||
}
|
} */
|
||||||
|
|
||||||
/* xhr shorthand helpers */
|
/* xhr shorthand helpers */
|
||||||
|
|
||||||
|
/* exported xhrPost */
|
||||||
function xhrPost(url, params, complete) {
|
function xhrPost(url, params, complete) {
|
||||||
console.log("xhrPost:", params);
|
console.log("xhrPost:", params);
|
||||||
|
|
||||||
|
@ -31,6 +29,7 @@ function xhrPost(url, params, complete) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* exported xhrJson */
|
||||||
function xhrJson(url, params, complete) {
|
function xhrJson(url, params, complete) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
return xhrPost(url, params).then((reply) => {
|
return xhrPost(url, params).then((reply) => {
|
||||||
|
@ -58,6 +57,7 @@ Array.prototype.remove = function(s) {
|
||||||
|
|
||||||
/* common helpers not worthy of separate Dojo modules */
|
/* common helpers not worthy of separate Dojo modules */
|
||||||
|
|
||||||
|
/* exported Lists */
|
||||||
const Lists = {
|
const Lists = {
|
||||||
onRowChecked: function(elem) {
|
onRowChecked: function(elem) {
|
||||||
const checked = elem.domNode ? elem.attr("checked") : elem.checked;
|
const checked = elem.domNode ? elem.attr("checked") : elem.checked;
|
||||||
|
@ -87,7 +87,7 @@ const Lists = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// noinspection JSUnusedGlobalSymbols
|
/* exported Tables */
|
||||||
const Tables = {
|
const Tables = {
|
||||||
onRowChecked: function(elem) {
|
onRowChecked: function(elem) {
|
||||||
// account for dojo checkboxes
|
// account for dojo checkboxes
|
||||||
|
@ -133,6 +133,7 @@ const Tables = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* exported Cookie */
|
||||||
const Cookie = {
|
const Cookie = {
|
||||||
set: function (name, value, lifetime) {
|
set: function (name, value, lifetime) {
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
|
@ -152,12 +153,12 @@ const Cookie = {
|
||||||
},
|
},
|
||||||
delete: function(name) {
|
delete: function(name) {
|
||||||
const expires = "expires=Thu, 01-Jan-1970 00:00:01 GMT";
|
const expires = "expires=Thu, 01-Jan-1970 00:00:01 GMT";
|
||||||
document.cookie = name + "=" + "" + "; " + expires;
|
document.cookie = name + "=; " + expires;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* runtime notifications */
|
/* runtime notifications */
|
||||||
|
/* exported Notify */
|
||||||
const Notify = {
|
const Notify = {
|
||||||
KIND_GENERIC: 0,
|
KIND_GENERIC: 0,
|
||||||
KIND_INFO: 1,
|
KIND_INFO: 1,
|
||||||
|
@ -237,30 +238,8 @@ const Notify = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// noinspection JSUnusedGlobalSymbols
|
|
||||||
function displayIfChecked(checkbox, elemId) {
|
|
||||||
if (checkbox.checked) {
|
|
||||||
Effect.Appear(elemId, {duration : 0.5});
|
|
||||||
} else {
|
|
||||||
Effect.Fade(elemId, {duration : 0.5});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* function strip_tags(s) {
|
|
||||||
return s.replace(/<\/?[^>]+(>|$)/g, "");
|
|
||||||
} */
|
|
||||||
|
|
||||||
// noinspection JSUnusedGlobalSymbols
|
|
||||||
function label_to_feed_id(label) {
|
|
||||||
return LABEL_BASE_INDEX - 1 - Math.abs(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
// noinspection JSUnusedGlobalSymbols
|
|
||||||
function feed_to_label_id(feed) {
|
|
||||||
return LABEL_BASE_INDEX - 1 + Math.abs(feed);
|
|
||||||
}
|
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac
|
// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac
|
||||||
|
/* exported getSelectionText */
|
||||||
function getSelectionText() {
|
function getSelectionText() {
|
||||||
let text = "";
|
let text = "";
|
||||||
|
|
||||||
|
@ -281,36 +260,3 @@ function getSelectionText() {
|
||||||
|
|
||||||
return text.stripTags();
|
return text.stripTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
// noinspection JSUnusedGlobalSymbols
|
|
||||||
function popupOpenUrl(url) {
|
|
||||||
const w = window.open("");
|
|
||||||
|
|
||||||
w.opener = null;
|
|
||||||
w.location = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
// noinspection JSUnusedGlobalSymbols
|
|
||||||
function popupOpenArticle(id) {
|
|
||||||
const w = window.open("",
|
|
||||||
"ttrss_article_popup",
|
|
||||||
"height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no");
|
|
||||||
|
|
||||||
if (w) {
|
|
||||||
w.opener = null;
|
|
||||||
w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + App.getInitParam("csrf_token");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// htmlspecialchars()-alike for headlines data-content attribute
|
|
||||||
function escapeHtml(text) {
|
|
||||||
const map = {
|
|
||||||
'&': '&',
|
|
||||||
'<': '<',
|
|
||||||
'>': '>',
|
|
||||||
'"': '"',
|
|
||||||
"'": '''
|
|
||||||
};
|
|
||||||
|
|
||||||
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue