From 2b2833bb4fa6f958b89a83adea89d9e7c73daee7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 14:56:36 +0300 Subject: plugins: load dialogs via xhr instead of http --- plugins/note/note.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'plugins/note/note.js') diff --git a/plugins/note/note.js b/plugins/note/note.js index ab2ed9208..215058b21 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -1,11 +1,8 @@ -/* global Plugins, xhrJson, Notify, fox, __ */ +/* global dojo, xhrPost, Plugins, xhrJson, Notify, fox, __ */ Plugins.Note = { edit: function(id) { - const query = "backend.php?op=pluginhandler&plugin=note&method=edit¶m=" + encodeURIComponent(id); - const dialog = new fox.SingleUseDialog({ - id: "editNoteDlg", title: __("Edit article note"), execute: function () { if (this.validate()) { @@ -30,7 +27,15 @@ Plugins.Note = { }); } }, - href: query, + content: __("Loading, please wait...") + }); + + const tmph = dojo.connect(dialog, 'onShow', function () { + dojo.disconnect(tmph); + + xhrPost("backend.php", {op: "pluginhandler", plugin: "note", method: "edit", id: id}, (transport) => { + dialog.attr('content', transport.responseText); + }); }); dialog.show(); -- cgit v1.2.3 From e4609c18efceebb1e021d814f53061ada7f6489a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 21:44:21 +0300 Subject: * add (disabled) shortcut syntax for plugin methods * add controls shortcut for pluginhandler tags * add similar shortcut for frontend * allow plugins to selectively exclude their methods from CSRF checking --- plugins/note/note.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/note/note.js') diff --git a/plugins/note/note.js b/plugins/note/note.js index 215058b21..bc6c48156 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -33,7 +33,7 @@ Plugins.Note = { const tmph = dojo.connect(dialog, 'onShow', function () { dojo.disconnect(tmph); - xhrPost("backend.php", {op: "pluginhandler", plugin: "note", method: "edit", id: id}, (transport) => { + xhrPost("backend.php", App.getPhArgs("note", "edit", {id: id}), (transport) => { dialog.attr('content', transport.responseText); }); }); -- cgit v1.2.3 From 00310d2d23dd459c17b3f6e86a127de348b330f8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 06:58:50 +0300 Subject: cleanup some unused code, fix App.byId() invoked by wrong name --- plugins/note/note.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/note/note.js') diff --git a/plugins/note/note.js b/plugins/note/note.js index bc6c48156..d2d9c2b01 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -13,7 +13,7 @@ Plugins.Note = { dialog.hide(); if (reply) { - const elem = $("POSTNOTE-" + id); + const elem = App.byId("POSTNOTE-" + id); if (elem) { elem.innerHTML = reply.note; -- cgit v1.2.3 From 6b43b788d909ce20f07f29f9f3ccd2f6a8715616 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 10:22:00 +0300 Subject: migrate xhrJson invocations to the new helper --- plugins/note/note.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/note/note.js') diff --git a/plugins/note/note.js b/plugins/note/note.js index d2d9c2b01..36bc426cd 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -8,7 +8,7 @@ Plugins.Note = { if (this.validate()) { Notify.progress("Saving article note...", true); - xhrJson("backend.php", this.attr('value'), (reply) => { + xhr.json("backend.php", this.attr('value'), (reply) => { Notify.close(); dialog.hide(); -- cgit v1.2.3 From 660a1bbe011fef5f0fa6bb0af43521fed7598cc7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 13:44:56 +0300 Subject: * switch to xhr.post() almost everywhere * call App.handlerpcjson() automatically on json request (if possible) * show net/log indicators in prefs --- plugins/note/note.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/note/note.js') diff --git a/plugins/note/note.js b/plugins/note/note.js index 36bc426cd..d42fca2c1 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -1,4 +1,4 @@ -/* global dojo, xhrPost, Plugins, xhrJson, Notify, fox, __ */ +/* global dojo, Plugins, xhr, App, Notify, fox, __ */ Plugins.Note = { edit: function(id) { @@ -33,8 +33,8 @@ Plugins.Note = { const tmph = dojo.connect(dialog, 'onShow', function () { dojo.disconnect(tmph); - xhrPost("backend.php", App.getPhArgs("note", "edit", {id: id}), (transport) => { - dialog.attr('content', transport.responseText); + xhr.post("backend.php", App.getPhArgs("note", "edit", {id: id}), (reply) => { + dialog.attr('content', reply); }); }); -- cgit v1.2.3 From d445530fa08cdbe2088150a3e7d23596eab9b142 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Feb 2021 17:15:22 +0300 Subject: format note on the client --- plugins/note/note.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'plugins/note/note.js') diff --git a/plugins/note/note.js b/plugins/note/note.js index d42fca2c1..a46acb355 100644 --- a/plugins/note/note.js +++ b/plugins/note/note.js @@ -13,16 +13,14 @@ Plugins.Note = { dialog.hide(); if (reply) { - const elem = App.byId("POSTNOTE-" + id); + App.findAll(`div[data-note-for="${reply.id}"]`).forEach((elem) => { + elem.querySelector(".body").innerHTML = reply.note; - if (elem) { - elem.innerHTML = reply.note; - - if (reply.raw_length != 0) - Element.show(elem); + if (reply.note) + elem.show(); else - Element.hide(elem); - } + elem.hide(); + }); } }); } -- cgit v1.2.3