1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 17:05:56 +00:00

refactor error reporting to AppBase; keep exception_error() for now as a shim

This commit is contained in:
Andrew Dolgov
2018-12-03 13:38:13 +03:00
parent a049b5bd88
commit 71fc6d45bd
17 changed files with 222 additions and 267 deletions

View File

@@ -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;
}
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 (!hasSandbox) {
alert(__("Sorry, your browser does not support sandboxed iframes."));
return;
}
}
let c = false;
const query = { op: "pluginhandler", plugin: "embed_original", method: "getUrl", id: id };
if (App.isCombinedMode()) {
c = $$("div#RROW-" + id + " div[class=content-inner]")[0];
} else if (id == Article.getActive()) {
c = $$(".post .content")[0];
}
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) {
const iframe = c.parentNode.getElementsByClassName("embeddedContent")[0];
if (iframe) {
Element.show(c);
c.parentNode.removeChild(iframe);
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);
}
}