PageSourceSearch

https://www.xanax.com/-/media/Base-Themes/Components-Theme/Scripts/component-disqus.js

js xanax.com collected 2026-09-24 22:55:15 UTC 2,478 bytes, 73 lines download raw bytes

1/**
2 * Component Disqus
3 * @module Disqus
4 * @param  {jQuery} $ Instance of jQuery
5 * @param  {Document} document Instance of Document
6 * @return {Object} List of Disqus methods
7 */
8XA.component.disqus = (function($, document) {
9    /**
10     * This object stores all public api methods
11     * @type {Object.<Methods>}
12     * @memberOf module:Archive
13     * */
14    var api = {};
15    /**
16     * initDisqus method create script element  for discuss component
17     * @memberOf module:Disqus
18     * @method
19     * @param {Object} prop option of disqus component
20     * @alias module:Disqus.initDisqus
21     * @private
22     */
23    function initDisqus(prop) {
24        var dsq = document.createElement("script");
25        dsq.type = "text/javascript";
26        dsq.async = true;
27        dsq.src = "//" + prop.disqus_shortname + ".disqus.com/embed.js";
28        (
29            document.getElementsByTagName("head")[0] ||
30            document.getElementsByTagName("body")[0]
31        ).appendChild(dsq);
32    }
33    /**
34     * initInstance method sets up disqus_config and calls
35     * [".initDisqus"]{@link module:Disqus.initDisqus}  method.
36     * @memberOf module:Disqus
37     * @method
38     * @param {jQuery} component Root DOM element of archive component wrapped by jQuery
39     * @param {Object} prop option of disqus component
40     * @alias module:Disqus.initInstance
41     */
42    api.initInstance = function(component, prop) {
43        window.disqus_config = function() {
44            this.page.url = prop.disqus_url;
45            this.page.identifier = prop.disqus_identifier;
46            this.page.title = prop.disqus_title;
47            this.page.category_id = prop.disqus_category_id;
48        };
49
50        if (component.find("#disqus_thread").length > 0) {
51            initDisqus(prop);
52        }
53    };
54    /**
55     * init method calls in a loop for each
56     * disqus component on a page and runs Disqus's
57     * [".initInstance"]{@link module:Disqus.initInstance}  method.
58     * @memberOf module:Disqus
59     * @alias module:Disqus.init
60     */
61    api.init = function() {
62        var disqus = $(".disqus:not(.initialized)");
63        disqus.each(function() {
64            var properties = $(this).data("properties");
65            api.initInstance($(this), properties);
66            $(this).addClass("initialized");
67        });
68    };
69
70    return api;
71})(jQuery, document);
72
73XA.register("disqus", XA.component.disqus);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.