From 049a37aa0e7d37cafd979e7d470c7649700b5010 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 1 Dec 2018 17:05:28 +0300 Subject: WIP reshuffling of JS global context into separate logical objects --- plugins/embed_original/init.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/embed_original') diff --git a/plugins/embed_original/init.js b/plugins/embed_original/init.js index 3c48b507e..d0731d5d1 100644 --- a/plugins/embed_original/init.js +++ b/plugins/embed_original/init.js @@ -9,7 +9,7 @@ function embedOriginalArticle(id) { let c = false; - if (isCombinedMode()) { + if (App.isCombinedMode()) { c = $$("div#RROW-" + id + " div[class=content-inner]")[0]; } else if (id == getActiveArticleId()) { c = $$(".post .content")[0]; @@ -22,7 +22,7 @@ function embedOriginalArticle(id) { Element.show(c); c.parentNode.removeChild(iframe); - if (isCombinedMode()) { + if (App.isCombinedMode()) { cdmScrollToArticleId(id, true); } @@ -47,7 +47,7 @@ function embedOriginalArticle(id) { Element.hide(c); c.parentNode.insertBefore(iframe, c); - if (isCombinedMode()) { + if (App.isCombinedMode()) { cdmScrollToArticleId(id, true); } } -- cgit v1.2.3 From 642c37ea6117954fc19e2a800f2fce4c1304d89d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 1 Dec 2018 21:01:53 +0300 Subject: further effocts to wrap JS stuff into objects --- plugins/embed_original/init.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/embed_original') diff --git a/plugins/embed_original/init.js b/plugins/embed_original/init.js index d0731d5d1..95a5ef9e5 100644 --- a/plugins/embed_original/init.js +++ b/plugins/embed_original/init.js @@ -11,7 +11,7 @@ function embedOriginalArticle(id) { if (App.isCombinedMode()) { c = $$("div#RROW-" + id + " div[class=content-inner]")[0]; - } else if (id == getActiveArticleId()) { + } else if (id == Article.getActiveArticleId()) { c = $$(".post .content")[0]; } @@ -23,7 +23,7 @@ function embedOriginalArticle(id) { c.parentNode.removeChild(iframe); if (App.isCombinedMode()) { - cdmScrollToArticleId(id, true); + Article.cdmScrollToArticleId(id, true); } return; @@ -48,7 +48,7 @@ function embedOriginalArticle(id) { c.parentNode.insertBefore(iframe, c); if (App.isCombinedMode()) { - cdmScrollToArticleId(id, true); + Article.cdmScrollToArticleId(id, true); } } } -- cgit v1.2.3 From 3678315bead3f7264dc2aa9c7feb6e0a0f20ea63 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 08:32:13 +0300 Subject: Article, Headlines: shorten several method names --- plugins/embed_original/init.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/embed_original') diff --git a/plugins/embed_original/init.js b/plugins/embed_original/init.js index 95a5ef9e5..6f797556b 100644 --- a/plugins/embed_original/init.js +++ b/plugins/embed_original/init.js @@ -11,7 +11,7 @@ function embedOriginalArticle(id) { if (App.isCombinedMode()) { c = $$("div#RROW-" + id + " div[class=content-inner]")[0]; - } else if (id == Article.getActiveArticleId()) { + } else if (id == Article.getActive()) { c = $$(".post .content")[0]; } @@ -23,7 +23,7 @@ function embedOriginalArticle(id) { c.parentNode.removeChild(iframe); if (App.isCombinedMode()) { - Article.cdmScrollToArticleId(id, true); + Article.cdmScrollToId(id, true); } return; @@ -48,7 +48,7 @@ function embedOriginalArticle(id) { c.parentNode.insertBefore(iframe, c); if (App.isCombinedMode()) { - Article.cdmScrollToArticleId(id, true); + Article.cdmScrollToId(id, true); } } } -- cgit v1.2.3 From 71fc6d45bd761a9d2715faa68f2b8c0271ee7169 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 3 Dec 2018 13:38:13 +0300 Subject: refactor error reporting to AppBase; keep exception_error() for now as a shim --- plugins/embed_original/init.js | 86 ++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 45 deletions(-) (limited to 'plugins/embed_original') 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); - } } -- cgit v1.2.3