don't use declare() for static objects with no inheritance because apparently it's not actually needed by AMD
This commit is contained in:
parent
06cc6e3a2a
commit
e37f8cfa78
644
js/Article.js
644
js/Article.js
|
@ -1,355 +1,351 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
/* global __, ngettext */
|
/* global __, ngettext */
|
||||||
define(["dojo/_base/declare"], function (declare) {
|
const Article = {
|
||||||
Article = {
|
_scroll_reset_timeout: false,
|
||||||
_scroll_reset_timeout: false,
|
getScoreClass: function (score) {
|
||||||
getScoreClass: function (score) {
|
if (score > 500) {
|
||||||
if (score > 500) {
|
return "score-high";
|
||||||
return "score-high";
|
} else if (score > 0) {
|
||||||
} else if (score > 0) {
|
return "score-half-high";
|
||||||
return "score-half-high";
|
} else if (score < -100) {
|
||||||
} else if (score < -100) {
|
return "score-low";
|
||||||
return "score-low";
|
} else if (score < 0) {
|
||||||
} else if (score < 0) {
|
return "score-half-low";
|
||||||
return "score-half-low";
|
} else {
|
||||||
} else {
|
return "score-neutral";
|
||||||
return "score-neutral";
|
}
|
||||||
|
},
|
||||||
|
getScorePic: function (score) {
|
||||||
|
if (score > 500) {
|
||||||
|
return "trending_up";
|
||||||
|
} else if (score > 0) {
|
||||||
|
return "trending_up";
|
||||||
|
} else if (score < 0) {
|
||||||
|
return "trending_down";
|
||||||
|
} else {
|
||||||
|
return "trending_neutral";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectionSetScore: function () {
|
||||||
|
const ids = Headlines.getSelected();
|
||||||
|
|
||||||
|
if (ids.length > 0) {
|
||||||
|
const score = prompt(__("Please enter new score for selected articles:"));
|
||||||
|
|
||||||
|
if (!isNaN(parseInt(score))) {
|
||||||
|
ids.each((id) => {
|
||||||
|
const row = $("RROW-" + id);
|
||||||
|
|
||||||
|
if (row) {
|
||||||
|
row.setAttribute("data-score", score);
|
||||||
|
|
||||||
|
const pic = row.select(".icon-score")[0];
|
||||||
|
|
||||||
|
pic.innerHTML = Article.getScorePic(score);
|
||||||
|
pic.setAttribute("title", score);
|
||||||
|
|
||||||
|
["score-low", "score-high", "score-half-low", "score-half-high", "score-neutral"]
|
||||||
|
.each(function(scl) {
|
||||||
|
if (row.hasClassName(scl))
|
||||||
|
row.removeClassName(scl);
|
||||||
|
});
|
||||||
|
|
||||||
|
row.addClassName(Article.getScoreClass(score));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
|
||||||
getScorePic: function (score) {
|
} else {
|
||||||
if (score > 500) {
|
alert(__("No articles selected."));
|
||||||
return "trending_up";
|
}
|
||||||
} else if (score > 0) {
|
},
|
||||||
return "trending_up";
|
setScore: function (id, pic) {
|
||||||
} else if (score < 0) {
|
const row = pic.up("div[id*=RROW]");
|
||||||
return "trending_down";
|
|
||||||
} else {
|
if (row) {
|
||||||
return "trending_neutral";
|
const score_old = row.getAttribute("data-score");
|
||||||
|
const score = prompt(__("Please enter new score for this article:"), score_old);
|
||||||
|
|
||||||
|
if (!isNaN(parseInt(score))) {
|
||||||
|
row.setAttribute("data-score", score);
|
||||||
|
|
||||||
|
const pic = row.select(".icon-score")[0];
|
||||||
|
|
||||||
|
pic.innerHTML = Article.getScorePic(score);
|
||||||
|
pic.setAttribute("title", score);
|
||||||
|
|
||||||
|
["score-low", "score-high", "score-half-low", "score-half-high", "score-neutral"]
|
||||||
|
.each(function(scl) {
|
||||||
|
if (row.hasClassName(scl))
|
||||||
|
row.removeClassName(scl);
|
||||||
|
});
|
||||||
|
|
||||||
|
row.addClassName(Article.getScoreClass(score));
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
selectionSetScore: function () {
|
},
|
||||||
const ids = Headlines.getSelected();
|
cdmUnsetActive: function (event) {
|
||||||
|
const row = $("RROW-" + Article.getActive());
|
||||||
|
|
||||||
if (ids.length > 0) {
|
if (row) {
|
||||||
const score = prompt(__("Please enter new score for selected articles:"));
|
row.removeClassName("active");
|
||||||
|
|
||||||
if (!isNaN(parseInt(score))) {
|
if (event)
|
||||||
ids.each((id) => {
|
event.stopPropagation();
|
||||||
const row = $("RROW-" + id);
|
|
||||||
|
|
||||||
if (row) {
|
return false;
|
||||||
row.setAttribute("data-score", score);
|
}
|
||||||
|
},
|
||||||
|
close: function () {
|
||||||
|
if (dijit.byId("content-insert"))
|
||||||
|
dijit.byId("headlines-wrap-inner").removeChild(
|
||||||
|
dijit.byId("content-insert"));
|
||||||
|
|
||||||
const pic = row.select(".icon-score")[0];
|
Article.setActive(0);
|
||||||
|
},
|
||||||
|
displayUrl: function (id) {
|
||||||
|
const query = {op: "rpc", method: "getlinktitlebyid", id: id};
|
||||||
|
|
||||||
pic.innerHTML = Article.getScorePic(score);
|
xhrJson("backend.php", query, (reply) => {
|
||||||
pic.setAttribute("title", score);
|
if (reply && reply.link) {
|
||||||
|
prompt(__("Article URL:"), reply.link);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
openInNewWindow: function (id) {
|
||||||
|
const w = window.open("");
|
||||||
|
|
||||||
["score-low", "score-high", "score-half-low", "score-half-high", "score-neutral"]
|
if (w) {
|
||||||
.each(function(scl) {
|
w.opener = null;
|
||||||
if (row.hasClassName(scl))
|
w.location = "backend.php?op=article&method=redirect&id=" + id;
|
||||||
row.removeClassName(scl);
|
|
||||||
});
|
|
||||||
|
|
||||||
row.addClassName(Article.getScoreClass(score));
|
Headlines.toggleUnread(id, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
render: function (article) {
|
||||||
|
App.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);
|
||||||
|
|
||||||
|
//Headlines.correctHeadlinesOffset(Article.getActive());
|
||||||
|
|
||||||
|
try {
|
||||||
|
c.focus();
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatComments: function(hl) {
|
||||||
|
let comments = "";
|
||||||
|
|
||||||
|
if (hl.comments || hl.num_comments > 0) {
|
||||||
|
let comments_msg = __("comments");
|
||||||
|
|
||||||
|
if (hl.num_comments > 0) {
|
||||||
|
comments_msg = hl.num_comments + " " + ngettext("comment", "comments", hl.num_comments)
|
||||||
|
}
|
||||||
|
|
||||||
|
comments = `<a href="${escapeHtml(hl.comments ? hl.comments : hl.link)}">(${comments_msg})</a>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return comments;
|
||||||
|
},
|
||||||
|
formatOriginallyFrom: function(hl) {
|
||||||
|
return hl.orig_feed ? `<span>
|
||||||
|
${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${escapeHtml(hl.orig_feed[1])}">${hl.orig_feed[0]}</a>
|
||||||
|
</span>` : "";
|
||||||
|
},
|
||||||
|
unpack: function(row) {
|
||||||
|
if (row.hasAttribute("data-content")) {
|
||||||
|
console.log("unpacking: " + row.id);
|
||||||
|
|
||||||
|
const container = row.querySelector(".content-inner");
|
||||||
|
|
||||||
|
container.innerHTML = row.getAttribute("data-content").trim();
|
||||||
|
|
||||||
|
// blank content element might screw up onclick selection and keyboard moving
|
||||||
|
if (container.textContent.length == 0)
|
||||||
|
container.innerHTML += " ";
|
||||||
|
|
||||||
|
// in expandable mode, save content for later, so that we can pack unfocused rows back
|
||||||
|
if (App.isCombinedMode() && $("main").hasClassName("expandable"))
|
||||||
|
row.setAttribute("data-content-original", row.getAttribute("data-content"));
|
||||||
|
|
||||||
|
row.removeAttribute("data-content");
|
||||||
|
|
||||||
|
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
pack: function(row) {
|
||||||
|
if (row.hasAttribute("data-content-original")) {
|
||||||
|
console.log("packing", row.id);
|
||||||
|
row.setAttribute("data-content", row.getAttribute("data-content-original"));
|
||||||
|
row.removeAttribute("data-content-original");
|
||||||
|
|
||||||
|
row.querySelector(".content-inner").innerHTML = " ";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
view: function (id, no_expand) {
|
||||||
|
this.setActive(id);
|
||||||
|
Headlines.scrollToArticleId(id);
|
||||||
|
|
||||||
|
if (!no_expand) {
|
||||||
|
const hl = Headlines.objectById(id);
|
||||||
|
|
||||||
|
if (hl) {
|
||||||
|
|
||||||
|
const comments = this.formatComments(hl);
|
||||||
|
const originally_from = this.formatOriginallyFrom(hl);
|
||||||
|
|
||||||
|
const article = `<div class="post post-${hl.id}" data-article-id="${hl.id}">
|
||||||
|
<div class="header">
|
||||||
|
<div class="row">
|
||||||
|
<div class="title"><a target="_blank" rel="noopener noreferrer"
|
||||||
|
title="${escapeHtml(hl.title)}"
|
||||||
|
href="${escapeHtml(hl.link)}">${hl.title}</a></div>
|
||||||
|
<div class="date">${hl.updated_long}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="buttons left">${hl.buttons_left}</div>
|
||||||
|
<div class="comments">${comments}</div>
|
||||||
|
<div class="author">${hl.author}</div>
|
||||||
|
<i class="material-icons">label_outline</i>
|
||||||
|
<span id="ATSTR-${hl.id}">${hl.tags_str}</span>
|
||||||
|
<a title="${__("Edit tags for this article")}" href="#"
|
||||||
|
onclick="Article.editTags(${hl.id})">(+)</a>
|
||||||
|
<div class="buttons right">${hl.buttons}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="POSTNOTE-${hl.id}">${hl.note}</div>
|
||||||
|
<div class="content" lang="${hl.lang ? hl.lang : 'en'}">
|
||||||
|
${originally_from}
|
||||||
|
${hl.content}
|
||||||
|
${hl.enclosures}
|
||||||
|
</div>
|
||||||
|
</div>`;
|
||||||
|
|
||||||
|
Headlines.toggleUnread(id, 0);
|
||||||
|
this.render(article);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
editTags: function (id) {
|
||||||
|
const query = "backend.php?op=article&method=editArticleTags¶m=" + encodeURIComponent(id);
|
||||||
|
|
||||||
|
if (dijit.byId("editTagsDlg"))
|
||||||
|
dijit.byId("editTagsDlg").destroyRecursive();
|
||||||
|
|
||||||
|
const dialog = new dijit.Dialog({
|
||||||
|
id: "editTagsDlg",
|
||||||
|
title: __("Edit article Tags"),
|
||||||
|
style: "width: 600px",
|
||||||
|
execute: function () {
|
||||||
|
if (this.validate()) {
|
||||||
|
Notify.progress("Saving article tags...", true);
|
||||||
|
|
||||||
|
xhrPost("backend.php", this.attr('value'), (transport) => {
|
||||||
|
try {
|
||||||
|
Notify.close();
|
||||||
|
dialog.hide();
|
||||||
|
|
||||||
|
const data = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
const id = data.id;
|
||||||
|
|
||||||
|
const tags = $("ATSTR-" + id);
|
||||||
|
const tooltip = dijit.byId("ATSTRTIP-" + id);
|
||||||
|
|
||||||
|
if (tags) tags.innerHTML = data.content;
|
||||||
|
if (tooltip) tooltip.attr('label', data.content_full);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
App.Error.report(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
href: query
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
const tmph = dojo.connect(dialog, 'onLoad', function () {
|
||||||
alert(__("No articles selected."));
|
dojo.disconnect(tmph);
|
||||||
}
|
|
||||||
},
|
|
||||||
setScore: function (id, pic) {
|
|
||||||
const row = pic.up("div[id*=RROW]");
|
|
||||||
|
|
||||||
if (row) {
|
new Ajax.Autocompleter('tags_str', 'tags_choices',
|
||||||
const score_old = row.getAttribute("data-score");
|
"backend.php?op=article&method=completeTags",
|
||||||
const score = prompt(__("Please enter new score for this article:"), score_old);
|
{tokens: ',', paramName: "search"});
|
||||||
|
});
|
||||||
|
|
||||||
if (!isNaN(parseInt(score))) {
|
dialog.show();
|
||||||
row.setAttribute("data-score", score);
|
},
|
||||||
|
cdmMoveToId: function (id, params) {
|
||||||
|
params = params || {};
|
||||||
|
|
||||||
const pic = row.select(".icon-score")[0];
|
const force_to_top = params.force_to_top || false;
|
||||||
|
|
||||||
pic.innerHTML = Article.getScorePic(score);
|
const ctr = $("headlines-frame");
|
||||||
pic.setAttribute("title", score);
|
const row = $("RROW-" + id);
|
||||||
|
|
||||||
["score-low", "score-high", "score-half-low", "score-half-high", "score-neutral"]
|
if (!row || !ctr) return;
|
||||||
.each(function(scl) {
|
|
||||||
if (row.hasClassName(scl))
|
|
||||||
row.removeClassName(scl);
|
|
||||||
});
|
|
||||||
|
|
||||||
row.addClassName(Article.getScoreClass(score));
|
if (force_to_top || !App.Scrollable.fitsInContainer(row, ctr)) {
|
||||||
}
|
ctr.scrollTop = row.offsetTop;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cdmUnsetActive: function (event) {
|
setActive: function (id) {
|
||||||
const row = $("RROW-" + Article.getActive());
|
if (id != Article.getActive()) {
|
||||||
|
console.log("setActive", id, "was", Article.getActive());
|
||||||
|
|
||||||
if (row) {
|
$$("div[id*=RROW][class*=active]").each((row) => {
|
||||||
row.removeClassName("active");
|
row.removeClassName("active");
|
||||||
|
Article.pack(row);
|
||||||
if (event)
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
close: function () {
|
|
||||||
if (dijit.byId("content-insert"))
|
|
||||||
dijit.byId("headlines-wrap-inner").removeChild(
|
|
||||||
dijit.byId("content-insert"));
|
|
||||||
|
|
||||||
Article.setActive(0);
|
|
||||||
},
|
|
||||||
displayUrl: function (id) {
|
|
||||||
const query = {op: "rpc", method: "getlinktitlebyid", id: id};
|
|
||||||
|
|
||||||
xhrJson("backend.php", query, (reply) => {
|
|
||||||
if (reply && reply.link) {
|
|
||||||
prompt(__("Article URL:"), reply.link);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
openInNewWindow: function (id) {
|
|
||||||
const w = window.open("");
|
|
||||||
|
|
||||||
if (w) {
|
|
||||||
w.opener = null;
|
|
||||||
w.location = "backend.php?op=article&method=redirect&id=" + id;
|
|
||||||
|
|
||||||
Headlines.toggleUnread(id, 0);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
render: function (article) {
|
|
||||||
App.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);
|
|
||||||
|
|
||||||
//Headlines.correctHeadlinesOffset(Article.getActive());
|
|
||||||
|
|
||||||
try {
|
|
||||||
c.focus();
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
formatComments: function(hl) {
|
|
||||||
let comments = "";
|
|
||||||
|
|
||||||
if (hl.comments || hl.num_comments > 0) {
|
|
||||||
let comments_msg = __("comments");
|
|
||||||
|
|
||||||
if (hl.num_comments > 0) {
|
|
||||||
comments_msg = hl.num_comments + " " + ngettext("comment", "comments", hl.num_comments)
|
|
||||||
}
|
|
||||||
|
|
||||||
comments = `<a href="${escapeHtml(hl.comments ? hl.comments : hl.link)}">(${comments_msg})</a>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return comments;
|
|
||||||
},
|
|
||||||
formatOriginallyFrom: function(hl) {
|
|
||||||
return hl.orig_feed ? `<span>
|
|
||||||
${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${escapeHtml(hl.orig_feed[1])}">${hl.orig_feed[0]}</a>
|
|
||||||
</span>` : "";
|
|
||||||
},
|
|
||||||
unpack: function(row) {
|
|
||||||
if (row.hasAttribute("data-content")) {
|
|
||||||
console.log("unpacking: " + row.id);
|
|
||||||
|
|
||||||
const container = row.querySelector(".content-inner");
|
|
||||||
|
|
||||||
container.innerHTML = row.getAttribute("data-content").trim();
|
|
||||||
|
|
||||||
// blank content element might screw up onclick selection and keyboard moving
|
|
||||||
if (container.textContent.length == 0)
|
|
||||||
container.innerHTML += " ";
|
|
||||||
|
|
||||||
// in expandable mode, save content for later, so that we can pack unfocused rows back
|
|
||||||
if (App.isCombinedMode() && $("main").hasClassName("expandable"))
|
|
||||||
row.setAttribute("data-content-original", row.getAttribute("data-content"));
|
|
||||||
|
|
||||||
row.removeAttribute("data-content");
|
|
||||||
|
|
||||||
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
pack: function(row) {
|
|
||||||
if (row.hasAttribute("data-content-original")) {
|
|
||||||
console.log("packing", row.id);
|
|
||||||
row.setAttribute("data-content", row.getAttribute("data-content-original"));
|
|
||||||
row.removeAttribute("data-content-original");
|
|
||||||
|
|
||||||
row.querySelector(".content-inner").innerHTML = " ";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
view: function (id, no_expand) {
|
|
||||||
this.setActive(id);
|
|
||||||
Headlines.scrollToArticleId(id);
|
|
||||||
|
|
||||||
if (!no_expand) {
|
|
||||||
const hl = Headlines.objectById(id);
|
|
||||||
|
|
||||||
if (hl) {
|
|
||||||
|
|
||||||
const comments = this.formatComments(hl);
|
|
||||||
const originally_from = this.formatOriginallyFrom(hl);
|
|
||||||
|
|
||||||
const article = `<div class="post post-${hl.id}" data-article-id="${hl.id}">
|
|
||||||
<div class="header">
|
|
||||||
<div class="row">
|
|
||||||
<div class="title"><a target="_blank" rel="noopener noreferrer"
|
|
||||||
title="${escapeHtml(hl.title)}"
|
|
||||||
href="${escapeHtml(hl.link)}">${hl.title}</a></div>
|
|
||||||
<div class="date">${hl.updated_long}</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="buttons left">${hl.buttons_left}</div>
|
|
||||||
<div class="comments">${comments}</div>
|
|
||||||
<div class="author">${hl.author}</div>
|
|
||||||
<i class="material-icons">label_outline</i>
|
|
||||||
<span id="ATSTR-${hl.id}">${hl.tags_str}</span>
|
|
||||||
<a title="${__("Edit tags for this article")}" href="#"
|
|
||||||
onclick="Article.editTags(${hl.id})">(+)</a>
|
|
||||||
<div class="buttons right">${hl.buttons}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="POSTNOTE-${hl.id}">${hl.note}</div>
|
|
||||||
<div class="content" lang="${hl.lang ? hl.lang : 'en'}">
|
|
||||||
${originally_from}
|
|
||||||
${hl.content}
|
|
||||||
${hl.enclosures}
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
|
|
||||||
Headlines.toggleUnread(id, 0);
|
|
||||||
this.render(article);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
editTags: function (id) {
|
|
||||||
const query = "backend.php?op=article&method=editArticleTags¶m=" + encodeURIComponent(id);
|
|
||||||
|
|
||||||
if (dijit.byId("editTagsDlg"))
|
|
||||||
dijit.byId("editTagsDlg").destroyRecursive();
|
|
||||||
|
|
||||||
const dialog = new dijit.Dialog({
|
|
||||||
id: "editTagsDlg",
|
|
||||||
title: __("Edit article Tags"),
|
|
||||||
style: "width: 600px",
|
|
||||||
execute: function () {
|
|
||||||
if (this.validate()) {
|
|
||||||
Notify.progress("Saving article tags...", true);
|
|
||||||
|
|
||||||
xhrPost("backend.php", this.attr('value'), (transport) => {
|
|
||||||
try {
|
|
||||||
Notify.close();
|
|
||||||
dialog.hide();
|
|
||||||
|
|
||||||
const data = JSON.parse(transport.responseText);
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
const id = data.id;
|
|
||||||
|
|
||||||
const tags = $("ATSTR-" + id);
|
|
||||||
const tooltip = dijit.byId("ATSTRTIP-" + id);
|
|
||||||
|
|
||||||
if (tags) tags.innerHTML = data.content;
|
|
||||||
if (tooltip) tooltip.attr('label', data.content_full);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
App.Error.report(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
href: query
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const tmph = dojo.connect(dialog, 'onLoad', function () {
|
|
||||||
dojo.disconnect(tmph);
|
|
||||||
|
|
||||||
new Ajax.Autocompleter('tags_str', 'tags_choices',
|
|
||||||
"backend.php?op=article&method=completeTags",
|
|
||||||
{tokens: ',', paramName: "search"});
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.show();
|
|
||||||
},
|
|
||||||
cdmMoveToId: function (id, params) {
|
|
||||||
params = params || {};
|
|
||||||
|
|
||||||
const force_to_top = params.force_to_top || false;
|
|
||||||
|
|
||||||
const ctr = $("headlines-frame");
|
|
||||||
const row = $("RROW-" + id);
|
const row = $("RROW-" + id);
|
||||||
|
|
||||||
if (!row || !ctr) return;
|
if (row) {
|
||||||
|
Article.unpack(row);
|
||||||
|
|
||||||
if (force_to_top || !App.Scrollable.fitsInContainer(row, ctr)) {
|
row.removeClassName("Unread");
|
||||||
ctr.scrollTop = row.offsetTop;
|
row.addClassName("active");
|
||||||
|
|
||||||
|
PluginHost.run(PluginHost.HOOK_ARTICLE_SET_ACTIVE, row.getAttribute("data-article-id"));
|
||||||
}
|
}
|
||||||
},
|
|
||||||
setActive: function (id) {
|
|
||||||
if (id != Article.getActive()) {
|
|
||||||
console.log("setActive", id, "was", Article.getActive());
|
|
||||||
|
|
||||||
$$("div[id*=RROW][class*=active]").each((row) => {
|
|
||||||
row.removeClassName("active");
|
|
||||||
Article.pack(row);
|
|
||||||
});
|
|
||||||
|
|
||||||
const row = $("RROW-" + id);
|
|
||||||
|
|
||||||
if (row) {
|
|
||||||
Article.unpack(row);
|
|
||||||
|
|
||||||
row.removeClassName("Unread");
|
|
||||||
row.addClassName("active");
|
|
||||||
|
|
||||||
PluginHost.run(PluginHost.HOOK_ARTICLE_SET_ACTIVE, row.getAttribute("data-article-id"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getActive: function () {
|
|
||||||
const row = document.querySelector("#headlines-frame > div[id*=RROW][class*=active]");
|
|
||||||
|
|
||||||
if (row)
|
|
||||||
return row.getAttribute("data-article-id");
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
},
|
|
||||||
scrollByPages: function (page_offset) {
|
|
||||||
App.Scrollable.scrollByPages($("content-insert"), page_offset);
|
|
||||||
},
|
|
||||||
scroll: function (offset) {
|
|
||||||
App.Scrollable.scroll($("content-insert"), offset);
|
|
||||||
},
|
|
||||||
mouseIn: function (id) {
|
|
||||||
this.post_under_pointer = id;
|
|
||||||
},
|
|
||||||
mouseOut: function (id) {
|
|
||||||
this.post_under_pointer = false;
|
|
||||||
},
|
|
||||||
getUnderPointer: function () {
|
|
||||||
return this.post_under_pointer;
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
getActive: function () {
|
||||||
|
const row = document.querySelector("#headlines-frame > div[id*=RROW][class*=active]");
|
||||||
|
|
||||||
return Article;
|
if (row)
|
||||||
});
|
return row.getAttribute("data-article-id");
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
scrollByPages: function (page_offset) {
|
||||||
|
App.Scrollable.scrollByPages($("content-insert"), page_offset);
|
||||||
|
},
|
||||||
|
scroll: function (offset) {
|
||||||
|
App.Scrollable.scroll($("content-insert"), offset);
|
||||||
|
},
|
||||||
|
mouseIn: function (id) {
|
||||||
|
this.post_under_pointer = id;
|
||||||
|
},
|
||||||
|
mouseOut: function (id) {
|
||||||
|
this.post_under_pointer = false;
|
||||||
|
},
|
||||||
|
getUnderPointer: function () {
|
||||||
|
return this.post_under_pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
/* global __, ngettext */
|
/* global __, ngettext */
|
||||||
define(["dojo/_base/declare"], function (declare) {
|
// noinspection JSUnusedGlobalSymbols
|
||||||
// noinspection JSUnusedGlobalSymbols
|
const CommonDialogs = {
|
||||||
CommonDialogs = {
|
|
||||||
closeInfoBox: function() {
|
closeInfoBox: function() {
|
||||||
const dialog = dijit.byId("infoBox");
|
const dialog = dijit.byId("infoBox");
|
||||||
if (dialog) dialog.hide();
|
if (dialog) dialog.hide();
|
||||||
|
@ -478,6 +477,3 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return CommonDialogs;
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,383 +1,380 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
/* global __, ngettext */
|
/* global __, ngettext */
|
||||||
define(["dojo/_base/declare"], function (declare) {
|
|
||||||
Filters = {
|
|
||||||
filterDlgCheckAction: function(sender) {
|
|
||||||
const action = sender.value;
|
|
||||||
|
|
||||||
const action_param = $("filterDlg_paramBox");
|
const Filters = {
|
||||||
|
filterDlgCheckAction: function(sender) {
|
||||||
|
const action = sender.value;
|
||||||
|
|
||||||
if (!action_param) {
|
const action_param = $("filterDlg_paramBox");
|
||||||
console.log("filterDlgCheckAction: can't find action param box!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if selected action supports parameters, enable params field
|
if (!action_param) {
|
||||||
if (action == 4 || action == 6 || action == 7 || action == 9) {
|
console.log("filterDlgCheckAction: can't find action param box!");
|
||||||
new Effect.Appear(action_param, {duration: 0.5});
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Element.hide(dijit.byId("filterDlg_actionParam").domNode);
|
// if selected action supports parameters, enable params field
|
||||||
Element.hide(dijit.byId("filterDlg_actionParamLabel").domNode);
|
if (action == 4 || action == 6 || action == 7 || action == 9) {
|
||||||
Element.hide(dijit.byId("filterDlg_actionParamPlugin").domNode);
|
new Effect.Appear(action_param, {duration: 0.5});
|
||||||
|
|
||||||
if (action == 7) {
|
Element.hide(dijit.byId("filterDlg_actionParam").domNode);
|
||||||
Element.show(dijit.byId("filterDlg_actionParamLabel").domNode);
|
Element.hide(dijit.byId("filterDlg_actionParamLabel").domNode);
|
||||||
} else if (action == 9) {
|
Element.hide(dijit.byId("filterDlg_actionParamPlugin").domNode);
|
||||||
Element.show(dijit.byId("filterDlg_actionParamPlugin").domNode);
|
|
||||||
} else {
|
|
||||||
Element.show(dijit.byId("filterDlg_actionParam").domNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (action == 7) {
|
||||||
|
Element.show(dijit.byId("filterDlg_actionParamLabel").domNode);
|
||||||
|
} else if (action == 9) {
|
||||||
|
Element.show(dijit.byId("filterDlg_actionParamPlugin").domNode);
|
||||||
} else {
|
} else {
|
||||||
Element.hide(action_param);
|
Element.show(dijit.byId("filterDlg_actionParam").domNode);
|
||||||
}
|
|
||||||
},
|
|
||||||
createNewRuleElement: function(parentNode, replaceNode) {
|
|
||||||
const form = document.forms["filter_new_rule_form"];
|
|
||||||
const query = {op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form)};
|
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
|
||||||
try {
|
|
||||||
const li = dojo.create("li");
|
|
||||||
|
|
||||||
const cb = dojo.create("input", {type: "checkbox"}, li);
|
|
||||||
|
|
||||||
new dijit.form.CheckBox({
|
|
||||||
onChange: function () {
|
|
||||||
Lists.onRowChecked(this);
|
|
||||||
},
|
|
||||||
}, cb);
|
|
||||||
|
|
||||||
dojo.create("input", {
|
|
||||||
type: "hidden",
|
|
||||||
name: "rule[]",
|
|
||||||
value: dojo.formToJson(form)
|
|
||||||
}, li);
|
|
||||||
|
|
||||||
dojo.create("span", {
|
|
||||||
onclick: function () {
|
|
||||||
dijit.byId('filterEditDlg').editRule(this);
|
|
||||||
},
|
|
||||||
innerHTML: transport.responseText
|
|
||||||
}, li);
|
|
||||||
|
|
||||||
if (replaceNode) {
|
|
||||||
parentNode.replaceChild(li, replaceNode);
|
|
||||||
} else {
|
|
||||||
parentNode.appendChild(li);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
App.Error.report(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
createNewActionElement: function(parentNode, replaceNode) {
|
|
||||||
const form = document.forms["filter_new_action_form"];
|
|
||||||
|
|
||||||
if (form.action_id.value == 7) {
|
|
||||||
form.action_param.value = form.action_param_label.value;
|
|
||||||
} else if (form.action_id.value == 9) {
|
|
||||||
form.action_param.value = form.action_param_plugin.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = {
|
} else {
|
||||||
op: "pref-filters", method: "printactionname",
|
Element.hide(action_param);
|
||||||
action: dojo.formToJson(form)
|
}
|
||||||
};
|
},
|
||||||
|
createNewRuleElement: function(parentNode, replaceNode) {
|
||||||
|
const form = document.forms["filter_new_rule_form"];
|
||||||
|
const query = {op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form)};
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
try {
|
try {
|
||||||
const li = dojo.create("li");
|
const li = dojo.create("li");
|
||||||
|
|
||||||
const cb = dojo.create("input", {type: "checkbox"}, li);
|
const cb = dojo.create("input", {type: "checkbox"}, li);
|
||||||
|
|
||||||
new dijit.form.CheckBox({
|
new dijit.form.CheckBox({
|
||||||
onChange: function () {
|
onChange: function () {
|
||||||
Lists.onRowChecked(this);
|
Lists.onRowChecked(this);
|
||||||
},
|
},
|
||||||
}, cb);
|
}, cb);
|
||||||
|
|
||||||
dojo.create("input", {
|
dojo.create("input", {
|
||||||
type: "hidden",
|
type: "hidden",
|
||||||
name: "action[]",
|
name: "rule[]",
|
||||||
value: dojo.formToJson(form)
|
value: dojo.formToJson(form)
|
||||||
}, li);
|
}, li);
|
||||||
|
|
||||||
dojo.create("span", {
|
dojo.create("span", {
|
||||||
onclick: function () {
|
onclick: function () {
|
||||||
dijit.byId('filterEditDlg').editAction(this);
|
dijit.byId('filterEditDlg').editRule(this);
|
||||||
},
|
},
|
||||||
innerHTML: transport.responseText
|
innerHTML: transport.responseText
|
||||||
}, li);
|
}, li);
|
||||||
|
|
||||||
if (replaceNode) {
|
if (replaceNode) {
|
||||||
parentNode.replaceChild(li, replaceNode);
|
parentNode.replaceChild(li, replaceNode);
|
||||||
} else {
|
} else {
|
||||||
parentNode.appendChild(li);
|
parentNode.appendChild(li);
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
App.Error.report(e);
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
App.Error.report(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
createNewActionElement: function(parentNode, replaceNode) {
|
||||||
|
const form = document.forms["filter_new_action_form"];
|
||||||
|
|
||||||
|
if (form.action_id.value == 7) {
|
||||||
|
form.action_param.value = form.action_param_label.value;
|
||||||
|
} else if (form.action_id.value == 9) {
|
||||||
|
form.action_param.value = form.action_param_plugin.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = {
|
||||||
|
op: "pref-filters", method: "printactionname",
|
||||||
|
action: dojo.formToJson(form)
|
||||||
|
};
|
||||||
|
|
||||||
|
xhrPost("backend.php", query, (transport) => {
|
||||||
|
try {
|
||||||
|
const li = dojo.create("li");
|
||||||
|
|
||||||
|
const cb = dojo.create("input", {type: "checkbox"}, li);
|
||||||
|
|
||||||
|
new dijit.form.CheckBox({
|
||||||
|
onChange: function () {
|
||||||
|
Lists.onRowChecked(this);
|
||||||
|
},
|
||||||
|
}, cb);
|
||||||
|
|
||||||
|
dojo.create("input", {
|
||||||
|
type: "hidden",
|
||||||
|
name: "action[]",
|
||||||
|
value: dojo.formToJson(form)
|
||||||
|
}, li);
|
||||||
|
|
||||||
|
dojo.create("span", {
|
||||||
|
onclick: function () {
|
||||||
|
dijit.byId('filterEditDlg').editAction(this);
|
||||||
|
},
|
||||||
|
innerHTML: transport.responseText
|
||||||
|
}, li);
|
||||||
|
|
||||||
|
if (replaceNode) {
|
||||||
|
parentNode.replaceChild(li, replaceNode);
|
||||||
|
} else {
|
||||||
|
parentNode.appendChild(li);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
App.Error.report(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addFilterRule: function(replaceNode, ruleStr) {
|
||||||
|
if (dijit.byId("filterNewRuleDlg"))
|
||||||
|
dijit.byId("filterNewRuleDlg").destroyRecursive();
|
||||||
|
|
||||||
|
const rule_dlg = new dijit.Dialog({
|
||||||
|
id: "filterNewRuleDlg",
|
||||||
|
title: ruleStr ? __("Edit rule") : __("Add rule"),
|
||||||
|
style: "width: 600px",
|
||||||
|
execute: function () {
|
||||||
|
if (this.validate()) {
|
||||||
|
Filters.createNewRuleElement($("filterDlg_Matches"), replaceNode);
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
content: __('Loading, please wait...'),
|
||||||
|
});
|
||||||
|
|
||||||
|
const tmph = dojo.connect(rule_dlg, "onShow", null, function (e) {
|
||||||
|
dojo.disconnect(tmph);
|
||||||
|
|
||||||
|
xhrPost("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (transport) => {
|
||||||
|
rule_dlg.attr('content', transport.responseText);
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
addFilterRule: function(replaceNode, ruleStr) {
|
|
||||||
if (dijit.byId("filterNewRuleDlg"))
|
|
||||||
dijit.byId("filterNewRuleDlg").destroyRecursive();
|
|
||||||
|
|
||||||
const rule_dlg = new dijit.Dialog({
|
rule_dlg.show();
|
||||||
id: "filterNewRuleDlg",
|
},
|
||||||
title: ruleStr ? __("Edit rule") : __("Add rule"),
|
addFilterAction: function(replaceNode, actionStr) {
|
||||||
style: "width: 600px",
|
if (dijit.byId("filterNewActionDlg"))
|
||||||
execute: function () {
|
dijit.byId("filterNewActionDlg").destroyRecursive();
|
||||||
if (this.validate()) {
|
|
||||||
Filters.createNewRuleElement($("filterDlg_Matches"), replaceNode);
|
|
||||||
this.hide();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
content: __('Loading, please wait...'),
|
|
||||||
});
|
|
||||||
|
|
||||||
const tmph = dojo.connect(rule_dlg, "onShow", null, function (e) {
|
const query = "backend.php?op=pref-filters&method=newaction&action=" +
|
||||||
dojo.disconnect(tmph);
|
encodeURIComponent(actionStr);
|
||||||
|
|
||||||
xhrPost("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (transport) => {
|
const rule_dlg = new dijit.Dialog({
|
||||||
rule_dlg.attr('content', transport.responseText);
|
id: "filterNewActionDlg",
|
||||||
});
|
title: actionStr ? __("Edit action") : __("Add action"),
|
||||||
});
|
style: "width: 600px",
|
||||||
|
execute: function () {
|
||||||
|
if (this.validate()) {
|
||||||
|
Filters.createNewActionElement($("filterDlg_Actions"), replaceNode);
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
href: query
|
||||||
|
});
|
||||||
|
|
||||||
rule_dlg.show();
|
rule_dlg.show();
|
||||||
},
|
},
|
||||||
addFilterAction: function(replaceNode, actionStr) {
|
editFilterTest: function(params) {
|
||||||
if (dijit.byId("filterNewActionDlg"))
|
|
||||||
dijit.byId("filterNewActionDlg").destroyRecursive();
|
|
||||||
|
|
||||||
const query = "backend.php?op=pref-filters&method=newaction&action=" +
|
if (dijit.byId("filterTestDlg"))
|
||||||
encodeURIComponent(actionStr);
|
dijit.byId("filterTestDlg").destroyRecursive();
|
||||||
|
|
||||||
const rule_dlg = new dijit.Dialog({
|
const test_dlg = new dijit.Dialog({
|
||||||
id: "filterNewActionDlg",
|
id: "filterTestDlg",
|
||||||
title: actionStr ? __("Edit action") : __("Add action"),
|
title: "Test Filter",
|
||||||
style: "width: 600px",
|
style: "width: 600px",
|
||||||
execute: function () {
|
results: 0,
|
||||||
if (this.validate()) {
|
limit: 100,
|
||||||
Filters.createNewActionElement($("filterDlg_Actions"), replaceNode);
|
max_offset: 10000,
|
||||||
this.hide();
|
getTestResults: function (params, offset) {
|
||||||
}
|
params.method = 'testFilterDo';
|
||||||
},
|
params.offset = offset;
|
||||||
href: query
|
params.limit = test_dlg.limit;
|
||||||
});
|
|
||||||
|
|
||||||
rule_dlg.show();
|
console.log("getTestResults:" + offset);
|
||||||
},
|
|
||||||
editFilterTest: function(params) {
|
|
||||||
|
|
||||||
if (dijit.byId("filterTestDlg"))
|
xhrPost("backend.php", params, (transport) => {
|
||||||
dijit.byId("filterTestDlg").destroyRecursive();
|
try {
|
||||||
|
const result = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
const test_dlg = new dijit.Dialog({
|
if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) {
|
||||||
id: "filterTestDlg",
|
test_dlg.results += result.length;
|
||||||
title: "Test Filter",
|
|
||||||
style: "width: 600px",
|
|
||||||
results: 0,
|
|
||||||
limit: 100,
|
|
||||||
max_offset: 10000,
|
|
||||||
getTestResults: function (params, offset) {
|
|
||||||
params.method = 'testFilterDo';
|
|
||||||
params.offset = offset;
|
|
||||||
params.limit = test_dlg.limit;
|
|
||||||
|
|
||||||
console.log("getTestResults:" + offset);
|
console.log("got results:" + result.length);
|
||||||
|
|
||||||
xhrPost("backend.php", params, (transport) => {
|
$("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...")
|
||||||
try {
|
.replace("%f", test_dlg.results)
|
||||||
const result = JSON.parse(transport.responseText);
|
.replace("%d", offset);
|
||||||
|
|
||||||
if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) {
|
console.log(offset + " " + test_dlg.max_offset);
|
||||||
test_dlg.results += result.length;
|
|
||||||
|
|
||||||
console.log("got results:" + result.length);
|
for (let i = 0; i < result.length; i++) {
|
||||||
|
const tmp = dojo.create("table", { innerHTML: result[i]});
|
||||||
|
|
||||||
$("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...")
|
$("prefFilterTestResultList").innerHTML += tmp.innerHTML;
|
||||||
.replace("%f", test_dlg.results)
|
}
|
||||||
.replace("%d", offset);
|
|
||||||
|
|
||||||
console.log(offset + " " + test_dlg.max_offset);
|
if (test_dlg.results < 30 && offset < test_dlg.max_offset) {
|
||||||
|
|
||||||
for (let i = 0; i < result.length; i++) {
|
// get the next batch
|
||||||
const tmp = dojo.create("table", { innerHTML: result[i]});
|
window.setTimeout(function () {
|
||||||
|
test_dlg.getTestResults(params, offset + test_dlg.limit);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
$("prefFilterTestResultList").innerHTML += tmp.innerHTML;
|
} else {
|
||||||
}
|
// all done
|
||||||
|
|
||||||
if (test_dlg.results < 30 && offset < test_dlg.max_offset) {
|
|
||||||
|
|
||||||
// get the next batch
|
|
||||||
window.setTimeout(function () {
|
|
||||||
test_dlg.getTestResults(params, offset + test_dlg.limit);
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// all done
|
|
||||||
|
|
||||||
Element.hide("prefFilterLoadingIndicator");
|
|
||||||
|
|
||||||
if (test_dlg.results == 0) {
|
|
||||||
$("prefFilterTestResultList").innerHTML = `<tr><td align='center'>
|
|
||||||
${__('No recent articles matching this filter have been found.')}</td></tr>`;
|
|
||||||
$("prefFilterProgressMsg").innerHTML = "Articles matching this filter:";
|
|
||||||
} else {
|
|
||||||
$("prefFilterProgressMsg").innerHTML = __("Found %d articles matching this filter:")
|
|
||||||
.replace("%d", test_dlg.results);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (!result) {
|
|
||||||
console.log("getTestResults: can't parse results object");
|
|
||||||
|
|
||||||
Element.hide("prefFilterLoadingIndicator");
|
Element.hide("prefFilterLoadingIndicator");
|
||||||
|
|
||||||
Notify.error("Error while trying to get filter test results.");
|
if (test_dlg.results == 0) {
|
||||||
|
$("prefFilterTestResultList").innerHTML = `<tr><td align='center'>
|
||||||
|
${__('No recent articles matching this filter have been found.')}</td></tr>`;
|
||||||
|
$("prefFilterProgressMsg").innerHTML = "Articles matching this filter:";
|
||||||
|
} else {
|
||||||
|
$("prefFilterProgressMsg").innerHTML = __("Found %d articles matching this filter:")
|
||||||
|
.replace("%d", test_dlg.results);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log("getTestResults: dialog closed, bailing out.");
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
App.Error.report(e);
|
} else if (!result) {
|
||||||
|
console.log("getTestResults: can't parse results object");
|
||||||
|
|
||||||
|
Element.hide("prefFilterLoadingIndicator");
|
||||||
|
|
||||||
|
Notify.error("Error while trying to get filter test results.");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log("getTestResults: dialog closed, bailing out.");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
App.Error.report(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
href: "backend.php?op=pref-filters&method=testFilterDlg"
|
||||||
|
});
|
||||||
|
|
||||||
|
dojo.connect(test_dlg, "onLoad", null, function (e) {
|
||||||
|
test_dlg.getTestResults(params, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test_dlg.show();
|
||||||
|
},
|
||||||
|
quickAddFilter: function() {
|
||||||
|
let query;
|
||||||
|
|
||||||
|
if (!App.isPrefs()) {
|
||||||
|
query = {
|
||||||
|
op: "pref-filters", method: "newfilter",
|
||||||
|
feed: Feeds.getActive(), is_cat: Feeds.activeIsCat()
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
query = {op: "pref-filters", method: "newfilter"};
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('quickAddFilter', query);
|
||||||
|
|
||||||
|
if (dijit.byId("feedEditDlg"))
|
||||||
|
dijit.byId("feedEditDlg").destroyRecursive();
|
||||||
|
|
||||||
|
if (dijit.byId("filterEditDlg"))
|
||||||
|
dijit.byId("filterEditDlg").destroyRecursive();
|
||||||
|
|
||||||
|
const dialog = new dijit.Dialog({
|
||||||
|
id: "filterEditDlg",
|
||||||
|
title: __("Create Filter"),
|
||||||
|
style: "width: 600px",
|
||||||
|
test: function () {
|
||||||
|
Filters.editFilterTest(dojo.formToObject("filter_new_form"));
|
||||||
|
},
|
||||||
|
selectRules: function (select) {
|
||||||
|
Lists.select("filterDlg_Matches", select);
|
||||||
|
},
|
||||||
|
selectActions: function (select) {
|
||||||
|
Lists.select("filterDlg_Actions", select);
|
||||||
|
},
|
||||||
|
editRule: function (e) {
|
||||||
|
const li = e.parentNode;
|
||||||
|
const rule = li.getElementsByTagName("INPUT")[1].value;
|
||||||
|
Filters.addFilterRule(li, rule);
|
||||||
|
},
|
||||||
|
editAction: function (e) {
|
||||||
|
const li = e.parentNode;
|
||||||
|
const action = li.getElementsByTagName("INPUT")[1].value;
|
||||||
|
Filters.addFilterAction(li, action);
|
||||||
|
},
|
||||||
|
addAction: function () {
|
||||||
|
Filters.addFilterAction();
|
||||||
|
},
|
||||||
|
addRule: function () {
|
||||||
|
Filters.addFilterRule();
|
||||||
|
},
|
||||||
|
deleteAction: function () {
|
||||||
|
$$("#filterDlg_Actions li[class*=Selected]").each(function (e) {
|
||||||
|
e.parentNode.removeChild(e)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
deleteRule: function () {
|
||||||
|
$$("#filterDlg_Matches li[class*=Selected]").each(function (e) {
|
||||||
|
e.parentNode.removeChild(e)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
execute: function () {
|
||||||
|
if (this.validate()) {
|
||||||
|
|
||||||
|
const query = dojo.formToQuery("filter_new_form");
|
||||||
|
|
||||||
|
xhrPost("backend.php", query, () => {
|
||||||
|
if (App.isPrefs()) {
|
||||||
|
dijit.byId("filterTree").reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dialog.hide();
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
href: "backend.php?op=pref-filters&method=testFilterDlg"
|
},
|
||||||
});
|
href: "backend.php?" + dojo.objectToQuery(query)
|
||||||
|
});
|
||||||
|
|
||||||
dojo.connect(test_dlg, "onLoad", null, function (e) {
|
if (!App.isPrefs()) {
|
||||||
test_dlg.getTestResults(params, 0);
|
const selectedText = getSelectionText();
|
||||||
});
|
|
||||||
|
|
||||||
test_dlg.show();
|
const lh = dojo.connect(dialog, "onLoad", function () {
|
||||||
},
|
dojo.disconnect(lh);
|
||||||
quickAddFilter: function() {
|
|
||||||
let query;
|
|
||||||
|
|
||||||
if (!App.isPrefs()) {
|
if (selectedText != "") {
|
||||||
query = {
|
|
||||||
op: "pref-filters", method: "newfilter",
|
|
||||||
feed: Feeds.getActive(), is_cat: Feeds.activeIsCat()
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
query = {op: "pref-filters", method: "newfilter"};
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('quickAddFilter', query);
|
const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) :
|
||||||
|
Feeds.getActive();
|
||||||
|
|
||||||
if (dijit.byId("feedEditDlg"))
|
const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1};
|
||||||
dijit.byId("feedEditDlg").destroyRecursive();
|
|
||||||
|
|
||||||
if (dijit.byId("filterEditDlg"))
|
Filters.addFilterRule(null, dojo.toJson(rule));
|
||||||
dijit.byId("filterEditDlg").destroyRecursive();
|
|
||||||
|
|
||||||
const dialog = new dijit.Dialog({
|
} else {
|
||||||
id: "filterEditDlg",
|
|
||||||
title: __("Create Filter"),
|
const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()};
|
||||||
style: "width: 600px",
|
|
||||||
test: function () {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
Filters.editFilterTest(dojo.formToObject("filter_new_form"));
|
const reply = JSON.parse(transport.responseText);
|
||||||
},
|
|
||||||
selectRules: function (select) {
|
let title = false;
|
||||||
Lists.select("filterDlg_Matches", select);
|
|
||||||
},
|
if (reply && reply.title) title = reply.title;
|
||||||
selectActions: function (select) {
|
|
||||||
Lists.select("filterDlg_Actions", select);
|
if (title || Feeds.getActive() || Feeds.activeIsCat()) {
|
||||||
},
|
|
||||||
editRule: function (e) {
|
console.log(title + " " + Feeds.getActive());
|
||||||
const li = e.parentNode;
|
|
||||||
const rule = li.getElementsByTagName("INPUT")[1].value;
|
const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) :
|
||||||
Filters.addFilterRule(li, rule);
|
Feeds.getActive();
|
||||||
},
|
|
||||||
editAction: function (e) {
|
const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1};
|
||||||
const li = e.parentNode;
|
|
||||||
const action = li.getElementsByTagName("INPUT")[1].value;
|
Filters.addFilterRule(null, dojo.toJson(rule));
|
||||||
Filters.addFilterAction(li, action);
|
}
|
||||||
},
|
|
||||||
addAction: function () {
|
|
||||||
Filters.addFilterAction();
|
|
||||||
},
|
|
||||||
addRule: function () {
|
|
||||||
Filters.addFilterRule();
|
|
||||||
},
|
|
||||||
deleteAction: function () {
|
|
||||||
$$("#filterDlg_Actions li[class*=Selected]").each(function (e) {
|
|
||||||
e.parentNode.removeChild(e)
|
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
deleteRule: function () {
|
|
||||||
$$("#filterDlg_Matches li[class*=Selected]").each(function (e) {
|
|
||||||
e.parentNode.removeChild(e)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
execute: function () {
|
|
||||||
if (this.validate()) {
|
|
||||||
|
|
||||||
const query = dojo.formToQuery("filter_new_form");
|
|
||||||
|
|
||||||
xhrPost("backend.php", query, () => {
|
|
||||||
if (App.isPrefs()) {
|
|
||||||
dijit.byId("filterTree").reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.hide();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
href: "backend.php?" + dojo.objectToQuery(query)
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
if (!App.isPrefs()) {
|
dialog.show();
|
||||||
const selectedText = getSelectionText();
|
},
|
||||||
|
};
|
||||||
const lh = dojo.connect(dialog, "onLoad", function () {
|
|
||||||
dojo.disconnect(lh);
|
|
||||||
|
|
||||||
if (selectedText != "") {
|
|
||||||
|
|
||||||
const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) :
|
|
||||||
Feeds.getActive();
|
|
||||||
|
|
||||||
const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1};
|
|
||||||
|
|
||||||
Filters.addFilterRule(null, dojo.toJson(rule));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()};
|
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
|
||||||
const reply = JSON.parse(transport.responseText);
|
|
||||||
|
|
||||||
let title = false;
|
|
||||||
|
|
||||||
if (reply && reply.title) title = reply.title;
|
|
||||||
|
|
||||||
if (title || Feeds.getActive() || Feeds.activeIsCat()) {
|
|
||||||
|
|
||||||
console.log(title + " " + Feeds.getActive());
|
|
||||||
|
|
||||||
const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) :
|
|
||||||
Feeds.getActive();
|
|
||||||
|
|
||||||
const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1};
|
|
||||||
|
|
||||||
Filters.addFilterRule(null, dojo.toJson(rule));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialog.show();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return Filters;
|
|
||||||
});
|
|
||||||
|
|
1111
js/Feeds.js
1111
js/Feeds.js
File diff suppressed because it is too large
Load Diff
2674
js/Headlines.js
2674
js/Headlines.js
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
// based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system
|
// based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system
|
||||||
|
|
||||||
PluginHost = {
|
const PluginHost = {
|
||||||
HOOK_ARTICLE_RENDERED: 1,
|
HOOK_ARTICLE_RENDERED: 1,
|
||||||
HOOK_ARTICLE_RENDERED_CDM: 2,
|
HOOK_ARTICLE_RENDERED_CDM: 2,
|
||||||
HOOK_ARTICLE_SET_ACTIVE: 3,
|
HOOK_ARTICLE_SET_ACTIVE: 3,
|
||||||
|
|
|
@ -2,12 +2,6 @@
|
||||||
/* global dijit,__ */
|
/* global dijit,__ */
|
||||||
|
|
||||||
let App;
|
let App;
|
||||||
let CommonDialogs;
|
|
||||||
let Filters;
|
|
||||||
let Feeds;
|
|
||||||
let Headlines;
|
|
||||||
let Article;
|
|
||||||
let PluginHost;
|
|
||||||
|
|
||||||
const Plugins = {};
|
const Plugins = {};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue