Guest User

disqus embed.js

a guest
Oct 11th, 2010
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var DISQUS;
  2. var disqus_config;
  3. var DsqLocal;
  4. var disqus_callback;
  5. var disqus_callback_params;
  6. var disqus_category_id;
  7. var disqus_container_id;
  8. var disqus_custom_strings;
  9. var disqus_def_email;
  10. var disqus_def_name;
  11. var disqus_default_text;
  12. var disqus_dev;
  13. var disqus_developer;
  14. var disqus_domain;
  15. var disqus_facebook_forum;
  16. var disqus_facebook_key;
  17. var disqus_frame_theme;
  18. var disqus_href;
  19. var disqus_identifier;
  20. var disqus_iframe_css;
  21. var disqus_message;
  22. var disqus_shortname;
  23. var disqus_thread_slug;
  24. var disqus_skip_auth;
  25. var disqus_sort;
  26. var disqus_title;
  27. var disqus_url;
  28. var disqus_per_page;
  29. DISQUS = (function () {
  30.     var m = {};
  31.     var g;
  32.     var a;
  33.     var b;
  34.     var e = false;
  35.     g = document.getElementsByTagName("head")[0] || document.getElementById("disqus_thread");
  36.     b = {
  37.         running: false,
  38.         timer: null,
  39.         queue: []
  40.     };
  41.  
  42.     function h(i) {
  43.         var n = window.onload;
  44.         if (typeof window.onload != "function") {
  45.             window.onload = i
  46.         } else {
  47.             window.onload = function () {
  48.                 if (n) {
  49.                     n()
  50.                 }
  51.                 i()
  52.             }
  53.         }
  54.     }
  55.     function j(q) {
  56.         var r = (q.getAttribute) ? q.getAttribute("src") : q.src;
  57.         var n = [/https?:\/\/(www\.)?disqus\.com\/forums\/([\w_\-]+)/i, /https?:\/\/(www\.)?([\w_\-]+)\.disqus\.com/i, /https?:\/\/(www\.)?dev\.disqus\.org\/forums\/([\w_\-]+)/i];
  58.         if (r) {
  59.             for (var p = 0; p < n.length; p++) {
  60.                 var o = r.match(n[p]);
  61.                 if (o && o.length && o.length == 3) {
  62.                     return o[2]
  63.                 }
  64.             }
  65.         }
  66.         return null
  67.     }
  68.     function l() {
  69.         var n;
  70.         var q;
  71.         var o;
  72.         if (!DISQUS.isReady) {
  73.             if (!a) {
  74.                 a = window.setInterval(l, 500)
  75.             }
  76.             return
  77.         }
  78.         if (a) {
  79.             clearInterval(a)
  80.         }
  81.         n = document.getElementById(disqus_container_id);
  82.         q = document.getElementsByTagName("iframe");
  83.         o = document.getElementById("dsq-content");
  84.         if (o) {
  85.             for (var p = 0; p < q.length; p++) {
  86.                 q[p].style.width = o.offsetWidth
  87.             }
  88.         }
  89.     }
  90.     function d() {
  91.         if (b.queue.length === 0) {
  92.             b.running = false;
  93.             clearInterval(b.timer);
  94.             return
  95.         }
  96.         var i = b.queue.shift();
  97.         if (i[0]()) {
  98.             i[1]()
  99.         } else {
  100.             b.queue.push(i)
  101.         }
  102.     }
  103.     function f(i) {
  104.         var n = document.getElementById("dsq-content-progress");
  105.         if (!n) {
  106.             return
  107.         }
  108.         if (typeof i == "undefined") {
  109.             i = parseInt(n.style.width, 10) + 10
  110.         }
  111.         n.style.width = i + "px"
  112.     }
  113.     m.browser = {
  114.         ie: /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent),
  115.         ie6: (!window.XMLHttpRequest) ? true : false,
  116.         ie7: (document.all && !window.opera && window.XMLHttpRequest) ? true : false,
  117.         webkit: navigator.userAgent.indexOf("AppleWebKit/") > -1,
  118.         opera: !! (window.opera && window.opera.buildNumber),
  119.         gecko: navigator.userAgent.indexOf("Gecko/") > -1,
  120.         mobile: /(iPhone|Android|iPod|iPad|webOS|Mobile Safari)/i.test(navigator.userAgent)
  121.     };
  122.     m.cache = {
  123.         buttonsToRestore: [],
  124.         popupProfileCache: {},
  125.         popupStatusCache: {},
  126.         toggledReplies: {},
  127.         realtime: {
  128.             interval: null,
  129.             ongoing_request: null,
  130.             prev_script: null,
  131.             last_checked: null,
  132.             newPosts: []
  133.         }
  134.     };
  135.     m.states = {
  136.         edit: {},
  137.         realtime: false,
  138.         useLoginWindow: false,
  139.         loginDisabled: false,
  140.         metaViewport: false
  141.     };
  142.     var k = document.getElementsByTagName("meta");
  143.     for (var c = 0; c < k.length; c++) {
  144.         if (k[c].getAttribute("name") == "viewport") {
  145.             m.states.metaViewport = true;
  146.             break
  147.         }
  148.     }
  149.     m.blocks = {};
  150.     m.curPageId = "dsq-comments";
  151.     m.frames = {};
  152.     m.config = {
  153.         template: null,
  154.         callbacks: {
  155.             preData: [],
  156.             preInit: [],
  157.             onInit: [],
  158.             afterRender: [],
  159.             onReady: [],
  160.             onPaginate: [],
  161.             onNewComment: []
  162.         }
  163.     };
  164.     m.modules = {};
  165.     m.isReady = false;
  166.     m.jsonData = null;
  167.     m.callback = function (s) {
  168.         var p, r, n;
  169.         var q = function (i) {
  170.             if (window.console && console.log) {
  171.                 console.log(i)
  172.             }
  173.         };
  174.         if (arguments.length > 1) {
  175.             n = Array.prototype.slice.call(arguments, 1)
  176.         }
  177.         for (p = 0; p < s.length; p++) {
  178.             r = s[p];
  179.             if (typeof r != "function") {
  180.                 continue
  181.             }
  182.             try {
  183.                 r.apply({}, n || [])
  184.             } catch (o) {
  185.                 if (o.toString().search("Dsq") > -1) {
  186.                     q("WARNING: This page uses deprecated Disqus APIs. See blog.disqus.com for more info")
  187.                 } else {
  188.                     q(o)
  189.                 }
  190.             }
  191.         }
  192.     };
  193.     m.getResourceURL = function (n, q, i) {
  194.         if (typeof q != "undefined") {
  195.             if (n.indexOf("?") === -1) {
  196.                 n += "?"
  197.             } else {
  198.                 n += "&"
  199.             }
  200.             for (var o in q) {
  201.                 if (q.hasOwnProperty(o)) {
  202.                     n += o + "=" + encodeURIComponent(q[o]);
  203.                     n += "&"
  204.                 }
  205.             }
  206.         }
  207.         var p = n.slice(n.length - 1);
  208.         if (i) {
  209.             if (p != "&" && p != "?") {
  210.                 n += "?"
  211.             }
  212.             n += (new Date()).getTime()
  213.         }
  214.         return n
  215.     };
  216.     m.require = function (o, p, n) {
  217.         var i = document.createElement("script");
  218.         i.src = m.getResourceURL(o, p, n);
  219.         i.async = true;
  220.         i.charset = "UTF-8";
  221.         g.appendChild(i);
  222.         return m
  223.     };
  224.     m.requireStylesheet = function (n, p, i) {
  225.         var o = document.createElement("link");
  226.         o.rel = "stylesheet";
  227.         o.type = "text/css";
  228.         o.href = m.getResourceURL(n, p, i);
  229.         g.appendChild(o);
  230.         return m
  231.     };
  232.     m.startLoading = function () {
  233.         var i;
  234.         var o;
  235.         var r;
  236.         var q;
  237.         var s;
  238.         var n;
  239.         if (m.browser.ie && m.config.frame_theme !== "cnn2") {
  240.             h(l)
  241.         }
  242.         r = document.createElement("style");
  243.         g.appendChild(r);
  244.         m.cache.inlineStylesheet = r.sheet;
  245.         if (!m.cache.inlineStylesheet) {
  246.             m.cache.inlineStylesheet = document.styleSheets[document.styleSheets.length - 1]
  247.         }
  248.         if (m.browser.ie6 || m.browser.ie7) {
  249.             n = {
  250.                 b: (m.browser.ie6 ? "ie6" : "ie7")
  251.             }
  252.         }
  253.         m.requireStylesheet("http://" + m.config.domain + "/forums/" + m.config.shortname + "/styles.css", n);
  254.         m.callback(m.config.callbacks.preData);
  255.         if (m.jsonData === null) {
  256.             m.require(m.config.json_url, m.config.page, true)
  257.         }
  258.         o = document.createElement("div");
  259.         o.id = "dsq-content";
  260.         o.style.display = "none";
  261.         s = {
  262.             wrapper: "height: 15px;width: 300px;border: solid 1px #999;background-color: #fff;margin: 10px 0;",
  263.             bar: "height: 15px;width: 15px;background-color: #d4e4ff;",
  264.             problem: "font-size: 8pt;display: none;"
  265.         };
  266.         q = document.createElement("div");
  267.         q.id = "dsq-content-stub";
  268.         q.innerHTML = 'Loading comments...<div style="' + s.wrapper + '"><div style="' + s.bar + '">&nbsp;</div></div><div style="' + s.problem + '" id="dsq-loading-problem"><a href="#">Problems loading Disqus?</a></div>';
  269.         i = document.getElementById(DISQUS.config.container_id);
  270.         i.appendChild(o);
  271.         i.appendChild(q);
  272.         m.container = document.getElementById("dsq-content");
  273.         window.setTimeout(function () {
  274.             if (q.style.display != "none") {
  275.                 document.getElementById("dsq-loading-problem").style.display = "block"
  276.             }
  277.         }, 10000);
  278.         try {
  279.             if (m.browser.ie6) {
  280.                 document.execCommand("BackgroundImageCache", false, true)
  281.             }
  282.         } catch (p) {}
  283.         m.addJob(function () {
  284.             return m.jsonData !== null
  285.         }, function () {
  286.             var y = m.jsonData.settings.media_url;
  287.             var t = y + "/javascript/embed/dtpl/";
  288.             var z = y + "/build/system/";
  289.             var w = y + "/build/lang/";
  290.             var v = m.jsonData.forum.template.css;
  291.             var x = m.jsonData.forum.template.url;
  292.             m.callback(DISQUS.config.callbacks.preInit);
  293.             if (m.browser.mobile && m.states.metaViewport && !m.jsonData.forum.mobile_theme_disabled) {
  294.                 v = y + "/build/themes/mobile.css";
  295.                 x = y + "/build/themes/mobile.js"
  296.             } else {
  297.                 if (m.config.template) {
  298.                     v = m.config.template.css;
  299.                     x = m.config.template.js
  300.                 }
  301.             }
  302.             if ((window.location.search.indexOf("fbc_channel=1") > -1) || (window.location.search.indexOf("?fb_xd_fragment") > -1)) {
  303.                 if (m.jsonData.settings.debug) {
  304.                     m.require(x).require(t + "utils.js", {}, true).require(t + "api.js", {}, true).require(t + "dtpl.js", {}, true)
  305.                 } else {
  306.                     m.require(m.jsonData.forum.template.url).require(z + "dsq.js", false)
  307.                 }
  308.                 m.addJob(function () {
  309.                     return m.modules.utils && m.modules.api && m.modules.template && m.modules.dtpl
  310.                 }, function () {
  311.                     DISQUS.registerActions();
  312.                     var A = new DISQUS.api.FacebookLoginBox()
  313.                 });
  314.                 return
  315.             }
  316.             if (m.jsonData.settings.debug) {
  317.                 m.require(x).require(t + "dtpl.js", {}, true).require(t + "utils.js", {}, true).require(t + "sandbox.js", {}, true).require(t + "newframes.js", {}, true).require(t + "parentmessenger.js", {}, true).require(t + "jsonrpc.js", {}, true).require(t + "fragmentpacket.js", {}, true).require(t + "postmessagepacket.js", {}, true).require(t + "tooltip.js", {}, true).require(t + "api.js", {}, true).require(t + "ui.js", {}, true)
  318.             } else {
  319.                 m.require(x).require(z + "disqus.js", false);
  320.                 if (m.jsonData.forum.use_new_iframe) {
  321.                     var u = document.createElement("iframe");
  322.                     u.style.display = "none";
  323.                     u.src = m.jsonData.urls.stats;
  324.                     document.body.appendChild(u)
  325.                 }
  326.             }
  327.             if (!window.disqus_no_style) {
  328.                 m.requireStylesheet(y + "/styles/embed/thread.css", {}, m.jsonData.settings.debug);
  329.                 if (v) {
  330.                     m.requireStylesheet(v, {}, m.jsonData.settings.debug)
  331.                 }
  332.             }
  333.             m.addJob(function () {
  334.                 var B = ["utils", "sandbox", "template", "dtpl", "NewFrames", "ParentMessenger", "JsonRpc", "api", "FragmentPacket", "PostMessagePacket", "tooltip", "ui"];
  335.                 for (var A = 0; A < B.length; A++) {
  336.                     if (!m.modules[B[A]]) {
  337.                         return false
  338.                     }
  339.                 }
  340.                 return true
  341.             }, function () {
  342.                 DISQUS.states.useLoginWindow = !DISQUS.ParentMessenger.isSupported(DISQUS.jsonData.integration.receiver_url);
  343.                 if (m.jsonData.forum.language != "en") {
  344.                     m.require(w + m.jsonData.forum.language + ".js")
  345.                 } else {
  346.                     m.modules.lang = true
  347.                 }
  348.                 m.addJob(function () {
  349.                     return m.modules.lang === true
  350.                 }, function () {
  351.                     if (m.config.custom_strings) {
  352.                         DISQUS.lang.extend(DISQUS.strings.translations, m.config.custom_strings)
  353.                     }
  354.                     if (m.config.def_text === "") {
  355.                         m.config.def_text = DISQUS.strings.get("Type your comment here.")
  356.                     }
  357.                     DISQUS.nodes.addClass(o, "clearfix");
  358.                     var A = o.parentNode;
  359.                     A.removeChild(o);
  360.                     o.innerHTML = DISQUS.renderBlock("thread");
  361.                     A.appendChild(o);
  362.                     m.callback(m.config.callbacks.onInit);
  363.                     f();
  364.                     DISQUS.registerActions();
  365.                     DISQUS.dtpl.actions.fire("thread.initialize");
  366.                     f(300);
  367.                     m.callback(m.config.callbacks.afterRender);
  368.                     DISQUS.nodes.container = DISQUS.nodes.get("#dsq-content");
  369.                     o.style.display = "block";
  370.                     q.style.display = "none";
  371.                     var C, B;
  372.                     if (m.config.page.anchor_post_id) {
  373.                         DISQUS.nodes.scrollTo("#comment-" + m.config.page.anchor_post_id)
  374.                     }
  375.                     DISQUS.dtpl.actions.fire("thread.ready")
  376.                 })
  377.             })
  378.         })
  379.     };
  380.     m.reload = function (i) {
  381.         DISQUS.jsonData.request.expired = true;
  382.         m.require(m.config.json_url, m.config.page, true);
  383.         m.addJob(function () {
  384.             return !DISQUS.jsonData.request.expired
  385.         }, function () {
  386.             e = true;
  387.             if (typeof i == "function") {
  388.                 i()
  389.             }
  390.         })
  391.     };
  392.     m.redraw = function (n) {
  393.         var i;
  394.         if (e || n) {
  395.             DISQUS.sandbox.invalidateGlobals();
  396.             i = DISQUS.nodes.get("#dsq-content");
  397.             i.innerHTML = DISQUS.renderBlock("thread");
  398.             DISQUS.frames = [];
  399.             DISQUS.dtpl.actions.fire("thread.initialize");
  400.             e = false
  401.         }
  402.     };
  403.     m.addJob = function (n, i) {
  404.         b.queue.push([n, i]);
  405.         d();
  406.         if (!b.running) {
  407.             b.running = true;
  408.             b.timer = setInterval(d, 100)
  409.         }
  410.     };
  411.     m.getShortname = function () {
  412.         var n = document.getElementsByTagName("script");
  413.         for (var p = n.length - 1; p >= 0; p--) {
  414.             var o = j(n[p]);
  415.             if (o !== null) {
  416.                 return o
  417.             }
  418.         }
  419.         return null
  420.     };
  421.     m.renderBlock = function (i, o) {
  422.         var n = m.blocks[i];
  423.         if (typeof n == "undefined") {
  424.             throw "Block " + i + " was not found!"
  425.         }
  426.         return DISQUS.sandbox.wrap(i, n, o)
  427.     };
  428.     return m
  429. }());
  430. DISQUS.lang = (function () {
  431.     var a = {};
  432.     a.contains = function (d, c) {
  433.         for (var b = 0; b < d.length; b++) {
  434.             if (d[b] == c) {
  435.                 return true
  436.             }
  437.         }
  438.         return false
  439.     };
  440.     a.forEach = function (f, g) {
  441.         var d = f.length;
  442.         var e = Array.prototype.forEach;
  443.         if (d == "number") {
  444.             if (e) {
  445.                 e.call(f, g)
  446.             } else {
  447.                 for (var c = 0; c < d; c++) {
  448.                     g(f[c], c, f)
  449.                 }
  450.             }
  451.         } else {
  452.             for (var b in f) {
  453.                 if (f.hasOwnProperty(b)) {
  454.                     g(f[b], b, f)
  455.                 }
  456.             }
  457.         }
  458.     };
  459.     a.extend = function () {
  460.         var d = arguments[0] || {},
  461.             c = 1;
  462.         var b = Array.prototype.slice.call(arguments, 1);
  463.         a.forEach(b, function (e, f) {
  464.             a.forEach(e, function (h, g) {
  465.                 d[g] = h
  466.             })
  467.         });
  468.         return d
  469.     };
  470.     a.partial = function () {
  471.         var c = arguments[0];
  472.         var b = Array.prototype.slice.call(arguments, 1);
  473.         return function () {
  474.             var e = Array.prototype.slice.call(arguments);
  475.             var f = [];
  476.             for (var d = 0; d < b.length; d++) {
  477.                 f.push(b[d] === undefined ? e.shift() : b[d])
  478.             }
  479.             while (e.length > 0) {
  480.                 f.push(e.shift())
  481.             }
  482.             return c.apply(this, f)
  483.         }
  484.     };
  485.     a.trim = function (d) {
  486.         d = d.replace(/^\s\s*/, "");
  487.         var b = /\s/,
  488.             c = d.length;
  489.         while (b.test(d.charAt(--c))) {}
  490.         return d.slice(0, c + 1)
  491.     };
  492.     return a
  493. }());
  494. (function () {
  495.     var d;
  496.     var a;
  497.     var e = (function () {
  498.         var g, m = document.getElementsByTagName("META");
  499.  
  500.         function n(j, i) {
  501.             return j.hasAttribute ? j.hasAttribute(i) : j.getAttribute(i) !== null
  502.         }
  503.         function l(i) {
  504.             var j = function (o, p) {
  505.                 return n(i, o) && i.getAttribute(o) == p
  506.             };
  507.             return j("name", "generator") && j("content", "blogger")
  508.         }
  509.         function f(i) {
  510.             return !n(i, "src") && n(i, "name") && parseInt(i.getAttribute("name"), 10) && i.innerHTML === ""
  511.         }
  512.         for (var k = 0; k < m.length; k++) {
  513.             if (l(m[k])) {
  514.                 g = document.getElementsByTagName("A");
  515.                 for (var h = 0; h < g.length; h++) {
  516.                     if (f(g[h])) {
  517.                         return g[h].getAttribute("name")
  518.                     }
  519.                 }
  520.             }
  521.         }
  522.         return null
  523.     }());
  524.     DsqLocal = DsqLocal || {};
  525.     disqus_href = window.location.href;
  526.     d = disqus_href.indexOf("#");
  527.     if (d != -1) {
  528.         disqus_href = disqus_href.substring(0, d)
  529.     }
  530.     DISQUS.lang.extend(DISQUS.config, {
  531.         container_id: disqus_container_id || "disqus_thread",
  532.         page: {
  533.             url: (typeof disqus_url == "undefined" || disqus_url === "") ? disqus_href : disqus_url,
  534.             title: disqus_title || "",
  535.             sort: disqus_sort || "",
  536.             per_page: disqus_per_page || null,
  537.             category_id: disqus_category_id || "",
  538.             developer: (disqus_developer && disqus_developer !== "0") ? 1 : 0,
  539.             identifier: disqus_identifier || "",
  540.             trackback_url: DsqLocal.trackback_url || null,
  541.             trackbacks: DsqLocal.trackbacks || null
  542.         }
  543.     });
  544.     if (e) {
  545.         DISQUS.config.page.blogger_id = e
  546.     }
  547.     if (typeof disqus_message == "undefined") {
  548.         DISQUS.config.message = ""
  549.     } else {
  550.         a = false;
  551.         if (DISQUS.browser.ie) {
  552.             for (var c = 0; c < disqus_message.length; c++) {
  553.                 if (disqus_message.charCodeAt(c) > 256) {
  554.                     a = true;
  555.                     break
  556.                 }
  557.             }
  558.         }
  559.         if (a) {
  560.             DISQUS.config.message = ""
  561.         } else {
  562.             if (disqus_message.length > 400) {
  563.                 DISQUS.config.message = disqus_message.substring(0, disqus_message.indexOf(" ", 350))
  564.             }
  565.         }
  566.     }
  567.     if (typeof disqus_require_moderation_s != "undefined") {
  568.         DISQUS.config.page.require_mod_s = disqus_require_moderation_s
  569.     }
  570.     if (typeof disqus_remote_auth_s2 != "undefined") {
  571.         DISQUS.config.page.remote_auth_s2 = disqus_remote_auth_s2
  572.     }
  573.     if (typeof disqus_per_page != "undefined") {
  574.         DISQUS.config.page.per_page = disqus_per_page
  575.     }
  576.     if (typeof disqus_author_s2 != "undefined") {
  577.         DISQUS.config.page.author_s2 = disqus_author_s2
  578.     }
  579.     if (typeof disqus_thread_slug != "undefined") {
  580.         DISQUS.config.page.slug = disqus_thread_slug
  581.     }
  582.     var b;
  583.     if (window.location.hash) {
  584.         b = window.location.hash.match(/comment\-([0-9]+)/);
  585.         if (b) {
  586.             DISQUS.config.page.anchor_post_id = b[1]
  587.         }
  588.     }
  589.     DISQUS.config.callback_params = disqus_callback_params || null;
  590.     if (typeof disqus_callback == "function") {
  591.         DISQUS.config.callbacks.afterRender.push(function () {
  592.             disqus_callback(DISQUS.config.callback_params)
  593.         })
  594.     }
  595.     if (typeof disqus_custom_strings == "object") {
  596.         DISQUS.config.custom_strings = disqus_custom_strings
  597.     }
  598.     DISQUS.config.domain = disqus_domain || (disqus_dev ? "dev.disqus.org" : "disqus.com");
  599.     DISQUS.config.shortname = disqus_shortname || DISQUS.getShortname();
  600.     DISQUS.config.iframe_css = disqus_iframe_css || "";
  601.     DISQUS.config.facebook_forum = disqus_facebook_forum || null;
  602.     DISQUS.config.facebook_key = disqus_facebook_key || null;
  603.     DISQUS.config.frame_theme = disqus_frame_theme || null;
  604.     DISQUS.config.def_name = disqus_def_name || "";
  605.     DISQUS.config.def_email = disqus_def_email || "";
  606.     DISQUS.config.def_text = disqus_default_text || "";
  607.     DISQUS.config.skip_auth = disqus_skip_auth || false;
  608.     DISQUS.config.json_url = "http://" + DISQUS.config.shortname + "." + DISQUS.config.domain + "/thread.js";
  609.     if (typeof disqus_config == "function") {
  610.         disqus_config.call(DISQUS.config)
  611.     }
  612.     DISQUS.startLoading()
  613. })();
Advertisement
Add Comment
Please, Sign In to add comment