forked from sepich/tt-rss-mobilize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.js
79 lines (62 loc) · 2.11 KB
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//hotkey
hotkey_actions['mobilize'] = function() {
if (getActiveArticleId()) {
mobilizeArticle(getActiveArticleId());
return;
}
};
//iframe
function mobilizeArticle(id) {
try {
var hasSandbox = "sandbox" in document.createElement("iframe");
if (!hasSandbox) {
alert(__("Sorry, your browser does not support sandboxed iframes."));
return;
}
var query = "op=pluginhandler&plugin=mobilize&method=getUrl&id=" +param_escape(id);
var c = false;
if (isCdmMode()) {
c = $$("div#RROW-" + id + " div[class=cdmContentInner]")[0];
} else if (id == getActiveArticleId()) {
c = $$("div[class=postContent]")[0];
}
if (c) {
var iframe = c.parentNode.getElementsByClassName("embeddedContent")[0];
if (iframe) {
Element.show(c);
c.parentNode.removeChild(iframe);
if (isCdmMode()) {
cdmScrollToArticleId(id, true);
}
return;
}
}
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: 'plugins/mobilize/m.php?'+ti.url,
width: (c.parentNode.offsetWidth-5)+'px',
height: (c.parentNode.parentNode.offsetHeight-c.parentNode.firstChild.offsetHeight-5)+'px',
// height: (c.parentNode.parentNode.offsetHeight-c.parentNode.firstChild.offsetHeight-15)+'px',
style: "overflow: auto; border: none; min-height: "+(document.body.clientHeight/2)+"px;",
// style: "overflow: scroll; border: none; min-height: "+(document.body.clientHeight-180)+"px; max-height: "+(document.body.clientHeight-80)+"px;",
// style: "overflow: scroll; border: none; min-height: "+(document.body.clientHeight-214)+"px; max-height: "+(document.body.clientHeight-85)+"px;",
sandbox: 'allow-same-origin allow-scripts allow-popups allow-forms',
});
if (c) {
Element.hide(c);
c.parentNode.insertBefore(iframe,c);
if (isCdmMode()) {
cdmScrollToArticleId(id, true);
}
}
}
} });
} catch (e) {
exception_error("autoEmbedOriginalArticle", e);
}
}