File: init.js

package info (click to toggle)
tt-rss 21~git20210204.b4cbc79%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,436 kB
  • sloc: php: 29,355; javascript: 13,884; sql: 2,341; sh: 315; makefile: 81; perl: 9
file content (33 lines) | stat: -rw-r--r-- 1,155 bytes parent folder | download | duplicates (3)
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
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.cdmMoveToId(id);

            return;
        }

        Notify.progress("Loading, please wait...");

        xhrJson("backend.php",{ op: "pluginhandler", plugin: "af_readability", method: "embed", param: id }, (reply) => {

            if (content && reply.content) {
                content.setAttribute(self.orig_attr_name, content.innerHTML);
                content.innerHTML = reply.content;
                Notify.close();

                if (App.isCombinedMode()) Article.cdmMoveToId(id);

            } else {
                Notify.error("Unable to fetch full text for this article");
            }
        });
    }
};