move some more shared stuff to CommonDialogs, Filters, and Utils

This commit is contained in:
Andrew Dolgov 2018-12-01 22:39:29 +03:00
parent 4b492cc93e
commit 1e2d4410d3
12 changed files with 502 additions and 495 deletions

View File

@ -174,7 +174,7 @@ class Dlg extends Handler_Protected {
print "<div align='center'>"; print "<div align='center'>";
print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('$feed_id', '$is_cat')\">". print "<button dojoType=\"dijit.form.Button\" onclick=\"return CommonDialogs.genUrlChangeKey('$feed_id', '$is_cat')\">".
__('Generate new URL')."</button> "; __('Generate new URL')."</button> ";
print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">". print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">".

View File

@ -765,7 +765,7 @@ class Pref_Feeds extends Handler_Protected {
print "<div class='dlgButtons'> print "<div class='dlgButtons'>
<div style=\"float : left\"> <div style=\"float : left\">
<button class=\"btn-danger\" dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed($feed_id, \"$title\")'>". <button class=\"btn-danger\" dojoType=\"dijit.form.Button\" onclick='return CommonDialogs.unsubscribeFeed($feed_id, \"$title\")'>".
__('Unsubscribe')."</button>"; __('Unsubscribe')."</button>";
print "</div>"; print "</div>";
@ -1247,7 +1247,7 @@ class Pref_Feeds extends Handler_Protected {
var bare_id = id.substr(id.indexOf(':')+1); var bare_id = id.substr(id.indexOf(':')+1);
if (id.match('FEED:')) { if (id.match('FEED:')) {
editFeed(bare_id); CommonDialogs.editFeed(bare_id);
} else if (id.match('CAT:')) { } else if (id.match('CAT:')) {
editCat(bare_id, item); editCat(bare_id, item);
} }
@ -1441,7 +1441,7 @@ class Pref_Feeds extends Handler_Protected {
print "<a class=\"visibleLink\" href=\"#\" ". print "<a class=\"visibleLink\" href=\"#\" ".
"title=\"".__("Click to edit feed")."\" ". "title=\"".__("Click to edit feed")."\" ".
"onclick=\"editFeed(".$line["id"].")\">". "onclick=\"CommonDialogs.editFeed(".$line["id"].")\">".
htmlspecialchars($line["title"])."</a>"; htmlspecialchars($line["title"])."</a>";
print "</td><td class=\"insensitive\" align='right'>"; print "</td><td class=\"insensitive\" align='right'>";
@ -1506,7 +1506,7 @@ class Pref_Feeds extends Handler_Protected {
print "<a class=\"visibleLink\" href=\"#\" ". print "<a class=\"visibleLink\" href=\"#\" ".
"title=\"".__("Click to edit feed")."\" ". "title=\"".__("Click to edit feed")."\" ".
"onclick=\"editFeed(".$line["id"].")\">". "onclick=\"CommonDialogs.editFeed(".$line["id"].")\">".
htmlspecialchars($line["title"])."</a>: "; htmlspecialchars($line["title"])."</a>: ";
print "<span class=\"insensitive\">"; print "<span class=\"insensitive\">";

View File

@ -797,7 +797,7 @@ class Pref_Filters extends Handler_Protected {
dojoType=\"dijit.MenuItem\">".__('None')."</div>"; dojoType=\"dijit.MenuItem\">".__('None')."</div>";
print "</div></div>"; print "</div></div>";
print "<button dojoType=\"dijit.form.Button\" onclick=\"return quickAddFilter()\">". print "<button dojoType=\"dijit.form.Button\" onclick=\"return Filters.quickAddFilter()\">".
__('Create filter')."</button> "; __('Create filter')."</button> ";
print "<button dojoType=\"dijit.form.Button\" onclick=\"return joinSelectedFilters()\">". print "<button dojoType=\"dijit.form.Button\" onclick=\"return joinSelectedFilters()\">".
@ -1044,7 +1044,7 @@ class Pref_Filters extends Handler_Protected {
print "<div class=\"dlgSecCont\">"; print "<div class=\"dlgSecCont\">";
print "<select name=\"action_id\" dojoType=\"dijit.form.Select\" print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"
onchange=\"filterDlgCheckAction(this)\">"; onchange=\"Filters.filterDlgCheckAction(this)\">";
$res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions $res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions
ORDER BY name"); ORDER BY name");

View File

@ -48,7 +48,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Edit feed"), label: __("Edit feed"),
onClick: function() { onClick: function() {
editFeed(this.getParent().row_id, false); CommonDialogs.editFeed(this.getParent().row_id, false);
}})); }}));
/* menu.addChild(new dijit.MenuItem({ /* menu.addChild(new dijit.MenuItem({

View File

@ -55,13 +55,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Edit feed"), label: __("Edit feed"),
onClick: function() { onClick: function() {
editFeed(this.getParent().row_id); CommonDialogs.editFeed(this.getParent().row_id);
}})); }}));
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Unsubscribe"), label: __("Unsubscribe"),
onClick: function() { onClick: function() {
unsubscribeFeed(this.getParent().row_id, this.getParent().item.name); CommonDialogs.unsubscribeFeed(this.getParent().row_id, this.getParent().item.name);
}})); }}));
menu.bindDomNode(tnode.domNode); menu.bindDomNode(tnode.domNode);

View File

@ -291,7 +291,7 @@ const Utils = {
} }
if (k == "daemon_is_running" && v != 1) { if (k == "daemon_is_running" && v != 1) {
notify_error("<span onclick=\"explainError(1)\">Update daemon is not running.</span>", true); notify_error("<span onclick=\"Utils.explainError(1)\">Update daemon is not running.</span>", true);
return; return;
} }
@ -306,7 +306,7 @@ const Utils = {
} }
if (k == "daemon_stamp_ok" && v != 1) { if (k == "daemon_stamp_ok" && v != 1) {
notify_error("<span onclick=\"explainError(3)\">Update daemon is not updating feeds.</span>", true); notify_error("<span onclick=\"Utils.explainError(3)\">Update daemon is not updating feeds.</span>", true);
return; return;
} }
@ -376,7 +376,10 @@ const Utils = {
} }
App.initSecondStage(); App.initSecondStage();
} },
explainError: function(code) {
return this.displayDlg(__("Error explained"), "explainError", code);
},
}; };
const CommonDialogs = { const CommonDialogs = {
@ -674,6 +677,97 @@ const CommonDialogs = {
} }
}); });
} }
},
unsubscribeFeed: function(feed_id, title) {
const msg = __("Unsubscribe from %s?").replace("%s", title);
if (title == undefined || confirm(msg)) {
notify_progress("Removing feed...");
const query = {op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id};
xhrPost("backend.php", query, (transport) => {
if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide();
if (App.isPrefs()) {
Feeds.reload();
} else {
if (feed_id == Feeds.getActiveFeedId())
setTimeout(() => {
Feeds.viewfeed({feed: -5})
},
100);
if (feed_id < 0) Feeds.reload();
}
});
}
return false;
},
editFeed: function (feed) {
if (feed <= 0)
return alert(__("You can't edit this kind of feed."));
const query = {op: "pref-feeds", method: "editfeed", id: feed};
console.log("editFeed", query);
if (dijit.byId("filterEditDlg"))
dijit.byId("filterEditDlg").destroyRecursive();
if (dijit.byId("feedEditDlg"))
dijit.byId("feedEditDlg").destroyRecursive();
const dialog = new dijit.Dialog({
id: "feedEditDlg",
title: __("Edit Feed"),
style: "width: 600px",
execute: function () {
if (this.validate()) {
notify_progress("Saving data...", true);
xhrPost("backend.php", dialog.attr('value'), () => {
dialog.hide();
notify('');
Feeds.reload();
});
}
},
href: "backend.php?" + dojo.objectToQuery(query)
});
dialog.show();
},
genUrlChangeKey: function(feed, is_cat) {
if (confirm(__("Generate new syndication address for this feed?"))) {
notify_progress("Trying to change address...", true);
const query = {op: "pref-feeds", method: "regenFeedKey", id: feed, is_cat: is_cat};
xhrJson("backend.php", query, (reply) => {
const new_link = reply.link;
const e = $('gen_feed_url');
if (new_link) {
e.innerHTML = e.innerHTML.replace(/\&amp;key=.*$/,
"&amp;key=" + new_link);
e.href = e.href.replace(/\&key=.*$/,
"&key=" + new_link);
new Effect.Highlight(e);
notify('');
} else {
notify_error("Could not change feed URL.");
}
});
}
return false;
} }
}; };
@ -994,8 +1088,8 @@ function fatalError(code, msg, ext_info) {
} }
// noinspection JSUnusedGlobalSymbols const Filters = {
function filterDlgCheckAction(sender) { filterDlgCheckAction: function(sender) {
const action = sender.value; const action = sender.value;
const action_param = $("filterDlg_paramBox"); const action_param = $("filterDlg_paramBox");
@ -1024,73 +1118,8 @@ function filterDlgCheckAction(sender) {
} else { } else {
Element.hide(action_param); Element.hide(action_param);
} }
} },
createNewRuleElement: function(parentNode, replaceNode) {
function explainError(code) {
return Utils.displayDlg(__("Error explained"), "explainError", code);
}
function strip_tags(s) {
return s.replace(/<\/?[^>]+(>|$)/g, "");
}
// noinspection JSUnusedGlobalSymbols
function uploadIconHandler(rc) {
switch (rc) {
case 0:
notify_info("Upload complete.");
if (App.isPrefs()) {
Feeds.reload();
} else {
setTimeout('Feeds.reload(false, false)', 50);
}
break;
case 1:
notify_error("Upload failed: icon is too big.");
break;
case 2:
notify_error("Upload failed.");
break;
}
}
// noinspection JSUnusedGlobalSymbols
function removeFeedIcon(id) {
if (confirm(__("Remove stored feed icon?"))) {
notify_progress("Removing feed icon...", true);
const query = { op: "pref-feeds", method: "removeicon", feed_id: id };
xhrPost("backend.php", query, (transport) => {
notify_info("Feed icon removed.");
if (App.isPrefs()) {
Feeds.reload();
} else {
setTimeout('Feeds.reload(false, false)', 50);
}
});
}
return false;
}
// noinspection JSUnusedGlobalSymbols
function uploadFeedIcon() {
const file = $("icon_file");
if (file.value.length == 0) {
alert(__("Please select an image file to upload."));
} else if (confirm(__("Upload new icon for this feed?"))) {
notify_progress("Uploading, please wait...", true);
return true;
}
return false;
}
function createNewRuleElement(parentNode, replaceNode) {
const form = document.forms["filter_new_rule_form"]; const form = document.forms["filter_new_rule_form"];
const query = {op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form)}; const query = {op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form)};
@ -1102,18 +1131,22 @@ function createNewRuleElement(parentNode, replaceNode) {
new dijit.form.CheckBox({ new dijit.form.CheckBox({
onChange: function () { onChange: function () {
toggleSelectListRow2(this) }, toggleSelectListRow2(this)
},
}, cb); }, cb);
dojo.create("input", { type: "hidden", dojo.create("input", {
type: "hidden",
name: "rule[]", name: "rule[]",
value: dojo.formToJson(form) }, li); value: dojo.formToJson(form)
}, li);
dojo.create("span", { dojo.create("span", {
onclick: function () { onclick: function () {
dijit.byId('filterEditDlg').editRule(this); dijit.byId('filterEditDlg').editRule(this);
}, },
innerHTML: transport.responseText }, li); innerHTML: transport.responseText
}, li);
if (replaceNode) { if (replaceNode) {
parentNode.replaceChild(li, replaceNode); parentNode.replaceChild(li, replaceNode);
@ -1124,9 +1157,8 @@ function createNewRuleElement(parentNode, replaceNode) {
exception_error(e); exception_error(e);
} }
}); });
} },
createNewActionElement: function(parentNode, replaceNode) {
function createNewActionElement(parentNode, replaceNode) {
const form = document.forms["filter_new_action_form"]; const form = document.forms["filter_new_action_form"];
if (form.action_id.value == 7) { if (form.action_id.value == 7) {
@ -1135,8 +1167,10 @@ function createNewActionElement(parentNode, replaceNode) {
form.action_param.value = form.action_param_plugin.value; form.action_param.value = form.action_param_plugin.value;
} }
const query = { op: "pref-filters", method: "printactionname", const query = {
action: dojo.formToJson(form) }; op: "pref-filters", method: "printactionname",
action: dojo.formToJson(form)
};
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
try { try {
@ -1146,18 +1180,22 @@ function createNewActionElement(parentNode, replaceNode) {
new dijit.form.CheckBox({ new dijit.form.CheckBox({
onChange: function () { onChange: function () {
toggleSelectListRow2(this) }, toggleSelectListRow2(this)
},
}, cb); }, cb);
dojo.create("input", { type: "hidden", dojo.create("input", {
type: "hidden",
name: "action[]", name: "action[]",
value: dojo.formToJson(form) }, li); value: dojo.formToJson(form)
}, li);
dojo.create("span", { dojo.create("span", {
onclick: function () { onclick: function () {
dijit.byId('filterEditDlg').editAction(this); dijit.byId('filterEditDlg').editAction(this);
}, },
innerHTML: transport.responseText }, li); innerHTML: transport.responseText
}, li);
if (replaceNode) { if (replaceNode) {
parentNode.replaceChild(li, replaceNode); parentNode.replaceChild(li, replaceNode);
@ -1169,10 +1207,8 @@ function createNewActionElement(parentNode, replaceNode) {
exception_error(e); exception_error(e);
} }
}); });
} },
addFilterRule: function(replaceNode, ruleStr) {
function addFilterRule(replaceNode, ruleStr) {
if (dijit.byId("filterNewRuleDlg")) if (dijit.byId("filterNewRuleDlg"))
dijit.byId("filterNewRuleDlg").destroyRecursive(); dijit.byId("filterNewRuleDlg").destroyRecursive();
@ -1185,16 +1221,16 @@ function addFilterRule(replaceNode, ruleStr) {
style: "width: 600px", style: "width: 600px",
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
createNewRuleElement($("filterDlg_Matches"), replaceNode); Filters.createNewRuleElement($("filterDlg_Matches"), replaceNode);
this.hide(); this.hide();
} }
}, },
href: query}); href: query
});
rule_dlg.show(); rule_dlg.show();
} },
addFilterAction: function(replaceNode, actionStr) {
function addFilterAction(replaceNode, actionStr) {
if (dijit.byId("filterNewActionDlg")) if (dijit.byId("filterNewActionDlg"))
dijit.byId("filterNewActionDlg").destroyRecursive(); dijit.byId("filterNewActionDlg").destroyRecursive();
@ -1207,16 +1243,16 @@ function addFilterAction(replaceNode, actionStr) {
style: "width: 600px", style: "width: 600px",
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
createNewActionElement($("filterDlg_Actions"), replaceNode); Filters.createNewActionElement($("filterDlg_Actions"), replaceNode);
this.hide(); this.hide();
} }
}, },
href: query}); href: query
});
rule_dlg.show(); rule_dlg.show();
} },
editFilterTest: function(query) {
function editFilterTest(query) {
if (dijit.byId("filterTestDlg")) if (dijit.byId("filterTestDlg"))
dijit.byId("filterTestDlg").destroyRecursive(); dijit.byId("filterTestDlg").destroyRecursive();
@ -1294,22 +1330,23 @@ function editFilterTest(query) {
}); });
}, },
href: query}); href: query
});
dojo.connect(test_dlg, "onLoad", null, function (e) { dojo.connect(test_dlg, "onLoad", null, function (e) {
test_dlg.getTestResults(query, 0); test_dlg.getTestResults(query, 0);
}); });
test_dlg.show(); test_dlg.show();
},
} quickAddFilter: function() {
function quickAddFilter() {
let query; let query;
if (!App.isPrefs()) { if (!App.isPrefs()) {
query = { op: "pref-filters", method: "newfilter", query = {
feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat() }; op: "pref-filters", method: "newfilter",
feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat()
};
} else { } else {
query = {op: "pref-filters", method: "newfilter"}; query = {op: "pref-filters", method: "newfilter"};
} }
@ -1329,7 +1366,7 @@ function quickAddFilter() {
test: function () { test: function () {
const query = "backend.php?" + dojo.formToQuery("filter_new_form") + "&savemode=test"; const query = "backend.php?" + dojo.formToQuery("filter_new_form") + "&savemode=test";
editFilterTest(query); Filters.editFilterTest(query);
}, },
selectRules: function (select) { selectRules: function (select) {
$$("#filterDlg_Matches input[type=checkbox]").each(function (e) { $$("#filterDlg_Matches input[type=checkbox]").each(function (e) {
@ -1354,27 +1391,35 @@ function quickAddFilter() {
editRule: function (e) { editRule: function (e) {
const li = e.parentNode; const li = e.parentNode;
const rule = li.getElementsByTagName("INPUT")[1].value; const rule = li.getElementsByTagName("INPUT")[1].value;
addFilterRule(li, rule); Filters.addFilterRule(li, rule);
}, },
editAction: function (e) { editAction: function (e) {
const li = e.parentNode; const li = e.parentNode;
const action = li.getElementsByTagName("INPUT")[1].value; const action = li.getElementsByTagName("INPUT")[1].value;
addFilterAction(li, action); Filters.addFilterAction(li, action);
},
addAction: function () {
Filters.addFilterAction();
},
addRule: function () {
Filters.addFilterRule();
}, },
addAction: function() { addFilterAction(); },
addRule: function() { addFilterRule(); },
deleteAction: function () { deleteAction: function () {
$$("#filterDlg_Actions li[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) }); $$("#filterDlg_Actions li[class*=Selected]").each(function (e) {
e.parentNode.removeChild(e)
});
}, },
deleteRule: function () { deleteRule: function () {
$$("#filterDlg_Matches li[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) }); $$("#filterDlg_Matches li[class*=Selected]").each(function (e) {
e.parentNode.removeChild(e)
});
}, },
execute: function () { execute: function () {
if (this.validate()) { if (this.validate()) {
const query = dojo.formToQuery("filter_new_form"); const query = dojo.formToQuery("filter_new_form");
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, () => {
if (App.isPrefs()) { if (App.isPrefs()) {
updateFilterList(); updateFilterList();
} }
@ -1383,7 +1428,8 @@ function quickAddFilter() {
}); });
} }
}, },
href: "backend.php?" + dojo.objectToQuery(query)}); href: "backend.php?" + dojo.objectToQuery(query)
});
if (!App.isPrefs()) { if (!App.isPrefs()) {
const selectedText = getSelectionText(); const selectedText = getSelectionText();
@ -1398,7 +1444,7 @@ function quickAddFilter() {
const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1}; const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1};
addFilterRule(null, dojo.toJson(rule)); Filters.addFilterRule(null, dojo.toJson(rule));
} else { } else {
@ -1420,7 +1466,7 @@ function quickAddFilter() {
const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1}; const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1};
addFilterRule(null, dojo.toJson(rule)); Filters.addFilterRule(null, dojo.toJson(rule));
} }
}); });
} }
@ -1428,29 +1474,47 @@ function quickAddFilter() {
} }
dialog.show(); dialog.show();
},
};
} /* function strip_tags(s) {
return s.replace(/<\/?[^>]+(>|$)/g, "");
function unsubscribeFeed(feed_id, title) { } */
const msg = __("Unsubscribe from %s?").replace("%s", title);
if (title == undefined || confirm(msg)) {
notify_progress("Removing feed...");
const query = { op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id };
xhrPost("backend.php", query, (transport) => {
if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide();
// noinspection JSUnusedGlobalSymbols
function uploadIconHandler(rc) {
switch (rc) {
case 0:
notify_info("Upload complete.");
if (App.isPrefs()) { if (App.isPrefs()) {
Feeds.reload(); Feeds.reload();
} else { } else {
if (feed_id == Feeds.getActiveFeedId()) setTimeout('Feeds.reload(false, false)', 50);
setTimeout(() => { Feeds.viewfeed({feed:-5}) }, }
100); break;
case 1:
notify_error("Upload failed: icon is too big.");
break;
case 2:
notify_error("Upload failed.");
break;
}
}
if (feed_id < 0) Feeds.reload(); // noinspection JSUnusedGlobalSymbols
function removeFeedIcon(id) {
if (confirm(__("Remove stored feed icon?"))) {
notify_progress("Removing feed icon...", true);
const query = { op: "pref-feeds", method: "removeicon", feed_id: id };
xhrPost("backend.php", query, (transport) => {
notify_info("Feed icon removed.");
if (App.isPrefs()) {
Feeds.reload();
} else {
setTimeout('Feeds.reload(false, false)', 50);
} }
}); });
} }
@ -1459,33 +1523,16 @@ function unsubscribeFeed(feed_id, title) {
} }
// noinspection JSUnusedGlobalSymbols // noinspection JSUnusedGlobalSymbols
function genUrlChangeKey(feed, is_cat) { function uploadFeedIcon() {
if (confirm(__("Generate new syndication address for this feed?"))) { const file = $("icon_file");
notify_progress("Trying to change address...", true); if (file.value.length == 0) {
alert(__("Please select an image file to upload."));
const query = { op: "pref-feeds", method: "regenFeedKey", id: feed, is_cat: is_cat }; } else if (confirm(__("Upload new icon for this feed?"))) {
notify_progress("Uploading, please wait...", true);
xhrJson("backend.php", query, (reply) => { return true;
const new_link = reply.link;
const e = $('gen_feed_url');
if (new_link) {
e.innerHTML = e.innerHTML.replace(/\&amp;key=.*$/,
"&amp;key=" + new_link);
e.href = e.href.replace(/\&key=.*$/,
"&key=" + new_link);
new Effect.Highlight(e);
notify('');
} else {
notify_error("Could not change feed URL.");
}
});
} }
return false; return false;
} }
@ -1541,7 +1588,6 @@ function selectTableRows(id, mode) {
} }
} }
} }
} }
function getSelectedTableRowIds(id) { function getSelectedTableRowIds(id) {
@ -1559,45 +1605,6 @@ function getSelectedTableRowIds(id) {
return rows; return rows;
} }
function editFeed(feed) {
if (feed <= 0)
return alert(__("You can't edit this kind of feed."));
const query = { op: "pref-feeds", method: "editfeed", id: feed };
console.log("editFeed", query);
if (dijit.byId("filterEditDlg"))
dijit.byId("filterEditDlg").destroyRecursive();
if (dijit.byId("feedEditDlg"))
dijit.byId("feedEditDlg").destroyRecursive();
const dialog = new dijit.Dialog({
id: "feedEditDlg",
title: __("Edit Feed"),
style: "width: 600px",
execute: function() {
if (this.validate()) {
notify_progress("Saving data...", true);
xhrPost("backend.php", dialog.attr('value'), () => {
dialog.hide();
notify('');
Feeds.reload();
});
}
},
href: "backend.php?" + dojo.objectToQuery(query)});
dialog.show();
}
function get_timestamp() {
const date = new Date();
return Math.round(date.getTime() / 1000);
}
// noinspection JSUnusedGlobalSymbols // noinspection JSUnusedGlobalSymbols
function label_to_feed_id(label) { function label_to_feed_id(label) {
return _label_base_index - 1 - Math.abs(label); return _label_base_index - 1 - Math.abs(label);

View File

@ -82,7 +82,7 @@ const App = {
const param = getURLParam('methodparam'); const param = getURLParam('methodparam');
window.setTimeout(function () { window.setTimeout(function () {
editFeed(param) CommonDialogs.editFeed(param)
}, 100); }, 100);
} }
}, },
@ -100,7 +100,7 @@ const App = {
CommonDialogs.addLabel(); CommonDialogs.addLabel();
return false; return false;
case "create_filter": case "create_filter":
quickAddFilter(); Filters.quickAddFilter();
return false; return false;
case "help_dialog": case "help_dialog":
Utils.helpDialog("main"); Utils.helpDialog("main");
@ -575,7 +575,7 @@ function editSelectedFeed() {
notify(""); notify("");
editFeed(rows[0], {}); CommonDialogs.editFeed(rows[0], {});
} }

