summaryrefslogtreecommitdiff
path: root/plugins/embed_original
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-03 13:38:13 +0300
committerAndrew Dolgov <[email protected]>2018-12-03 13:38:13 +0300
commit71fc6d45bd761a9d2715faa68f2b8c0271ee7169 (patch)
tree47677db3e0d147dbe5c3d3cc71a6576a392881f3 /plugins/embed_original
parenta049b5bd88f3ce07af0e2aa7c21992dc0605eea6 (diff)
refactor error reporting to AppBase; keep exception_error() for now as a shim
Diffstat (limited to 'plugins/embed_original')
-rw-r--r--plugins/embed_original/init.js86
1 files changed, 41 insertions, 45 deletions
diff --git a/plugins/embed_original/init.js b/plugins/embed_original/init.js
index 6f797556b..1e9fcb253 100644
--- a/plugins/embed_original/init.js
+++ b/plugins/embed_original/init.js
@@ -1,60 +1,56 @@
function embedOriginalArticle(id) {
- try {
- const 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;
- }
+ if (!hasSandbox) {
+ alert(__("Sorry, your browser does not support sandboxed iframes."));
+ return;
+ }
- let c = false;
+ let c = false;
+
+ if (App.isCombinedMode()) {
+ c = $$("div#RROW-" + id + " div[class=content-inner]")[0];
+ } else if (id == Article.getActive()) {
+ c = $$(".post .content")[0];
+ }
+
+ if (c) {
+ const iframe = c.parentNode.getElementsByClassName("embeddedContent")[0];
+
+ if (iframe) {
+ Element.show(c);
+ c.parentNode.removeChild(iframe);
+
+ if (App.isCombinedMode()) {
+ Article.cdmScrollToId(id, true);
+ }
- if (App.isCombinedMode()) {
- c = $$("div#RROW-" + id + " div[class=content-inner]")[0];
- } else if (id == Article.getActive()) {
- c = $$(".post .content")[0];
+ return;
}
+ }
- if (c) {
- const iframe = c.parentNode.getElementsByClassName("embeddedContent")[0];
+ const query = { op: "pluginhandler", plugin: "embed_original", method: "getUrl", id: id };
- if (iframe) {
- Element.show(c);
- c.parentNode.removeChild(iframe);
+ 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 (App.isCombinedMode()) {
Article.cdmScrollToId(id, true);
}
-
- return;
}
}
+ });
- 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 (App.isCombinedMode()) {
- Article.cdmScrollToId(id, true);
- }
- }
- }
- });
-
- } catch (e) {
- exception_error("embedOriginalArticle", e);
- }
}