2020-06-04 20:27:22 +00:00
|
|
|
'use strict';
|
|
|
|
|
2021-02-12 16:02:09 +00:00
|
|
|
/* eslint-disable no-new */
|
2021-02-28 18:50:05 +00:00
|
|
|
/* global __, dijit, dojo, Tables, Notify, xhr, App, fox */
|
2020-06-04 20:27:22 +00:00
|
|
|
|
2020-06-04 17:04:17 +00:00
|
|
|
const Helpers = {
|
|
|
|
AppPasswords: {
|
|
|
|
getSelected: function() {
|
|
|
|
return Tables.getSelected("app-password-list");
|
|
|
|
},
|
|
|
|
updateContent: function(data) {
|
2021-02-18 18:51:18 +00:00
|
|
|
App.byId("app_passwords_holder").innerHTML = data;
|
2020-06-04 17:04:17 +00:00
|
|
|
dojo.parser.parse("app_passwords_holder");
|
|
|
|
},
|
|
|
|
removeSelected: function() {
|
|
|
|
const rows = this.getSelected();
|
2019-11-01 12:03:57 +00:00
|
|
|
|
2020-06-04 17:04:17 +00:00
|
|
|
if (rows.length == 0) {
|
|
|
|
alert("No passwords selected.");
|
2020-06-04 20:27:22 +00:00
|
|
|
} else if (confirm(__("Remove selected app passwords?"))) {
|
2019-11-01 12:03:57 +00:00
|
|
|
|
2021-03-02 05:08:48 +00:00
|
|
|
xhr.post("backend.php", {op: "pref-prefs", method: "deleteAppPasswords", "ids[]": rows}, (reply) => {
|
2021-02-19 10:44:56 +00:00
|
|
|
this.updateContent(reply);
|
2020-06-04 20:27:22 +00:00
|
|
|
Notify.close();
|
|
|
|
});
|
2019-11-01 12:03:57 +00:00
|
|
|
|
2020-06-04 20:27:22 +00:00
|
|
|
Notify.progress("Loading, please wait...");
|
2020-06-04 17:04:17 +00:00
|
|
|
}
|
2019-11-01 12:03:57 +00:00
|
|
|
},
|
2020-06-04 17:04:17 +00:00
|
|
|
generate: function() {
|
|
|
|
const title = prompt("Password description:")
|
2018-12-02 14:00:58 +00:00
|
|
|
|
2020-06-04 17:04:17 +00:00
|
|
|
if (title) {
|
2021-02-19 10:44:56 +00:00
|
|
|
xhr.post("backend.php", {op: "pref-prefs", method: "generateAppPassword", title: title}, (reply) => {
|
|
|
|
this.updateContent(reply);
|
2020-06-04 17:04:17 +00:00
|
|
|
Notify.close();
|
2018-12-02 14:00:58 +00:00
|
|
|
});
|
|
|
|
|
2018-12-02 17:56:30 +00:00
|
|
|
Notify.progress("Loading, please wait...");
|
2018-12-02 14:00:58 +00:00
|
|
|
}
|
|
|
|
},
|
2020-06-04 17:04:17 +00:00
|
|
|
},
|
2021-02-12 18:51:32 +00:00
|
|
|
Feeds: {
|
|
|
|
clearFeedAccessKeys: function() {
|
|
|
|
if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) {
|
|
|
|
Notify.progress("Clearing URLs...");
|
2018-12-02 14:00:58 +00:00
|
|
|
|
2021-02-19 08:28:14 +00:00
|
|
|
xhr.post("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => {
|
2021-02-12 18:51:32 +00:00
|
|
|
Notify.info("Generated URLs cleared.");
|
|
|
|
});
|
|
|
|
}
|
2018-12-02 14:00:58 +00:00
|
|
|
|
2021-02-12 18:51:32 +00:00
|
|
|
return false;
|
|
|
|
},
|
2020-06-04 17:04:17 +00:00
|
|
|
},
|
2021-03-02 16:21:21 +00:00
|
|
|
Digest: {
|
|
|
|
preview: function() {
|
|
|
|
const dialog = new fox.SingleUseDialog({
|
2021-03-03 11:10:18 +00:00
|
|
|
title: __("Digest preview"),
|
2021-03-02 16:21:21 +00:00
|
|
|
content: `
|
|
|
|
<div class='panel panel-scrollable digest-preview'>
|
|
|
|
<div class='text-center'>${__("Loading, please wait...")}</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<footer class='text-center'>
|
|
|
|
${App.FormFields.submit_tag(__('Close this window'))}
|
|
|
|
</footer>
|
|
|
|
`
|
|
|
|
});
|
|
|
|
|
|
|
|
const tmph = dojo.connect(dialog, 'onShow', function () {
|
|
|
|
dojo.disconnect(tmph);
|
|
|
|
|
|
|
|
xhr.json("backend.php", {op: "pref-prefs", method: "previewDigest"}, (reply) => {
|
|
|
|
dialog.domNode.querySelector('.digest-preview').innerHTML = reply[0];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
2021-02-12 18:43:38 +00:00
|
|
|
System: {
|
2021-02-14 09:29:08 +00:00
|
|
|
//
|
2021-02-12 18:43:38 +00:00
|
|
|
},
|
2021-02-06 07:10:54 +00:00
|
|
|
EventLog: {
|
|
|
|
log_page: 0,
|
|
|
|
refresh: function() {
|
|
|
|
this.log_page = 0;
|
|
|
|
this.update();
|
|
|
|
},
|
|
|
|
update: function() {
|
2021-02-19 10:44:56 +00:00
|
|
|
xhr.post("backend.php", {
|
|
|
|
op: "pref-system",
|
|
|
|
severity: dijit.byId("severity").attr('value'),
|
|
|
|
page: Helpers.EventLog.log_page
|
|
|
|
}, (reply) => {
|
|
|
|
|
|
|
|
dijit.byId('systemTab').attr('content', reply);
|
2021-02-06 07:10:54 +00:00
|
|
|
Notify.close();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
nextPage: function() {
|
|
|
|
this.log_page += 1;
|
|
|
|
this.update();
|
|
|
|
},
|
|
|
|
prevPage: function() {
|
|
|
|
if (this.log_page > 0) this.log_page -= 1;
|
2020-06-04 17:04:17 +00:00
|
|
|
|
2021-02-06 07:10:54 +00:00
|
|
|
this.update();
|
|
|
|
},
|
|
|
|
clear: function() {
|
|
|
|
if (confirm(__("Clear event log?"))) {
|
2020-06-04 17:04:17 +00:00
|
|
|
|
2021-02-06 07:10:54 +00:00
|
|
|
Notify.progress("Loading, please wait...");
|
|
|
|
|
2021-02-19 08:28:14 +00:00
|
|
|
xhr.post("backend.php", {op: "pref-system", method: "clearLog"}, () => {
|
2021-02-06 07:10:54 +00:00
|
|
|
Helpers.EventLog.refresh();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2020-06-04 17:04:17 +00:00
|
|
|
},
|
2021-02-12 18:51:32 +00:00
|
|
|
Profiles: {
|
|
|
|
edit: function() {
|
|
|
|
const dialog = new fox.SingleUseDialog({
|
|
|
|
id: "profileEditDlg",
|
2021-03-03 11:10:18 +00:00
|
|
|
title: __("Manage profiles"),
|
2021-02-12 18:51:32 +00:00
|
|
|
getSelectedProfiles: function () {
|
|
|
|
return Tables.getSelected("pref-profiles-list");
|
|
|
|
},
|
|
|
|
removeSelected: function () {
|
|
|
|
const sel_rows = this.getSelectedProfiles();
|
|
|
|
|
|
|
|
if (sel_rows.length > 0) {
|
|
|
|
if (confirm(__("Remove selected profiles? Active and default profiles will not be removed."))) {
|
|
|
|
Notify.progress("Removing selected profiles...", true);
|
|
|
|
|
2021-03-04 09:30:45 +00:00
|
|
|
xhr.post("backend.php", {op: "pref-prefs", method: "remprofiles", "ids[]": sel_rows}, () => {
|
2021-02-12 18:51:32 +00:00
|
|
|
Notify.close();
|
|
|
|
dialog.refresh();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
alert(__("No profiles selected."));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
addProfile: function () {
|
|
|
|
if (this.validate()) {
|
|
|
|
Notify.progress("Creating profile...", true);
|
|
|
|
|
2021-02-18 08:54:22 +00:00
|
|
|
const query = {op: "pref-prefs", method: "addprofile", title: dialog.attr('value').newprofile};
|
2018-12-02 14:00:58 +00:00
|
|
|
|
2021-02-19 08:28:14 +00:00
|
|
|
xhr.post("backend.php", query, () => {
|
2018-12-02 17:56:30 +00:00
|
|
|
Notify.close();
|
2021-02-12 12:22:10 +00:00
|
|
|
dialog.refresh();
|
2018-12-02 14:00:58 +00:00
|
|
|
});
|
2018-12-11 11:25:41 +00:00
|
|
|
|
2021-02-12 18:51:32 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
refresh: function() {
|
2021-02-19 07:22:00 +00:00
|
|
|
xhr.json("backend.php", {op: 'pref-prefs', method: 'getprofiles'}, (reply) => {
|
2021-02-18 08:54:22 +00:00
|
|
|
dialog.attr('content', `
|
|
|
|
<div dojoType='fox.Toolbar'>
|
|
|
|
<div dojoType='fox.form.DropDownButton'>
|
|
|
|
<span>${__('Select')}</span>
|
|
|
|
<div dojoType='dijit.Menu' style='display: none'>
|
|
|
|
<div onclick="Tables.select('pref-profiles-list', true)"
|
|
|
|
dojoType='dijit.MenuItem'>${__('All')}</div>
|
|
|
|
<div onclick="Tables.select('pref-profiles-list', false)"
|
|
|
|
dojoType='dijit.MenuItem'>${__('None')}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="pull-right">
|
|
|
|
<input name='newprofile' dojoType='dijit.form.ValidationTextBox' required='1'>
|
|
|
|
${App.FormFields.button_tag(__('Create profile'), "", {onclick: 'App.dialogOf(this).addProfile()'})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<form onsubmit='return false'>
|
|
|
|
<div class='panel panel-scrollable'>
|
|
|
|
<table width='100%' id='pref-profiles-list'>
|
|
|
|
${reply.map((profile) => `
|
|
|
|
<tr data-row-id="${profile.id}">
|
2021-03-06 17:03:36 +00:00
|
|
|
<td class='checkbox'>
|
2021-02-18 08:54:22 +00:00
|
|
|
${App.FormFields.checkbox_tag("", false, "", {onclick: 'Tables.onRowChecked(this)'})}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
${profile.id > 0 ?
|
|
|
|
`<span dojoType='dijit.InlineEditBox' width='300px' autoSave='false'
|
|
|
|
profile-id='${profile.id}'>${profile.title}
|
|
|
|
<script type='dojo/method' event='onChange' args='value'>
|
2021-02-19 10:44:56 +00:00
|
|
|
xhr.post("backend.php",
|
|
|
|
{op: 'pref-prefs', method: 'saveprofile', value: value, id: this.attr('profile-id')}, () => {
|
2021-02-18 08:54:22 +00:00
|
|
|
//
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</span>` : `${profile.title}`}
|
|
|
|
${profile.active ? __("(active)") : ""}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
`).join("")}
|
|
|
|
</table>
|
|
|
|
</div>
|
2021-02-18 08:55:00 +00:00
|
|
|
|
2021-02-18 08:54:22 +00:00
|
|
|
<footer>
|
2021-03-06 20:32:25 +00:00
|
|
|
${App.FormFields.button_tag(App.FormFields.icon("delete") + " " +__('Remove selected profiles'), "",
|
2021-02-18 08:54:22 +00:00
|
|
|
{class: 'pull-left alt-danger', onclick: 'App.dialogOf(this).removeSelected()'})}
|
2021-03-06 20:32:25 +00:00
|
|
|
${App.FormFields.submit_tag(App.FormFields.icon("check") + " " + __('Activate profile'), {onclick: 'App.dialogOf(this).execute()'})}
|
2021-02-18 08:54:22 +00:00
|
|
|
${App.FormFields.cancel_dialog_tag(__('Cancel'))}
|
|
|
|
</footer>
|
|
|
|
</form>
|
|
|
|
`);
|
2020-06-04 17:04:17 +00:00
|
|
|
});
|
2021-02-12 18:51:32 +00:00
|
|
|
},
|
|
|
|
execute: function () {
|
|
|
|
const sel_rows = this.getSelectedProfiles();
|
2020-06-04 17:04:17 +00:00
|
|
|
|
2021-02-12 18:51:32 +00:00
|
|
|
if (sel_rows.length == 1) {
|
|
|
|
if (confirm(__("Activate selected profile?"))) {
|
|
|
|
Notify.progress("Loading, please wait...");
|
2021-02-12 07:35:13 +00:00
|
|
|
|
2021-02-19 08:28:14 +00:00
|
|
|
xhr.post("backend.php", {op: "pref-prefs", method: "activateprofile", id: sel_rows.toString()}, () => {
|
2021-02-12 18:51:32 +00:00
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
}
|
2021-02-12 07:35:13 +00:00
|
|
|
|
2021-02-12 18:51:32 +00:00
|
|
|
} else {
|
|
|
|
alert(__("Please choose a profile to activate."));
|
2021-02-12 07:35:13 +00:00
|
|
|
}
|
2021-02-12 18:51:32 +00:00
|
|
|
},
|
|
|
|
content: ""
|
|
|
|
});
|
2021-02-12 07:35:13 +00:00
|
|
|
|
2021-02-12 18:51:32 +00:00
|
|
|
dialog.refresh();
|
|
|
|
dialog.show();
|
|
|
|
},
|
2020-06-04 17:04:17 +00:00
|
|
|
},
|
2021-02-12 18:51:32 +00:00
|
|
|
Prefs: {
|
|
|
|
customizeCSS: function() {
|
2021-02-19 07:22:00 +00:00
|
|
|
xhr.json("backend.php", {op: "pref-prefs", method: "customizeCSS"}, (reply) => {
|
2021-02-12 18:51:32 +00:00
|
|
|
|
|
|
|
const dialog = new fox.SingleUseDialog({
|
|
|
|
title: __("Customize stylesheet"),
|
|
|
|
apply: function() {
|
2021-02-19 08:28:14 +00:00
|
|
|
xhr.post("backend.php", this.attr('value'), () => {
|
2021-02-18 18:51:18 +00:00
|
|
|
Element.show("css_edit_apply_msg");
|
|
|
|
App.byId("user_css_style").innerText = this.attr('value');
|
2021-02-12 18:51:32 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
execute: function () {
|
|
|
|
Notify.progress('Saving data...', true);
|
2021-02-12 06:02:44 +00:00
|
|
|
|
2021-02-19 08:28:14 +00:00
|
|
|
xhr.post("backend.php", this.attr('value'), () => {
|
2021-02-12 18:51:32 +00:00
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
content: `
|
|
|
|
<div class='alert alert-info'>
|
|
|
|
${__("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here.")}
|
|
|
|
</div>
|
2020-06-04 17:04:17 +00:00
|
|
|
|
2021-02-17 16:34:54 +00:00
|
|
|
${App.FormFields.hidden_tag('op', 'rpc')}
|
|
|
|
${App.FormFields.hidden_tag('method', 'setpref')}
|
|
|
|
${App.FormFields.hidden_tag('key', 'USER_STYLESHEET')}
|
2021-02-12 18:51:32 +00:00
|
|
|
|
|
|
|
<div id='css_edit_apply_msg' style='display : none'>
|
|
|
|
<div class='alert alert-warning'>
|
|
|
|
${__("User CSS has been applied, you might need to reload the page to see all changes.")}
|
|
|
|
</div>
|
2021-02-12 06:02:44 +00:00
|
|
|
</div>
|
2018-12-02 14:00:58 +00:00
|
|
|
|
2021-02-12 18:51:32 +00:00
|
|
|
<textarea class='panel user-css-editor' dojoType='dijit.form.SimpleTextarea'
|
|
|
|
style='font-size : 12px;' name='value'>${reply.value}</textarea>
|
|
|
|
|
|
|
|
<footer>
|
|
|
|
<button dojoType='dijit.form.Button' class='alt-success' onclick="App.dialogOf(this).apply()">
|
2021-03-06 20:32:25 +00:00
|
|
|
${App.FormFields.icon("check")}
|
2021-02-12 18:51:32 +00:00
|
|
|
${__('Apply')}
|
|
|
|
</button>
|
|
|
|
<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>
|
2021-03-06 20:32:25 +00:00
|
|
|
${App.FormFields.icon("refresh")}
|
2021-02-12 18:51:32 +00:00
|
|
|
${__('Save and reload')}
|
|
|
|
</button>
|
|
|
|
<button dojoType='dijit.form.Button' onclick="App.dialogOf(this).hide()">
|
|
|
|
${__('Cancel')}
|
|
|
|
</button>
|
|
|
|
</footer>
|
|
|
|
`
|
|
|
|
});
|
|
|
|
|
|
|
|
dialog.show();
|
2020-06-04 17:04:17 +00:00
|
|
|
|
2018-12-02 14:00:58 +00:00
|
|
|
});
|
2021-02-12 18:51:32 +00:00
|
|
|
},
|
|
|
|
confirmReset: function() {
|
|
|
|
if (confirm(__("Reset to defaults?"))) {
|
2021-02-19 10:44:56 +00:00
|
|
|
xhr.post("backend.php", {op: "pref-prefs", method: "resetconfig"}, (reply) => {
|
2021-02-12 18:51:32 +00:00
|
|
|
Helpers.Prefs.refresh();
|
2021-02-19 10:44:56 +00:00
|
|
|
Notify.info(reply);
|
2021-02-12 18:51:32 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2021-02-27 10:05:02 +00:00
|
|
|
refresh: function() {
|
|
|
|
xhr.post("backend.php", { op: "pref-prefs" }, (reply) => {
|
|
|
|
dijit.byId('prefsTab').attr('content', reply);
|
|
|
|
Notify.close();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Plugins: {
|
2021-03-06 15:14:25 +00:00
|
|
|
_list_of_plugins: [],
|
|
|
|
_search_query: "",
|
|
|
|
enableSelected: function() {
|
|
|
|
const form = dijit.byId("changePluginsForm");
|
2018-12-03 09:26:49 +00:00
|
|
|
|
2021-03-06 15:14:25 +00:00
|
|
|
if (form.validate()) {
|
|
|
|
xhr.post("backend.php", form.getValues(), () => {
|
|
|
|
Notify.close();
|
|
|
|
if (confirm(__('Selected plugins have been enabled. Reload?'))) {
|
|
|
|
window.location.reload();
|
|
|
|
}
|
|
|
|
})
|
2021-02-12 18:51:32 +00:00
|
|
|
}
|
|
|
|
},
|
2021-03-06 15:14:25 +00:00
|
|
|
search: function() {
|
|
|
|
this._search_query = dijit.byId("changePluginsForm").getValues().search;
|
|
|
|
this.render_contents();
|
|
|
|
},
|
|
|
|
reload: function() {
|
|
|
|
xhr.json("backend.php", {op: "pref-prefs", method: "getPluginsList"}, (reply) => {
|
|
|
|
this._list_of_plugins = reply;
|
|
|
|
this.render_contents();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
render_contents: function() {
|
|
|
|
const container = document.querySelector(".prefs-plugin-list");
|
2021-02-27 14:29:41 +00:00
|
|
|
|
2021-03-06 15:14:25 +00:00
|
|
|
container.innerHTML = "";
|
|
|
|
let results_rendered = 0;
|
2021-02-27 14:29:41 +00:00
|
|
|
|
2021-03-06 15:14:25 +00:00
|
|
|
const is_admin = this._list_of_plugins.is_admin;
|
2021-02-27 14:29:41 +00:00
|
|
|
|
2021-03-06 15:14:25 +00:00
|
|
|
const search_tokens = this._search_query
|
|
|
|
.split(/ {1,}/)
|
|
|
|
.filter((stoken) => (stoken.length > 0 ? stoken : null));
|
2021-02-27 14:29:41 +00:00
|
|
|
|
2021-03-06 15:14:25 +00:00
|
|
|
this._list_of_plugins.plugins.forEach((plugin) => {
|
|
|
|
|
|
|
|
if (search_tokens.length == 0 ||
|
|
|
|
Object.values(plugin).filter((pval) =>
|
|
|
|
search_tokens.filter((stoken) =>
|
|
|
|
(pval.toString().indexOf(stoken) != -1 ? stoken : null)
|
|
|
|
).length == search_tokens.length).length > 0) {
|
|
|
|
|
|
|
|
++results_rendered;
|
|
|
|
|
|
|
|
container.innerHTML += `
|
|
|
|
<li data-row-value="${App.escapeHtml(plugin.name)}" data-plugin-name="${App.escapeHtml(plugin.name)}" title="${plugin.is_system ? __("System plugins are enabled using global configuration.") : ""}">
|
|
|
|
<label class="checkbox ${plugin.is_system ? "system text-info" : ""}">
|
|
|
|
${App.FormFields.checkbox_tag("plugins[]", plugin.user_enabled || plugin.system_enabled, plugin.name,
|
|
|
|
{disabled: plugin.is_system})}</div>
|
|
|
|
<span class='name'>${plugin.name}:</span>
|
|
|
|
</label>
|
|
|
|
<div class="description ${plugin.is_system ? "text-info" : ""}">
|
|
|
|
${plugin.description}
|
|
|
|
</div>
|
|
|
|
<div class='actions'>
|
|
|
|
${plugin.is_system ?
|
|
|
|
App.FormFields.button_tag(App.FormFields.icon("security"), "",
|
|
|
|
{disabled: true}) : ''}
|
|
|
|
${plugin.more_info ?
|
|
|
|
App.FormFields.button_tag(App.FormFields.icon("help"), "",
|
|
|
|
{class: 'alt-info', onclick: `window.open("${App.escapeHtml(plugin.more_info)}")`}) : ''}
|
|
|
|
${is_admin && plugin.is_local ?
|
|
|
|
App.FormFields.button_tag(App.FormFields.icon("update"), "",
|
|
|
|
{title: __("Update"), class: 'alt-warning', "data-update-btn-for-plugin": plugin.name, style: 'display : none',
|
|
|
|
onclick: `Helpers.Plugins.update("${App.escapeHtml(plugin.name)}")`}) : ''}
|
|
|
|
${is_admin && plugin.has_data ?
|
|
|
|
App.FormFields.button_tag(App.FormFields.icon("clear"), "",
|
|
|
|
{title: __("Clear data"), onclick: `Helpers.Plugins.clearData("${App.escapeHtml(plugin.name)}")`}) : ''}
|
|
|
|
${is_admin && plugin.is_local ?
|
|
|
|
App.FormFields.button_tag(App.FormFields.icon("delete"), "",
|
|
|
|
{title: __("Uninstall"), onclick: `Helpers.Plugins.uninstall("${App.escapeHtml(plugin.name)}")`}) : ''}
|
|
|
|
</div>
|
|
|
|
<div class='version text-muted'>${plugin.version}</div>
|
|
|
|
</li>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
});
|
2021-02-27 14:29:41 +00:00
|
|
|
|
2021-03-06 15:14:25 +00:00
|
|
|
if (results_rendered == 0) {
|
|
|
|
container.innerHTML = `<li class='text-center text-info'>${__("Could not find any plugins for this search query.")}</li>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
dojo.parser.parse(container);
|
2021-03-05 07:25:32 +00:00
|
|
|
|
2021-03-06 15:14:25 +00:00
|
|
|
},
|
|
|
|
clearData: function(name) {
|
|
|
|
if (confirm(__("Clear stored data for %s?").replace("%s", name))) {
|
|
|
|
Notify.progress("Loading, please wait...");
|
|
|
|
|
|
|
|
xhr.post("backend.php", {op: "pref-prefs", method: "clearPluginData", name: name}, () => {
|
|
|
|
Helpers.Prefs.refresh();
|
|
|
|
});
|
|
|
|
}
|
2021-02-27 14:29:41 +00:00
|
|
|
},
|
2021-03-03 16:35:11 +00:00
|
|
|
uninstall: function(plugin) {
|
|
|
|
const msg = __("Uninstall plugin %s?").replace("%s", plugin);
|
|
|
|
|
|
|
|
if (confirm(msg)) {
|
|
|
|
Notify.progress("Loading, please wait...");
|
|
|
|
|
|
|
|
xhr.json("backend.php", {op: "pref-prefs", method: "uninstallPlugin", plugin: plugin}, (reply) => {
|
|
|
|
if (reply && reply.status == 1)
|
|
|
|
Helpers.Prefs.refresh();
|
|
|
|
else {
|
|
|
|
Notify.error("Plugin uninstallation failed.");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
2021-03-03 16:07:39 +00:00
|
|
|
install: function() {
|
|
|
|
const dialog = new fox.SingleUseDialog({
|
|
|
|
PI_RES_ALREADY_INSTALLED: "PI_RES_ALREADY_INSTALLED",
|
|
|
|
PI_RES_SUCCESS: "PI_RES_SUCCESS",
|
|
|
|
PI_ERR_NO_CLASS: "PI_ERR_NO_CLASS",
|
|
|
|
PI_ERR_NO_INIT_PHP: "PI_ERR_NO_INIT_PHP",
|
|
|
|
PI_ERR_EXEC_FAILED: "PI_ERR_EXEC_FAILED",
|
|
|
|
PI_ERR_NO_TEMPDIR: "PI_ERR_NO_TEMPDIR",
|
|
|
|
PI_ERR_PLUGIN_NOT_FOUND: "PI_ERR_PLUGIN_NOT_FOUND",
|
|
|
|
PI_ERR_NO_WORKDIR: "PI_ERR_NO_WORKDIR",
|
2021-03-04 12:52:37 +00:00
|
|
|
title: __("Available plugins"),
|
2021-03-03 16:07:39 +00:00
|
|
|
need_refresh: false,
|
2021-03-04 12:52:37 +00:00
|
|
|
entries: false,
|
|
|
|
search_query: "",
|
2021-03-04 16:50:19 +00:00
|
|
|
installed_plugins: [],
|
2021-03-03 16:07:39 +00:00
|
|
|
onHide: function() {
|
|
|
|
if (this.need_refresh) {
|
|
|
|
Helpers.Prefs.refresh();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
performInstall: function(plugin) {
|
|
|
|
|
|
|
|
const install_dialog = new fox.SingleUseDialog({
|
|
|
|
title: __("Plugin installer"),
|
|
|
|
content: `
|
|
|
|
<ul class="panel panel-scrollable contents">
|
|
|
|
<li class='text-center'>${__("Installing %s, please wait...").replace("%s", plugin)}</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<footer class='text-center'>
|
|
|
|
${App.FormFields.submit_tag(__("Close this window"))}
|
|
|
|
</footer>`
|
|
|
|
});
|
|
|
|
|
|
|
|
const tmph = dojo.connect(install_dialog, 'onShow', function () {
|
|
|
|
dojo.disconnect(tmph);
|
|
|
|
|
|
|
|
const container = install_dialog.domNode.querySelector(".contents");
|
|
|
|
|
|
|
|
xhr.json("backend.php", {op: "pref-prefs", method: "installPlugin", plugin: plugin}, (reply) => {
|
|
|
|
if (!reply) {
|
|
|
|
container.innerHTML = `<li class='text-center text-error'>${__("Operation failed: check event log.")}</li>`;
|
|
|
|
} else {
|
|
|
|
switch (reply.result) {
|
|
|
|
case dialog.PI_RES_SUCCESS:
|
|
|
|
container.innerHTML = `<li class='text-success text-center'>${__("Plugin has been installed.")}</li>`
|
|
|
|
dialog.need_refresh = true;
|
|
|
|
break;
|
|
|
|
case dialog.PI_RES_ALREADY_INSTALLED:
|
|
|
|
container.innerHTML = `<li class='text-success text-center'>${__("Plugin is already installed.")}</li>`
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
container.innerHTML = `
|
|
|
|
<li>
|
|
|
|
<h3 style="margin-top: 0">${plugin}</h3>
|
2021-03-03 16:18:43 +00:00
|
|
|
<div class='text-error'>${reply.result}</div>
|
|
|
|
${reply.stderr ? `<pre class="small text-error pre-wrap">${reply.stderr}</pre>` : ''}
|
|
|
|
${reply.stdour ? `<pre class="small text-success pre-wrap">${reply.stdout}</pre>` : ''}
|
2021-03-03 16:07:39 +00:00
|
|
|
<p class="small">
|
|
|
|
${App.FormFields.icon("error_outline") + " " + __("Exited with RC: %d").replace("%d", reply.git_status)}
|
|
|
|
</p>
|
|
|
|
</li>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
install_dialog.show();
|
|
|
|
|
|
|
|
},
|
2021-03-04 12:52:37 +00:00
|
|
|
search: function() {
|
|
|
|
this.search_query = this.attr('value').search.toLowerCase();
|
2021-03-06 15:14:25 +00:00
|
|
|
|
|
|
|
if ('requestIdleCallback' in window)
|
|
|
|
window.requestIdleCallback(() => {
|
|
|
|
this.render_contents();
|
|
|
|
});
|
|
|
|
else
|
|
|
|
this.render_contents();
|
2021-03-04 12:52:37 +00:00
|
|
|
},
|
|
|
|
render_contents: function() {
|
2021-03-03 16:07:39 +00:00
|
|
|
const container = dialog.domNode.querySelector(".contents");
|
|
|
|
|
2021-03-04 12:52:37 +00:00
|
|
|
if (!dialog.entries) {
|
|
|
|
container.innerHTML = `<li class='text-center text-error'>${__("Operation failed: check event log.")}</li>`;
|
|
|
|
} else {
|
|
|
|
container.innerHTML = "";
|
|
|
|
|
|
|
|
let results_rendered = 0;
|
2021-03-03 16:07:39 +00:00
|
|
|
|
2021-03-04 13:28:58 +00:00
|
|
|
const search_tokens = dialog.search_query
|
|
|
|
.split(/ {1,}/)
|
|
|
|
.filter((stoken) => (stoken.length > 0 ? stoken : null));
|
|
|
|
|
2021-03-04 12:52:37 +00:00
|
|
|
dialog.entries.forEach((plugin) => {
|
2021-03-04 16:50:19 +00:00
|
|
|
const is_installed = (dialog.installed_plugins
|
2021-03-05 19:33:06 +00:00
|
|
|
.filter((p) => plugin.topics.map((t) => t.replace(/-/g, "_")).includes(p))).length > 0;
|
2021-03-04 16:50:19 +00:00
|
|
|
|
2021-03-04 13:28:58 +00:00
|
|
|
if (search_tokens.length == 0 ||
|
|
|
|
Object.values(plugin).filter((pval) =>
|
|
|
|
search_tokens.filter((stoken) =>
|
|
|
|
(pval.indexOf(stoken) != -1 ? stoken : null)
|
|
|
|
).length == search_tokens.length).length > 0) {
|
2021-03-04 12:52:37 +00:00
|
|
|
|
|
|
|
++results_rendered;
|
2021-03-03 16:07:39 +00:00
|
|
|
|
|
|
|
container.innerHTML += `
|
2021-03-04 16:50:19 +00:00
|
|
|
<li data-row-value="${App.escapeHtml(plugin.name)}" class="${is_installed ? "plugin-installed" : ""}">
|
2021-03-06 20:32:25 +00:00
|
|
|
${App.FormFields.button_tag((is_installed ?
|
|
|
|
App.FormFields.icon("check") + " " +__("Already installed") :
|
|
|
|
App.FormFields.icon("file_download") + " " +__('Install')), "", {class: 'alt-primary pull-right',
|
2021-03-04 16:50:19 +00:00
|
|
|
disabled: is_installed,
|
2021-03-04 12:58:26 +00:00
|
|
|
onclick: `App.dialogOf(this).performInstall("${App.escapeHtml(plugin.name)}")`})}
|
|
|
|
|
2021-03-06 17:03:36 +00:00
|
|
|
<h3>${plugin.name}
|
2021-03-03 16:07:39 +00:00
|
|
|
<a target="_blank" href="${App.escapeHtml(plugin.html_url)}">
|
|
|
|
${App.FormFields.icon("open_in_new_window")}
|
|
|
|
</a>
|
|
|
|
</h3>
|
|
|
|
|
2021-03-06 17:03:36 +00:00
|
|
|
<div class='small text-muted'>${__("Updated: %s").replace("%s", plugin.last_update)}</div>
|
2021-03-05 05:23:26 +00:00
|
|
|
|
2021-03-06 17:03:36 +00:00
|
|
|
<div class='description'>${plugin.description}</div>
|
2021-03-03 16:07:39 +00:00
|
|
|
</li>
|
|
|
|
`
|
2021-03-04 12:52:37 +00:00
|
|
|
}
|
|
|
|
});
|
2021-03-03 16:07:39 +00:00
|
|
|
|
2021-03-04 12:52:37 +00:00
|
|
|
if (results_rendered == 0) {
|
|
|
|
container.innerHTML = `<li class='text-center text-info'>${__("Could not find any plugins for this search query.")}</li>`;
|
2021-03-03 16:07:39 +00:00
|
|
|
}
|
2021-03-04 12:52:37 +00:00
|
|
|
|
|
|
|
dojo.parser.parse(container);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
reload: function() {
|
|
|
|
const container = dialog.domNode.querySelector(".contents");
|
|
|
|
container.innerHTML = `<li class='text-center'>${__("Looking for plugins...")}</li>`;
|
|
|
|
|
2021-03-04 16:50:19 +00:00
|
|
|
xhr.json("backend.php", {op: "pref-prefs", method: "getAvailablePlugins"}, (reply) => {
|
2021-03-04 12:52:37 +00:00
|
|
|
dialog.entries = reply;
|
|
|
|
dialog.render_contents();
|
2021-03-03 16:07:39 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
content: `
|
2021-03-04 12:52:37 +00:00
|
|
|
<div dojoType='fox.Toolbar'>
|
|
|
|
<div class='pull-right'>
|
|
|
|
<input name="search" placeholder="${__("Search...")}" type="search" dojoType="dijit.form.TextBox" onkeyup="App.dialogOf(this).search()">
|
|
|
|
</div>
|
|
|
|
<div style='height : 16px'> </div> <!-- disgusting -->
|
|
|
|
</div>
|
|
|
|
|
2021-03-04 16:50:19 +00:00
|
|
|
<ul style='clear : both' class="panel panel-scrollable-400px contents plugin-installer-list"> </ul>
|
2021-03-03 16:07:39 +00:00
|
|
|
|
|
|
|
<footer>
|
2021-03-06 20:32:25 +00:00
|
|
|
${App.FormFields.button_tag(App.FormFields.icon("refresh") + " " +__("Refresh"), "", {class: 'alt-primary', onclick: 'App.dialogOf(this).reload()'})}
|
2021-03-03 16:07:39 +00:00
|
|
|
${App.FormFields.cancel_dialog_tag(__("Close"))}
|
|
|
|
</footer>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
const tmph = dojo.connect(dialog, 'onShow', function () {
|
|
|
|
dojo.disconnect(tmph);
|
2021-03-04 16:50:19 +00:00
|
|
|
|
|
|
|
dialog.installed_plugins = [...document.querySelectorAll('*[data-plugin-name]')].map((p) => p.getAttribute('data-plugin-name'));
|
|
|
|
|
2021-03-04 12:52:37 +00:00
|
|
|
dialog.reload();
|
2021-03-03 16:07:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
},
|
2021-02-27 14:29:41 +00:00
|
|
|
update: function(name = null) {
|
2021-02-27 10:05:02 +00:00
|
|
|
|
2021-02-28 06:46:06 +00:00
|
|
|
const dialog = new fox.SingleUseDialog({
|
2021-03-03 16:07:39 +00:00
|
|
|
title: __("Update plugins"),
|
2021-02-28 06:46:06 +00:00
|
|
|
need_refresh: false,
|
2021-02-28 18:50:05 +00:00
|
|
|
plugins_to_update: [],
|
2021-02-28 06:46:06 +00:00
|
|
|
onHide: function() {
|
|
|
|
if (this.need_refresh) {
|
2021-02-27 14:32:41 +00:00
|
|
|
Helpers.Prefs.refresh();
|
2021-02-28 06:46:06 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
performUpdate: function() {
|
|
|
|
const container = dialog.domNode.querySelector(".update-results");
|
2021-02-27 10:05:02 +00:00
|
|
|
|
2021-02-28 18:50:05 +00:00
|
|
|
console.log('updating', dialog.plugins_to_update);
|
|
|
|
|
2021-02-28 09:52:27 +00:00
|
|
|
container.innerHTML = `<li class='text-center'>${__("Updating, please wait...")}</li>`;
|
|
|
|
let enable_update_btn = false;
|
2021-02-27 10:05:02 +00:00
|
|
|
|
2021-02-28 18:50:05 +00:00
|
|
|
xhr.json("backend.php", {op: "pref-prefs", method: "updateLocalPlugins", plugins: dialog.plugins_to_update.join(",")}, (reply) => {
|
2021-02-27 10:05:02 +00:00
|
|
|
|
|
|
|
if (!reply) {
|
2021-02-28 09:52:27 +00:00
|
|
|
container.innerHTML = `<li class='text-center text-error'>${__("Operation failed: check event log.")}</li>`;
|
2021-02-27 10:05:02 +00:00
|
|
|
} else {
|
|
|
|
container.innerHTML = "";
|
|
|
|
|
|
|
|
reply.forEach((p) => {
|
2021-02-28 09:52:27 +00:00
|
|
|
if (p.rv.s == 0)
|
|
|
|
dialog.need_refresh = true;
|
|
|
|
else
|
|
|
|
enable_update_btn = true;
|
2021-02-28 06:46:06 +00:00
|
|
|
|
2021-02-27 10:05:02 +00:00
|
|
|
container.innerHTML +=
|
|
|
|
`
|
2021-03-06 17:03:36 +00:00
|
|
|
<li>
|
|
|
|
<h3>${p.plugin}</h3>
|
2021-03-03 16:18:43 +00:00
|
|
|
${p.rv.e ? `<pre class="small text-error pre-wrap">${p.rv.e}</pre>` : ''}
|
|
|
|
${p.rv.o ? `<pre class="small text-success pre-wrap">${p.rv.o}</pre>` : ''}
|
2021-03-06 17:03:36 +00:00
|
|
|
<div class="small">
|
2021-02-28 09:52:27 +00:00
|
|
|
${p.rv.s ? App.FormFields.icon("error_outline") + " " + __("Exited with RC: %d").replace("%d", p.rv.s) :
|
|
|
|
App.FormFields.icon("check") + " " + __("Update done.")}
|
2021-03-06 17:03:36 +00:00
|
|
|
</div>
|
2021-02-27 10:05:02 +00:00
|
|
|
</li>
|
|
|
|
`
|
|
|
|
});
|
|
|
|
}
|
2021-02-28 09:52:27 +00:00
|
|
|
|
|
|
|
dijit.getEnclosingWidget(dialog.domNode.querySelector(".update-btn")).attr('disabled', !enable_update_btn);
|
2021-02-27 10:05:02 +00:00
|
|
|
});
|
2021-02-28 06:46:06 +00:00
|
|
|
},
|
|
|
|
content: `
|
2021-03-06 17:03:36 +00:00
|
|
|
<ul class="panel panel-scrollable plugin-updater-list update-results">
|
2021-02-28 09:52:27 +00:00
|
|
|
<li class='text-center'>${__("Looking for changes...")}</li>
|
2021-02-28 06:46:06 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<footer>
|
2021-03-06 20:32:25 +00:00
|
|
|
${App.FormFields.button_tag(App.FormFields.icon("update") + " " + __("Update"), "", {disabled: true, class: "update-btn alt-primary", onclick: "App.dialogOf(this).performUpdate()"})}
|
2021-02-28 06:46:06 +00:00
|
|
|
${App.FormFields.cancel_dialog_tag(__("Close"))}
|
|
|
|
</footer>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
|
|
|
|
const tmph = dojo.connect(dialog, 'onShow', function () {
|
|
|
|
dojo.disconnect(tmph);
|
|
|
|
|
|
|
|
xhr.json("backend.php", {op: "pref-prefs", method: "checkForPluginUpdates", name: name}, (reply) => {
|
|
|
|
const container = dialog.domNode.querySelector(".update-results");
|
2021-02-28 09:52:27 +00:00
|
|
|
let enable_update_btn = false;
|
2021-02-27 10:05:02 +00:00
|
|
|
|
2021-02-28 06:46:06 +00:00
|
|
|
if (!reply) {
|
2021-02-28 09:52:27 +00:00
|
|
|
container.innerHTML = `<li class='text-center text-error'>${__("Operation failed: check event log.")}</li>`;
|
2021-02-28 06:46:06 +00:00
|
|
|
} else {
|
|
|
|
container.innerHTML = "";
|
|
|
|
|
2021-02-28 18:50:05 +00:00
|
|
|
dialog.plugins_to_update = [];
|
|
|
|
|
2021-02-28 06:46:06 +00:00
|
|
|
reply.forEach((p) => {
|
2021-02-28 18:50:05 +00:00
|
|
|
if (p.rv.s == 0) {
|
2021-02-28 09:52:27 +00:00
|
|
|
enable_update_btn = true;
|
2021-02-28 18:50:05 +00:00
|
|
|
dialog.plugins_to_update.push(p.plugin);
|
|
|
|
}
|
2021-02-28 09:52:27 +00:00
|
|
|
|
2021-03-06 15:14:25 +00:00
|
|
|
const update_button = dijit.getEnclosingWidget(
|
|
|
|
App.find(`*[data-update-btn-for-plugin="${p.plugin}"]`));
|
|
|
|
|
|
|
|
if (update_button)
|
|
|
|
update_button.domNode.show();
|
|
|
|
|
2021-02-28 06:46:06 +00:00
|
|
|
container.innerHTML +=
|
|
|
|
`
|
2021-03-06 17:03:36 +00:00
|
|
|
<li><h3>${p.plugin}</h3>
|
2021-03-03 16:18:43 +00:00
|
|
|
${p.rv.e ? `<pre class="small text-error pre-wrap">${p.rv.e}</pre>` : ''}
|
|
|
|
${p.rv.o ? `<pre class="small text-success pre-wrap">${p.rv.o}</pre>` : ''}
|
2021-03-06 17:03:36 +00:00
|
|
|
<div class="small">
|
2021-02-28 09:52:27 +00:00
|
|
|
${p.rv.s ? App.FormFields.icon("error_outline") + " " + __("Exited with RC: %d").replace("%d", p.rv.s) :
|
|
|
|
App.FormFields.icon("check") + " " + __("Ready to update")}
|
2021-03-06 17:03:36 +00:00
|
|
|
</div>
|
2021-02-28 06:46:06 +00:00
|
|
|
</li>
|
|
|
|
`
|
|
|
|
});
|
2021-03-06 15:14:25 +00:00
|
|
|
|
|
|
|
if (!enable_update_btn) {
|
|
|
|
container.innerHTML = `<li class='text-center text-info'>${name ? __("Plugin %s is up-to-date").replace("%s", name) :
|
|
|
|
__("All local plugins are up-to-date.")}</li>`;
|
|
|
|
}
|
2021-02-28 06:46:06 +00:00
|
|
|
}
|
2021-02-28 09:52:27 +00:00
|
|
|
|
|
|
|
dijit.getEnclosingWidget(dialog.domNode.querySelector(".update-btn")).attr('disabled', !enable_update_btn);
|
|
|
|
|
2021-02-27 10:05:02 +00:00
|
|
|
});
|
|
|
|
|
2021-02-28 06:46:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
dialog.show();
|
2021-02-12 18:51:32 +00:00
|
|
|
},
|
2020-06-04 17:04:17 +00:00
|
|
|
},
|
|
|
|
OPML: {
|
|
|
|
import: function() {
|
2021-02-18 18:51:18 +00:00
|
|
|
const opml_file = App.byId("opml_file");
|
2020-06-04 17:04:17 +00:00
|
|
|
|
|
|
|
if (opml_file.value.length == 0) {
|
|
|
|
alert(__("Please choose an OPML file first."));
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
Notify.progress("Importing, please wait...", true);
|
2018-12-03 09:26:49 +00:00
|
|
|
|
2021-02-12 05:22:00 +00:00
|
|
|
const xhr = new XMLHttpRequest();
|
2018-12-03 09:26:49 +00:00
|
|
|
|
2021-02-12 05:22:00 +00:00
|
|
|
xhr.open( 'POST', 'backend.php', true );
|
|
|
|
xhr.onload = function () {
|
|
|
|
Notify.close();
|
|
|
|
|
2021-02-12 12:22:10 +00:00
|
|
|
const dialog = new fox.SingleUseDialog({
|
2021-02-12 05:22:00 +00:00
|
|
|
title: __("OPML Import"),
|
|
|
|
onCancel: function () {
|
2021-02-12 12:22:10 +00:00
|
|
|
this.execute();
|
2021-02-12 05:22:00 +00:00
|
|
|
},
|
|
|
|
execute: function () {
|
2021-02-12 12:22:10 +00:00
|
|
|
const tree = dijit.byId('feedTree');
|
|
|
|
|
|
|
|
if (tree) tree.reload();
|
2021-02-12 05:22:00 +00:00
|
|
|
},
|
|
|
|
content: `
|
|
|
|
<div class='alert alert-info'>
|
|
|
|
${__("If you have imported labels and/or filters, you might need to reload preferences to see your new data.")}
|
|
|
|
</div>
|
|
|
|
<div class='panel panel-scrollable'>
|
|
|
|
${xhr.responseText}
|
|
|
|
</div>
|
|
|
|
<footer class='text-center'>
|
|
|
|
<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>
|
|
|
|
${__('Close this window')}
|
|
|
|
</button>
|
|
|
|
</footer>
|
|
|
|
`
|
|
|
|
});
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
};
|
|
|
|
|
2021-02-18 18:51:18 +00:00
|
|
|
xhr.send(new FormData(App.byId("opml_import_form")));
|
2021-02-12 05:22:00 +00:00
|
|
|
|
|
|
|
return false;
|
2020-06-04 17:04:17 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
export: function() {
|
|
|
|
console.log("export");
|
|
|
|
window.open("backend.php?op=opml&method=export&" + dojo.formToQuery("opmlExportForm"));
|
|
|
|
},
|
2021-02-21 15:04:44 +00:00
|
|
|
publish: function() {
|
|
|
|
Notify.progress("Loading, please wait...", true);
|
|
|
|
|
|
|
|
xhr.json("backend.php", {op: "pref-feeds", method: "getOPMLKey"}, (reply) => {
|
|
|
|
try {
|
|
|
|
const dialog = new fox.SingleUseDialog({
|
|
|
|
title: __("Public OPML URL"),
|
|
|
|
regenOPMLKey: function() {
|
|
|
|
if (confirm(__("Replace current OPML publishing address with a new one?"))) {
|
|
|
|
Notify.progress("Trying to change address...", true);
|
|
|
|
|
|
|
|
xhr.json("backend.php", {op: "pref-feeds", method: "regenOPMLKey"}, (reply) => {
|
|
|
|
if (reply) {
|
|
|
|
const new_link = reply.link;
|
|
|
|
const target = this.domNode.querySelector('.generated_url');
|
|
|
|
|
|
|
|
if (new_link && target) {
|
|
|
|
target.href = new_link;
|
|
|
|
target.innerHTML = new_link;
|
|
|
|
|
|
|
|
Notify.close();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
Notify.error("Could not change feed URL.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
content: `
|
|
|
|
<header>${__("Your Public OPML URL is:")}</header>
|
|
|
|
<section>
|
|
|
|
<div class='panel text-center'>
|
|
|
|
<a class='generated_url' href="${App.escapeHtml(reply.link)}" target='_blank'>${App.escapeHtml(reply.link)}</a>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
<footer class='text-center'>
|
|
|
|
<button dojoType='dijit.form.Button' onclick="return App.dialogOf(this).regenOPMLKey()">
|
2021-03-06 20:32:25 +00:00
|
|
|
${App.FormFields.icon("refresh")}
|
2021-02-21 15:04:44 +00:00
|
|
|
${__('Generate new URL')}
|
|
|
|
</button>
|
|
|
|
<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>
|
|
|
|
${__('Close this window')}
|
|
|
|
</button>
|
|
|
|
</footer>
|
|
|
|
`
|
|
|
|
});
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
Notify.close();
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
App.Error.report(e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-06-04 17:04:17 +00:00
|
|
|
}
|
|
|
|
};
|