Skip to content

Instantly share code, notes, and snippets.

Created December 24, 2012 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4367411 to your computer and use it in GitHub Desktop.
Save anonymous/4367411 to your computer and use it in GitHub Desktop.
var DISQUS = function (e) {
var g = e.DISQUS || {};
g.AssertionError = function (b) {
this.message = b
};
g.AssertionError.prototype.toString = function () {
return "Assertion Error: " + (this.message || "[no message]")
};
g.assert = function (b, d, f) {
if (!b) if (f) e.console && e.console.log("DISQUS assertion failed: " + d);
else throw new g.AssertionError(d);
};
var d = [];
g.define = function (b, m) {
typeof b === "function" && (m = b, b = "");
for (var f = b.split("."), a = f.shift(), c = g, n = (m || function () {
return {}
}).call({
overwrites: function (a) {
a.__overwrites__ = !0;
return a
}
}, e); a;) c = c[a] ? c[a] : c[a] = {}, a = f.shift();
for (var h in n) n.hasOwnProperty(h) && (!n.__overwrites__ && c[h] !== null && g.assert(!c.hasOwnProperty(h), "Unsafe attempt to redefine existing module: " + h, !0), c[h] = n[h], d.push(function (a, c) {
return function () {
delete a[c]
}
}(c, h)));
return c
};
g.use = function (b) {
return g.define(b)
};
g.cleanup = function () {
for (var b = 0; b < d.length; b++) d[b]()
};
return g
}(window);
DISQUS.define(function (e, g) {
var d = e.DISQUS,
b = e.document,
m = b.getElementsByTagName("head")[0] || b.body,
f = {
running: !1,
timer: null,
queue: []
};
d.defer = function (a, c) {
function b() {
var a = f.queue;
if (a.length === 0) f.running = !1, clearInterval(f.timer);
for (var c = 0, d; d = a[c]; c++) d[0]() && (a.splice(c--, 1), d[1]())
}
f.queue.push([a, c]);
b();
if (!f.running) f.running = !0, f.timer = setInterval(b, 100)
};
d.each = function (a, c) {
var b = a.length,
d = Array.prototype.forEach;
if (isNaN(b)) for (var e in a) a.hasOwnProperty(e) && c(a[e], e, a);
else if (d) d.call(a,
c);
else for (d = 0; d < b; d++) c(a[d], d, a)
};
d.extend = function (a) {
d.each(Array.prototype.slice.call(arguments, 1), function (c) {
for (var d in c) a[d] = c[d]
});
return a
};
d.serializeArgs = function (a) {
var c = [];
d.each(a, function (a, d) {
a !== g && c.push(d + (a !== null ? "=" + encodeURIComponent(a) : ""))
});
return c.join("&")
};
d.isString = function (a) {
return Object.prototype.toString.call(a) === "[object String]"
};
d.serialize = function (a, c, b) {
c && (a += ~a.indexOf("?") ? a.charAt(a.length - 1) == "&" ? "" : "&" : "?", a += d.serializeArgs(c));
if (b) return c = {}, c[(new Date).getTime()] = null, d.serialize(a, c);
c = a.length;
return a.charAt(c - 1) == "&" ? a.slice(0, c - 1) : a
};
d.require = function (a, c, e, h, g) {
function f(a) {
if (a.type == "load" || /^(complete|loaded)$/.test(a.target.readyState)) h && h(), t && clearTimeout(t), d.bean.remove(a.target, l, f)
}
var i = b.createElement("script"),
l = i.addEventListener ? "load" : "readystatechange",
t = null;
i.src = d.serialize(a, c, e);
i.async = !0;
i.charset = "UTF-8";
(h || g) && d.bean.add(i, l, f);
g && (t = setTimeout(function () {
g()
}, 2E4));
m.appendChild(i);
return d
};
d.requireStylesheet = function (a, c, e) {
var h = b.createElement("link");
h.rel = "stylesheet";
h.type = "text/css";
h.href = d.serialize(a, c, e);
m.appendChild(h);
return d
};
d.requireSet = function (a, c, b) {
var e = a.length;
d.each(a, function (a) {
d.require(a, {}, c, function () {
--e === 0 && b()
})
})
};
d.injectCss = function (a) {
var c = b.createElement("style");
c.setAttribute("type", "text/css");
a = a.replace(/\}/g, "}\n");
e.location.href.match(/^https/) && (a = a.replace(/http:\/\//g, "https://"));
c.styleSheet ? c.styleSheet.cssText = a : c.appendChild(b.createTextNode(a));
m.appendChild(c)
}
});
DISQUS.define("JSON", function () {
function e(a) {
return a < 10 ? "0" + a : a
}
function g(c) {
a.lastIndex = 0;
return a.test(c) ? '"' + c.replace(a, function (a) {
var c = h[a];
return typeof c === "string" ? c : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4)
}) + '"' : '"' + c + '"'
}
function d(a, b) {
var l, e, h, f, i = c,
k, o = b[a];
o && typeof o === "object" && typeof o.toJSON === "function" && !m && (o = o.toJSON(a));
typeof p === "function" && (o = p.call(b, a, o));
switch (typeof o) {
case "string":
return g(o);
case "number":
return isFinite(o) ? String(o) : "null";
case "boolean":
case "null":
return String(o);
case "object":
if (!o) return "null";
c += n;
k = [];
if (Object.prototype.toString.apply(o) === "[object Array]") {
f = o.length;
for (l = 0; l < f; l += 1) k[l] = d(l, o) || "null";
h = k.length === 0 ? "[]" : c ? "[\n" + c + k.join(",\n" + c) + "\n" + i + "]" : "[" + k.join(",") + "]";
c = i;
return h
}
if (p && typeof p === "object") {
f = p.length;
for (l = 0; l < f; l += 1) e = p[l], typeof e === "string" && (h = d(e, o)) && k.push(g(e) + (c ? ": " : ":") + h)
} else for (e in o) Object.hasOwnProperty.call(o, e) && (h = d(e, o)) && k.push(g(e) + (c ? ": " : ":") + h);
h = k.length === 0 ? "{}" : c ? "{\n" + c + k.join(",\n" + c) + "\n" + i + "}" : "{" + k.join(",") + "}";
c = i;
return h
}
}
var b = {}, m = !1;
if (typeof Date.prototype.toJSON !== "function") Date.prototype.toJSON = function () {
return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + e(this.getUTCMonth() + 1) + "-" + e(this.getUTCDate()) + "T" + e(this.getUTCHours()) + ":" + e(this.getUTCMinutes()) + ":" + e(this.getUTCSeconds()) + "Z" : null
}, String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function () {
return this.valueOf()
};
var f = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
a = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
c, n, h = {
"\u0008": "\\b",
"\t": "\\t",
"\n": "\\n",
"\u000c": "\\f",
"\r": "\\r",
'"': '\\"',
"\\": "\\\\"
}, p;
b.stringify = function (a, b, l) {
var e;
n = c = "";
if (typeof l === "number") for (e = 0; e < l; e += 1) n += " ";
else typeof l === "string" && (n = l);
if ((p = b) && typeof b !== "function" && (typeof b !== "object" || typeof b.length !== "number")) throw Error("JSON.stringify");
return d("", {
"": a
})
};
b.parse = function (a, c) {
function b(a,
l) {
var d, e, h = a[l];
if (h && typeof h === "object") for (d in h) Object.hasOwnProperty.call(h, d) && (e = b(h, d), e !== void 0 ? h[d] = e : delete h[d]);
return c.call(a, l, h)
}
var l, a = String(a);
f.lastIndex = 0;
f.test(a) && (a = a.replace(f, function (a) {
return "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4)
}));
if (/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) return l = eval("(" + a + ")"),
typeof c === "function" ? b({
"": l
}, "") : l;
throw new SyntaxError("JSON.parse");
};
var k = {
a: [1, 2, 3]
}, i, l;
if (Object.toJSON && Object.toJSON(k).replace(/\s/g, "") === '{"a":[1,2,3]}') i = Object.toJSON;
typeof String.prototype.evalJSON === "function" && (k = '{"a":[1,2,3]}'.evalJSON(), k.a && k.a.length === 3 && k.a[2] === 3 && (l = function (a) {
return a.evalJSON()
}));
(function () {
var a = [1, 2, 3];
typeof a.toJSON === "function" && (a = a.toJSON(), m = !(a && a.length === 3 && a[2] === 3))
})();
if (m || !i || !l) return {
stringify: b.stringify,
parse: b.parse
};
return {
stringify: i,
parse: l
}
});
DISQUS.define(function () {
function e(c) {
for (a = 1; c = g.shift();) c()
}
var g = [],
d, b = document,
m = b.documentElement,
f = m.doScroll,
a = /^loade|c/.test(b.readyState),
c;
b.addEventListener && b.addEventListener("DOMContentLoaded", d = function () {
b.removeEventListener("DOMContentLoaded", d, !1);
e()
}, !1);
f && b.attachEvent("onreadystatechange", d = function () {
/^c/.test(b.readyState) && (b.detachEvent("onreadystatechange", d), e())
});
c = f ? function (b) {
self != top ? a ? b() : g.push(b) : function () {
try {
m.doScroll("left")
} catch (a) {
return setTimeout(function () {
c(b)
}, 50)
}
b()
}()
} : function (c) {
a ? c() : g.push(c)
};
return {
domready: c
}
});
DISQUS.define("Events", function () {
var e = /\s+/,
g = {
on: function (d, b, g) {
var f, a;
if (!b) return this;
d = d.split(e);
for (f = this._callbacks || (this._callbacks = {}); a = d.shift();) a = f[a] || (f[a] = []), a.push(b), a.push(g);
return this
},
off: function (d, b, g) {
var f, a, c;
if (!(a = this._callbacks)) return this;
if (!d && !b && !g) return delete this._callbacks, this;
for (d = d ? d.split(e) : _.keys(a); f = d.shift();) if (!(c = a[f]) || !b && !g) delete a[f];
else for (f = c.length - 2; f >= 0; f -= 2) b && c[f] !== b || g && c[f + 1] !== g || c.splice(f, 2);
return this
},
trigger: function (d) {
var b,
g, f, a, c, n, h;
if (!(g = this._callbacks)) return this;
h = [];
d = d.split(e);
a = 1;
for (c = arguments.length; a < c; a++) h[a - 1] = arguments[a];
for (; b = d.shift();) {
if (n = g.all) n = n.slice();
if (f = g[b]) f = f.slice();
if (f) {
a = 0;
for (c = f.length; a < c; a += 2) f[a].apply(f[a + 1] || this, h)
}
if (n) {
b = [b].concat(h);
a = 0;
for (c = n.length; a < c; a += 2) n[a].apply(n[a + 1] || this, b)
}
}
return this
}
};
g.bind = g.on;
g.unbind = g.off;
return g
});
DISQUS.define(function (e) {
function g() {
throw Error(Array.prototype.join.call(arguments, " "));
}
function d(a, c, b) {
if (a.addEventListener) a.addEventListener(c, b, !1);
else if (a.attachEvent) a.attachEvent("on" + c, b);
else throw Error("No event support.");
}
var b = e.document,
m = DISQUS.use("JSON"),
f = {}, a = {}, c = 0;
if (!(DISQUS.version && DISQUS.version() === "2")) {
d(e, "message", function (c) {
var b, d;
for (d in a) if (Object.prototype.hasOwnProperty.call(a, d) && c.origin == a[d].origin) {
b = !0;
break
}
if (b) switch (b = m.parse(c.data), (d = a[b.sender]) || g("Message from our server but with invalid sender UID:", b.sender), b.scope) {
case "host":
d.trigger(b.name, b.data);
break;
case "global":
DISQUS.trigger(b.name, b.data);
break;
default:
g("Message", b.scope, "not supported. Sender:", c.origin)
}
}, !1);
d(e, "hashchange", function () {
DISQUS.trigger("window.hashchange", {
hash: e.location.hash
})
}, !1);
d(e, "resize", function () {
DISQUS.trigger("window.resize")
}, !1);
var n = function () {
DISQUS.trigger("window.scroll")
};
(function (a, b, c, e) {
var h = (new Date).getTime();
d(a, b, function () {
var a = (new Date).getTime();
a - h >= e && (h = a, c())
})
})(e, "scroll", n, 250);
(function (a, b, c, e) {
var h;
d(a, b, function (a) {
h && clearTimeout(h);
h = setTimeout(function () {
c(a)
}, e)
})
})(e, "scroll", n, 300);
d(b, "click", function () {
DISQUS.trigger("window.click")
});
n = function () {
this.uid = c++;
f[this.uid] = this
};
DISQUS.extend(n.prototype, DISQUS.Events);
n.prototype.destroy = function () {
delete f[this.uid]
};
DISQUS.extend(n, {
listByKey: function () {
var a = {}, b;
for (b in f) Object.prototype.hasOwnProperty.call(f, b) && (a[b] = f[b]);
return a
},
list: function () {
var a = [],
b;
for (b in f) Object.prototype.hasOwnProperty.call(f, b) && a.push(f[b]);
return a
},
get: function (a) {
if (Object.prototype.hasOwnProperty.call(f, a)) return f[a];
return null
}
});
var h = function (a) {
a = a || {};
this.isReady = !1;
this.uid = a.uid || c++;
this.elem = null;
this.styles = {};
this.role = a.role || "application"
};
h.prototype.load = function () {
var a = this.elem = b.createElement("iframe");
a.setAttribute("id", "dsq" + this.uid);
a.setAttribute("data-disqus-uid", this.uid);
a.setAttribute("allowTransparency",
"true");
a.setAttribute("frameBorder", "0");
a.setAttribute("role", this.role);
for (var c in this.styles) this.styles.hasOwnProperty(c) && (a.style[c] = this.styles[c])
};
h.prototype.destroy = function () {
this.elem && this.elem.parentNode.removeChild(this.elem)
};
var p = function (b) {
var c = this;
h.call(c, b);
c.listeners = {};
c.origin = b.origin;
c.target = b.target;
c.container = b.container;
c.styles = DISQUS.extend({
width: "100%",
border: "none",
overflow: "hidden",
display: "none"
}, b.styles || {});
a[c.uid] = c;
c.on("ready", function () {
c.isReady = !0
})
};
DISQUS.extend(p.prototype, DISQUS.Events);
p.prototype.load = function (a) {
h.prototype.load.call(this);
var c = this.elem;
c.setAttribute("width", "100%");
c.setAttribute("src", this.target + "#" + this.uid);
d(c, "load", function () {
c.style.display = "";
a && a()
});
(b.getElementById(this.container) || b.body).appendChild(c);
this.elem = c
};
p.prototype.sendMessage = function (a, c) {
var b = function (a, c, b) {
return function () {
b.elem.contentWindow.postMessage(a, c)
}
}(m.stringify({
scope: "client",
data: {
eventName: a,
data: c
}
}), this.origin,
this);
if (this.isReady) b();
else this.on("ready", b)
};
p.prototype.getPosition = function () {
for (var a = this.elem, c = 0, b = 0; a;) c += a.offsetLeft, b += a.offsetTop, a = a.offsetParent;
return {
top: b,
left: c
}
};
p.prototype.inViewport = function (a) {
var a = a || this.getPosition(),
a = a.top,
c = a + this.elem.offsetHeight,
b = e.pageYOffset;
return !(a > b + e.innerHeight || c < b)
};
p.prototype.destroy = function () {
this.off();
h.prototype.destroy.call(this)
};
var k = function (a) {
h.call(this, a);
this.contents = a.contents;
this.container = a.container;
this.styles = {
width: "100%",
border: "none",
overflow: "hidden"
};
a.styles = a.styles || {};
for (var c in a.styles) a.styles.hasOwnProperty(c) && (this.styles[c] = a.styles[c])
};
k.prototype.load = function () {
h.prototype.load.call(this);
var a = this.elem;
a.setAttribute("scrolling", "no");
(b.getElementById(this.container) || b.body).appendChild(a);
this.element = a;
this.window = a.contentWindow;
try {
this.window.document.open()
} catch (c) {
a.src = "javascript:var d=document.open();d.domain='" + b.domain + "';void(0);"
}
this.document = this.window.document;
this.document.write(this.contents);
this.document.close();
if (a = this.document.body) {
var d = this.element.style;
d.height = d.minHeight = d.maxHeight = a.offsetHeight + "px"
}
};
k.prototype.exec = function (a) {
a.call(this, this.window, this.document)
};
k.prototype.hide = function () {
var a = this.element.style.display;
if (a !== "none") this._display = a;
this.element.style.display = "none"
};
k.prototype.show = function () {
this.element.style.display = this._display || "block"
};
k.prototype.click = function (a) {
d(this.document.body, "click", function (c) {
a(c)
})
};
k.prototype.destroy = h.prototype.destroy;
var i = DISQUS.extend({}, DISQUS.Events);
return {
IFRAME: "__widget_iframe__",
log: function (a) {
var c = b.getElementById("messages");
if (c) {
var d = b.createElement("p");
d.innerHTML = a;
c.appendChild(d)
}
},
version: function () {
return "2"
},
on: i.on,
off: i.off,
trigger: i.trigger,
Channel: p,
Sandbox: k,
App: n
}
}
});
DISQUS.define("next.publisher", function (e) {
function g(a, c, b) {
var d, b = b || c;
if (a === f) return "";
e.getComputedStyle ? d = f.defaultView.getComputedStyle(a, null).getPropertyValue(c) : a.currentStyle && (d = a.currentStyle[c] ? a.currentStyle[c] : a.currentStyle[b]);
return d == "transparent" || d === "" || d == "rgba(0, 0, 0, 0)" ? g(a.parentNode, c, b) : d || null
}
function d(a) {
function c(a) {
a = Number(a).toString(16);
return a.length == 1 ? "0" + a : a
}
if (a.substr(0, 1) === "#") return a;
var b = /.*?rgb\((\d+),\s*(\d+),\s*(\d+)\)/.exec(a);
if (!b || b.length !== 4) return "";
var a = c(b[1]),
d = c(b[2]),
b = c(b[3]);
return "#" + a + d + b
}
function b(a, b, d, e) {
DISQUS.isString(b) && (b = f.createElement(b));
var m = null;
b.style.visibility = "hidden";
a.appendChild(b);
m = g(b, d, e);
a.removeChild(b);
return m
}
function m(a) {
return a.toLowerCase().replace(/^\s+|\s+$/g, "").replace(/['"]/g, "")
}
var f = e.document;
return {
getContrastYIQ: function (a) {
a.match("^rgb") && (a = d(a).substr(1));
var b = parseInt(a.substr(0, 2), 16),
e = parseInt(a.substr(2, 2), 16),
a = parseInt(a.substr(4, 2), 16);
return (b * 299 + e * 587 + a * 114) / 1E3
},
colorToHex: d,
getElementStyle: b,
getAnchorColor: function (a) {
var c = f.createElement("a");
c.href = +new Date;
return b(a, c, "color")
},
normalizeFontValue: m,
isSerif: function (a) {
for (var a = b(a, "span", "font-family", "fontFamily").split(","), c = {
courier: 1,
times: 1,
"times new roman": 1,
georgia: 1,
palatino: 1,
serif: 1
}, d, e = 0; e < a.length; e++) if (d = m(a[e]), c.hasOwnProperty(d)) return !0;
return !1
}
}
});
DISQUS.define(function () {
function e(e) {
DISQUS.App.call(this);
this.switches = {};
var d = {
target: e.useSSL ? "https://securecdn.disqus.com/1356132141/build/next-switches/client_ssl.html" : "http://mediacdn.disqus.com/1356132141/build/next-switches/client.html",
container: e.container
};
d.origin = e.useSSL ? "https://securecdn.disqus.com" : "http://mediacdn.disqus.com";
this.frame = new DISQUS.Channel(d);
var b = this;
this.frame.load(function () {
b.frame.elem.style.display = "none"
})
}
e.prototype = DISQUS.extend({
fetch: function (e) {
var d = this,
e = e || {}, b = e.success;
delete e.success;
this.frame.on("switches.received", function (e) {
d.switches = e;
DISQUS.trigger("switches.changed", e);
b && b(e)
});
this.frame.sendMessage("fetch", e)
},
enabled: function (e) {
return this.switches[e] ? this.switches[e] : !1
}
}, DISQUS.App.prototype);
return {
Switches: function (g) {
return new e(g)
}
}
});
DISQUS.define(function () {
var e = function (e) {
DISQUS.App.call(this);
this.settings = e;
this.frame = null
};
DISQUS.extend(e.prototype, DISQUS.App.prototype);
e.prototype.init = function () {
var e = this.settings,
d = "http://disqus.com/embed/profile/",
b = "http://disqus.com";
e.useSSL && (d = "https://disqus.com/embed/profile/", b = "https://disqus.com");
var m = this.frame = new DISQUS.Channel({
origin: b,
target: DISQUS.serialize(d, {
f: e.forum
}),
container: e.container,
uid: this.uid,
styles: {
height: "100%",
position: "fixed",
top: 0,
left: 0
}
});
m.on("ready", function a() {
m.off("ready", a);
m.sendMessage("init");
this.trigger("loading.init")
}, this);
m.on("close", function () {
this.frame.elem.style.display = "none"
}, this);
m.load();
this.trigger("loading.start")
};
e.prototype.showProfile = function (e) {
var d = this.frame;
if (!d.isReady) return void d.on("ready", function m() {
d.off("ready", m);
this.showProfile(e)
}, this);
d.sendMessage("showProfile", e);
d.elem.style.display = "block"
};
e.prototype.destroy = function () {
DISQUS.App.prototype.destroy.call(this)
};
return {
Profile: function (g) {
return new e(g)
}
}
});
DISQUS.define("backplane", function () {
var e;
try {
localStorage.setItem("disqus.localStorageTest", "disqus"), localStorage.removeItem("disqus.localStorageTest"), e = !0
} catch (g) {
e = !1
}
var d = function (b) {
this.frame = b;
this.credentials = "unset";
var d = this;
typeof Backplane === "function" && typeof Backplane.version === "string" && typeof Backplane.subscribe === "function" && e && Backplane(function () {
d.initialize()
})
};
DISQUS.extend(d.prototype, {
frameEvents: {
invalidate: "clearCredentials"
},
initialize: function () {
var b = this;
DISQUS.each(this.frameEvents,
function (d, e) {
b.frame.on("backplane." + e, typeof d === "function" ? d : b[d], b)
});
this.credentialsFromLocalStorage() && this.frame.sendMessage("login", {
backplane: this.credentials
});
this.subscribe()
},
subscribe: function () {
var b = this;
Backplane.subscribe(function (d) {
var e = b.handlers[d.type];
e && e.call(b, d)
})
},
handlers: {
"identity/login": function (b) {
var d = b.messageURL,
b = b.channel;
this.credentials !== "unset" && this.credentials !== null && this.credentials.channel === b && this.credentials.messageUrl === d || (this.setCredentials(b,
d), this.frame.sendMessage("login", {
backplane: this.getCredentials()
}))
}
},
credentialsFromLocalStorage: function () {
var b = localStorage.getItem("disqus.backplane.channel"),
d = localStorage.getItem("disqus.backplane.messageUrl");
this.setCredentials(b, d, !0);
return this.credentials
},
setCredentials: function (b, d, e) {
if (!b || !d) return void this.clearCredentials();
e || (localStorage.setItem("disqus.backplane.channel", b), localStorage.setItem("disqus.backplane.messageUrl", d));
this.credentials = {
channel: b,
messageUrl: d
}
},
getCredentials: function () {
if (this.credentials !== "unset") return this.credentials;
return this.credentialsFromLocalStorage()
},
clearCredentials: function (b) {
b = b || {};
this.credentials = null;
localStorage.removeItem("disqus.backplane.channel");
localStorage.removeItem("disqus.backplane.messageUrl");
if (b.redirectUrl) window.location = b.redirectUrl
}
});
return {
BackplaneIntegration: d
}
});
DISQUS.define(function (e, g) {
function d(a, b, c, d, e, f) {
return '<img width="' + a + '" height="' + b + '" alt="' + d + '" src="data:image/' + c + ";base64," + e + '"' + (f ? 'style="' + f + '"' : "") + "/>"
}
function b(a) {
for (var b = DISQUS.App.list(), d = 0, e = b.length, b = b[d]; d < e; d++) b instanceof c && a(b)
}
var m = e.document,
f = ["iVBORw0KGgoAAAANSUhEUgAAAEcAAAARCAYAAAH4YIFjAAAAGXRFWHRTb2Z0d2FyZQBB", "ZG9iZSBJbWFnZVJlYWR5ccllPAAABwdJREFUeNpi/P//PwMhwAIiGBkZGeK6V8JVh9rq", "dfrc0ixnEDb+wPD2rAAjMSYBBBBRisDWwKxCthIE/q8Q+A8yhCiTAAIIrCi+ZxVMZSAQ", "r19UGs4IMxWd/X8Rw3/GOKDhW43fgzwF1hX7n5EJ2dSp2QFNUKcZwJ31/78CkvPBGkGG",
"MXidSUTWCxBAxAUAEQAcJzCvIXsDBPwsNBU2nbj+AMpdsFA8PAHsLZj3QC5D9hrIAEtN", "+RMwAzRkxcB0iK3eQ6iQIRAnoMTE//8CyHwmWHQdv/7QAiZ44/ErMP383acsqNB5iMnP", "lsFdsUZ6IU3CCCCA4AYBw8kBJgj06gGkmHJAFgPyQV4ExeQEoNgHJHUBQMoAWRzoerBe", "YHgeQOJ/APIvQPkNUP4EuIdADBAGBRMQOABxQcakdSipHZldNGvL2zWHL8kD1d0HieVN", "33QYqnc/EAfULNwJVw8KTniQwvjAdPz/SEwKmL1KfC5QjwEQr4e5AyVdA3P4ASCe8O3n", "b1whmtib6r3IXlfpATBEFbpWH9ygJSdmBtXrOHPbyZWPXn1AqOZRwDSBS+YHo82SOQwi", "ZnYMoS+EGC42nGdYzBiAnKpgGAbeA3ECkjwYQNnzH758///6o5cgofVIagy+/vgFF//y", "/ecHJLn1/18AA+/teZBcPZL4eSTxBJg7AAKIaomRmpkeV2IG5UcD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gnqhpHIeR", "vsDawqns0qeN5+y967tYLyicBYE7EYkYAgAh+QQJCwAAACwAAAAAEAALAAAFNiAgjoth",
"LOOIJAkiGgxjpGKiKMkbz7SN6zIawJcDwIK9W/HISxGBzdHTuBNOmcJVCyoUlk7CEAAh", "+QQJCwAAACwAAAAAEAALAAAFNSAgjqQIRRFUAo3jNGIkSdHqPI8Tz3V55zuaDacDyIQ+", "YrBH+hWPzJFzOQQaeavWi7oqnVIhACH5BAkLAAAALAAAAAAQAAsAAAUyICCOZGme1rJY", "5kRRk7hI0mJSVUXJtF3iOl7tltsBZsNfUegjAY3I5sgFY55KqdX1GgIAIfkECQsAAAAs", "AAAAABAACwAABTcgII5kaZ4kcV2EqLJipmnZhWGXaOOitm2aXQ4g7P2Ct2ER4AMul00k", "j5g0Al8tADY2y6C+4FIIACH5BAkLAAAALAAAAAAQAAsAAAUvICCOZGme5ERRk6iy7qpy", "HCVStA3gNa/7txxwlwv2isSacYUc+l4tADQGQ1mvpBAAIfkECQsAAAAsAAAAABAACwAA", "BS8gII5kaZ7kRFGTqLLuqnIcJVK0DeA1r/u3HHCXC/aKxJpxhRz6Xi0ANAZDWa+kEAA7",
"AAAAAAAAAAAA"],
c = function (a) {
DISQUS.App.call(this);
this.settings = a;
this.indicators = {
north: null,
south: null
};
this._boundGlobalEvents = [];
this.frame = null
};
DISQUS.extend(c.prototype, DISQUS.App.prototype);
c.prototype.init = function () {
function b(a, c, d) {
j.on("affiliateLink", function (b) {
var e = DISQUS.vglnk.$;
if (!e) return void j.sendMessage("affiliateLink");
e.request(a + "/click", {
format: "jsonp",
out: b.url,
key: c,
loc: j.target,
subId: d
}, {
fn: function (a) {
return function (b) {
var c = {
token: a
};
if (b) c.url = b;
j.sendMessage("affiliateLink",
c)
}
}(b.token),
timeout: DISQUS.vglnk.opt("click_timeout")
})
})
}
function c(a, b) {
k._boundGlobalEvents.push(a);
DISQUS.on(a, b, k)
}
var k = this,
i = k.settings,
l = "http://disqus.com/embed/comments/",
n = "http://disqus.com";
i.useSSL && (l = "https://disqus.com/embed/comments/", n = "https://disqus.com");
var q = {
f: i.forum,
t_i: i.identifier,
t_u: i.url || e.location.href,
t_s: i.slug,
t_t: i.title,
s_o: i.sortOrder,
c: i.useConman || g
};
if (i.notSupported) q.n_s = 1;
var r = DISQUS.isString(i.container) ? m.getElementById(i.container) : i.container,
j = k.frame = new DISQUS.Channel({
origin: n,
target: DISQUS.serialize(l, q),
container: i.container,
uid: this.uid
});
if (i.notSupported) j.styles.height = "500px";
var u = !1,
s, v;
if (!i.notSupported) s = m.createElement("div"), s.innerHTML = d(71, 17, "png", "DISQUS", f.join("")) + d(16, 11, "gif", "...", a.join(""), "margin:0 0 3px 5px"), r.appendChild(s);
l = function () {
var a = j.getPosition(),
b = e.pageYOffset,
c = e.innerHeight,
d = j.inViewport(a);
d ? (u = !0, j.sendMessage("window.scroll", {
frameOffset: a,
pageOffset: b,
height: c
}), j.sendMessage("window.inViewport")) : u && !d && (u = !1, j.sendMessage("window.scrollOffViewport"))
};
j.on("ready", function o(a) {
j.off("ready", o);
s && s.parentNode === r && r.removeChild(s);
e.clearTimeout(v);
var b = {
themeUrl: i.themeUrl,
permalink: i.permalink,
anchorColor: i.anchorColor,
referrer: e.location.href,
colorScheme: i.colorScheme,
language: i.language,
typeface: i.typeface,
remoteAuthS3: i.remoteAuthS3,
apiKey: i.apiKey,
sso: i.sso,
parentWindowHash: e.location.hash
};
if (e.navigator.userAgent.match(/(iPad|iPhone|iPod)/)) b.width = j.elem.offsetWidth;
j.inViewport() && j.sendMessage("window.inViewport");
k.clientData = a;
j.sendMessage("init", b);
k.trigger("loading.init")
});
j.on("resize", function (a) {
j.elem.style.height = a.height + "px"
});
j.on("reload", function () {
e.location.reload()
});
j.on("reset", function () {
DISQUS.reset({
reload: !0
})
});
j.on("posts.paginate", function () {
k.trigger("posts.paginate")
});
j.on("posts.create", function (a) {
k.trigger("posts.create", {
id: a.id,
text: a.raw_message
})
});
j.on("scrollTo", function (a) {
var b = j.getPosition(),
b = a.relative === "window" ? a.top : b.top + a.top;
(a.force || !(b > e.pageYOffset && b < e.pageYOffset + e.innerHeight)) && e.scrollTo(0, b)
});
j.on("fakeScroll", l);
j.on("realtime.init", function (a) {
for (var b = ["north", "south"], c, d, e = 0; e < b.length; e++) d = b[e], c = new DISQUS.Sandbox({
uid: "-indicator-" + d,
container: k.settings.container,
contents: a[d].contents,
styles: a[d].styles
}), c.load(), c.hide(),
function (a) {
c.click(function () {
j.sendMessage("realtime.click", a)
})
}(d), k.indicators[d] = c
});
j.on("realtime.showNorth", function (a) {
var b = k.indicators.north;
b.document.getElementById("message").innerHTML = a;
b.show()
});
j.on("realtime.hideNorth", function () {
k.indicators.north.hide()
});
j.on("realtime.showSouth", function (a) {
var b = k.indicators.south;
b.document.getElementById("message").innerHTML = a;
b.show()
});
j.on("realtime.hideSouth", function () {
k.indicators.south.hide()
});
j.on("mainViewRendered", function () {
DISQUS.trigger("lounge:mainViewRendered");
k.trigger("loading.done")
});
j.on("profile.show", function (a) {
if (!k.profile) k.profile = DISQUS.Profile({
container: i.container,
useSSL: i.useSSL,
forum: i.forum
}), k.profile.init();
k.profile.showProfile(a.username)
});
j.on("loadLinkAffiliator", function (a) {
j.off("loadLinkAffiliator");
if (!e.vglnk_self && !e.vglnk && ! function () {
for (var a in e) if (a.indexOf("skimlinks") === 0 || a.indexOf("skimwords") === 0) return !0;
return !1
}()) {
var c = a.apiUrl,
d = a.key,
f = String(a.id);
if (!(a.clientUrl == null || c == null || d == null || a.id == null)) DISQUS.define("vglnk", function () {
return {
api_url: c,
key: d,
sub_id: f
}
}), e.vglnk_self = "DISQUS.vglnk", DISQUS.require(a.clientUrl), DISQUS.defer(function () {
return DISQUS.vglnk.opt
},
function () {
j.sendMessage("affiliationOptions", {
timeout: DISQUS.vglnk.opt("click_timeout")
})
}), b(c, d, f)
}
});
j.on("loadBackplane", function () {
j.off("loadBackplane");
k.backplane = new DISQUS.backplane.BackplaneIntegration(j)
});
v = e.setTimeout(function () {
s.innerHTML += '<p>DISQUS seems to be taking longer than usual. <a href="#" onclick="DISQUS.reset({reload: true}); return false;">Reload</a>?</p>'
}, 1E4);
j.load(function () {
i.notSupported ? (j.elem.setAttribute("height", "500px"), j.elem.setAttribute("scrolling", "yes"),
j.elem.setAttribute("horizontalscrolling", "no"), j.elem.setAttribute("verticalscrolling", "yes")) : (j.elem.setAttribute("scrolling", "no"), j.elem.setAttribute("horizontalscrolling", "no"), j.elem.setAttribute("verticalscrolling", "no"))
});
c("window.hashchange", function (a) {
j.sendMessage("window.hashchange", a.hash)
});
c("window.resize", function () {
j.sendMessage("window.resize")
});
c("window.scroll", l);
c("window.click", function () {
j.sendMessage("window.click")
});
c("switches.changed", function (a) {
j.sendMessage("switches.changed",
a)
});
k.trigger("loading.start")
};
c.prototype.destroy = function () {
var a = this.indicators;
this.off();
if (this._boundGlobalEvents.length) DISQUS.off(this._boundGlobalEvents.join(" "), null, this), this._boundGlobalEvents = null;
this.frame && this.frame.destroy();
if (a.north) a.north.destroy(), a.north = null;
if (a.south) a.south.destroy(), a.south = null;
DISQUS.App.prototype.destroy.call(this)
};
var n = function (a) {
return new c(a)
};
DISQUS.extend(n, {
listByKey: function () {
var a = {};
b(function (b) {
a[b.uid] = b
});
return a
},
list: function () {
var a = [];
b(function (b) {
a.push(b)
});
return a
},
get: function (a) {
a = DISQUS.App.get(a);
return a instanceof c && a
}
});
return {
Lounge: n
}
});
(function (e, g, d) {
function b() {
function a(b) {
var b = b.getAttribute ? b.getAttribute("src") : b.src,
c = [/(https?:)\/\/(www\.)?disqus\.com\/forums\/([\w_\-]+)/i, /(https?:)\/\/(www\.)?([\w_\-]+)\.disqus\.com/i, /(https?:)\/\/(www\.)?dev\.disqus\.org\/forums\/([\w_\-]+)/i, /(https?:)\/\/(www\.)?([\w_\-]+)\.dev\.disqus\.org/i],
d = c.length;
if (!b || b.substring(b.length - 8) != "embed.js") return null;
for (var e = 0; e < d; e++) {
var f = b.match(c[e]);
if (f && f.length && f.length == 4) return p = f[1] || null, f[3]
}
return null
}
for (var b = g.getElementsByTagName("script"),
c = b.length - 1; c >= 0; c--) {
var d = a(b[c]);
if (d !== null) return d
}
return null
}
function m() {
if (e.location.protocol === "https:") return !0;
p === d && b();
return p === "https:"
}
function f() {
for (var a = g.getElementsByTagName("h1"), b = g.title, c = b.length, e = b, f = 0.6, h = 0; h < a.length; h++)(function (a) {
var a = a.textContent || a.innerText,
g;
if (!(a === null || a === d)) {
g = 0;
for (var h = Array(b.length), i = 0; i <= b.length; i++) {
h[i] = Array(a.length);
for (var j = 0; j <= a.length; j++) h[i][j] = 0
}
for (i = 0; i < b.length; i++) for (j = 0; j < a.length; j++) b[i] == a[j] && (h[i + 1][j + 1] = h[i][j] + 1, h[i + 1][j + 1] > g && (g = h[i + 1][j + 1]));
g /= c;
g > f && (f = g, e = a)
}
})(a[h]);
return e
}
function a() {
g.getElementById(n).innerHTML = "";
var a = i.page;
if (!e.postMessage || !e.JSON) r = !0;
if (e.navigator.appName === "Microsoft Internet Explorer" && (!g.documentMode || g.documentMode < 8)) r = !0;
a = {
container: n,
forum: l,
sortOrder: "popular",
permalink: k,
useSSL: m(),
language: i.language,
typeface: c.isSerif(h) ? "serif" : "sans-serif",
anchorColor: c.getAnchorColor(h),
colorScheme: 128 < c.getContrastYIQ(c.getElementStyle(h, "span", "color")) ? "dark" : "light",
url: a.url || e.location.href.replace(/#.*$/, ""),
title: a.title || f(),
slug: a.slug,
category: a.category_id,
identifier: a.identifier,
apiKey: a.api_key,
remoteAuthS3: a.remote_auth_s3,
sso: i.sso,
themeUrl: e.disqus_theme_root_url,
useConman: e.disqus_demo,
notSupported: r
};
q = DISQUS.Lounge(a);
var b = {
onReady: "loading.done",
onNewComment: "posts.create",
onPaginate: "posts.paginate"
};
DISQUS.each(i.callbacks, function (a, c) {
b[c] && DISQUS.each(a, function (a) {
q.on(b[c], a)
})
});
q.init()
}
var c = DISQUS.use("next.publisher"),
n = e.disqus_container_id || "disqus_thread",
h = g.getElementById(n),
p, k = function () {
var a = e.location.hash;
return (a = a && a.match(/comment\-([0-9]+)/)) && a[1]
}(),
i = {
page: {
url: d,
title: d,
slug: d,
category_id: d,
identifier: d,
language: d,
api_key: d,
remote_auth_s3: d,
author_s3: d,
developer: d
},
strings: d,
sso: {},
callbacks: {
preData: [],
preInit: [],
onInit: [],
afterRender: [],
onReady: [],
onNewComment: [],
preReset: [],
onPaginate: []
}
};
DISQUS.each(["developer", "shortname", "identifier", "url", "title", "category_id", "language", "slug"], function (a) {
var b = e["disqus_" + a];
typeof b !== "undefined" && (i.page[a] = b)
});
var l = e.disqus_shortname || b(),
l = l.toLowerCase();
if (typeof e.disqus_config === "function") try {
e.disqus_config.call(i)
} catch (t) {}
var q, r = !1;
a();
if (!r) {
var j = DISQUS.Switches({
container: n,
useSSL: m()
});
j.fetch({
data: {
forum: l
}
});
DISQUS.domready(function () {
if (g.getElementsByClassName) {
var a = g.getElementsByClassName("dsq-brlink");
a && a.length && a[0].parentNode.removeChild(a[0])
}
});
DISQUS.request = {
get: function (a, b, c) {
DISQUS.require(a, b, c)
}
};
DISQUS.reset = function (b) {
b = b || {};
if (typeof b.config === "function") try {
b.config.call(i)
} catch (c) {}
q && (q.destroy(), q = null);
b.reload && (a(), DISQUS.trigger("switches.changed", j.switches))
}
}
})(this, this.document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment