2018-11-29 18:03:55 +00:00
|
|
|
/* global dijit, __ */
|
|
|
|
|
2010-11-19 13:08:02 +00:00
|
|
|
var loading_progress = 0;
|
2010-09-13 11:14:18 +00:00
|
|
|
var sanity_check_done = false;
|
2011-12-26 08:02:52 +00:00
|
|
|
var init_params = {};
|
2013-03-27 05:40:07 +00:00
|
|
|
var _label_base_index = -1024;
|
2013-04-17 06:50:46 +00:00
|
|
|
var notify_hide_timerid = false;
|
2011-12-26 08:02:52 +00:00
|
|
|
|
|
|
|
Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap(
|
|
|
|
function (callOriginal, options) {
|
|
|
|
|
|
|
|
if (getInitParam("csrf_token") != undefined) {
|
|
|
|
Object.extend(options, options || { });
|
|
|
|
|
|
|
|
if (Object.isString(options.parameters))
|
|
|
|
options.parameters = options.parameters.toQueryParams();
|
|
|
|
else if (Object.isHash(options.parameters))
|
|
|
|
options.parameters = options.parameters.toObject();
|
|
|
|
|
|
|
|
options.parameters["csrf_token"] = getInitParam("csrf_token");
|
|
|
|
}
|
|
|
|
|
|
|
|
return callOriginal(options);
|
|
|
|
}
|
|
|
|
);
|
2008-05-15 04:21:00 +00:00
|
|
|
|
2007-05-15 11:41:39 +00:00
|
|
|
/* add method to remove element from array */
|
|
|
|
|
|
|
|
Array.prototype.remove = function(s) {
|
2018-11-29 17:07:23 +00:00
|
|
|
for (let i=0; i < this.length; i++) {
|
2007-05-15 11:41:39 +00:00
|
|
|
if (s == this[i]) this.splice(i, 1);
|
|
|
|
}
|
2011-12-10 17:26:59 +00:00
|
|
|
};
|
2007-05-15 11:41:39 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
function report_error(message, filename, lineno, colno, error) {
|
2017-03-05 07:50:15 +00:00
|
|
|
exception_error(error, null, filename, lineno);
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
2007-02-18 07:30:16 +00:00
|
|
|
|
2017-03-05 07:50:15 +00:00
|
|
|
function exception_error(e, e_compat, filename, lineno, colno) {
|
2017-03-04 11:34:44 +00:00
|
|
|
if (typeof e == "string") e = e_compat;
|
2009-01-23 14:20:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (!e) return; // no exception object, nothing to report.
|
2009-02-04 20:19:16 +00:00
|
|
|
|
2009-01-23 17:19:17 +00:00
|
|
|
try {
|
2017-03-05 07:50:15 +00:00
|
|
|
console.error(e);
|
2018-11-29 17:07:23 +00:00
|
|
|
const msg = e.toString();
|
2009-01-23 14:20:36 +00:00
|
|
|
|
2013-04-20 06:43:21 +00:00
|
|
|
try {
|
|
|
|
new Ajax.Request("backend.php", {
|
2017-03-05 07:50:15 +00:00
|
|
|
parameters: {op: "rpc", method: "log",
|
|
|
|
file: e.fileName ? e.fileName : filename,
|
|
|
|
line: e.lineNumber ? e.lineNumber : lineno,
|
|
|
|
msg: msg, context: e.stack},
|
2013-04-20 06:43:21 +00:00
|
|
|
onComplete: function (transport) {
|
2017-03-05 07:50:15 +00:00
|
|
|
console.warn(transport.responseText);
|
2013-04-20 06:43:21 +00:00
|
|
|
} });
|
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error("Exception while trying to log the error.", e);
|
2013-04-20 06:43:21 +00:00
|
|
|
}
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
let content = "<div class='fatalError'><p>" + msg + "</p>";
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-05 07:30:49 +00:00
|
|
|
if (e.stack) {
|
2017-03-04 11:34:44 +00:00
|
|
|
content += "<div><b>Stack trace:</b></div>" +
|
|
|
|
"<textarea name=\"stack\" readonly=\"1\">" + e.stack + "</textarea>";
|
2009-01-23 14:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-11-15 10:12:02 +00:00
|
|
|
content += "</div>";
|
|
|
|
|
2011-03-06 07:56:08 +00:00
|
|
|
content += "<div class='dlgButtons'>";
|
|
|
|
|
|
|
|
content += "<button dojoType=\"dijit.form.Button\" "+
|
2011-03-18 11:31:54 +00:00
|
|
|
"onclick=\"dijit.byId('exceptionDlg').hide()\">" +
|
2011-03-06 07:56:08 +00:00
|
|
|
__('Close') + "</button>";
|
|
|
|
content += "</div>";
|
|
|
|
|
2011-04-21 11:27:09 +00:00
|
|
|
if (dijit.byId("exceptionDlg"))
|
|
|
|
dijit.byId("exceptionDlg").destroyRecursive();
|
2010-11-14 20:46:49 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const dialog = new dijit.Dialog({
|
2011-03-06 07:56:08 +00:00
|
|
|
id: "exceptionDlg",
|
2010-11-15 10:12:02 +00:00
|
|
|
title: "Unhandled exception",
|
|
|
|
style: "width: 600px",
|
|
|
|
content: content});
|
|
|
|
|
|
|
|
dialog.show();
|
2010-11-14 20:46:49 +00:00
|
|
|
|
2013-04-20 06:43:21 +00:00
|
|
|
} catch (ei) {
|
2017-03-04 11:34:44 +00:00
|
|
|
console.error("Exception while trying to report an exception:", ei);
|
|
|
|
console.error("Original exception:", e);
|
2013-04-20 06:43:21 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
alert("Exception occured while trying to report an exception.\n" +
|
|
|
|
ei.stack + "\n\nOriginal exception:\n" + e.stack);
|
2005-12-14 07:29:38 +00:00
|
|
|
}
|
|
|
|
|
2005-11-26 10:06:56 +00:00
|
|
|
}
|
|
|
|
|
2005-08-22 05:28:27 +00:00
|
|
|
function param_escape(arg) {
|
2017-12-04 08:02:13 +00:00
|
|
|
return encodeURIComponent(arg);
|
2005-08-22 05:28:27 +00:00
|
|
|
}
|
|
|
|
|
2007-03-02 19:58:58 +00:00
|
|
|
function notify_real(msg, no_hide, n_type) {
|
2005-08-22 05:28:27 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const n = $("notify");
|
2005-08-22 05:28:27 +00:00
|
|
|
|
2013-04-17 06:50:46 +00:00
|
|
|
if (!n) return;
|
2005-09-05 12:02:00 +00:00
|
|
|
|
2006-05-19 05:44:23 +00:00
|
|
|
if (notify_hide_timerid) {
|
|
|
|
window.clearTimeout(notify_hide_timerid);
|
|
|
|
}
|
|
|
|
|
2005-11-19 18:01:06 +00:00
|
|
|
if (msg == "") {
|
2014-11-02 17:58:46 +00:00
|
|
|
if (n.hasClassName("visible")) {
|
|
|
|
notify_hide_timerid = window.setTimeout(function() {
|
|
|
|
n.removeClassName("visible") }, 0);
|
2006-05-19 05:44:23 +00:00
|
|
|
}
|
|
|
|
return;
|
2005-11-19 18:01:06 +00:00
|
|
|
}
|
2005-08-22 05:28:27 +00:00
|
|
|
|
2007-03-02 19:58:58 +00:00
|
|
|
/* types:
|
|
|
|
|
|
|
|
1 - generic
|
|
|
|
2 - progress
|
|
|
|
3 - error
|
|
|
|
4 - info
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-04-17 06:50:46 +00:00
|
|
|
msg = "<span class=\"msg\"> " + __(msg) + "</span>";
|
2007-03-06 06:54:47 +00:00
|
|
|
|
2014-11-02 17:58:46 +00:00
|
|
|
if (n_type == 2) {
|
2017-02-09 20:19:26 +00:00
|
|
|
msg = "<span><img src=\""+getInitParam("icon_indicator_white")+"\"></span>" + msg;
|
2013-04-17 06:50:46 +00:00
|
|
|
no_hide = true;
|
2007-03-02 19:58:58 +00:00
|
|
|
} else if (n_type == 3) {
|
2017-02-09 20:19:26 +00:00
|
|
|
msg = "<span><img src=\""+getInitParam("icon_alert")+"\"></span>" + msg;
|
2007-03-02 19:58:58 +00:00
|
|
|
} else if (n_type == 4) {
|
2017-02-09 20:19:26 +00:00
|
|
|
msg = "<span><img src=\""+getInitParam("icon_information")+"\"></span>" + msg;
|
2013-03-18 12:44:23 +00:00
|
|
|
}
|
|
|
|
|
2017-02-09 20:19:26 +00:00
|
|
|
msg += " <span><img src=\""+getInitParam("icon_cross")+"\" class=\"close\" title=\"" +
|
2013-04-17 06:50:46 +00:00
|
|
|
__("Click to close") + "\" onclick=\"notify('')\"></span>";
|
2013-03-18 12:44:23 +00:00
|
|
|
|
2013-04-17 06:50:46 +00:00
|
|
|
n.innerHTML = msg;
|
2006-05-18 07:56:52 +00:00
|
|
|
|
2014-11-09 17:31:29 +00:00
|
|
|
window.setTimeout(function() {
|
|
|
|
// goddamnit firefox
|
|
|
|
if (n_type == 2) {
|
|
|
|
n.className = "notify notify_progress visible";
|
|
|
|
} else if (n_type == 3) {
|
|
|
|
n.className = "notify notify_error visible";
|
|
|
|
msg = "<span><img src='images/alert.png'></span>" + msg;
|
|
|
|
} else if (n_type == 4) {
|
|
|
|
n.className = "notify notify_info visible";
|
|
|
|
} else {
|
|
|
|
n.className = "notify visible";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!no_hide) {
|
|
|
|
notify_hide_timerid = window.setTimeout(function() {
|
2014-11-02 17:58:46 +00:00
|
|
|
n.removeClassName("visible") }, 5*1000);
|
2014-11-09 17:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}, 10);
|
|
|
|
|
2006-05-18 12:01:09 +00:00
|
|
|
}
|
|
|
|
|
2007-03-02 19:58:58 +00:00
|
|
|
function notify(msg, no_hide) {
|
|
|
|
notify_real(msg, no_hide, 1);
|
2006-05-18 12:01:09 +00:00
|
|
|
}
|
|
|
|
|
2007-03-02 19:58:58 +00:00
|
|
|
function notify_progress(msg, no_hide) {
|
|
|
|
notify_real(msg, no_hide, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function notify_error(msg, no_hide) {
|
|
|
|
notify_real(msg, no_hide, 3);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function notify_info(msg, no_hide) {
|
|
|
|
notify_real(msg, no_hide, 4);
|
2005-08-22 05:28:27 +00:00
|
|
|
}
|
|
|
|
|
2006-03-20 16:53:11 +00:00
|
|
|
function setCookie(name, value, lifetime, path, domain, secure) {
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
let d = false;
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2006-03-20 16:53:11 +00:00
|
|
|
if (lifetime) {
|
|
|
|
d = new Date();
|
2007-03-21 15:36:24 +00:00
|
|
|
d.setTime(d.getTime() + (lifetime * 1000));
|
2006-03-20 16:53:11 +00:00
|
|
|
}
|
2007-03-22 06:46:49 +00:00
|
|
|
|
2010-09-05 09:41:19 +00:00
|
|
|
console.log("setCookie: " + name + " => " + value + ": " + d);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2006-03-20 16:53:11 +00:00
|
|
|
int_setCookie(name, value, d, path, domain, secure);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function int_setCookie(name, value, expires, path, domain, secure) {
|
2005-09-06 04:14:17 +00:00
|
|
|
document.cookie= name + "=" + escape(value) +
|
|
|
|
((expires) ? "; expires=" + expires.toGMTString() : "") +
|
|
|
|
((path) ? "; path=" + path : "") +
|
|
|
|
((domain) ? "; domain=" + domain : "") +
|
|
|
|
((secure) ? "; secure" : "");
|
|
|
|
}
|
|
|
|
|
2006-03-20 16:53:11 +00:00
|
|
|
function delCookie(name, path, domain) {
|
|
|
|
if (getCookie(name)) {
|
|
|
|
document.cookie = name + "=" +
|
|
|
|
((path) ? ";path=" + path : "") +
|
|
|
|
((domain) ? ";domain=" + domain : "" ) +
|
|
|
|
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
|
|
|
|
}
|
|
|
|
}
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2006-03-20 16:53:11 +00:00
|
|
|
|
2005-09-06 04:14:17 +00:00
|
|
|
function getCookie(name) {
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const dc = document.cookie;
|
|
|
|
const prefix = name + "=";
|
|
|
|
let begin = dc.indexOf("; " + prefix);
|
2005-09-06 04:14:17 +00:00
|
|
|
if (begin == -1) {
|
|
|
|
begin = dc.indexOf(prefix);
|
|
|
|
if (begin != 0) return null;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
begin += 2;
|
|
|
|
}
|
2018-11-29 17:07:23 +00:00
|
|
|
let end = document.cookie.indexOf(";", begin);
|
2005-09-06 04:14:17 +00:00
|
|
|
if (end == -1) {
|
|
|
|
end = dc.length;
|
|
|
|
}
|
|
|
|
return unescape(dc.substring(begin + prefix.length, end));
|
|
|
|
}
|
|
|
|
|
2005-09-07 07:19:14 +00:00
|
|
|
function gotoPreferences() {
|
|
|
|
document.location.href = "prefs.php";
|
|
|
|
}
|
|
|
|
|
2013-02-06 16:14:06 +00:00
|
|
|
function gotoLogout() {
|
|
|
|
document.location.href = "backend.php?op=logout";
|
|
|
|
}
|
|
|
|
|
2005-09-07 07:19:14 +00:00
|
|
|
function gotoMain() {
|
2011-12-11 19:59:25 +00:00
|
|
|
document.location.href = "index.php";
|
2005-09-07 07:19:14 +00:00
|
|
|
}
|
|
|
|
|
2005-12-13 05:52:32 +00:00
|
|
|
function toggleSelectRowById(sender, id) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const row = $(id);
|
2010-11-14 12:55:51 +00:00
|
|
|
return toggleSelectRow(sender, row);
|
2005-12-13 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
2010-11-18 19:26:04 +00:00
|
|
|
/* this is for dijit Checkbox */
|
|
|
|
function toggleSelectListRow2(sender) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const row = sender.domNode.parentNode;
|
2010-11-18 19:26:04 +00:00
|
|
|
return toggleSelectRow(sender, row);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is for dijit Checkbox */
|
2013-02-28 10:22:13 +00:00
|
|
|
function toggleSelectRow2(sender, row, is_cdm) {
|
2010-11-18 19:26:04 +00:00
|
|
|
|
2013-02-28 10:22:13 +00:00
|
|
|
if (!row)
|
|
|
|
if (!is_cdm)
|
|
|
|
row = sender.domNode.parentNode.parentNode;
|
|
|
|
else
|
|
|
|
row = sender.domNode.parentNode.parentNode.parentNode; // oh ffs
|
2010-11-18 19:26:04 +00:00
|
|
|
|
|
|
|
if (sender.checked && !row.hasClassName('Selected'))
|
|
|
|
row.addClassName('Selected');
|
|
|
|
else
|
|
|
|
row.removeClassName('Selected');
|
2013-04-15 09:16:14 +00:00
|
|
|
|
|
|
|
if (typeof updateSelectedPrompt != undefined)
|
|
|
|
updateSelectedPrompt();
|
2010-11-18 19:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-28 11:48:09 +00:00
|
|
|
function toggleSelectRow(sender, row) {
|
2005-11-27 14:56:10 +00:00
|
|
|
|
2013-02-28 11:48:09 +00:00
|
|
|
if (!row) row = sender.parentNode.parentNode;
|
2010-11-14 12:55:51 +00:00
|
|
|
|
|
|
|
if (sender.checked && !row.hasClassName('Selected'))
|
|
|
|
row.addClassName('Selected');
|
|
|
|
else
|
|
|
|
row.removeClassName('Selected');
|
2013-04-15 09:16:14 +00:00
|
|
|
|
|
|
|
if (typeof updateSelectedPrompt != undefined)
|
|
|
|
updateSelectedPrompt();
|
2005-11-27 14:56:10 +00:00
|
|
|
}
|
|
|
|
|
2007-08-11 16:43:45 +00:00
|
|
|
function checkboxToggleElement(elem, id) {
|
|
|
|
if (elem.checked) {
|
2010-11-15 10:12:02 +00:00
|
|
|
Effect.Appear(id, {duration : 0.5});
|
2007-08-11 16:43:45 +00:00
|
|
|
} else {
|
2008-08-06 07:51:28 +00:00
|
|
|
Effect.Fade(id, {duration : 0.5});
|
2007-08-11 16:43:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-08 08:28:21 +00:00
|
|
|
function getURLParam(param){
|
|
|
|
return String(window.location.href).parseQuery()[param];
|
2011-03-18 11:31:54 +00:00
|
|
|
}
|
2006-02-28 16:25:38 +00:00
|
|
|
|
2017-12-04 08:02:13 +00:00
|
|
|
function closeInfoBox() {
|
2018-11-29 17:07:23 +00:00
|
|
|
const dialog = dijit.byId("infoBox");
|
2010-11-15 10:12:02 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dialog) dialog.hide();
|
2009-01-23 14:20:36 +00:00
|
|
|
|
2006-07-25 10:47:51 +00:00
|
|
|
return false;
|
2006-05-18 04:58:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-01 06:47:41 +00:00
|
|
|
function displayDlg(title, id, param, callback) {
|
2006-05-18 02:48:33 +00:00
|
|
|
|
2010-11-14 20:46:49 +00:00
|
|
|
notify_progress("Loading, please wait...", true);
|
2006-05-18 08:29:17 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "?op=dlg&method=" +
|
2007-08-25 12:11:54 +00:00
|
|
|
param_escape(id) + "¶m=" + param_escape(param);
|
|
|
|
|
2009-12-29 15:49:27 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
2007-08-25 12:11:54 +00:00
|
|
|
onComplete: function (transport) {
|
2013-04-01 06:47:41 +00:00
|
|
|
infobox_callback2(transport, title);
|
2010-01-06 11:17:28 +00:00
|
|
|
if (callback) callback(transport);
|
2007-08-25 12:11:54 +00:00
|
|
|
} });
|
|
|
|
|
2006-07-25 10:47:51 +00:00
|
|
|
return false;
|
2006-05-18 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
2013-04-01 06:47:41 +00:00
|
|
|
function infobox_callback2(transport, title) {
|
2018-11-29 17:07:23 +00:00
|
|
|
let dialog = false;
|
2010-11-17 07:12:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("infoBox")) {
|
|
|
|
dialog = dijit.byId("infoBox");
|
|
|
|
}
|
2007-05-14 08:08:18 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
//console.log("infobox_callback2");
|
|
|
|
notify('');
|
2007-05-14 08:08:18 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const content = transport.responseText;
|
2007-08-10 07:35:55 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (!dialog) {
|
|
|
|
dialog = new dijit.Dialog({
|
|
|
|
title: title,
|
|
|
|
id: 'infoBox',
|
|
|
|
style: "width: 600px",
|
|
|
|
onCancel: function() {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
onExecute: function() {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
onClose: function() {
|
|
|
|
return true;
|
2010-11-17 07:12:50 +00:00
|
|
|
},
|
2017-03-04 11:34:44 +00:00
|
|
|
content: content});
|
|
|
|
} else {
|
|
|
|
dialog.attr('title', title);
|
|
|
|
dialog.attr('content', content);
|
|
|
|
}
|
2010-11-15 10:12:02 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dialog.show();
|
2010-11-15 10:12:02 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
notify("");
|
2007-05-14 05:41:04 +00:00
|
|
|
}
|
|
|
|
|
2006-05-23 06:15:49 +00:00
|
|
|
function getInitParam(key) {
|
2007-03-26 05:23:15 +00:00
|
|
|
return init_params[key];
|
2006-05-23 06:15:49 +00:00
|
|
|
}
|
2006-05-23 05:34:50 +00:00
|
|
|
|
2010-01-12 08:48:31 +00:00
|
|
|
function setInitParam(key, value) {
|
2007-05-11 07:50:02 +00:00
|
|
|
init_params[key] = value;
|
2007-03-21 15:36:24 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 17:19:17 +00:00
|
|
|
function fatalError(code, msg, ext_info) {
|
2017-03-04 11:34:44 +00:00
|
|
|
if (code == 6) {
|
|
|
|
window.location.href = "index.php";
|
|
|
|
} else if (code == 5) {
|
|
|
|
window.location.href = "public.php?op=dbupdate";
|
|
|
|
} else {
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (msg == "") msg = "Unknown error";
|
2007-03-02 19:58:58 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (ext_info) {
|
|
|
|
if (ext_info.responseText) {
|
|
|
|
ext_info = ext_info.responseText;
|
2011-02-18 09:28:03 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
2011-02-18 09:28:03 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (ERRORS && ERRORS[code] && !msg) {
|
|
|
|
msg = ERRORS[code];
|
|
|
|
}
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
let content = "<div><b>Error code:</b> " + code + "</div>" +
|
2017-03-04 11:34:44 +00:00
|
|
|
"<p>" + msg + "</p>";
|
2011-02-18 09:28:03 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (ext_info) {
|
|
|
|
content = content + "<div><b>Additional information:</b></div>" +
|
|
|
|
"<textarea style='width: 100%' readonly=\"1\">" +
|
|
|
|
ext_info + "</textarea>";
|
|
|
|
}
|
2011-02-18 09:28:03 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const dialog = new dijit.Dialog({
|
2017-03-04 11:34:44 +00:00
|
|
|
title: "Fatal error",
|
|
|
|
style: "width: 600px",
|
|
|
|
content: content});
|
2011-02-18 09:28:03 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dialog.show();
|
2011-02-18 09:28:03 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
2006-05-23 07:15:48 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
return false;
|
2011-02-18 09:28:03 +00:00
|
|
|
|
2006-05-23 07:15:48 +00:00
|
|
|
}
|
|
|
|
|
2006-12-08 08:05:21 +00:00
|
|
|
function filterDlgCheckAction(sender) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const action = sender.value;
|
2006-12-08 08:05:21 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const action_param = $("filterDlg_paramBox");
|
2006-12-08 08:05:21 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (!action_param) {
|
|
|
|
console.log("filterDlgCheckAction: can't find action param box!");
|
|
|
|
return;
|
|
|
|
}
|
2015-08-11 20:28:41 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
// if selected action supports parameters, enable params field
|
|
|
|
if (action == 4 || action == 6 || action == 7 || action == 9) {
|
|
|
|
new Effect.Appear(action_param, {duration : 0.5});
|
2015-08-11 20:28:41 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
Element.hide(dijit.byId("filterDlg_actionParam").domNode);
|
|
|
|
Element.hide(dijit.byId("filterDlg_actionParamLabel").domNode);
|
|
|
|
Element.hide(dijit.byId("filterDlg_actionParamPlugin").domNode);
|
2015-08-11 20:28:41 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (action == 7) {
|
|
|
|
Element.show(dijit.byId("filterDlg_actionParamLabel").domNode);
|
|
|
|
} else if (action == 9) {
|
|
|
|
Element.show(dijit.byId("filterDlg_actionParamPlugin").domNode);
|
2006-12-08 08:05:21 +00:00
|
|
|
} else {
|
2017-03-04 11:34:44 +00:00
|
|
|
Element.show(dijit.byId("filterDlg_actionParam").domNode);
|
2006-12-08 08:05:21 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} else {
|
|
|
|
Element.hide(action_param);
|
2006-12-08 08:05:21 +00:00
|
|
|
}
|
|
|
|
}
|
2007-01-27 09:21:55 +00:00
|
|
|
|
2008-12-13 11:57:53 +00:00
|
|
|
|
2007-01-27 09:21:55 +00:00
|
|
|
function explainError(code) {
|
2013-04-01 06:47:41 +00:00
|
|
|
return displayDlg(__("Error explained"), "explainError", code);
|
2007-01-27 09:21:55 +00:00
|
|
|
}
|
2007-03-01 09:43:54 +00:00
|
|
|
|
2008-05-19 08:03:53 +00:00
|
|
|
function loading_set_progress(p) {
|
2017-03-04 11:34:44 +00:00
|
|
|
loading_progress += p;
|
2008-05-19 08:12:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("loading_bar"))
|
|
|
|
dijit.byId("loading_bar").update({progress: loading_progress});
|
2008-05-19 08:03:53 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (loading_progress >= 90)
|
|
|
|
remove_splash();
|
2008-05-19 07:37:44 +00:00
|
|
|
|
|
|
|
}
|
2008-05-19 12:00:35 +00:00
|
|
|
|
|
|
|
function remove_splash() {
|
2018-11-29 18:03:55 +00:00
|
|
|
Element.hide("overlay");
|
2008-05-19 12:00:35 +00:00
|
|
|
}
|
2008-08-07 08:06:12 +00:00
|
|
|
|
2009-02-03 16:09:59 +00:00
|
|
|
function strip_tags(s) {
|
|
|
|
return s.replace(/<\/?[^>]+(>|$)/g, "");
|
|
|
|
}
|
|
|
|
|
2009-10-09 09:13:57 +00:00
|
|
|
function hotkey_prefix_timeout() {
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const date = new Date();
|
|
|
|
const ts = Math.round(date.getTime() / 1000);
|
2009-10-09 09:13:57 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (hotkey_prefix_pressed && ts - hotkey_prefix_pressed >= 5) {
|
|
|
|
console.log("hotkey_prefix seems to be stuck, aborting");
|
|
|
|
hotkey_prefix_pressed = false;
|
|
|
|
hotkey_prefix = false;
|
|
|
|
Element.hide('cmdline');
|
|
|
|
}
|
2009-10-09 09:13:57 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
setTimeout(hotkey_prefix_timeout, 1000);
|
2009-10-09 09:13:57 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-01-14 09:47:28 +00:00
|
|
|
function uploadIconHandler(rc) {
|
2017-03-04 11:34:44 +00:00
|
|
|
switch (rc) {
|
|
|
|
case 0:
|
|
|
|
notify_info("Upload complete.");
|
|
|
|
if (inPreferences()) {
|
|
|
|
updateFeedList();
|
|
|
|
} else {
|
|
|
|
setTimeout('updateFeedList(false, false)', 50);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
notify_error("Upload failed: icon is too big.");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
notify_error("Upload failed.");
|
|
|
|
break;
|
2010-01-14 09:47:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeFeedIcon(id) {
|
2017-03-04 11:34:44 +00:00
|
|
|
if (confirm(__("Remove stored feed icon?"))) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=pref-feeds&method=removeicon&feed_id=" + param_escape(id);
|
2010-01-14 09:47:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(query);
|
2010-01-14 09:47:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
notify_progress("Removing feed icon...", true);
|
2010-01-14 08:28:57 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function(transport) {
|
|
|
|
notify_info("Feed icon removed.");
|
|
|
|
if (inPreferences()) {
|
|
|
|
updateFeedList();
|
|
|
|
} else {
|
|
|
|
setTimeout('updateFeedList(false, false)', 50);
|
|
|
|
}
|
|
|
|
} });
|
|
|
|
}
|
2010-01-14 08:28:57 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-01-14 08:28:57 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
function uploadFeedIcon() {
|
2018-11-29 17:07:23 +00:00
|
|
|
const file = $("icon_file");
|
2010-01-14 09:47:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (file.value.length == 0) {
|
|
|
|
alert(__("Please select an image file to upload."));
|
2018-11-29 17:07:23 +00:00
|
|
|
} else if (confirm(__("Upload new icon for this feed?"))) {
|
2017-03-04 11:34:44 +00:00
|
|
|
notify_progress("Uploading, please wait...", true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-01-14 08:28:57 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
function addLabel(select, callback) {
|
2010-01-14 08:28:57 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const caption = prompt(__("Please enter label caption:"), "");
|
2010-01-14 08:28:57 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (caption != undefined) {
|
2010-01-14 08:28:57 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (caption == "") {
|
|
|
|
alert(__("Can't create label: missing caption."));
|
|
|
|
return false;
|
2010-01-14 08:28:57 +00:00
|
|
|
}
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
let query = "?op=pref-labels&method=add&caption=" +
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(caption);
|
2010-01-14 09:47:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (select)
|
|
|
|
query += "&output=select";
|
2010-01-14 08:28:57 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
notify_progress("Loading, please wait...", true);
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function(transport) {
|
|
|
|
if (callback) {
|
|
|
|
callback(transport);
|
|
|
|
} else if (inPreferences()) {
|
|
|
|
updateLabelList();
|
|
|
|
} else {
|
|
|
|
updateFeedList();
|
|
|
|
}
|
|
|
|
} });
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
function quickAddFeed() {
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=feeds&method=quickAddFeed";
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
// overlapping widgets
|
|
|
|
if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
|
|
|
|
if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
|
2010-11-08 22:04:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
var dialog = new dijit.Dialog({
|
|
|
|
id: "feedAddDlg",
|
|
|
|
title: __("Subscribe to Feed"),
|
|
|
|
style: "width: 600px",
|
|
|
|
show_error: function(msg) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const elem = $("fadd_error_message");
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
elem.innerHTML = msg;
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (!Element.visible(elem))
|
|
|
|
new Effect.Appear(elem);
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
},
|
|
|
|
execute: function() {
|
|
|
|
if (this.validate()) {
|
|
|
|
console.log(dojo.objectToQuery(this.attr('value')));
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const feed_url = this.attr('value').feed;
|
2010-02-03 13:06:24 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
Element.show("feed_add_spinner");
|
|
|
|
Element.hide("fadd_error_message");
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: dojo.objectToQuery(this.attr('value')),
|
|
|
|
onComplete: function(transport) {
|
|
|
|
try {
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
try {
|
|
|
|
var reply = JSON.parse(transport.responseText);
|
|
|
|
} catch (e) {
|
|
|
|
Element.hide("feed_add_spinner");
|
|
|
|
alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console."));
|
|
|
|
console.log('quickAddFeed, backend returned:' + transport.responseText);
|
|
|
|
return;
|
|
|
|
}
|
2017-01-28 09:45:49 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const rc = reply['result'];
|
2017-01-28 09:45:49 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
notify('');
|
|
|
|
Element.hide("feed_add_spinner");
|
2017-01-28 09:45:49 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(rc);
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
switch (parseInt(rc['code'])) {
|
|
|
|
case 1:
|
|
|
|
dialog.hide();
|
|
|
|
notify_info(__("Subscribed to %s").replace("%s", feed_url));
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
updateFeedList();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
dialog.show_error(__("Specified URL seems to be invalid."));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
dialog.show_error(__("Specified URL doesn't seem to contain any feeds."));
|
|
|
|
break;
|
|
|
|
case 4:
|
2018-03-11 19:35:36 +00:00
|
|
|
var feeds = rc['feeds'];
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
Element.show("fadd_multiple_notify");
|
2010-11-29 13:02:16 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
var select = dijit.byId("feedDlg_feedContainerSelect");
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
while (select.getOptions().length > 0)
|
|
|
|
select.removeOption(0);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
select.addOption({value: '', label: __("Expand to select feed")});
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
var count = 0;
|
2018-11-29 17:07:23 +00:00
|
|
|
for (const feedUrl in feeds) {
|
2017-03-04 11:34:44 +00:00
|
|
|
select.addOption({value: feedUrl, label: feeds[feedUrl]});
|
|
|
|
count++;
|
2010-11-20 18:06:36 +00:00
|
|
|
}
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
Effect.Appear('feedDlg_feedsContainer', {duration : 0.5});
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
dialog.show_error(__("Couldn't download the specified URL: %s").
|
|
|
|
replace("%s", rc['message']));
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
dialog.show_error(__("XML validation failed: %s").
|
|
|
|
replace("%s", rc['message']));
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
dialog.show_error(__("You are already subscribed to this feed."));
|
|
|
|
break;
|
2010-11-20 18:06:36 +00:00
|
|
|
}
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error(transport.responseText);
|
|
|
|
exception_error(e);
|
|
|
|
}
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} });
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
href: query});
|
|
|
|
|
|
|
|
dialog.show();
|
2010-02-03 13:54:17 +00:00
|
|
|
}
|
|
|
|
|
2012-08-30 14:50:56 +00:00
|
|
|
function createNewRuleElement(parentNode, replaceNode) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const form = document.forms["filter_new_rule_form"];
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
//form.reg_exp.value = form.reg_exp.value.replace(/(<([^>]+)>)/ig,"");
|
2013-03-17 10:55:55 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=pref-filters&method=printrulename&rule="+
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(dojo.formToJson(form));
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(query);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function (transport) {
|
|
|
|
try {
|
2018-11-29 17:07:23 +00:00
|
|
|
const li = dojo.create("li");
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const cb = dojo.create("input", { type: "checkbox" }, li);
|
2012-08-31 11:26:11 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new dijit.form.CheckBox({
|
|
|
|
onChange: function() {
|
|
|
|
toggleSelectListRow2(this) },
|
|
|
|
}, cb);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dojo.create("input", { type: "hidden",
|
|
|
|
name: "rule[]",
|
|
|
|
value: dojo.formToJson(form) }, li);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dojo.create("span", {
|
|
|
|
onclick: function() {
|
|
|
|
dijit.byId('filterEditDlg').editRule(this);
|
|
|
|
},
|
|
|
|
innerHTML: transport.responseText }, li);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (replaceNode) {
|
|
|
|
parentNode.replaceChild(li, replaceNode);
|
|
|
|
} else {
|
|
|
|
parentNode.appendChild(li);
|
2012-08-30 14:50:56 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
} catch (e) {
|
|
|
|
exception_error(e);
|
|
|
|
}
|
|
|
|
} });
|
2012-08-30 14:50:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function createNewActionElement(parentNode, replaceNode) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const form = document.forms["filter_new_action_form"];
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
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;
|
|
|
|
}
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=pref-filters&method=printactionname&action="+
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(dojo.formToJson(form));
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(query);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function (transport) {
|
|
|
|
try {
|
2018-11-29 17:07:23 +00:00
|
|
|
const li = dojo.create("li");
|
2012-08-31 11:26:11 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const cb = dojo.create("input", { type: "checkbox" }, li);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new dijit.form.CheckBox({
|
|
|
|
onChange: function() {
|
|
|
|
toggleSelectListRow2(this) },
|
|
|
|
}, cb);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dojo.create("input", { type: "hidden",
|
|
|
|
name: "action[]",
|
|
|
|
value: dojo.formToJson(form) }, li);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dojo.create("span", {
|
|
|
|
onclick: function() {
|
|
|
|
dijit.byId('filterEditDlg').editAction(this);
|
|
|
|
},
|
|
|
|
innerHTML: transport.responseText }, li);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (replaceNode) {
|
|
|
|
parentNode.replaceChild(li, replaceNode);
|
|
|
|
} else {
|
|
|
|
parentNode.appendChild(li);
|
2012-08-30 14:50:56 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
exception_error(e);
|
|
|
|
}
|
|
|
|
} });
|
2012-08-30 14:50:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addFilterRule(replaceNode, ruleStr) {
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("filterNewRuleDlg"))
|
|
|
|
dijit.byId("filterNewRuleDlg").destroyRecursive();
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=pref-filters&method=newrule&rule=" +
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(ruleStr);
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const rule_dlg = new dijit.Dialog({
|
2017-03-04 11:34:44 +00:00
|
|
|
id: "filterNewRuleDlg",
|
|
|
|
title: ruleStr ? __("Edit rule") : __("Add rule"),
|
|
|
|
style: "width: 600px",
|
|
|
|
execute: function() {
|
|
|
|
if (this.validate()) {
|
|
|
|
createNewRuleElement($("filterDlg_Matches"), replaceNode);
|
|
|
|
this.hide();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
href: query});
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
rule_dlg.show();
|
2012-08-30 14:50:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addFilterAction(replaceNode, actionStr) {
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("filterNewActionDlg"))
|
|
|
|
dijit.byId("filterNewActionDlg").destroyRecursive();
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=pref-filters&method=newaction&action=" +
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(actionStr);
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const rule_dlg = new dijit.Dialog({
|
2017-03-04 11:34:44 +00:00
|
|
|
id: "filterNewActionDlg",
|
|
|
|
title: actionStr ? __("Edit action") : __("Add action"),
|
|
|
|
style: "width: 600px",
|
|
|
|
execute: function() {
|
|
|
|
if (this.validate()) {
|
|
|
|
createNewActionElement($("filterDlg_Actions"), replaceNode);
|
|
|
|
this.hide();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
href: query});
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
rule_dlg.show();
|
2012-08-30 14:50:56 +00:00
|
|
|
}
|
|
|
|
|
2015-09-09 19:13:43 +00:00
|
|
|
function editFilterTest(query) {
|
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("filterTestDlg"))
|
|
|
|
dijit.byId("filterTestDlg").destroyRecursive();
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
var test_dlg = new dijit.Dialog({
|
|
|
|
id: "filterTestDlg",
|
|
|
|
title: "Test Filter",
|
|
|
|
style: "width: 600px",
|
|
|
|
results: 0,
|
|
|
|
limit: 100,
|
|
|
|
max_offset: 10000,
|
|
|
|
getTestResults: function(query, offset) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const updquery = query + "&offset=" + offset + "&limit=" + test_dlg.limit;
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log("getTestResults:" + offset);
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: updquery,
|
|
|
|
onComplete: function (transport) {
|
|
|
|
try {
|
2018-11-29 17:07:23 +00:00
|
|
|
const result = JSON.parse(transport.responseText);
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) {
|
2018-11-29 18:03:55 +00:00
|
|
|
test_dlg.results += result.length;
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2018-11-29 18:03:55 +00:00
|
|
|
console.log("got results:" + result.length);
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
$("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...")
|
|
|
|
.replace("%f", test_dlg.results)
|
|
|
|
.replace("%d", offset);
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(offset + " " + test_dlg.max_offset);
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2018-11-29 18:03:55 +00:00
|
|
|
for (let i = 0; i < result.length; i++) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const tmp = new Element("table");
|
2017-03-04 11:34:44 +00:00
|
|
|
tmp.innerHTML = result[i];
|
|
|
|
dojo.parser.parse(tmp);
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
$("prefFilterTestResultList").innerHTML += tmp.innerHTML;
|
|
|
|
}
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (test_dlg.results < 30 && offset < test_dlg.max_offset) {
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
// get the next batch
|
|
|
|
window.setTimeout(function () {
|
|
|
|
test_dlg.getTestResults(query, offset + test_dlg.limit);
|
|
|
|
}, 0);
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} else {
|
|
|
|
// all done
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
Element.hide("prefFilterLoadingIndicator");
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
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);
|
2015-09-09 19:13:43 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} else if (!result) {
|
|
|
|
console.log("getTestResults: can't parse results object");
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
Element.hide("prefFilterLoadingIndicator");
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
notify_error("Error while trying to get filter test results.");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
console.log("getTestResults: dialog closed, bailing out.");
|
2015-09-09 19:13:43 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
} catch (e) {
|
|
|
|
exception_error(e);
|
|
|
|
}
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} });
|
|
|
|
},
|
|
|
|
href: query});
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dojo.connect(test_dlg, "onLoad", null, function(e) {
|
|
|
|
test_dlg.getTestResults(query, 0);
|
|
|
|
});
|
2015-09-09 19:13:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
test_dlg.show();
|
2015-09-09 19:13:43 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-02-03 13:54:17 +00:00
|
|
|
function quickAddFilter() {
|
2018-11-29 17:07:23 +00:00
|
|
|
let query = "";
|
2017-03-04 11:34:44 +00:00
|
|
|
if (!inPreferences()) {
|
|
|
|
query = "backend.php?op=pref-filters&method=newfilter&feed=" +
|
|
|
|
param_escape(getActiveFeedId()) + "&is_cat=" +
|
|
|
|
param_escape(activeFeedIsCat());
|
|
|
|
} else {
|
|
|
|
query = "backend.php?op=pref-filters&method=newfilter";
|
|
|
|
}
|
2010-11-20 11:10:26 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(query);
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("feedEditDlg"))
|
|
|
|
dijit.byId("feedEditDlg").destroyRecursive();
|
2011-12-28 10:43:55 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("filterEditDlg"))
|
|
|
|
dijit.byId("filterEditDlg").destroyRecursive();
|
2010-11-20 11:10:26 +00:00
|
|
|
|
2018-03-10 13:11:33 +00:00
|
|
|
var dialog = new dijit.Dialog({
|
2017-03-04 11:34:44 +00:00
|
|
|
id: "filterEditDlg",
|
|
|
|
title: __("Create Filter"),
|
|
|
|
style: "width: 600px",
|
|
|
|
test: function() {
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?" + dojo.formToQuery("filter_new_form") + "&savemode=test";
|
2012-09-03 11:05:43 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
editFilterTest(query);
|
|
|
|
},
|
|
|
|
selectRules: function(select) {
|
|
|
|
$$("#filterDlg_Matches input[type=checkbox]").each(function(e) {
|
|
|
|
e.checked = select;
|
|
|
|
if (select)
|
|
|
|
e.parentNode.addClassName("Selected");
|
|
|
|
else
|
|
|
|
e.parentNode.removeClassName("Selected");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
selectActions: function(select) {
|
|
|
|
$$("#filterDlg_Actions input[type=checkbox]").each(function(e) {
|
|
|
|
e.checked = select;
|
2010-11-20 12:02:20 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (select)
|
|
|
|
e.parentNode.addClassName("Selected");
|
|
|
|
else
|
|
|
|
e.parentNode.removeClassName("Selected");
|
2010-11-20 12:02:20 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
editRule: function(e) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const li = e.parentNode;
|
|
|
|
const rule = li.getElementsByTagName("INPUT")[1].value;
|
2017-03-04 11:34:44 +00:00
|
|
|
addFilterRule(li, rule);
|
|
|
|
},
|
|
|
|
editAction: function(e) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const li = e.parentNode;
|
|
|
|
const action = li.getElementsByTagName("INPUT")[1].value;
|
2017-03-04 11:34:44 +00:00
|
|
|
addFilterAction(li, action);
|
|
|
|
},
|
|
|
|
addAction: function() { addFilterAction(); },
|
|
|
|
addRule: function() { addFilterRule(); },
|
|
|
|
deleteAction: function() {
|
2018-02-04 09:50:21 +00:00
|
|
|
$$("#filterDlg_Actions li[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
|
2017-03-04 11:34:44 +00:00
|
|
|
},
|
|
|
|
deleteRule: function() {
|
2018-02-04 09:50:21 +00:00
|
|
|
$$("#filterDlg_Matches li[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
|
2017-03-04 11:34:44 +00:00
|
|
|
},
|
|
|
|
execute: function() {
|
|
|
|
if (this.validate()) {
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = dojo.formToQuery("filter_new_form");
|
2017-03-04 11:34:44 +00:00
|
|
|
|
|
|
|
console.log(query);
|
2010-11-20 12:02:20 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function (transport) {
|
|
|
|
if (inPreferences()) {
|
|
|
|
updateFilterList();
|
|
|
|
}
|
2012-08-30 14:50:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dialog.hide();
|
|
|
|
} });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
href: query});
|
2010-11-20 11:10:26 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (!inPreferences()) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const selectedText = getSelectionText();
|
2013-11-12 10:21:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
var lh = dojo.connect(dialog, "onLoad", function(){
|
|
|
|
dojo.disconnect(lh);
|
2012-08-31 13:33:22 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (selectedText != "") {
|
2012-08-31 13:33:22 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
|
2017-03-04 11:34:44 +00:00
|
|
|
getActiveFeedId();
|
2013-11-12 10:21:28 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const rule = { reg_exp: selectedText, feed_id: [feed_id], filter_type: 1 };
|
2013-11-12 10:21:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
addFilterRule(null, dojo.toJson(rule));
|
2013-11-12 10:21:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} else {
|
2012-08-31 13:33:22 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId();
|
2012-08-31 13:33:22 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function(transport) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const reply = JSON.parse(transport.responseText);
|
2012-08-31 13:33:22 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
let title = false;
|
2013-03-22 05:49:45 +00:00
|
|
|
|
2018-03-11 19:35:36 +00:00
|
|
|
if (reply && reply.title) title = reply.title;
|
2013-03-22 05:49:45 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (title || getActiveFeedId() || activeFeedIsCat()) {
|
2013-03-22 05:49:45 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(title + " " + getActiveFeedId());
|
2013-03-22 05:49:45 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
|
2017-03-04 11:34:44 +00:00
|
|
|
getActiveFeedId();
|
2013-03-22 05:49:45 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const rule = { reg_exp: title, feed_id: [feed_id], filter_type: 1 };
|
2013-11-12 10:21:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
addFilterRule(null, dojo.toJson(rule));
|
|
|
|
}
|
2013-11-12 10:21:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} });
|
2013-11-12 10:21:28 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
2012-08-31 13:33:22 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
});
|
|
|
|
}
|
2012-08-31 13:33:22 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dialog.show();
|
2012-06-20 06:19:29 +00:00
|
|
|
|
2010-02-03 13:54:17 +00:00
|
|
|
}
|
2010-02-15 12:16:53 +00:00
|
|
|
|
|
|
|
function unsubscribeFeed(feed_id, title) {
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const msg = __("Unsubscribe from %s?").replace("%s", title);
|
2010-02-15 12:16:53 +00:00
|
|
|
|
|
|
|
if (title == undefined || confirm(msg)) {
|
|
|
|
notify_progress("Removing feed...");
|
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "?op=pref-feeds&quiet=1&method=remove&ids=" + feed_id;
|
2010-02-15 12:16:53 +00:00
|
|
|
|
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function(transport) {
|
|
|
|
|
2010-11-20 18:06:36 +00:00
|
|
|
if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide();
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2010-02-15 12:16:53 +00:00
|
|
|
if (inPreferences()) {
|
2011-03-18 11:31:54 +00:00
|
|
|
updateFeedList();
|
2010-02-15 12:16:53 +00:00
|
|
|
} else {
|
2010-11-23 10:03:36 +00:00
|
|
|
if (feed_id == getActiveFeedId())
|
2017-01-20 18:13:31 +00:00
|
|
|
setTimeout(function() { viewfeed({feed:-5}) }, 100);
|
2013-02-28 16:09:25 +00:00
|
|
|
|
|
|
|
if (feed_id < 0) updateFeedList();
|
2010-02-15 12:16:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} });
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-13 11:14:18 +00:00
|
|
|
function backend_sanity_check_callback(transport) {
|
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (sanity_check_done) {
|
|
|
|
fatalError(11, "Sanity check request received twice. This can indicate "+
|
|
|
|
"presence of Firebug or some other disrupting extension. "+
|
|
|
|
"Please disable it and try again.");
|
|
|
|
return;
|
|
|
|
}
|
2010-09-13 11:14:18 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const reply = JSON.parse(transport.responseText);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (!reply) {
|
|
|
|
fatalError(3, "Sanity check: invalid RPC reply", transport.responseText);
|
|
|
|
return;
|
|
|
|
}
|
2010-09-13 11:14:18 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const error_code = reply['error']['code'];
|
2010-09-13 11:14:18 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (error_code && error_code != 0) {
|
|
|
|
return fatalError(error_code, reply['error']['message']);
|
|
|
|
}
|
2010-09-13 11:14:18 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log("sanity check ok");
|
2010-11-05 13:16:30 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const params = reply['init-params'];
|
2010-11-10 11:23:26 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (params) {
|
|
|
|
console.log('reading init-params...');
|
2013-04-27 16:01:54 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
for (const k in params) {
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log("IP: " + k + " => " + JSON.stringify(params[k]));
|
|
|
|
if (k == "label_base_index") _label_base_index = parseInt(params[k]);
|
2010-09-13 11:14:18 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
init_params = params;
|
2010-09-13 11:14:18 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
// PluginHost might not be available on non-index pages
|
|
|
|
window.PluginHost && PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, init_params);
|
2011-03-18 11:31:54 +00:00
|
|
|
}
|
2010-11-07 20:30:05 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
sanity_check_done = true;
|
2010-11-07 20:30:05 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
init_second_stage();
|
2010-11-07 20:30:05 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-11-08 10:11:56 +00:00
|
|
|
function genUrlChangeKey(feed, is_cat) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const ok = confirm(__("Generate new syndication address for this feed?"));
|
2010-11-08 10:11:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (ok) {
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
notify_progress("Trying to change address...", true);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "?op=pref-feeds&method=regenFeedKey&id=" + param_escape(feed) +
|
2017-03-04 11:34:44 +00:00
|
|
|
"&is_cat=" + param_escape(is_cat);
|
2010-11-08 10:11:56 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function(transport) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const reply = JSON.parse(transport.responseText);
|
|
|
|
const new_link = reply.link;
|
2010-11-08 22:04:00 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const e = $('gen_feed_url');
|
2010-11-08 22:04:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (new_link) {
|
2010-11-08 22:04:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
|
|
|
|
"&key=" + new_link);
|
2010-11-08 22:04:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
e.href = e.href.replace(/\&key=.*$/,
|
|
|
|
"&key=" + new_link);
|
2010-11-09 10:14:59 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Effect.Highlight(e);
|
2010-11-09 10:14:59 +00:00
|
|
|
|
|
|
|
notify('');
|
2010-11-08 22:04:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} else {
|
|
|
|
notify_error("Could not change feed URL.");
|
|
|
|
}
|
|
|
|
} });
|
2010-11-08 22:04:00 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
return false;
|
2010-11-08 22:04:00 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 10:52:53 +00:00
|
|
|
// mode = all, none, invert
|
|
|
|
function selectTableRows(id, mode) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const rows = $(id).rows;
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
for (let i = 0; i < rows.length; i++) {
|
|
|
|
const row = rows[i];
|
|
|
|
let cb = false;
|
|
|
|
let dcb = false;
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (row.id && row.className) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const bare_id = row.id.replace(/^[A-Z]*?-/, "");
|
|
|
|
const inputs = rows[i].getElementsByTagName("input");
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
for (let j = 0; j < inputs.length; j++) {
|
|
|
|
const input = inputs[j];
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (input.getAttribute("type") == "checkbox" &&
|
|
|
|
input.id.match(bare_id)) {
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
cb = input;
|
|
|
|
dcb = dijit.getEnclosingWidget(cb);
|
|
|
|
break;
|
2010-11-12 10:52:53 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (cb || dcb) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const issel = row.hasClassName("Selected");
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (mode == "all" && !issel) {
|
|
|
|
row.addClassName("Selected");
|
|
|
|
cb.checked = true;
|
|
|
|
if (dcb) dcb.set("checked", true);
|
|
|
|
} else if (mode == "none" && issel) {
|
|
|
|
row.removeClassName("Selected");
|
|
|
|
cb.checked = false;
|
|
|
|
if (dcb) dcb.set("checked", false);
|
|
|
|
|
|
|
|
} else if (mode == "invert") {
|
|
|
|
|
|
|
|
if (issel) {
|
2010-11-14 12:55:51 +00:00
|
|
|
row.removeClassName("Selected");
|
2010-11-12 10:52:53 +00:00
|
|
|
cb.checked = false;
|
2012-06-14 17:04:14 +00:00
|
|
|
if (dcb) dcb.set("checked", false);
|
2017-03-04 11:34:44 +00:00
|
|
|
} else {
|
|
|
|
row.addClassName("Selected");
|
|
|
|
cb.checked = true;
|
|
|
|
if (dcb) dcb.set("checked", true);
|
2010-11-12 10:52:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
|
2010-11-12 10:52:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSelectedTableRowIds(id) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const rows = [];
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const elem_rows = $(id).rows;
|
2010-11-12 10:52:53 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
for (let i = 0; i < elem_rows.length; i++) {
|
2017-03-04 11:34:44 +00:00
|
|
|
if (elem_rows[i].hasClassName("Selected")) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, "");
|
2017-03-04 11:34:44 +00:00
|
|
|
rows.push(bare_id);
|
2010-11-12 10:52:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rows;
|
|
|
|
}
|
|
|
|
|
2017-12-04 08:02:13 +00:00
|
|
|
function editFeed(feed) {
|
2017-03-04 11:34:44 +00:00
|
|
|
if (feed <= 0)
|
|
|
|
return alert(__("You can't edit this kind of feed."));
|
2010-11-20 12:36:42 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=pref-feeds&method=editfeed&id=" +
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(feed);
|
2010-11-20 12:29:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(query);
|
2010-11-20 12:29:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("filterEditDlg"))
|
|
|
|
dijit.byId("filterEditDlg").destroyRecursive();
|
2011-12-28 10:43:55 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("feedEditDlg"))
|
|
|
|
dijit.byId("feedEditDlg").destroyRecursive();
|
2010-11-20 12:29:50 +00:00
|
|
|
|
2018-03-10 13:11:33 +00:00
|
|
|
var dialog = new dijit.Dialog({
|
2017-03-04 11:34:44 +00:00
|
|
|
id: "feedEditDlg",
|
|
|
|
title: __("Edit Feed"),
|
|
|
|
style: "width: 600px",
|
|
|
|
execute: function() {
|
|
|
|
if (this.validate()) {
|
2010-11-21 08:55:28 +00:00
|
|
|
// console.log(dojo.objectToQuery(this.attr('value')));
|
2010-11-20 12:29:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
notify_progress("Saving data...", true);
|
2010-11-20 12:29:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: dojo.objectToQuery(dialog.attr('value')),
|
|
|
|
onComplete: function(transport) {
|
|
|
|
dialog.hide();
|
|
|
|
notify('');
|
|
|
|
updateFeedList();
|
|
|
|
}});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
href: query});
|
2010-11-20 12:29:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dialog.show();
|
2010-11-20 12:29:50 +00:00
|
|
|
}
|
|
|
|
|
2010-11-20 18:06:36 +00:00
|
|
|
function feedBrowser() {
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=feeds&method=feedBrowser";
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("feedAddDlg"))
|
|
|
|
dijit.byId("feedAddDlg").hide();
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("feedBrowserDlg"))
|
|
|
|
dijit.byId("feedBrowserDlg").destroyRecursive();
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
var dialog = new dijit.Dialog({
|
|
|
|
id: "feedBrowserDlg",
|
|
|
|
title: __("More Feeds"),
|
|
|
|
style: "width: 600px",
|
|
|
|
getSelectedFeedIds: function () {
|
2018-11-29 17:07:23 +00:00
|
|
|
const list = $$("#browseFeedList li[id*=FBROW]");
|
2018-11-29 18:03:55 +00:00
|
|
|
const selected = [];
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
list.each(function (child) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const id = child.id.replace("FBROW-", "");
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (child.hasClassName('Selected')) {
|
|
|
|
selected.push(id);
|
|
|
|
}
|
|
|
|
});
|
2011-04-20 14:39:30 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
return selected;
|
|
|
|
},
|
|
|
|
getSelectedFeeds: function () {
|
2018-11-29 17:07:23 +00:00
|
|
|
const list = $$("#browseFeedList li.Selected");
|
2018-11-29 18:03:55 +00:00
|
|
|
const selected = [];
|
2011-04-20 14:39:30 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
list.each(function (child) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const title = child.getElementsBySelector("span.fb_feedTitle")[0].innerHTML;
|
|
|
|
const url = child.getElementsBySelector("a.fb_feedUrl")[0].href;
|
2011-04-20 14:39:30 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
selected.push([title, url]);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
});
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
return selected;
|
|
|
|
},
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
subscribe: function () {
|
2018-11-29 17:07:23 +00:00
|
|
|
const mode = this.attr('value').mode;
|
|
|
|
let selected = [];
|
2011-04-20 14:39:30 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (mode == "1")
|
|
|
|
selected = this.getSelectedFeeds();
|
|
|
|
else
|
|
|
|
selected = this.getSelectedFeedIds();
|
2010-11-20 18:06:36 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (selected.length > 0) {
|
|
|
|
dijit.byId("feedBrowserDlg").hide();
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
notify_progress("Loading, please wait...", true);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
// we use dojo.toJson instead of JSON.stringify because
|
|
|
|
// it somehow escapes everything TWICE, at least in Chrome 9
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "?op=rpc&method=massSubscribe&payload=" +
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(dojo.toJson(selected)) + "&mode=" + param_escape(mode);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(query);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2010-11-20 18:06:36 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
2017-03-04 11:34:44 +00:00
|
|
|
onComplete: function (transport) {
|
2010-11-20 18:06:36 +00:00
|
|
|
notify('');
|
2017-03-04 11:34:44 +00:00
|
|
|
updateFeedList();
|
|
|
|
}
|
|
|
|
});
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
} else {
|
|
|
|
alert(__("No feeds are selected."));
|
|
|
|
}
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
},
|
|
|
|
update: function () {
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = dojo.objectToQuery(dialog.attr('value'));
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
Element.show('feed_browser_spinner');
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function (transport) {
|
|
|
|
notify('');
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
Element.hide('feed_browser_spinner');
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const c = $("browseFeedList");
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const reply = JSON.parse(transport.responseText);
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const r = reply['content'];
|
|
|
|
const mode = reply['mode'];
|
2011-03-18 11:31:54 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (c && r) {
|
|
|
|
c.innerHTML = r;
|
2010-11-20 18:06:36 +00:00
|
|
|
}
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dojo.parser.parse("browseFeedList");
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (mode == 2) {
|
|
|
|
Element.show(dijit.byId('feed_archive_remove').domNode);
|
|
|
|
} else {
|
|
|
|
Element.hide(dijit.byId('feed_archive_remove').domNode);
|
|
|
|
}
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
removeFromArchive: function () {
|
2018-11-29 17:07:23 +00:00
|
|
|
const selected = this.getSelectedFeedIds();
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (selected.length > 0) {
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const pr = __("Remove selected feeds from the archive? Feeds with stored articles will not be removed.");
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (confirm(pr)) {
|
|
|
|
Element.show('feed_browser_spinner');
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "?op=rpc&method=remarchive&ids=" +
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(selected.toString());
|
2018-11-29 17:07:23 +00:00
|
|
|
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function (transport) {
|
|
|
|
dialog.update();
|
|
|
|
}
|
|
|
|
});
|
2011-04-08 11:37:50 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
execute: function () {
|
|
|
|
if (this.validate()) {
|
|
|
|
this.subscribe();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
href: query
|
|
|
|
});
|
2011-04-08 11:37:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dialog.show();
|
2011-04-08 11:37:50 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
function showFeedsWithErrors() {
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=pref-feeds&method=feedsWithErrors";
|
2010-11-20 12:29:50 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("errorFeedsDlg"))
|
|
|
|
dijit.byId("errorFeedsDlg").destroyRecursive();
|
2011-08-11 22:51:00 +00:00
|
|
|
|
2018-03-10 13:11:33 +00:00
|
|
|
var dialog = new dijit.Dialog({
|
2017-03-04 11:34:44 +00:00
|
|
|
id: "errorFeedsDlg",
|
|
|
|
title: __("Feeds with update errors"),
|
|
|
|
style: "width: 600px",
|
|
|
|
getSelectedFeeds: function() {
|
|
|
|
return getSelectedTableRowIds("prefErrorFeedList");
|
|
|
|
},
|
|
|
|
removeSelected: function() {
|
2018-11-29 17:07:23 +00:00
|
|
|
const sel_rows = this.getSelectedFeeds();
|
2011-08-11 22:51:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
console.log(sel_rows);
|
2011-08-11 22:51:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (sel_rows.length > 0) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const ok = confirm(__("Remove selected feeds?"));
|
2011-08-11 22:51:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (ok) {
|
|
|
|
notify_progress("Removing selected feeds...", true);
|
2011-08-11 22:51:00 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "?op=pref-feeds&method=remove&ids="+
|
2017-03-04 11:34:44 +00:00
|
|
|
param_escape(sel_rows.toString());
|
2011-08-11 22:51:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
new Ajax.Request("backend.php", {
|
|
|
|
parameters: query,
|
|
|
|
onComplete: function(transport) {
|
|
|
|
notify('');
|
|
|
|
dialog.hide();
|
|
|
|
updateFeedList();
|
|
|
|
} });
|
|
|
|
}
|
2011-08-11 22:51:00 +00:00
|
|
|
|
|
|
|
} else {
|
2017-03-04 11:34:44 +00:00
|
|
|
alert(__("No feeds are selected."));
|
2011-08-11 22:51:00 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
},
|
|
|
|
execute: function() {
|
|
|
|
if (this.validate()) {
|
2011-08-11 22:51:00 +00:00
|
|
|
}
|
2017-03-04 11:34:44 +00:00
|
|
|
},
|
|
|
|
href: query});
|
2011-08-11 22:51:00 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dialog.show();
|
2011-08-11 22:51:00 +00:00
|
|
|
}
|
2012-08-14 15:30:49 +00:00
|
|
|
|
|
|
|
function get_timestamp() {
|
2018-11-29 17:07:23 +00:00
|
|
|
const date = new Date();
|
2012-08-14 15:30:49 +00:00
|
|
|
return Math.round(date.getTime() / 1000);
|
|
|
|
}
|
2012-12-28 11:42:02 +00:00
|
|
|
|
|
|
|
function helpDialog(topic) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const query = "backend.php?op=backend&method=help&topic=" + param_escape(topic);
|
2012-12-28 11:42:02 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
if (dijit.byId("helpDlg"))
|
|
|
|
dijit.byId("helpDlg").destroyRecursive();
|
2012-12-28 11:42:02 +00:00
|
|
|
|
2018-11-29 17:07:23 +00:00
|
|
|
const dialog = new dijit.Dialog({
|
2017-03-04 11:34:44 +00:00
|
|
|
id: "helpDlg",
|
|
|
|
title: __("Help"),
|
|
|
|
style: "width: 600px",
|
|
|
|
href: query,
|
|
|
|
});
|
2012-12-28 11:42:02 +00:00
|
|
|
|
2017-03-04 11:34:44 +00:00
|
|
|
dialog.show();
|
2012-12-28 11:42:02 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 09:17:48 +00:00
|
|
|
function htmlspecialchars_decode (string, quote_style) {
|
|
|
|
// http://kevin.vanzonneveld.net
|
|
|
|
// + original by: Mirek Slugen
|
|
|
|
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
|
|
|
// + bugfixed by: Mateusz "loonquawl" Zalega
|
|
|
|
// + input by: ReverseSyntax
|
|
|
|
// + input by: Slawomir Kaniecki
|
|
|
|
// + input by: Scott Cariss
|
|
|
|
// + input by: Francois
|
|
|
|
// + bugfixed by: Onno Marsman
|
|
|
|
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
|
|
|
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
|
|
|
|
// + input by: Ratheous
|
|
|
|
// + input by: Mailfaker (http://www.weedem.fr/)
|
|
|
|
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
|
|
|
|
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
|
|
|
|
// * example 1: htmlspecialchars_decode("<p>this -> "</p>", 'ENT_NOQUOTES');
|
|
|
|
// * returns 1: '<p>this -> "</p>'
|
|
|
|
// * example 2: htmlspecialchars_decode("&quot;");
|
|
|
|
// * returns 2: '"'
|
2018-11-29 17:07:23 +00:00
|
|
|
let optTemp = 0,
|
2013-03-20 09:17:48 +00:00
|
|
|
i = 0,
|
|
|
|
noquotes = false;
|
|
|
|
if (typeof quote_style === 'undefined') {
|
|
|
|
quote_style = 2;
|
|
|
|
}
|
|
|
|
string = string.toString().replace(/</g, '<').replace(/>/g, '>');
|
2018-11-29 17:07:23 +00:00
|
|
|
const OPTS = {
|
2013-03-20 09:17:48 +00:00
|
|
|
'ENT_NOQUOTES': 0,
|
|
|
|
'ENT_HTML_QUOTE_SINGLE': 1,
|
|
|
|
'ENT_HTML_QUOTE_DOUBLE': 2,
|
|
|
|
'ENT_COMPAT': 2,
|
|
|
|
'ENT_QUOTES': 3,
|
|
|
|
'ENT_IGNORE': 4
|
|
|
|
};
|
|
|
|
if (quote_style === 0) {
|
|
|
|
noquotes = true;
|
|
|
|
}
|
|
|
|
if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
|
|
|
|
quote_style = [].concat(quote_style);
|
|
|
|
for (i = 0; i < quote_style.length; i++) {
|
|
|
|
// Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
|
|
|
|
if (OPTS[quote_style[i]] === 0) {
|
|
|
|
noquotes = true;
|
|
|
|
} else if (OPTS[quote_style[i]]) {
|
|
|
|
optTemp = optTemp | OPTS[quote_style[i]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
quote_style = optTemp;
|
|
|
|
}
|
|
|
|
if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
|
|
|
|
string = string.replace(/�*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
|
|
|
|
// string = string.replace(/'|�*27;/g, "'"); // This would also be useful here, but not a part of PHP
|
|
|
|
}
|
|
|
|
if (!noquotes) {
|
|
|
|
string = string.replace(/"/g, '"');
|
|
|
|
}
|
|
|
|
// Put this in last place to avoid escape being double-decoded
|
|
|
|
string = string.replace(/&/g, '&');
|
|
|
|
|
|
|
|
return string;
|
|
|
|
}
|
2013-03-27 05:40:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
function label_to_feed_id(label) {
|
|
|
|
return _label_base_index - 1 - Math.abs(label);
|
|
|
|
}
|
|
|
|
|
|
|
|
function feed_to_label_id(feed) {
|
|
|
|
return _label_base_index - 1 + Math.abs(feed);
|
|
|
|
}
|
|
|
|
|
2013-11-12 10:21:28 +00:00
|
|
|
// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac
|
|
|
|
|
|
|
|
function getSelectionText() {
|
2018-11-29 17:07:23 +00:00
|
|
|
let text = "";
|
2013-11-12 10:21:28 +00:00
|
|
|
|
|
|
|
if (typeof window.getSelection != "undefined") {
|
2018-11-29 17:07:23 +00:00
|
|
|
const sel = window.getSelection();
|
2013-11-12 10:21:28 +00:00
|
|
|
if (sel.rangeCount) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const container = document.createElement("div");
|
|
|
|
for (let i = 0, len = sel.rangeCount; i < len; ++i) {
|
2013-11-12 10:21:28 +00:00
|
|
|
container.appendChild(sel.getRangeAt(i).cloneContents());
|
|
|
|
}
|
|
|
|
text = container.innerHTML;
|
|
|
|
}
|
|
|
|
} else if (typeof document.selection != "undefined") {
|
|
|
|
if (document.selection.type == "Text") {
|
|
|
|
text = document.selection.createRange().textText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return text.stripTags();
|
|
|
|
}
|
2015-09-11 10:05:08 +00:00
|
|
|
|
2017-02-08 12:07:05 +00:00
|
|
|
function openUrlPopup(url) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const w = window.open("");
|
2017-02-08 12:07:05 +00:00
|
|
|
|
|
|
|
w.opener = null;
|
|
|
|
w.location = url;
|
|
|
|
}
|
2015-09-11 10:05:08 +00:00
|
|
|
function openArticlePopup(id) {
|
2018-11-29 17:07:23 +00:00
|
|
|
const w = window.open("",
|
2015-09-11 10:05:08 +00:00
|
|
|
"ttrss_article_popup",
|
|
|
|
"height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no");
|
2017-02-08 12:07:05 +00:00
|
|
|
|
|
|
|
w.opener = null;
|
|
|
|
w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + getInitParam("csrf_token");
|
2017-03-04 11:34:44 +00:00
|
|
|
}
|