]>
Commit | Line | Data |
---|---|---|
a479f3ef AD |
1 | function embedOriginalArticle(id) { |
2 | try { | |
dbb4cdbe | 3 | const hasSandbox = "sandbox" in document.createElement("iframe"); |
a479f3ef AD |
4 | |
5 | if (!hasSandbox) { | |
6 | alert(__("Sorry, your browser does not support sandboxed iframes.")); | |
7 | return; | |
8 | } | |
9 | ||
dbb4cdbe | 10 | let c = false; |
a479f3ef AD |
11 | |
12 | if (isCdmMode()) { | |
13 | c = $$("div#RROW-" + id + " div[class=cdmContentInner]")[0]; | |
14 | } else if (id == getActiveArticleId()) { | |
15 | c = $$("div[class=postContent]")[0]; | |
16 | } | |
17 | ||
18 | if (c) { | |
dbb4cdbe | 19 | const iframe = c.parentNode.getElementsByClassName("embeddedContent")[0]; |
a479f3ef AD |
20 | |
21 | if (iframe) { | |
44db06b6 SS |
22 | Element.show(c); |
23 | c.parentNode.removeChild(iframe); | |
a479f3ef AD |
24 | |
25 | if (isCdmMode()) { | |
26 | cdmScrollToArticleId(id, true); | |
27 | } | |
28 | ||
29 | return; | |
30 | } | |
31 | } | |
32 | ||
2f961ee8 AD |
33 | const query = { op: "pluginhandler", plugin: "embed_original", method: "getUrl", id: id }; |
34 | ||
35 | xhrJson("backend.php", query, (reply) => { | |
36 | if (reply) { | |
37 | const iframe = new Element("iframe", { | |
38 | class: "embeddedContent", | |
39 | src: reply.url, | |
40 | width: (c.parentNode.offsetWidth - 5) + 'px', | |
41 | height: (c.parentNode.parentNode.offsetHeight - c.parentNode.firstChild.offsetHeight - 5) + 'px', | |
42 | style: "overflow: auto; border: none; min-height: " + (document.body.clientHeight / 2) + "px;", | |
43 | sandbox: 'allow-scripts', | |
44 | }); | |
45 | ||
46 | if (c) { | |
47 | Element.hide(c); | |
48 | c.parentNode.insertBefore(iframe, c); | |
49 | ||
50 | if (isCdmMode()) { | |
51 | cdmScrollToArticleId(id, true); | |
a479f3ef AD |
52 | } |
53 | } | |
2f961ee8 AD |
54 | } |
55 | }); | |
a479f3ef AD |
56 | |
57 | } catch (e) { | |
58 | exception_error("embedOriginalArticle", e); | |
59 | } | |
60 | } |