View File

@ -360,7 +360,7 @@ const App = {
if (Feeds.activeFeedIsCat()) if (Feeds.activeFeedIsCat())
alert(__("You can't edit this kind of feed.")); alert(__("You can't edit this kind of feed."));
else else
editFeed(Feeds.getActiveFeedId()); CommonDialogs.editFeed(Feeds.getActiveFeedId());
}; };
this.hotkey_actions["feed_catchup"] = function () { this.hotkey_actions["feed_catchup"] = function () {
if (Feeds.getActiveFeedId() != undefined) { if (Feeds.getActiveFeedId() != undefined) {
@ -424,7 +424,7 @@ const App = {
CommonDialogs.addLabel(); CommonDialogs.addLabel();
}; };
this.hotkey_actions["create_filter"] = function () { this.hotkey_actions["create_filter"] = function () {
quickAddFilter(); Filters.quickAddFilter();
}; };
this.hotkey_actions["collapse_sidebar"] = function () { this.hotkey_actions["collapse_sidebar"] = function () {
Feeds.viewCurrentFeed(); Feeds.viewCurrentFeed();
@ -501,7 +501,7 @@ const App = {
if (Feeds.activeFeedIsCat()) if (Feeds.activeFeedIsCat())
alert(__("You can't edit this kind of feed.")); alert(__("You can't edit this kind of feed."));
else else
editFeed(Feeds.getActiveFeedId()); CommonDialogs.editFeed(Feeds.getActiveFeedId());
break; break;
case "qmcRemoveFeed": case "qmcRemoveFeed":
var actid = Feeds.getActiveFeedId(); var actid = Feeds.getActiveFeedId();
@ -521,7 +521,7 @@ const App = {
var pr = __("Unsubscribe from %s?").replace("%s", fn); var pr = __("Unsubscribe from %s?").replace("%s", fn);
if (confirm(pr)) { if (confirm(pr)) {
unsubscribeFeed(actid); CommonDialogs.unsubscribeFeed(actid);
} }
break; break;
case "qmcCatchupAll": case "qmcCatchupAll":

View File

@ -1560,7 +1560,7 @@ const Headlines = {
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Edit feed"), label: __("Edit feed"),
onClick: function () { onClick: function () {
editFeed(this.getParent().currentTarget.getAttribute("data-feed-id")); CommonDialogs.editFeed(this.getParent().currentTarget.getAttribute("data-feed-id"));
} }
})); }));

View File

@ -202,7 +202,7 @@ class Af_Psql_Trgm extends Plugin {
print "<li>" . print "<li>" .
"<img src='images/pub_set.png' "<img src='images/pub_set.png'
style='vertical-align : middle'> <a href='#' style='vertical-align : middle'> <a href='#'
onclick='editFeed($f)'>" . onclick='CommonDialogs.editFeed($f)'>" .
Feeds::getFeedTitle($f) . "</a></li>"; Feeds::getFeedTitle($f) . "</a></li>";
} }
print "</ul>"; print "</ul>";

View File

@ -94,7 +94,7 @@ class Af_Readability extends Plugin {
print "<li>" . print "<li>" .
"<img src='images/pub_set.png' "<img src='images/pub_set.png'
style='vertical-align : middle'> <a href='#' style='vertical-align : middle'> <a href='#'
onclick='editFeed($f)'>". onclick='CommonDialogs.editFeed($f)'>".
Feeds::getFeedTitle($f) . "</a></li>"; Feeds::getFeedTitle($f) . "</a></li>";
} }
print "</ul>"; print "</ul>";

View File

@ -25,7 +25,7 @@ class BasicTest extends PHPUnit_Extensions_Selenium2TestCase {
public function testBasicDialogs() { public function testBasicDialogs() {
$this->testLogin(); $this->testLogin();
$this->execute(["script" => "quickAddFilter()", "args" => []]); $this->execute(["script" => "Filters.quickAddFilter()", "args" => []]);
$this->byCssSelector("#filterEditDlg")->displayed(); $this->byCssSelector("#filterEditDlg")->displayed();
$this->execute(["script" => "dijit.byId('filterEditDlg').hide();", "args" => []]); $this->execute(["script" => "dijit.byId('filterEditDlg').hide();", "args" => []]);