X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=plugins%2Fembed_original%2Finit.js;h=8487bbd34e06e27949dfc1e495255813b7dcf1c2;hb=8359ca6dad9051702d2635f5c2ce6b20ad0d4c2b;hp=17090653d48722988a92f63e9cadbb337598abae;hpb=44db06b6be95f481d83951a2b1bc1f0a9063a465;p=tt-rss.git diff --git a/plugins/embed_original/init.js b/plugins/embed_original/init.js index 17090653..8487bbd3 100644 --- a/plugins/embed_original/init.js +++ b/plugins/embed_original/init.js @@ -1,25 +1,22 @@ function embedOriginalArticle(id) { try { - var hasSandbox = "sandbox" in document.createElement("iframe"); + const hasSandbox = "sandbox" in document.createElement("iframe"); if (!hasSandbox) { alert(__("Sorry, your browser does not support sandboxed iframes.")); return; } - var query = "op=pluginhandler&plugin=embed_original&method=getUrl&id=" + - param_escape(id); - - var c = false; + let c = false; if (isCdmMode()) { - c = $$("div#RROW-" + id + " div[class=cdmContentInner]")[0]; + c = $$("div#RROW-" + id + " div[class=content-inner]")[0]; } else if (id == getActiveArticleId()) { c = $$("div[class=postContent]")[0]; } if (c) { - var iframe = c.parentNode.getElementsByClassName("embeddedContent")[0]; + const iframe = c.parentNode.getElementsByClassName("embeddedContent")[0]; if (iframe) { Element.show(c); @@ -33,34 +30,29 @@ function embedOriginalArticle(id) { } } - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - var ti = JSON.parse(transport.responseText); - - if (ti) { - - var 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);