diff options
author | Andrew Dolgov <[email protected]> | 2018-11-30 15:23:48 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-11-30 15:23:48 +0300 |
commit | 2f961ee830af21166d22bf3fae104291f614e7dd (patch) | |
tree | 1bc280bf9d8f480b70200fcf6dcc1d9406874bd2 /plugins/embed_original | |
parent | 764434a491ee0b42b70d262fa49aee2b6a9e93a8 (diff) |
plugins: add some xhrPost refactoring
Diffstat (limited to 'plugins/embed_original')
-rw-r--r-- | plugins/embed_original/init.js | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/plugins/embed_original/init.js b/plugins/embed_original/init.js index 865491142..6bc13ddfa 100644 --- a/plugins/embed_original/init.js +++ b/plugins/embed_original/init.js @@ -7,9 +7,6 @@ function embedOriginalArticle(id) { return; } - const query = "op=pluginhandler&plugin=embed_original&method=getUrl&id=" + - param_escape(id); - let c = false; if (isCdmMode()) { @@ -33,34 +30,29 @@ function embedOriginalArticle(id) { } } - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - const ti = JSON.parse(transport.responseText); - - if (ti) { - - const iframe = new Element("iframe", { - class: "embeddedContent", - src: ti.url, - width: (c.parentNode.offsetWidth-5)+'px', - height: (c.parentNode.parentNode.offsetHeight-c.parentNode.firstChild.offsetHeight-5)+'px', - style: "overflow: auto; border: none; min-height: "+(document.body.clientHeight/2)+"px;", - sandbox: 'allow-scripts', - }); - - if (c) { - Element.hide(c); - c.parentNode.insertBefore(iframe,c); - - if (isCdmMode()) { - cdmScrollToArticleId(id, true); - } + const query = { op: "pluginhandler", plugin: "embed_original", method: "getUrl", id: id }; + + xhrJson("backend.php", query, (reply) => { + if (reply) { + const iframe = new Element("iframe", { + class: "embeddedContent", + src: reply.url, + width: (c.parentNode.offsetWidth - 5) + 'px', + height: (c.parentNode.parentNode.offsetHeight - c.parentNode.firstChild.offsetHeight - 5) + 'px', + style: "overflow: auto; border: none; min-height: " + (document.body.clientHeight / 2) + "px;", + sandbox: 'allow-scripts', + }); + + if (c) { + Element.hide(c); + c.parentNode.insertBefore(iframe, c); + + if (isCdmMode()) { + cdmScrollToArticleId(id, true); } } - - } }); - + } + }); } catch (e) { exception_error("embedOriginalArticle", e); |