mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 17:05:56 +00:00
add embed_original plugin
This commit is contained in:
69
plugins/embed_original/init.js
Normal file
69
plugins/embed_original/init.js
Normal file
@@ -0,0 +1,69 @@
|
||||
function embedOriginalArticle(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=embed_original&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.getElementsByClassName("embeddedContent")[0];
|
||||
|
||||
if (iframe) {
|
||||
Element.show(c.firstChild);
|
||||
c.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: ti.url,
|
||||
sandbox: 'sandbox',
|
||||
});
|
||||
|
||||
if (c) {
|
||||
Element.hide(c.firstChild);
|
||||
|
||||
if (c.firstChild.nextSibling)
|
||||
c.insertBefore(iframe, c.firstChild.nextSibling);
|
||||
else
|
||||
c.appendChild(iframe);
|
||||
|
||||
if (isCdmMode()) {
|
||||
cdmScrollToArticleId(id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} });
|
||||
|
||||
|
||||
} catch (e) {
|
||||
exception_error("embedOriginalArticle", e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user