summaryrefslogtreecommitdiff
path: root/plugins/af_readability/init.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-02-28 08:03:25 +0300
committerAndrew Dolgov <[email protected]>2020-02-28 08:03:25 +0300
commit4e74da590ee935c2187dd02f6c2b312680065f13 (patch)
tree6b1912724386957b3c45638bb565603d2eab0850 /plugins/af_readability/init.js
parentbdb1e475e72d985065b564ccb8bba8576ac4f614 (diff)
af_readability: allow get full text button to work as a toggle; in cdm, scroll to article after embedding
Diffstat (limited to 'plugins/af_readability/init.js')
-rw-r--r--plugins/af_readability/init.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/plugins/af_readability/init.js b/plugins/af_readability/init.js
index fd603cbf1..644dff9fe 100644
--- a/plugins/af_readability/init.js
+++ b/plugins/af_readability/init.js
@@ -1,16 +1,32 @@
Plugins.Af_Readability = {
+ orig_attr_name: 'data-readability-orig-content',
+ self: this,
embed: function(id) {
+ const content = $$(App.isCombinedMode() ? ".cdm[data-article-id=" + id + "] .content-inner" :
+ ".post[data-article-id=" + id + "] .content")[0];
+
+ if (content.hasAttribute(self.orig_attr_name)) {
+ content.innerHTML = content.getAttribute(self.orig_attr_name);
+ content.removeAttribute(self.orig_attr_name);
+
+ if (App.isCombinedMode()) Article.cdmScrollToId(id);
+
+ return;
+ }
+
Notify.progress("Loading, please wait...");
xhrJson("backend.php",{ op: "pluginhandler", plugin: "af_readability", method: "embed", param: id }, (reply) => {
- const content = $$(App.isCombinedMode() ? ".cdm[data-article-id=" + id + "] .content-inner" :
- ".post[data-article-id=" + id + "] .content")[0];
if (content && reply.content) {
+ content.setAttribute(self.orig_attr_name, content.innerHTML);
content.innerHTML = reply.content;
Notify.close();
+
+ if (App.isCombinedMode()) Article.cdmScrollToId(id);
+
} else {
- Notify.error("Unable to fetch content for this article");
+ Notify.error("Unable to fetch full text for this article");
}
});
}