|
|
@ -1,6 +1,6 @@
|
|
|
|
'use strict'
|
|
|
|
'use strict'
|
|
|
|
|
|
|
|
|
|
|
|
/* global __, App, Article, Lists, Effect */
|
|
|
|
/* global __, App, Article, Lists, Effect, fox */
|
|
|
|
/* global xhrPost, dojo, dijit, Notify, $$, Feeds */
|
|
|
|
/* global xhrPost, dojo, dijit, Notify, $$, Feeds */
|
|
|
|
|
|
|
|
|
|
|
|
const Filters = {
|
|
|
|
const Filters = {
|
|
|
@ -138,10 +138,7 @@ const Filters = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
test: function(params) {
|
|
|
|
test: function(params) {
|
|
|
|
|
|
|
|
|
|
|
|
if (dijit.byId("filterTestDlg"))
|
|
|
|
const test_dlg = new fox.SingleUseDialog({
|
|
|
|
dijit.byId("filterTestDlg").destroyRecursive();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const test_dlg = new dijit.Dialog({
|
|
|
|
|
|
|
|
id: "filterTestDlg",
|
|
|
|
id: "filterTestDlg",
|
|
|
|
title: "Test Filter",
|
|
|
|
title: "Test Filter",
|
|
|
|
results: 0,
|
|
|
|
results: 0,
|
|
|
@ -249,128 +246,127 @@ const Filters = {
|
|
|
|
console.log('Filters.edit', query);
|
|
|
|
console.log('Filters.edit', query);
|
|
|
|
|
|
|
|
|
|
|
|
xhrPost("backend.php", query, function (transport) {
|
|
|
|
xhrPost("backend.php", query, function (transport) {
|
|
|
|
if (dijit.byId("feedEditDlg"))
|
|
|
|
try {
|
|
|
|
dijit.byId("feedEditDlg").destroyRecursive();
|
|
|
|
const dialog = new fox.SingleUseDialog({
|
|
|
|
|
|
|
|
id: "filterEditDlg",
|
|
|
|
if (dijit.byId("filterEditDlg"))
|
|
|
|
title: __("Create Filter"),
|
|
|
|
dijit.byId("filterEditDlg").destroyRecursive();
|
|
|
|
test: function () {
|
|
|
|
|
|
|
|
Filters.test(this.attr('value'));
|
|
|
|
const dialog = new dijit.Dialog({
|
|
|
|
},
|
|
|
|
id: "filterEditDlg",
|
|
|
|
selectRules: function (select) {
|
|
|
|
title: __("Create Filter"),
|
|
|
|
Lists.select("filterDlg_Matches", select);
|
|
|
|
test: function () {
|
|
|
|
},
|
|
|
|
Filters.test(this.attr('value'));
|
|
|
|
selectActions: function (select) {
|
|
|
|
},
|
|
|
|
Lists.select("filterDlg_Actions", select);
|
|
|
|
selectRules: function (select) {
|
|
|
|
},
|
|
|
|
Lists.select("filterDlg_Matches", select);
|
|
|
|
editRule: function (e) {
|
|
|
|
},
|
|
|
|
const li = e.closest('li');
|
|
|
|
selectActions: function (select) {
|
|
|
|
const rule = li.querySelector('input[name="rule[]"]').value
|
|
|
|
Lists.select("filterDlg_Actions", select);
|
|
|
|
|
|
|
|
},
|
|
|
|
Filters.addFilterRule(li, rule);
|
|
|
|
editRule: function (e) {
|
|
|
|
},
|
|
|
|
const li = e.closest('li');
|
|
|
|
editAction: function (e) {
|
|
|
|
const rule = li.querySelector('input[name="rule[]"]').value
|
|
|
|
const li = e.closest('li');
|
|
|
|
|
|
|
|
const action = li.querySelector('input[name="action[]"]').value
|
|
|
|
Filters.addFilterRule(li, rule);
|
|
|
|
|
|
|
|
},
|
|
|
|
Filters.addFilterAction(li, action);
|
|
|
|
editAction: function (e) {
|
|
|
|
},
|
|
|
|
const li = e.closest('li');
|
|
|
|
removeFilter: function () {
|
|
|
|
const action = li.querySelector('input[name="action[]"]').value
|
|
|
|
const msg = __("Remove filter?");
|
|
|
|
|
|
|
|
|
|
|
|
Filters.addFilterAction(li, action);
|
|
|
|
if (confirm(msg)) {
|
|
|
|
},
|
|
|
|
this.hide();
|
|
|
|
removeFilter: function () {
|
|
|
|
|
|
|
|
const msg = __("Remove filter?");
|
|
|
|
Notify.progress("Removing filter...");
|
|
|
|
|
|
|
|
|
|
|
|
if (confirm(msg)) {
|
|
|
|
const query = {op: "pref-filters", method: "remove", ids: this.attr('value').id};
|
|
|
|
this.hide();
|
|
|
|
|
|
|
|
|
|
|
|
xhrPost("backend.php", query, () => {
|
|
|
|
Notify.progress("Removing filter...");
|
|
|
|
const tree = dijit.byId("filterTree");
|
|
|
|
|
|
|
|
|
|
|
|
const query = {op: "pref-filters", method: "remove", ids: this.attr('value').id};
|
|
|
|
if (tree) tree.reload();
|
|
|
|
|
|
|
|
});
|
|
|
|
xhrPost("backend.php", query, () => {
|
|
|
|
}
|
|
|
|
const tree = dijit.byId("filterTree");
|
|
|
|
},
|
|
|
|
|
|
|
|
addAction: function () {
|
|
|
|
if (tree) tree.reload();
|
|
|
|
Filters.addFilterAction();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
addRule: function () {
|
|
|
|
|
|
|
|
Filters.addFilterRule();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteAction: function () {
|
|
|
|
|
|
|
|
$$("#filterDlg_Actions li[class*=Selected]").each(function (e) {
|
|
|
|
|
|
|
|
e.parentNode.removeChild(e)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
deleteRule: function () {
|
|
|
|
addAction: function () {
|
|
|
|
$$("#filterDlg_Matches li[class*=Selected]").each(function (e) {
|
|
|
|
Filters.addFilterAction();
|
|
|
|
e.parentNode.removeChild(e)
|
|
|
|
},
|
|
|
|
});
|
|
|
|
addRule: function () {
|
|
|
|
},
|
|
|
|
Filters.addFilterRule();
|
|
|
|
execute: function () {
|
|
|
|
},
|
|
|
|
if (this.validate()) {
|
|
|
|
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()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Notify.progress("Saving data...", true);
|
|
|
|
Notify.progress("Saving data...", true);
|
|
|
|
|
|
|
|
|
|
|
|
xhrPost("backend.php", this.attr('value'), () => {
|
|
|
|
xhrPost("backend.php", this.attr('value'), () => {
|
|
|
|
dialog.hide();
|
|
|
|
dialog.hide();
|
|
|
|
|
|
|
|
|
|
|
|
const tree = dijit.byId("filterTree");
|
|
|
|
const tree = dijit.byId("filterTree");
|
|
|
|
if (tree) tree.reload();
|
|
|
|
if (tree) tree.reload();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
content: transport.responseText
|
|
|
|
content: transport.responseText
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!App.isPrefs()) {
|
|
|
|
if (!App.isPrefs()) {
|
|
|
|
/* global getSelectionText */
|
|
|
|
/* global getSelectionText */
|
|
|
|
const selectedText = getSelectionText();
|
|
|
|
const selectedText = getSelectionText();
|
|
|
|
|
|
|
|
|
|
|
|
const lh = dojo.connect(dialog, "onShow", function () {
|
|
|
|
const lh = dojo.connect(dialog, "onShow", function () {
|
|
|
|
dojo.disconnect(lh);
|
|
|
|
dojo.disconnect(lh);
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedText != "") {
|
|
|
|
if (selectedText != "") {
|
|
|
|
|
|
|
|
|
|
|
|
const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) :
|
|
|
|
const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) :
|
|
|
|
Feeds.getActive();
|
|
|
|
Feeds.getActive();
|
|
|
|
|
|
|
|
|
|
|
|
const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1};
|
|
|
|
const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1};
|
|
|
|
|
|
|
|
|
|
|
|
Filters.addFilterRule(null, dojo.toJson(rule));
|
|
|
|
Filters.addFilterRule(null, dojo.toJson(rule));
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()};
|
|
|
|
const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()};
|
|
|
|
|
|
|
|
|
|
|
|
xhrPost("backend.php", query, (transport) => {
|
|
|
|
xhrPost("backend.php", query, (transport) => {
|
|
|
|
const reply = JSON.parse(transport.responseText);
|
|
|
|
const reply = JSON.parse(transport.responseText);
|
|
|
|
|
|
|
|
|
|
|
|
let title = false;
|
|
|
|
let title = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (reply && reply.title) title = reply.title;
|
|
|
|
if (reply && reply.title) title = reply.title;
|
|
|
|
|
|
|
|
|
|
|
|
if (title || Feeds.getActive() || Feeds.activeIsCat()) {
|
|
|
|
if (title || Feeds.getActive() || Feeds.activeIsCat()) {
|
|
|
|
|
|
|
|
|
|
|
|
console.log(title + " " + Feeds.getActive());
|
|
|
|
console.log(title + " " + Feeds.getActive());
|
|
|
|
|
|
|
|
|
|
|
|
const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) :
|
|
|
|
const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) :
|
|
|
|
Feeds.getActive();
|
|
|
|
Feeds.getActive();
|
|
|
|
|
|
|
|
|
|
|
|
const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1};
|
|
|
|
const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1};
|
|
|
|
|
|
|
|
|
|
|
|
Filters.addFilterRule(null, dojo.toJson(rule));
|
|
|
|
Filters.addFilterRule(null, dojo.toJson(rule));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
App.Error.report(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|