Skip to content

Instantly share code, notes, and snippets.

@rschrieken
Created August 28, 2014 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rschrieken/10522b425691b203f245 to your computer and use it in GitHub Desktop.
Save rschrieken/10522b425691b203f245 to your computer and use it in GitHub Desktop.
full SE js script
"use strict";
function moveScroller() {
var e = $("#scroller").width(),
t = function () {
var t = $(window).scrollTop(),
n = $("#scroller-anchor").offset().top,
i = $("#scroller");
t > n ? i.height() > $(window).height() ? i.css({
"position" : "fixed",
"top" : "",
"bottom" : "0px",
"width" : e
}) : i.css({
"position" : "fixed",
"top" : "0px",
"bottom" : "",
"width" : e
}) : n >= t && i.css({
"position" : "relative",
"top" : "",
"bottom" : ""
})
};
$(window).scroll(t).resize(t),
t()
}
function sanitizeAndSplitTags(e, t) {
e = $.trim(e).replace(/([A-Za-z0-9])\+(?=[A-Za-z0-9])/g, "$1 ");
for (var n = e.split(/[\s|,;]+/), i = [], o = 0; o < n.length; o++) {
var a = n[o].toLowerCase();
StackExchange.options.site.nonAsciiTags || (a = StackExchange.helpers.noDiacritics(a)),
a = a.replace(/_/g, "-");
var r = "[^a-z0-9.#+" + (t ? "*" : "") + (StackExchange.options.site.nonAsciiTags ? "0-9,A-Z,_,a-z,ª,µ,º,À-Ö,Ø-ö,ø-ˁ,ˆ-Ë‘,Ë -ˤ,ˬ,Ë®,Í°-Í´,Ͷ-Í·,ͺ-ͽ,Ά,Έ-Ί,ÎŒ,ÎŽ-Ρ,Σ-ϵ,Ï·-ҁ,ÒŠ-Ô£,Ô±-Õ–,Õ™,Õ¡-Ö‡,א-ת,×°-ײ,Ø¡-ÙŠ,Ù -Ù©,Ù®-Ù¯,Ù±-Û“,Û•,Û¥-Û¦,Û®-Û¼,Û¿,ܐ,Ü’-ܯ,ݍ-Þ¥,Þ±,߀-ߪ,ß´-ßµ,ߺ,ऄ-ह,ऽ,ॐ,क़-ॡ,०-९,ॱ-ॲ,ॻ-ॿ,অ-ঌ,এ-ঐ,ও-ন,প-র,ল,শ-হ,ঽ,ৎ,ড়-ঢ়,য়-ৡ,০-ৱ,ਅ-ਊ,ਏ-ਐ,ਓ-ਨ,ਪ-ਰ,ਲ-ਲ਼,ਵ-ਸ਼,ਸ-ਹ,à©™-à©œ,à©ž,੦-੯,ੲ-à©´,અ-ઍ,એ-ઑ,ઓ-ન,પ-ર,લ-ળ,વ-હ,ઽ,ૐ,à« -à«¡,૦-૯,ଅ-ଌ,ଏ-ଐ,ଓ-ନ,ପ-ର,ଲ-ଳ,ଵ-ହ,ଽ,à­œ-ଢ଼,à­Ÿ-à­¡,à­¦-à­¯,à­±,ஃ,à®…-ஊ,எ-ஐ,à®’-க,à®™-ச,ஜ,ஞ-ட,ண-த,ந-ப,à®®-ஹ,ௐ,௦-௯,à°…-à°Œ,à°Ž-ఐ,à°’-à°¨,à°ª-à°³,à°µ-à°¹,à°½,ౘ-à±™,à± -ౡ,౦-౯,ಅ-ಌ,ಎ-ಐ,ಒ-ನ,ಪ-ಳ,ವ-ಹ,ಽ,ೞ,à³ -ೡ,೦-೯,à´…-à´Œ,à´Ž-ഐ,à´’-à´¨,à´ª-à´¹,à´½,ൠ-ൡ,൦-൯,ൺ-ൿ,අ-ඖ,ක-න,ඳ-ර,ල,à·€-à·†,ก-ะ,า-ำ,เ-ๆ,๐-๙,ກ-ຂ,ຄ,ງ-ຈ,ຊ,ຍ,ດ-ທ,ນ-ຟ,ມ-ຣ,ລ,ວ,ສ-ຫ,ອ-ະ,າ-ຳ,ຽ,ເ-ໄ,ໆ,໐-à»™,ໜ-ໝ,ༀ,༠-༩,ཀ-ཇ,ཉ-ཬ,ྈ-ྋ,က-ဪ,ဿ-၉,ၐ-ၕ,ၚ-ၝ,ၡ,ၥ-ၦ,ၮ-ၰ,ၵ-ႁ,á‚Ž,႐-á‚™,á‚ -Ⴥ,ა-ჺ,ჼ,á„€-á…™,á…Ÿ-ᆢ,ᆨ-ᇹ,ሀ-ቈ,ቊ-ቍ,ቐ-ቖ,ቘ,ቚ-ቝ,በ-ኈ,ኊ-ኍ,ነ-ኰ,ኲ-ኵ,ኸ-ኾ,á‹€,á‹‚-á‹…,ወ-á‹–,ዘ-ጐ,ጒ-ጕ,ጘ-ፚ,ᎀ-ᎏ,Ꭰ-Ᏼ,ᐁ-ᙬ,ᙯ-ᙶ,ᚁ-ášš,áš -ᛪ,ᜀ-ᜌ,ᜎ-ᜑ,ᜠ-ᜱ,ᝀ-ᝑ,ᝠ-ᝬ,ᝮ-ᝰ,ក-áž³,ៗ,ៜ,០-៩,á -á ™,á -á¡·,ᢀ-ᢨ,ᢪ,ᤀ-ᤜ,᥆-ᥭ,ᥰ-ᥴ,ᦀ-ᦩ,ᧁ-ᧇ,᧐-᧙,ᨀ-ᨖ,ᬅ-ᬳ,á­…-á­‹,᭐-á­™,ᮃ-á® ,á®®-᮹,á°€-á°£,á±€-᱉,ᱍ-á±½,á´€-ᶿ,Ḁ-ἕ,Ἐ-Ἕ,á¼ -á½…,Ὀ-Ὅ,ὐ-á½—,á½™,á½›,Ὕ,Ὗ-á½½,á¾€-á¾´,ᾶ-á¾¼,á¾¾,á¿‚-á¿„,ῆ-á¿Œ,ῐ-á¿“,á¿–-á¿›,á¿ -Ῥ,ῲ-á¿´,ῶ-ῼ,‿-⁀,⁔,ⁱ,ⁿ,ₐ-â‚”,â„‚,ℇ,â„Š-â„“,â„•,â„™-ℝ,ℤ,Ω,ℨ,K-â„­,ℯ-ℹ,ℼ-â„¿,â……-â…‰,â…Ž,Ↄ-ↄ,â°€-â°®,â°°-ⱞ,â± -Ɐ,â±±-â±½,â²€-ⳤ,â´€-â´¥,â´°-âµ¥,ⵯ,ⶀ-ⶖ,ⶠ-ⶦ,ⶨ-ⶮ,ⶰ-ⶶ,ⶸ-ⶾ,â·€-â·†,â·ˆ-â·Ž,ⷐ-â·–,â·˜-â·ž,ⸯ,々-〆,〱-〵,〻-〼,ぁ-ã‚–,ゝ-ã‚Ÿ,ã‚¡-ヺ,ー-ヿ,ã„…-ã„­,ㄱ-ㆎ,ㆠ-ㆷ,ㇰ-ㇿ,㐀-䶵,一-鿃,ꀀ-ê’Œ,ꔀ-ꘌ,ꘐ-ꘫ,Ꙁ-ꙟ,Ꙣ-ê™®,ꙿ-êš—,ꜗ-ꜟ,Ꜣ-ꞈ,êž‹-ꞌ,ꟻ-ê ,ê ƒ-ê …,ê ‡-ê Š,ê Œ-ê ¢,ê¡€-ꡳ,ꢂ-ꢳ,꣐-꣙,꤀-ꤥ,ꤰ-ꥆ,ꨀ-ꨨ,ê©€-ê©‚,ê©„-ê©‹,꩐-ê©™,ê°€-힣,豈-鶴,侮-頻,ï©°-ï«™,ff-st,ﬓ-ﬗ,יִ,ײַ-ﬨ,שׁ-זּ,טּ-לּ,מּ,ï­€-סּ,ï­ƒ-ï­„,ï­†-ï®±,ﯓ-ï´½,ﵐ-ﶏ,ﶒ-ï·‡,ï·°-ï·»,︳-︴,﹍-﹏,ï¹°-ï¹´,ﹶ-ﻼ,0-ï¼™,A-Z,_,a-z,ヲ-ï¾¾,ï¿‚-ᅦ,ï¿Š-ᅬ,ï¿’-ï¿—,ï¿š-ï¿œ" : "") + "-]";
a = a.replace(new RegExp(r, "g"), ""),
a = a.replace(/^[#+-]+/, ""),
a = a.replace(/[.-]+$/, ""),
a.length > 0 && -1 == $.inArray(a, i) && "or" != a && "and" != a && i.push(a)
}
return i
}
function initTagRenderer(e, t) {
window.tagRenderer || (window.tagRendererRaw = function (n, i, o) {
i = i || "",
o = o || "a";
var a = "";
i || (e && $.inArray(n, e) > -1 ? a = "required-tag" : t && $.inArray(n, t) > -1 && (a = "moderator-tag"));
var r = $("<" + o + ">").addClass("post-tag").addClass(a).text(n);
return "a" === o.toLowerCase() && r.attr({
"rel" : "tag",
"href" : i + "/questions/tagged/" + encodeURIComponent(n),
"title" : function (e) {
return "show questions tagged '" + e.tag + "'"
}
({
"tag" : n
})
}),
r.outerHTML()
}, window.tagRenderer = function (e, t, n) {
return $(tagRendererRaw(e, t, n))
})
}
function showFadingHelpText(e) {
e.wrap('<div class="dno" />').show().parent().fadeIn("slow", function () {
$(this).children().unwrap()
})
}
function initFadingHelpText() {
var e = {
"wmd-input" : "#how-to-format",
"tagnames" : "#how-to-tag",
"tag-editor" : "#how-to-tag",
"title" : "#how-to-title",
"wmd-input-42" : "#how-to-format"
},
t = $("#wmd-input, #tagnames, #title, .tag-editor input, #wmd-input-42"),
n = function (t) {
var n = $(t);
return n.parent().hasClass("tag-editor") ? e["tag-editor"] : e[$(t).attr("id")]
};
t.focus(function () {
var e = n(this);
t.each(function () {
var t = n(this);
t != e && $(t).hide()
});
var i = $(e);
i.is(":visible") || showFadingHelpText(i)
})
}
function initSnippetRenderer() {
if (!window.snippetRenderer || !window.SnippetRedraw) {
var e = {},
t = function () {
function e() {
return Math.floor(65536 * (1 + Math.random())).toString(16).substring(1)
}
return function () {
return e() + e() + "-" + e() + "-" + e() + "-" + e() + "-" + e() + e() + e()
}
}
();
$("body").on("showSnippets", function () {
$(".wmd-preview").find("pre").each(function () {
var t = $(this);
if (e[t.text()]) {
var n = e[t.text()];
t.replaceWith(n)
}
})
}),
window.snippetRedraw = function () {
$("div.snippet").each(function () {
var e = $(this),
t = e.children("pre.snippet-code-js").text(),
n = e.children("pre.snippet-code-css").text(),
i = e.children("pre.snippet-code-html").text(),
o = {
"js" : t,
"css" : n,
"html" : i
};
e.snippet({
"state" : o
})
})
},
window.snippetRenderer = function (n) {
var i = /<!-- language: lang-js -->([\s\S]*?)(?:<!-- language:|$)/gi,
o = /<!-- language: lang-css -->([\s\S]*?)(?:<!-- language:|$)/gi,
a = /<!-- language: lang-html -->([\s\S]*?)(?:<!-- language:|$)/gi;
try {
var r = i.exec(n),
s = o.exec(n),
c = a.exec(n),
l = "",
u = "",
d = "";
if (null != r && (l = r[1].trim().replace(/^ /gm, "")), null != s && (u = s[1].trim().replace(/^ /gm, "")), null != c && (d = c[1].trim().replace(/^ /gm, "")), "" == l && "" == u && "" == d)
return n;
var h = $('<div class=""snippet"" data-lang=""js""></div>');
"" != l && h.append($('<pre class="snippet-code-js lang-js prettyprint-override">').append($("<code>").text(l))),
"" != u && h.append($('<pre class="snippet-code-css lang-css prettyprint-override">').append($("<code>").text(u))),
"" != d && h.append($('<pre class="snippet-code-html lang-html prettyprint-override">').append($("<code>").text(d)));
var p = {
"js" : l,
"css" : u,
"html" : d
},
f = t();
h.snippet({
"state" : p
}),
e[f] = h
} catch (g) {
return n
}
return "<pre>" + f + "</pre>"
},
window.snippetRedraw()
}
}
!function (e) {
function t() {}
function n(e, t) {
if (a)
return t.indexOf(e);
for (var n = t.length; n--; )
if (t[n] === e)
return n;
return -1
}
var i = t.prototype,
o = [],
a = o.indexOf ? !0 : !1;
i.getListeners = function (e) {
var t = this._events || (this._events = {});
return t[e] || (t[e] = [])
},
i.addListener = function (e, t) {
var i = this.getListeners(e);
return -1 === n(t, i) && i.push(t),
this
},
i.removeListener = function (e, t) {
var i = this.getListeners(e),
o = n(t, i);
return -1 !== o && (i.splice(o, 1), 0 === i.length && (this._events[e] = null)),
this
},
i.addListeners = function (e, t) {
return this.manipulateListeners(!1, e, t)
},
i.removeListeners = function (e, t) {
return this.manipulateListeners(!0, e, t)
},
i.manipulateListeners = function (e, t, n) {
var i,
o,
a = e ? this.removeListener : this.addListener,
r = e ? this.removeListeners : this.addListeners;
if ("object" == typeof t)
for (i in t)
t.hasOwnProperty(i) && (o = t[i]) && ("function" == typeof o ? a.call(this, i, o) : r.call(this, i, o));
else
for (i = n.length; i--; )
a.call(this, t, n[i]);
return this
},
i.removeEvent = function (e) {
return e ? this._events[e] = null : this._events = null,
this
},
i.emitEvent = function (e, t) {
for (var n = this.getListeners(e), i = n.length; i--; )
n[i].apply(null, t || o) === !0 && this.removeListener(e, n[i]);
return this
},
"function" == typeof define && define.amd ? define(function () {
return t
}) : e.EventEmitter = t
}
(this), StackExchange.realtime = function () {
function e(e) {
var o = e.split(","),
a = o.length,
r = L % a,
s = o[r];
if (null != s && 0 != s.indexOf("ws://") && 0 != s.indexOf("wss://") && (s = ("https:" === document.location.protocol ? "wss://" : "ws://") + s), "WebSocket" in window || "MozWebSocket" in window) {
if (q)
try {
n("closing WebSocket"),
q.close()
} catch (c) {}
if (!q) {
try {
q = "WebSocket" in window ? new WebSocket(s) : new MozWebSocket(s)
} catch (c) {
return n("Sockets disabled - " + c.message),
void 0
}
q.onopen = function () {
B || (B = !0),
L = 0,
n("WebSocket opened"),
t(),
i(),
setInterval(P, 6e4)
},
q.onmessage = function (e) {
var t = $.parseJSON(e.data);
U.emitEvent(t.action, [t.data])
},
q.onclose = function () {
q = null,
n("WebSocket closed"),
5 > L && D > 0 && (L++, D--, n("reconnect attempt:" + L + " max retries:" + D), setTimeout(function () {
StackExchange.realtime.init(e)
}, (new Date).getTime() % 50 / 20 * 1e3))
},
q.onerror = function () {
n("WebSocket failed"),
q = null
}
}
}
}
function t() {
if (null != q && 1 == q.readyState)
for (var e = 0, t = R.length; t > e; e++)
n("sending " + R[e]), q.send(R[e])
}
function n(e) {
StackExchange.options.enableLogging && console.log("realtime: " + e)
}
function i() {
U.addListener("hb", function (e) {
q.send(e)
})
}
function o(e) {
R.push(e),
t()
}
function a(e) {
n("unsubscribing " + e);
var t = $.inArray(e, R);
-1 != t && (R.splice(t, 1), null != q && 1 == q.readyState && q.send("-" + e))
}
function r(e, t) {
var n = e + "-question-" + t;
a(n)
}
function s(e, t) {
var n = e + "-question-" + t;
o(n),
U.addListener(n, function (e) {
var t = $.parseJSON(e);
if (t.acctid != StackExchange.options.user.accountId)
switch (t.a) {
case "score":
m(t);
break;
case "comment-add":
l(t);
break;
case "answer-add":
y(t);
break;
case "accept":
c(t);
break;
case "unaccept":
c(t, !0);
break;
case "post-edit":
S(t)
}
})
}
function c(e, t) {
1 != $("#vote-accepted-" + e.answerid).length && ($(".vote-accepted-on").remove(), t || $('.vote input[value="' + e.answerid + '"]').parent().append($("<span>", {
"class" : "vote-accepted-on",
"title" : "The question owner accepted this as the best answer",
"text" : "accepted"
})))
}
function l(e) {
0 == $("#comment-" + e.commentid).length && StackExchange.comments.realtimeMessage(e.id)
}
function u(e, t, n, i, a, r, s) {
var c = e + "-" + t;
_ = n,
N = r,
o(c),
U.addListener(c, function (e) {
var n = $.parseJSON(e);
if (null != a)
for (var o = 0; o < a.length; o++)
if (-1 == $.inArray(a[o], n.tags))
return;
E(n, i, t),
null != s && s(n)
})
}
function d(e) {
var t = e + "-review-dashboard-update";
o(t),
U.addListener(t, function (e) {
var t = $.parseJSON(e),
n = $('.dashboard-activity[data-review-task="' + t.i + '"]');
0 == n.find('.dashboard-user[data-user="' + t.u + '"]').length && (n.find(".dashboard-user:nth-child(6)").remove(), n.css("overflow", "hidden"), n.children().css({
"left" : "-44px"
}), n.prepend(t.html).children().animate({
"left" : 0
}, function () {
n.css("overflow", "visible")
}))
})
}
function h() {
if (null != StackExchange.options.user.accountId) {
var e = StackExchange.options.user.accountId + "-topbar";
o(e),
U.addListener(e, function (e) {
StackExchange.topbar.handleRealtimeMessage(e)
})
}
}
function p() {
if (null != StackExchange.options.user.accountId) {
var e = StackExchange.options.user.accountId + "-inbox";
o(e),
U.addListener(e, function (e) {
x(e)
})
}
}
function f(e) {
if (null != StackExchange.options.user.accountId) {
var t = e + "-" + StackExchange.options.user.userId + "-reputation";
o(t),
U.addListener(t, function (e) {
v(e)
})
}
}
function g(e) {
var t = e + "-suggested-edits-count-update";
o(t),
U.addListener(t, function () {
b()
})
}
function m(e) {
var t = $('.vote input[value="' + e.id + '"]').siblings(".vote-count-post");
t.text() != e.score && (t.text(e.score), 0 == $(":animated").length && t.fadeTo("fast", .7).fadeTo("fast", 1), StackExchange.question.canViewVoteCounts() && StackExchange.vote.bindFetchVoteCounts())
}
function v(e) {
var t = $("#hlinks .reputation-score, .links-container .reputation");
t.text() != e.score && (0 == $(":animated").length && t.fadeTo("fast", .8).fadeTo("fast", 1), t.text(e).attr("title", function (e) {
return "your reputation: " + e.reputation
}
({
"reputation" : e
})), t.trigger("reputationchange"))
}
function b() {
$.ajax({
"type" : "POST",
"url" : "/review/suggested-edit-count",
"data" : {
"fkey" : StackExchange.options.user.fkey
},
"dataType" : "json",
"success" : function (e) {
e && e.count && w(e.count)
}
})
}
function w(e) {
var t = $(".suggested-edits-count");
t.text() != e && (0 == $(":animated").length && t.fadeTo("fast", .5).fadeTo("fast", 1), t.text(e))
}
function x(e) {
$(".unreadCount").remove();
var t = $("<a>", {
"class" : "unreadCount",
"title" : "unread messages in your inbox",
"text" : e
}).insertAfter(".genu");
$("#portalLink .unreadCount").css({
"marginTop" : t.css("margin-top"),
"opacity" : 1
}, 2e3),
genuwine.setUnreadCount(e)
}
function y(e) {
if (0 == $("#answer-" + e.answerid).length && (j.push(e.answerid), StackExchange.cardiologist)) {
if (StackExchange.cardiologist.isHeartBeating()) {
var t = StackExchange.helpers.DelayedReaction(k, 5e3);
t.trigger()
} else
k();
StackExchange.cardiologist.notifiedOfNewAnswer()
}
}
function k() {
$("#new-answer-activity").remove(),
$("#answers-header").prepend(V)
}
function S(e) {
var t = $(".question[data-questionid=" + e.id + "], .answer[data-answerid=" + e.id + "]"),
n = $('<div class="new-post-activity" data-postid="' + e.id + '">an edit has been made to this post; click to load</div>');
t.find(".new-post-activity[data-postid=" + e.id + "]").length > 0 || t.prepend(n.click(function () {
$(".new-post-activity[data-postid=" + e.id + "]").remove(),
0 == $("#review-content").length && $.get("/posts/ajax-load-realtime/{postIdsSemiColonDelimited}?title=true".formatUnicorn({
"postIdsSemiColonDelimited" : e.id
}), F(t.find(".postcell, .answercell"), e)),
$(document).trigger("refreshEdit", e.id)
}))
}
function C() {
$("#tabs").show(),
$("#new-answer-activity").remove();
var e = $("#answers #answers-header"),
t = e.find(".answers-subheader h2"),
n = parseInt(t.text()) + j.length;
isNaN(n) && (n = j.length),
t.text(function (e) {
return 1 == e.answerCount ? e.answerCount + " Answer" : e.answerCount + " Answers"
}
({
"answerCount" : n
})),
$.ajax({
"url" : "/posts/ajax-load-realtime/{postIdsSemiColonDelimited}".formatUnicorn({
"postIdsSemiColonDelimited" : j.join(";")
})
}).done(function (t) {
var n = $('<div class="dno" />').append(t);
n.insertAfter(e).fadeIn(400, function () {
n.removeClass("dno"),
styleCode(),
StackExchange.vote.init($(".question").data("questionid")),
n.find(".answer").each(function () {
StackExchange.comments.init({
"post" : $(this)
})
})
})
}),
StackExchange.question.bindSuggestedEditPopupLinks(),
P(),
j = []
}
function E(e, t, n) {
null != StackExchange.options.user.accountId && StackExchange.tagPreferences.isIgnored(e.body) || (e.fetch && $.ajax({
"url" : "/posts/" + e.id + "/" + n
}).done(function (t) {
e.body = t,
O[e.id] = {
"id" : e.id,
"body" : e.body,
"index" : (new Date).getTime(),
"siteid" : e.siteid
}
}), O[e.id] = {
"id" : e.id,
"body" : e.body,
"index" : (new Date).getTime(),
"siteid" : e.siteid
}, $(".new-post-activity").remove(), $("#question-mini-list, #questions").prepend(H), $(".tag-sponsorship").length > 0 && $("#question-mini-list, #questions").css("margin-top", "0px"), t && I())
}
function T(e, t) {
return e.index < t.index ? -1 : e.index > t.index ? 1 : 0
}
function I() {
var e = [];
for (var t in O)
O.hasOwnProperty(t) && e.push(O[t]);
for (var n = e.sort(T), i = 0; i < n.length; i++) {
var o = n[i];
$("#question-summary-" + o.id).remove(),
$(o.body).prependTo("#question-mini-list, #questions").hide().fadeIn()
}
M(0),
null != StackExchange.options.user.accountId && StackExchange.tagPreferences.applyPrefs(!0, _),
styleCode(),
P(),
$(".new-post-activity").remove(),
O = {}
}
function M(e) {
var t = document.title.replace(/^\(\d*\*?\) /, "");
e > 0 && (t = "(" + e + ") " + t),
window.setTimeout(function () {
$(document).attr("title", t)
}, 200)
}
function P() {
for (var e = $("span.relativetime, span.relativetime-clean"), t = 0; t < e.length; t++)
if (e[t].title) {
var n = A(e[t].title);
n && (e[t].innerHTML = n)
}
}
function A(e) {
if (null != e && 20 == e.length) {
e = e.substr(0, 10) + "T" + e.substr(11, 10);
var t = new Date(e),
n = ((new Date).getTime() - t.getTime()) / 1e3 + StackExchange.options.serverTimeOffsetSec,
i = Math.floor(n / 86400);
if (!(isNaN(i) || 0 > i || i >= 31))
return 0 == i && (2 > n && "just now" || 60 > n && (N ? function (e) {
return e.seconds + "s ago"
}
({
"seconds" : Math.floor(n)
}) : function (e) {
return e.seconds + " secs ago"
}
({
"seconds" : Math.floor(n)
})) || 120 > n && (N ? "1m ago" : "1 min ago") || 3600 > n && (N ? function (e) {
return e.minutes + "m ago"
}
({
"minutes" : Math.floor(n / 60)
}) : function (e) {
return e.minutes + " mins ago"
}
({
"minutes" : Math.floor(n / 60)
})) || 7200 > n && (N ? "1h ago" : "1 hour ago") || 86400 > n && (N ? function (e) {
return 1 == e.hours,
e.hours + "h ago"
}
({
"hours" : Math.floor(n / 3600)
}) : function (e) {
return 1 == e.hours ? e.hours + " hour ago" : e.hours + " hours ago"
}
({
"hours" : Math.floor(n / 3600)
})))
}
}
var q,
_,
O = {},
j = [],
L = 0,
R = [],
D = 10,
B = !1,
N = !1,
U = new EventEmitter,
V = function () {
var e = Object.keys(j).length;
return 0 == e && $("#new-answer-activity").remove(),
$('<div id="new-answer-activity">' + function (e) {
return 1 == e.count ? e.count + " new answer to this question" : e.count + " new answers to this question"
}
({
"count" : e
}) + "</div>").click(function () {
StackExchange.realtime.expandAnswers()
})
},
F = function (e, t) {
return function (n) {
var i = $(n).filter(".question, .answer"),
o = i.find(".postcell, .answercell"),
a = e.closest(".question"),
r = a.length > 0,
s = $("h1 a.question-hyperlink"),
c = i.data("title"),
l = r && $.trim(s.text()) != c,
u = $(".question-status"),
d = 150,
h = function (e, t) {
return function () {
return $.Deferred(function (n) {
null == t || t() ? e.animate({
"opacity" : 0
}, d).promise().done(function () {
n.resolve()
}) : n.resolve()
})
}
},
p = h(s, function () {
return l
}),
f = h(e),
g = h(u);
$.when(p(), f(), g()).done(function () {
l && s.text(c).animate({
"opacity" : 1
}, d);
var t = function (e, t) {
return new $.Deferred(function (n) {
t.css({
"opacity" : 0
}),
e.replaceWith(t),
t.animate({
"opacity" : 1
}, d, function () {
n.resolve()
})
})
};
t(e, o).done(function () {
styleCode(),
StackExchange.question.bindSuggestedEditPopupLinks(),
r && StackExchange.inlineTagEditing && StackExchange.inlineTagEditing.init()
});
var i = $(n).find(".question-status:last");
i.length ? (u.length || (u = $("<div>").addClass("question-status").insertAfter(a)), t(u, i)) : u.remove()
}),
window.history.pushState(t, "new post", "#" + t.id)
}
},
H = function () {
var e = Object.keys(O).length;
return M(e),
$('<div class="new-post-activity">' + function (e) {
return 1 == e.count ? e.count + " question with new activity" : e.count + " questions with new activity"
}
({
"count" : e
}) + "</div>").click(function () {
StackExchange.realtime.expandActiveQuestions()
})
};
return {
"init" : e,
"expandActiveQuestions" : I,
"expandAnswers" : C,
"subscribeToActiveQuestions" : u,
"subscribeToInboxNotifications" : p,
"subscribeToQuestion" : s,
"unsubscribeToQuestion" : r,
"subscribeToReputationNotifications" : f,
"subscribeToSuggestedEdits" : g,
"updateRelativeDates" : P,
"subscribeToReviewDashboard" : d,
"subscribeToTopBarNotifications" : h
}
}
(), StackExchange.anonymous = {};
var gauth = function () {
return {
"informStackAuth" : function (e) {
if (gauth.enabled()) {
var t = document.domain;
"meta." == t.substr(0, 5) && (t = t.substr(4, t.length - 4));
var n = $.cookie("gauth");
if (null == n)
return $.cookie("gauth", null, {
"path" : "/",
"domain" : t
}), $.cookie("gauth", null, {
"path" : "/",
"domain" : document.domain
}), void 0;
"." != t.charAt(0) && (t = "." + t),
$.cookie("gauth", null, {
"path" : "/",
"domain" : t
}),
$.cookie("gauth", null, {
"path" : "/",
"domain" : document.domain
});
var i = n.indexOf(":"),
o = n.substr(0, i),
a = n.substr(i + 1),
r = e + "/auth/global/write?authToken=" + encodeURIComponent(o) + "&nonce=" + encodeURIComponent(a);
$(document).ready(function () {
$("#footer").append("<iframe style='display:none' src='" + r + "'></iframe>")
})
}
},
"checkStackAuth" : function (e) {
if (gauth.enabled()) {
var t = $.cookie("gauthed");
if (null == t) {
$.cookie("gauthed", "1", {
"path" : "/"
});
var n = function (t) {
var n = t.origin;
if (n == e) {
if ("No Local Storage" == t.data)
return gauth.noGAuthStorage(), void 0;
if ("No Session" == t.data)
return gauth.noGAuthSession(), void 0;
var i = t.data.substr(0, t.data.indexOf(",")),
o = t.data.substr(t.data.indexOf(",") + 1);
$.post("/users/login/global", {
"authToken" : i,
"nonce" : o
}, function (e) {
gauth.globallyAuthed(e)
}, "json")
}
};
window.attachEvent ? window.attachEvent("onmessage", n) : window.addEventListener("message", n, !1),
$.post("/users/login/global/request", "", function (t) {
var n = e + "/auth/global/read?request=" + encodeURIComponent(t.token) + "&nonce=" + encodeURIComponent(t.nonce);
$(document).ready(function () {
$("#footer").append("<iframe id='global-auth-frame' style='display:none' src='" + n + "'></iframe>")
})
}, "json")
}
}
},
"enabled" : function () {
return $.cookie("enabledCheck", "1"),
null == $.cookie("enabledCheck") ? !1 : ($.cookie("enabledCheck", null), "undefined" == typeof localStorage ? !1 : !0)
},
"noGAuthStorage" : function () {},
"noGAuthSession" : function () {},
"globallyAuthed" : function (e) {
if (e && e.Message) {
var t = e.Message;
e.MessageType && "WelcomeBack" === e.MessageType && (t = function (e) {
return "Welcome back " + e.userLink + ", you've been logged in."
}
({
"userLink" : e.UserLink
}));
var n,
i = t + " ",
o = !1,
a = "" + window.location,
r = a.indexOf("returnurl=");
if (-1 != r) {
var s = a.indexOf("&", r);
-1 == s && (s = a.length),
n = decodeURIComponent(a.substring(r + "returnurl=".length, s)),
n = /^(?:http:\/\/|\/)/.test(n) ? n.replace(/[^-a-z0-9+&@#\/%?=~_|!:,.;()]/g, "") : null
}
-1 != a.indexOf("/users/login") && (o = !0, n = n || "/"),
i += o ? "<br>You are being redirected..." : n ? function (e) {
return '<a href="' + e.url + '">Click here</a> to return to your last location.'
}
({
"url" : "javascript:window.location='" + n + "'"
}) : function (e) {
return '<a href="' + e.url + '">Click here</a> to refresh the page.'
}
({
"url" : "javascript:location.reload(true)"
}),
StackExchange.helpers.showFancyOverlay({
"message" : i,
"showClose" : !o,
"complete" : function () {
o && (window.location = n)
}
})
}
}
}
}
(), genuwine = function () {
var e,
t,
n,
i = "",
o = [],
a = function () {
return $(".genu").hasClass("genu-on")
},
r = function () {
var e = $(".genu"),
i = $("#seWrapper");
if (0 == i.length || t > 0 || n) {
c(),
i = $("#seWrapper");
var a;
t > 0 ? (a = $("#seTabInbox"), w(a)) : n ? (a = $("#seTabNotices"), u(a)) : (a = $("#seTabHot"), f(a)),
a.addClass("seCurrent")
}
var l = e.hasClass("genu-on");
if (l) {
$(".unreadCountTab").remove(),
$("#portalLink .itemBoxNew").removeClass("itemBoxNew"),
i.fadeOut("fast");
for (var d = 0; d < o.length; d++)
o[d]();
o = [],
n > 0 && $("#portalLink .unreadCount").text("" + n).addClass("newNotices").show().click(r)
} else
i.fadeIn("fast"), $("#portalLink .unreadCount").hide();
e.toggleClass("genu-on", !l),
-1 == t && $(e).ready(function () {
$("#seTabInbox").hide()
}),
s($("#seTabInbox"), $("#seTabNotices"))
},
s = function (e, i) {
StackExchange.options.site.isNoticesTabEnabled && n && 0 == i.find(".unreadCountTab").length && i.prepend('<span class="unreadCountTab newNotices">' + n + "</span>"),
t > 0 && 0 == e.find(".unreadCountTab").length && e.prepend('<span class="unreadCountTab">' + t + "</span>")
},
c = function () {
$("#seWrapper").remove();
var e = '<div id="seWrapper" class="seWrapper" style="position:absolute; display:none;"><div class="seIntro"><a href="' + i + '">Stack Exchange</a> is a network of free, community-driven Q&A sites.</div><div class="seNav"><ul class="seNavLinks"><li><a id="seTabHot">Hot Questions</a></li><li><a id="seTabSites">All Sites</a></li>' + (StackExchange.options.user.isAnonymous ? "" : '<li><a id="seTabInbox">Inbox</a></li>') + (!StackExchange.options.user.isAnonymous && StackExchange.options.site.isNoticesTabEnabled ? '<li><a id="seTabNotices">Notifications</a></li>' : "") + '</ul></div><div class="seContainer"></div><div class="seFooter"><a id="seClose">close</a></div></div>',
t = $("#hlinks"),
n = t.height() + t.offset().top + 5;
$(e).appendTo("#portalLink").css({
"top" : n
}).find("ul.seNavLinks a").click(function () {
l($(this))
}),
$("#seClose").click(function () {
r()
})
},
l = function (e) {
switch ($(".seNavLinks a").removeClass("seCurrent"), e.addClass("seCurrent"), e.attr("id")) {
case "seTabHot":
f(e),
$("#seContainerSites, #seContainerInbox, #seContainerEmail, #seContainerNotices").hide(),
$("#seContainerHot").fadeIn("fast");
break;
case "seTabSites":
v(e),
$("#seContainerHot, #seContainerInbox, #seContainerEmail, #seContainerNotices").hide(),
$("#seContainerSites").fadeIn("fast");
break;
case "seTabInbox":
w(e),
$("#seContainerHot, #seContainerSites, #seContainerEmail, #seContainerNotices").hide(),
$("#seContainerInbox").fadeIn("fast");
break;
case "seTabNotices":
u(e),
$("#seContainerHot, #seContainerSites, #seContainerInbox, #seContainerEmail").hide(),
$("#seContainerNotices").fadeIn("fast")
}
},
u = function (e) {
0 == $("#seContainerNotices").length && d(e)
},
d = function (e) {
S(e, "/notices/genuwine", "json", h, !0)
},
h = function (e, t) {
for (var i = '<div id="seContainerNotices" style="display:none">', a = 0; a < t.length; a++) {
var r = t[a],
c = r.text,
l = r.is_unread,
u = (r.created, r.site_url),
d = r.icon,
h = r.hasOwnProperty("type") ? ' data-type="' + r.type.toString() + '"' : "";
null != r.switch_type && (h = h + ' data-sw-type="' + r.switch_type.toString() + '" data-sw-site="' + r.site_id.toString() + '"'),
i += '<div class="noticeBox' + (l ? " itemBoxNew" : "") + '"' + h + '><a href="' + u + '" class="siteLinkFavicon"><img src="' + d + '"></a><div class="siteInfo"><p>' + c + "</p></div></div>"
}
i += "</div>",
C(e, i, "notifications_popup.click"),
o.push(function () {
n = 0,
s($("#seTabInbox"), $("#seTabNotices"))
}),
n = 0
},
p = function (t) {
var n = document.location.host;
S(t, i + "/genuwine/sites?callback=?&host=" + n + (e ? "&accountId=" + e : ""), "jsonp", b)
},
f = function (e) {
0 == $("#seContainerHot").length && g(e)
},
g = function (e) {
S(e, i + "/genuwine?callback=?", "jsonp", m)
},
m = function (e, t) {
for (var n = $("<div/>"), i = '<div id="seContainerHot" style="display:none">', o = 0; o < t.length; o++) {
var a = t[o],
r = a.SiteId,
s = 'href="http://' + r + "/q/" + a.Id + '?hq=1"',
c = parseInt(a.DisplayScore, 10);
i += '<div class="itemBox" data-sw-type="2" data-sw-name="' + r + '"><a ' + s + ' class="seNumAnswer">' + c + '</a><div class="siteInfo"><p><a ' + s + ">" + n.text(a.Title).html() + '</a></p><a href="http://' + r + '" class="siteLink">' + r + "</a></div></div>"
}
i += "</div>",
C(e, i)
},
v = function (e) {
0 == $("#seContainerSites").length && p(e)
},
p = function (t) {
var n = document.location.host;
S(t, i + "/genuwine/sites?callback=?&host=" + n + (e ? "&accountId=" + e : ""), "jsonp", b)
},
b = function (e, t) {
for (var n = '<div id="seContainerSites" style="display:none">', i = 0; i < t.length; i++) {
var o = t[i],
a = o.Name,
r = 'href="http://' + o.Id + '?as=1"';
n += '<div class="itemBox" data-sw-type="3" data-sw-name="' + o.Id + '"><a ' + r + ' class="siteFavicon"><img src="' + o.FaviconUrl + '" alt="' + a + '"></a><div class="siteInfo"><p><a ' + r + ">" + a + "</a></p><a " + r + ' class="siteLink">' + o.Description + "</a></div></div>"
}
n += "</div>",
C(e, n)
},
w = function (e) {
-1 != t && (0 == $("#seContainerInbox").length || t > 0) && x(e)
},
x = function (e) {
S(e, "/inbox/genuwine", "json", y, !0)
},
y = function (n, i) {
for (var a = '<div id="seContainerInbox" style="display:none">', r = 0; r < i.length; r++) {
var c = i[r],
l = 'href="' + c.Url + '"',
u = 'title="' + c.CreationDate + '"',
d = c.Count,
h = c.IsNew ? " itemBoxNew" : "",
p = c.hasOwnProperty("ItemType") ? ' data-type="' + c.ItemType.toString() + '"' : "";
if (null != c.SiteId && (p = p + ' data-sw-type="7" data-sw-site="' + c.SiteId.toString() + '"'), a += '<div class="itemBox' + h + '"' + p + "><a " + l + ' class="siteLinkFavicon"><img src="' + c.FaviconUrl + '" alt="' + c.SiteUrl + '"></a><div class="siteInfo">', "careers message" == c.Type)
a += "<p><a " + l + ' style="font-weight:normal"><b>' + c.Title + "</b> wants to contact you on <b>Stack Overflow Careers</b></a></p>";
else if ("invitation" == c.Type) {
var f = c.Count,
g = "invitation" + (f > 1 ? "s" : "");
a += "<p><a " + l + ' style="font-weight:normal"><b>' + f + "</b> " + g + " awarded on <b>Stack Overflow Careers</b></a></p>"
} else
a += "<p>" + (d > 1 ? d + " " : "") + c.Type + " on <a " + l + " " + u + ">" + c.Title + "</a></p>";
a += '<p class="inboxSummary">' + (c.Summary || "") + "</p></div></div>"
}
e && i.length >= 5 && (a += '<div class="itemMoreContainer"><div class="seIntro"><a href="http://stackexchange.com/users/' + e + '?tab=inbox">more inbox messages &hellip;</a></div></div>'),
a += "</div>",
C(n, a, "inbox_popup.click"),
o.push(function () {
t = 0,
s($("#seTabInbox"), $("#seTabNotices"))
}),
t = 0
},
k = {},
S = function (e, t, n, i, o) {
var a = e.attr("id");
if (k[a])
return E(), void 0;
k[a] = !0,
E();
var r = function () {
k[a] = !1,
StackExchange.helpers.showErrorMessage($("#seWrapper .seContainer"), "An error occurred while loading - please try again.")
};
$.ajax({
"type" : "GET",
"url" : t,
"dataType" : n,
"success" : function (t) {
k[a] = !1,
t && (t.length > 0 || o) ? i(e, t) : r()
},
"error" : r,
"complete" : function () {
$("#seWrapper .seContainer").removeSpinner()
}
})
},
C = function (e, t, n) {
var i = $(t);
i.prependTo("#seWrapper .seContainer"),
i.find(".itemBox a, .noticeBox a").click(function () {
var e = $(this).closest(".itemBox, .noticeBox");
n && n.length && StackExchange.gps.track(n, {
"item_type" : e.data("type")
});
var t = e.data("sw-type"),
i = e.data("sw-site"),
o = e.data("sw-name");
null == t || null == i && null == o || StackExchange.gps.track("site.switch", i ? {
"item_type" : t,
"target_site" : i
}
: {
"item_type" : t,
"target_name" : o
})
}),
e.hasClass("seCurrent") && i.fadeIn("fast")
},
E = function () {
StackExchange.helpers.removeSpinner(),
StackExchange.helpers.addSpinner("#seWrapper .seContainer", {
"position" : "relative",
"left" : "10px",
"top" : "10px"
})
},
T = function () {
var e = $("#portalLink .unreadCount"),
t = e.css("margin-top");
e.css({
"marginTop" : -20,
"opacity" : 0
}).show().animate({
"marginTop" : t,
"opacity" : 1
}, 2e3)
},
I = function (e) {
t = e;
var n = $("#seTabInbox");
e > 0 ? ($("#portalLink .unreadCount").text(t), n.hasClass("seCurrent") && a() && x(n), T()) : $("#portalLink .unreadCount").text("").hide(),
$("#portalLink .unreadCount").removeClass("newNotices"),
P()
},
M = function (e) {
n = e,
t > 0 || !StackExchange.options.site.isNoticesTabEnabled || (n > 99 && (n = 99), n > 0 && $("#portalLink .unreadCount").text("" + n).addClass("newNotices"), P())
},
P = function () {
var e = $("#portalLink .unreadCount"),
t = e.data("events");
t && t.click || e.length > 0 && e.click(r)
};
return {
"isVisible" : a,
"click" : r,
"setUnreadCount" : I,
"animateInbox" : T,
"init" : function (n, o, s) {
var c = $(".genu");
c.length >= 1 && (c[0].onclick = null),
e = n,
i = c.attr("href"),
t = o,
M(s),
c.removeAttr("href").click(r),
P(),
$(document).click(function (e) {
a() && !$.contains($("#portalLink")[0], e.target) && r()
})
}
}
}
();
StackExchange.topbar = function () {
function e(e) {
StackExchange.options.enableLogging && console.log("topbar: " + e)
}
function t(e) {
for (var t = 0; t < m.length; t++) {
var n = m[t].$button;
if (n && n[0] == e)
return !0
}
return !1
}
function n() {
for (var e = 0; e < m.length; e++)
m[e].toggle(!1)
}
function i(t) {
var n;
if (t && (n = JSON.parse(t))) {
e("realtime message - " + t);
for (var i in n)
for (var o = 0; o < m.length; o++)
if (i == m[o].name) {
m[o].handleRealtimeMessage(n[i]);
break
}
}
}
var o = klass({
"name" : "",
"url" : "",
"cssClass" : "",
"button" : null,
"$dialog" : null,
"$loadingPlaceholder" : null,
"$preloadedDialog" : null,
"hasRead" : !1
}).statics({
"$corral" : $(".js-topbar-dialog-corral")
}).methods({
"isLoading" : function () {
return null != this.$loadingPlaceholder
},
"isLoaded" : function () {
return null != this.$dialog
},
"isVisible" : function () {
var e = this.$dialog || this.$loadingPlaceholder;
return null != e && e.is(":visible")
},
"toggle" : function (e, t) {
if ("boolean" != typeof e)
throw new Error("showOrHide is a required parameter");
if (!e) {
if (this.isLoading())
return this.showOrHide(!1), void 0;
if (!this.isLoaded())
return
}
if (this.isLoaded() || this.isLoading() ? (e || t || !this.hasRead || this.markAsRead(), this.showOrHide(e)) : this.$preloadedDialog ? this.loadChildContent() : this.loadDialog(), e)
for (var n = 0; n < m.length; n++)
this.button != m[n] && m[n].toggle(!1, t)
},
"showOrHide" : function (e) {
var t = this.$dialog || this.$loadingPlaceholder;
t && t.toggle(e),
e && this.$dialog && (this.hasRead = !0)
},
"loadChildContent" : function () {
var e = this.$preloadedDialog.find(".child-content");
if (this.$dialog = this.$preloadedDialog, this.positionDialogUnderButton(), this.showOrHide(!0), this.url) {
$("<div>", {
"class" : "child-content-loading"
}).addSpinner().appendTo(e);
var t = this;
this.fetchUrl().done(function (n) {
e.html(n),
t.afterLoad()
})
}
},
"loadDialog" : function () {
if (!this.isLoading()) {
this.$loadingPlaceholder = this.getLoadingPlaceholder().appendTo(o.$corral),
this.positionDialogUnderButton(),
this.showOrHide(!0);
var e = this;
this.fetchUrl().done(function (t) {
e.$dialog = $(t).appendTo(o.$corral),
e.afterLoad();
var n = e.$loadingPlaceholder.is(":visible");
e.positionDialogUnderButton(),
e.showOrHide(n)
}).always(function () {
e.$loadingPlaceholder.remove(),
e.$loadingPlaceholder = null
})
}
},
"afterLoad" : function () {
this.$dialog.find(".js-close-button").click(function () {
StackExchange.topbar.hideAll()
}),
StackExchange.gps.bindTrackClicks(this.$dialog)
},
"getLoadingPlaceholder" : function () {
var e = $("<div/>").append(StackExchange.helpers.getSpinnerImg()).html(),
t = ['<div class="topbar-dialog ', this.cssClass, ' dno">', '<div class="header">', e, "</div>", '<div class="modal-content"/>', "</div>"];
return $(t.join(""))
},
"positionDialogUnderButton" : function () {
var e = this.button.$button.outerHeight(),
t = this.button.$button.offset().left - m[0].$button.offset().left;
(this.$dialog || this.$loadingPlaceholder).css({
"top" : e,
"left" : t
})
},
"fetchUrl" : function () {
e("fetching " + this.url);
var t = $.ajax({
"type" : "GET",
"url" : this.url,
"dataType" : "html"
});
return t
},
"markAsRead" : function () {
this.button.markAsRead(),
this.isLoaded() && this.$dialog.find(".unread-item").removeClass("unread-item")
},
"handleRealtimeMessage" : function () {
this.clearLoadedDialog()
},
"clearLoadedDialog" : function () {
this.isLoaded() && (this.$dialog.remove(), this.$dialog = null, this.hasRead = !1)
}
}),
a = klass({
"name" : "",
"selector" : "",
"dialog" : null,
"$button" : null,
"onClass" : "",
"unreadCountPrefix" : "",
"queuedUnreadCount" : 0,
"showsOnMouseOver" : !1
}).methods({
"initialize" : function () {
this.dialog.name = name,
this.dialog.button = this,
v.push(this.dialog);
var e = this;
this.$button = $(this.selector),
this.$button.click(function () {
return e.toggle(),
!1
}),
this.showsOnMouseOver && this.$button.mouseover(function () {
e.showOnMouseOver()
}),
this.onClass = "topbar-icon-on" + (this.onClass ? " " : "") + this.onClass
},
"toggle" : function (e, t) {
e = "boolean" == typeof e ? e : !this.$button.hasClass(this.onClass),
this.$button.toggleClass(this.onClass, e),
this.dialog.toggle(e, t)
},
"showOnMouseOver" : function () {
for (var e = !1, t = 0; t < m.length; t++) {
var n = m[t];
if (n != this && n.showsOnMouseOver && n.isOn()) {
e = !0;
break
}
}
e && this.toggle(!0, !0)
},
"isOn" : function () {
return this.$button.hasClass(this.onClass)
},
"markAsRead" : function () {
this.$button.find(".unread-count").fadeOut();
var e = this.$button.data("unread-class");
e && this.$button.removeClass(e),
this.dequeuePendingUnreadCount()
},
"dequeuePendingUnreadCount" : function () {
this.queuedUnreadCount && (this.setUnreadCount(this.queuedUnreadCount), this.queuedUnreadCount = 0, this.dialog.clearLoadedDialog())
},
"setUnreadCount" : function (e) {
if (void 0 === e);
else if (0 >= e)
this.queuedUnreadCount = 0, this.isOn() || this.markAsRead();
else if (e > 0)
if (this.isOn())
this.queuedUnreadCount = e;
else {
var t = this.$button.find(".unread-count");
t.text(this.unreadCountPrefix + e).fadeIn(),
this.addUnreadClass(),
this.dialog.clearLoadedDialog()
}
},
"addUnreadClass" : function () {
var e = this.$button.data("unread-class");
e && this.$button.addClass(e)
},
"handleRealtimeMessage" : function () {}
}),
r = o.extend({
"url" : "/topbar/site-switcher/site-list",
"cssClass" : "siteSwitcher-dialog",
"$searchItems" : null,
"$pinnedSiteSearchItems" : null,
"isPreloaded" : !0,
"$preloadedDialog" : o.$corral.find(".siteSwitcher-dialog")
}).methods({
"afterLoad" : function () {
this.$dialog.find("#js-site-filter-txt").typeWatch({
"highlight" : !1,
"wait" : 250,
"captureLength" : -1,
"callback" : $.proxy(this.filterSites, this)
}),
this.$searchItems = this.$dialog.find(".js-other-sites li").clone().map(function () {
return {
"title" : $(".site-icon", this).attr("title").toLowerCase(),
"description" : $(".site-desc", this).text().toLowerCase(),
"hostname" : $("a", this).first().attr("href"),
"li" : this
}
});
var e = this.$dialog;
this.$dialog.find("#js-site-filter-txt").focus(function () {
var t = e.offset().top + e.height(),
n = e.find(".other-sites li:nth-child(2)"),
i = n.offset().top + n.height();
i > t && e.animate({
"scrollTop" : e.scrollTop() + i - t
}, 750)
}),
!StackExchange.options.user.isAnonymous && $(".pinned-site-editor-container").length && ($(".js-found-sites").css({
"width" : $("#js-site-search-txt").outerWidth()
}), $(".js-found-sites").hide(), this.$dialog.find("#js-site-search-txt").typeWatch({
"highlight" : !1,
"wait" : 100,
"captureLength" : -1,
"callback" : $.proxy(this.findSitesToPin, this)
}), this.$dialog.find("#edit-pinned-sites").click($.proxy(this.editPinnedSites, this)), this.$dialog.find("#cancel-pinned-sites").click({
"forceListRefresh" : $("#save-pinned-sites-btn").is(":enabled")
}, this.cancelSiteListEdits), this.$dialog.find("#pin-site-btn").click($.proxy(this.pinSite, this)), this.$dialog.on("click", ".remove-pinned-site-link", function () {
return $(this).parent().remove(),
$("#save-pinned-sites-btn").enable(),
$("#reset-pinned-sites").show(),
!1
}), this.$dialog.find("#save-pinned-sites-btn").click($.proxy(this.savePinnedSites, this)), this.$dialog.find("#reset-pinned-sites").click($.proxy(this.resetPinnedSites, this))),
this.supr()
},
"showOrHide" : function (e) {
this.supr(e)
},
"pinSite" : function () {
$("#pin-site-btn").disable();
var e = $("#js-site-search-txt").val(),
t = $.grep(this.$pinnedSiteSearchItems, function (t) {
return t.sitename === e
});
if (!t.length)
return $("#pin-site-btn").enable(), void 0;
var n = t[0],
i = $(".pinned-site-link").map(function (e, t) {
return $(t).data("id")
}).toArray();
if (i.indexOf(n.siteid) > -1)
return $("#pin-site-btn").enable(), void 0;
var o = this;
$.ajax({
"type" : "GET",
"url" : "/topbar/site-switcher/pin-site",
"data" : {
"siteId" : n.siteid
},
"dataType" : "html"
}).done(function (e) {
var t = $(e);
t.hide(),
$(".pinned-site-list").append(t),
t.fadeIn("slow"),
$("#js-site-search-txt").val(""),
$("#save-pinned-sites-btn").enable(),
o.toggleSiteListResetLink(!0)
}).fail(function () {
$("#pin-site-btn").parent().showErrorMessage("Something bad happened; please try again"),
$("#pin-site-btn").enable()
})
},
"savePinnedSites" : function () {
var e = $(".pinned-site-list li .pinned-site-link").map(function (e, t) {
return $(t).data("id")
}).toArray(),
t = !$("#reset-pinned-sites").is(":visible") || !e.length;
return this.toggleSiteListResetLink(!t),
$.ajax({
"type" : "POST",
"url" : "/topbar/site-switcher/save-pinned-sites",
"data" : {
"siteIds" : t ? [] : e,
"fkey" : StackExchange.options.user.fkey
},
"dataType" : "html",
"traditional" : !0
}).done($.proxy(function (e) {
$(".my-sites").html(e),
this.cancelSiteListEdits(!1),
$(".pinned-site-list").data("custom-list", !t),
StackExchange.using("gps", function () {
StackExchange.gps.track("site_switcher.edit", {})
})
}, this)).fail(function () {
$("#save-pinned-sites-btn").parent().showErrorMessage("Something bad happened; please try again")
}),
!1
},
"resetPinnedSites" : function () {
var e = this;
return $.ajax({
"type" : "GET",
"url" : "/topbar/site-switcher/default-active-sites",
"dataType" : "html"
}).done(function (t) {
$(".pinned-site-list").html(t),
$("#save-pinned-sites-btn").enable(),
e.toggleSiteListResetLink(!1)
}).error(function () {
$("#reset-pinned-sites").parent().showErrorMessage("Something bad happened; please try again")
}),
!1
},
"doSearch" : function (e, t, n) {
var i;
t = t.toLowerCase();
var o = [];
return $.each(e, function (e, n) {
var i = {
"index" : e,
"li" : n.li,
"item" : n
},
a = n.title.indexOf(t);
n.title == t ? i.priority = 1 : 0 == a ? i.priority = 2 : a > -1 ? i.priority = 3 : n.description.indexOf(t) > -1 ? i.priority = 4 : n.hostname.indexOf(t) > -1 && (i.priority = 5),
i.priority && o.push(i)
}),
i = o.sort(function (e, t) {
return e.priority - t.priority || e.index - t.index
}),
n && StackExchange.using("gps", function () {
StackExchange.gps.track("sitesearch.submit", {
"term" : t,
"numresults" : o.length
}, !1)
}),
i
},
"_findSitesToPin" : function (e) {
var t = $(".js-found-sites"),
n = this.$pinnedSiteSearchItems;
if (t.empty(), "" === e)
return t.hide(), $("#pin-site-btn").disable(), void 0;
if (n = this.doSearch(n, e, !1), n.length) {
t.show(),
$("#pin-site-btn").enable();
var i = $(".pinned-site-link").map(function (e, t) {
return $(t).data("id")
}).toArray();
$.each(n, function (e, n) {
var o = $('<li class="pinned-site-candidate">' + n.item.sitename + "</li>");
i.indexOf(n.item.siteid) > -1 ? o.addClass("already-pinned-site") : o.click(function () {
var e = $(this).text();
return $("#js-site-search-txt").val(e),
$(".js-found-sites").hide(),
!1
}),
o.appendTo(t)
})
}
},
"findSitesToPin" : function (e) {
if (this.$pinnedSiteSearchItems)
return this._findSitesToPin(e), void 0;
var t = this;
$.ajax({
"type" : "GET",
"url" : "/topbar/site-switcher/all-pinnable-sites",
"dataType" : "json"
}).done(function (n) {
t.$pinnedSiteSearchItems = n,
t._findSitesToPin(e)
})
},
"filterSites" : function (e) {
var t = $(".js-other-sites"),
n = this.$searchItems;
t.empty(),
"" != e && (n = this.doSearch(n, e, !0)),
t.append(n.map(function (e) {
return this && this.li || e.li
}))
},
"editPinnedSites" : function () {
$(".header").not("#your-communities-header").css("opacity", .2),
$(".modal-content").not("#your-communities-section").css("opacity", .2),
$(".my-sites").hide(),
$(".pinned-site-editor-container").show(),
$("#edit-pinned-sites").hide(),
$("#cancel-pinned-sites").show();
var e = $(".pinned-site-list");
if ("" === e.html().trim()) {
var t = $("<div/>").append(StackExchange.helpers.getSpinnerImg()).html();
e.append('<li style="text-align:center;">' + t + "</li>"),
$.ajax({
"type" : "GET",
"url" : "/topbar/site-switcher/current-pinned-sites",
"dataType" : "html"
}).done(function (t) {
e.html(t)
}).fail(function () {
e.showErrorMessage("Something bad happened; please try again")
}).always(function () {
e.find(".ajax-loader").remove()
})
}
this.toggleSiteListResetLink("true" === e.data("custom-list").toString().toLowerCase());
var n = $(".sortable"),
i = this;
return n.data("isSortable") || StackExchange.loadJqueryUi().done(function () {
n.sortable({
"axis" : "y",
"update" : function () {
$("#save-pinned-sites-btn").enable(),
i.toggleSiteListResetLink(!0)
}
}).disableSelection().data("isSortable", !0)
}),
!1
},
"toggleSiteListResetLink" : function (e) {
$("#reset-pinned-sites").toggle(e)
},
"cancelSiteListEdits" : function (e) {
return $(".header").not("#your-communities-header").css("opacity", 1),
$(".modal-content").not("#your-communities-section").css("opacity", 1),
$(".my-sites").show(),
$("#edit-pinned-sites").show(),
$(".pinned-site-editor-container").hide(),
$("#cancel-pinned-sites").hide(),
$("#save-pinned-sites-btn").disable(),
e && ($(".pinned-site-list").empty(), $(".js-found-sites").hide(), $("#js-site-search-txt").val(""), $("#pin-site-btn").disable()),
!1
}
}),
s = a.extend({
"name" : "SiteSwitcher",
"selector" : ".js-site-switcher-button",
"dialog" : new r,
"showsOnMouseOver" : !0,
"onClass" : "icon-site-switcher-on"
}),
c = o.extend({
"url" : "/topbar/inbox",
"cssClass" : "inbox-dialog"
}),
l = a.extend({
"name" : "Inbox",
"selector" : ".js-inbox-button",
"dialog" : new c,
"showsOnMouseOver" : !0
}).methods({
"handleRealtimeMessage" : function (e) {
this.setUnreadCount(e.UnreadInboxCount)
}
}),
u = o.extend({
"url" : "/topbar/achievements",
"cssClass" : "achievements-dialog"
}).methods({
"afterLoad" : function () {
this.alignRep(),
this.bindDateGroupToggles(),
this.displayUtcTime(),
this.supr()
},
"alignRep" : function () {
var e = this.$dialog.find(".js-items .js-faux-column"),
t = 0;
e.filter(".js-rep-change").each(function () {
var e = $.trim($(this).text()).length;
e > t && (t = e)
}),
t > 0 && e.width(6 * t)
},
"bindDateGroupToggles" : function () {
this.$dialog.find(".js-date-group-toggle").click(function () {
var e = $(this),
t = e.closest(".js-date-group"),
n = t.find(".js-items"),
i = t.find(".rep-site-container");
e.find(".date-group-toggle").toggleClass("toggle-hidden"),
n.add(i).fadeToggle("fast")
}),
this.$dialog.find(".rep-site-container").on("click", function (e) {
e.stopImmediatePropagation()
})
},
"displayUtcTime" : function () {
var e = this.$dialog,
t = function () {
var t = new Date;
t.setTime(t.getTime() + 1e3 * StackExchange.options.serverTimeOffsetSec);
var n = t.getUTCHours(),
i = t.getUTCMinutes();
10 > n && (n = "0" + n),
10 > i && (i = "0" + i),
e.find(".js-utc-time").text(n + ":" + i)
};
t(),
setInterval(t, 6e4)
}
}),
d = a.extend({
"name" : "Achievements",
"selector" : ".js-achievements-button",
"dialog" : new u,
"unreadCountPrefix" : "+",
"showsOnMouseOver" : !0
}).methods({
"handleRealtimeMessage" : function (e) {
var t = 0 === (e.UnreadRepCount || 0) && e.UnreadNonRepCount > 0;
t ? this.addUnreadClass() : this.setUnreadCount(e.UnreadRepCount)
}
}),
h = o.extend({
"cssClass" : "help-dialog"
}).methods({
"loadDialog" : function () {
this.$dialog = $(".js-help-dialog").appendTo(o.$corral),
this.positionDialogUnderButton(),
this.showOrHide(!0)
}
}),
p = a.extend({
"name" : "Help",
"selector" : ".js-help-button",
"dialog" : new h
}),
f = o.extend({
"url" : "/topbar/mod-inbox",
"cssClass" : "modInbox-dialog"
}).methods({}),
g = a.extend({
"name" : "ModInbox",
"selector" : ".js-mod-inbox-button",
"dialog" : new f
}),
m = [],
v = [];
return {
"init" : function () {
window.devicePixelRatio >= 1.5 && $(".js-avatar-me").attr("src", function (e, t) {
return t.replace("?s=24", "?s=48")
}),
m.push(new s),
m.push(new l),
m.push(new d),
m.push(new p),
StackExchange.options.user.isModerator && m.push(new g),
$(document).click(function (e) {
t(e.target) || $.contains(o.$corral[0], e.target) || n()
})
},
"hideAll" : n,
"handleRealtimeMessage" : i
}
}
(), StackExchange.notify = function () {
function e(e, t) {
var n = $("#dismissed-messages");
n.val(n.val() + "~" + e + (t ? " " + t : "") + "~")
}
function t(e, t) {
var n = $("#dismissed-messages").val();
return n ? new RegExp("~" + e + (t ? " " + t : "") + "~").test(n) : !1
}
function n(e, t, n) {
var i = parseInt($("body").css("margin-top").match(/\d+/)),
o = t * i / e;
n ? $("body:not(.no-message-slide)").animate({
"marginTop" : o + "px"
}, "fast", "linear") : $("body:not(.no-message-slide)").css("marginTop", o + "px")
}
var i = 0,
o = -1,
a = "m",
r = function (t, a) {
var r = $("#notify-" + t + (a ? "-" + a : ""));
t == o ? c() : t > o && $.post("/messages/mark-as-read", {
"messagetypeid" : t,
"id" : a ? a : null
}),
e(t, a),
i--,
r.fadeOut("fast", function () {
n(i + 1, i, !0),
r.remove()
})
},
s = function (e) {
if (i++, t(e.messageTypeId, e.id))
return !1;
var n = "";
e.messageTypeId && (n = ' id="notify-' + e.messageTypeId + (e.id ? "-" + e.id : "") + '"');
var o = "<div" + n + ' style="display:none"><span class="notify-close">' + $("<a>&times;</a>").attr("title", "dismiss this notification").outerHTML() + '</span><span class="notify-text">' + e.text + "</span>";
if (e.showProfile) {
var a = encodeURIComponent("/users/" + e.userId + "?tab=badges&sort=recent");
o += " " + function (e) {
return 'See your <a href="' + e.url + '">profile</a>.'
}
({
"url" : "/messages/mark-as-read?messagetypeid=" + e.messageTypeId + "&returnurl=" + a
})
}
o += "</div>";
var s = $(o);
return s.find(".notify-close").click(function () {
e.close && e.close(),
r(e.messageTypeId, e.id)
}),
$("#notify-container").append(s),
!0
},
c = function (e) {
$.cookie(a, e ? e : "0", {
"expires" : 90,
"path" : "/"
})
},
l = function () {
$("#notify-container div").fadeIn("slow")
},
u = function () {
$("body:not(.no-message-slide)").animate({
"marginTop" : "2.5em"
}, "fast", "linear")
},
d = function (e, t) {
var n = $('<div class="link-more">').append($("<a>").text(function (e) {
return 1 == e.numNotifications ? "view " + e.numNotifications + " more notification" : "view " + e.numNotifications + " more notifications"
}
({
"numNotifications" : e
})));
$("#notify-container").append(n),
n.click(function () {
n.detach();
for (var e = 0; e < t.length; e++)
s(t[e]);
l()
})
};
return {
"showMessages" : function (e, t) {
for (var o = 0, a = t ? 2 : e.length, r = 0; a > r && r < e.length; r++)
s(e[r]) && o++;
if (n(i, o, !1), l(), t && o < e.length) {
var c = e.slice(a);
d(e.length - o, c)
}
},
"show" : function (e, t) {
u(),
s({
"text" : e,
"messageTypeId" : t
}),
l()
},
"close" : r,
"getMessageText" : function (e) {
return $("#notify-" + e + " .notify-text").text()
}
}
}
();
var styleCode = function () {
function e(e) {
var t = $("#prettify-lang").text();
return "" != t ? (e.addClass(t), !0) : !1
}
return function () {
"undefined" != typeof MathJax && MathJax.Hub.Queue(["Typeset", MathJax.Hub]),
window.snippetRedraw && window.snippetRedraw();
var t = !1;
if ($("pre code").parent().each(function () {
$(this).hasClass("prettyprint-override") && ($(this).removeClass("prettyprint-override").addClass("prettyprint"), t = !0),
$(this).hasClass("prettyprint") || e($(this)) && ($(this).addClass("prettyprint"), t = !0)
}), t) {
if ("undefined" != typeof jtab)
return jtab.renderimplicit(), void 0;
StackExchange.using("prettify", function () {
StackExchange.prettify.applyCodeStyling()
})
}
$(".spoiler").click(function () {
$(this).toggleClass("spoiler")
})
}
}
();
styleCode.updateLangdivDelayed = StackExchange.helpers.DelayedReaction(function (e) {
var t = $("#prettify-lang");
t.length && $.get("/api/tags/langdiv", {
"tags" : e.join(" ")
}).done(function (e) {
e ? t.replaceWith(e) : t.empty(),
StackExchange.MarkdownEditor.refreshAllPreviews(),
styleCode()
})
}, 1500, {
"sliding" : !0
}), StackExchange.helpers.MagicPopup = function (e) {
function t(t, i) {
var a = $("<div id='" + e.id + "'/>").html(i),
r = $("<div />").css({
"overflow" : "hidden",
"position" : "absolute",
"z-index" : 1002,
"width" : 1,
"height" : 1,
"top" : 0,
"left" : 0
}).append(a).appendTo("body");
window.MathJax && MathJax.Hub.Typeset(a.attr("id"));
var s = e.showing(t, a),
c = {
"left" : s.left
};
s.hasOwnProperty("bottom") ? (c.bottom = s.bottom, c.top = "auto") : c.top = 0 | s.top;
var l;
e.shown && (l = function () {
e.shown(t, a)
}),
r.css(c).animate({
"height" : a.outerHeight() + 8,
"width" : a.outerWidth() + 8
}, 300, l),
n = function () {
r.stop().remove(),
e.removed && e.removed(t, a),
o = null,
n = null
},
o = StackExchange.helpers.DelayedReaction(n, 5);
var u = r;
s.additional && (u = u.add(s.additional)),
u.hover(o.cancel, o.trigger)
}
var n,
i,
o,
a,
r = {},
s = StackExchange.helpers.DelayedReaction(function (i, o) {
if (!a && i) {
var s;
e.cache && "c_" + i in r ? s = $.Deferred().resolve(r["c_" + i]) : (s = $.ajax({
"type" : "GET",
"url" : i,
"dataType" : "html"
}), e.cache && s.done(function (e) {
r["c_" + i] = e
})),
s.done(function (e) {
n && n(),
"" != e && t(o, e)
})
}
}, 500);
$(document).delegate(e.selector, {
"mouseenter" : function () {
return o && this === i ? (o.cancel(), void 0) : (i = this, s.trigger(e.getUrl(this), this), a = !1, !1)
},
"mouseleave" : function () {
a = !0,
s.cancel(),
o && o.trigger()
}
})
}, StackExchange.tagmenu = function () {
function e(e) {
var t = $(e),
n = t.attr("href");
if (!n || "/" != n.charAt(0))
return null;
var i = t.text();
return i.indexOf("*") > -1 ? null : (t.attr("title", ""), "/tags/" + encodeURIComponent(i) + "/subscriber-info")
}
function t(e, t) {
var n = $(e),
i = n.offset(),
o = n.outerHeight(),
a = {
"left" : i.left
},
r = i.top + o,
s = i.left + t.outerWidth();
t.height() + r > $(window).height() + $(window).scrollTop() ? a.bottom = $(window).height() - i.top - 8 : a.top = r;
var c = Math.max(1024, $(window).width());
return s > c && (a.left -= s - c),
a
}
var n,
i,
o = function (o) {
n = o,
i || (i = !0, StackExchange.options.isMobile || (StackExchange.helpers.MagicPopup({
"selector" : ".post-tag:not(.user-tag,.no-tag-menu)",
"id" : "tag-menu",
"getUrl" : e,
"showing" : t,
"shown" : function (e, t) {
n && n(t, $(e).text())
}
}), $("#interesting-tags .post-tag").addClass("user-tag")))
};
return {
"init" : o
}
}
(), StackExchange.usermenu = function () {
function e(e, t) {
var n = $(e),
i = n.find("img:first"),
a = i.offset(),
r = i.height(),
s = i.width(),
c = Math.max(s, r),
l = 64 * r / c,
u = 64 * s / c,
d = t.find("img:first").css({
"width" : u,
"height" : l
}),
h = d.offset();
d.css("visibility", "hidden"),
o = i.clone().css({
"position" : "absolute",
"zIndex" : 1003,
"left" : a.left,
"top" : a.top,
"width" : s,
"height" : r
}).appendTo("body");
var p = function () {
return d[0].complete ? (d.css("visibility", "visible"), o.fadeOutAndRemove(), void 0) : (setTimeout(p, 100), void 0)
};
return o.animate({
"width" : u,
"height" : l,
"top" : a.top + h.top
}, 200, p),
t.trigger("userhovershowing", e), {
"top" : a.top,
"left" : a.left - h.left,
"additional" : o
}
}
function t(e, t) {
t.trigger("userhovershown")
}
function n(e) {
$(e).trigger("userhoverremoved"),
o.remove()
}
var i,
o,
a = function () {
function o(e) {
var t = $(e),
n = t.closest(".user-hover"),
i = n.find(".user-details a").attr("href"),
o = new RegExp("/users/([^/]+).*$"),
a = o.exec(i);
return a ? "/users/user-info/" + a[1] : null
}
i || (i = !0, StackExchange.options.isMobile || StackExchange.helpers.MagicPopup({
"selector" : ".user-hover .user-gravatar48, .user-hover .user-gravatar32",
"getUrl" : o,
"cache" : !0,
"id" : "user-menu",
"showing" : e,
"shown" : t,
"removed" : n
}))
};
return {
"init" : a
}
}
(), StackExchange.chatAd = function () {
function e() {
var e = $(".question .post-taglist .post-tag");
return e.length ? e.map(function (e, t) {
return $(t).text()
}).get().join(" ") : null
}
function t(e) {
return 10 > e ? "0" + e : e
}
function n(e) {
var n = new Date;
return n.setTime(1e3 * e),
[n.getUTCFullYear(), "-", t(n.getUTCMonth() + 1), "-", t(n.getUTCDate()), " ", t(n.getUTCHours()), ":", t(n.getUTCMinutes()), ":", t(n.getUTCSeconds()), "Z"].join("")
}
function i(e) {
var n = Math.floor((new Date).getTime() / 1e3),
i = n - e,
o = i % 60,
a = Math.floor(i / 60),
r = Math.floor(i / 3600);
if (1 > i)
return "just now";
if (60 > i)
return function (e) {
return 1 == e.seconds ? e.seconds + " sec ago" : e.seconds + " secs ago"
}
({
"seconds" : o
});
if (3600 > i)
return function (e) {
return 1 == e.minutes ? e.minutes + " min ago" : e.minutes + " mins ago"
}
({
"minutes" : a
});
if (86400 > i)
return function (e) {
return 1 == e.hours ? e.hours + " hour ago" : e.hours + " hours ago"
}
({
"hours" : r
});
var s = Math.floor(i / 86400);
if (1 == s)
return "yesterday";
if (2 >= s)
return function (e) {
return e.days + " days ago"
}
({
"days" : s
});
var c = new Date(1e3 * e);
return function (e) {
return e.month + " " + e.date + " at " + e.hours + ":" + e.minutes
}
({
"month" : v[c.getMonth()],
"date" : c.getDate(),
"hours" : c.getHours(),
"minutes" : t(c.getMinutes())
})
}
function o(e) {
var t = $("<div />");
return t.text(e),
t.html().replace('"', "&quot;")
}
function a() {
p && $.get(p, null, function (e, t, n) {
d(e, t, n)
})
}
function r(e) {
if ("!" == e.charAt(0)) {
var t = e.substr(1);
if (/^https?:\/\/i.stack.imgur.com\//.test(t)) {
var n = /\?/.test(t) ? "&" : "?";
t += n + "g&s=32"
}
return t
}
return "https://www.gravatar.com/avatar/" + e + "?s=23&d=identicon&r=PG"
}
function s(e) {
for (var t = $('<div class="ad502-users" />'), n = 0; n < e.length && 7 > n; n++) {
var o = e[n],
a = o.name;
o.lastPost && (a += ": " + i(o.lastPost));
var s = h + "/users/" + o.id,
c = $('<a href="' + s + '" />');
$("<img height='23' width='23' />").attr("title", a).attr("src", r(o.emailhash)).appendTo(c),
t.append(c)
}
return t
}
function c(e) {
return $('<div class="ad502-users"><img src="' + h + "/rooms/users/" + e + '.jpeg" /></div>')
}
function l(e) {
var t = e.user,
n = e.userid;
return n ? '<a href="' + h + "/users/" + n + '">' + o(t) + "</a>" : o(t)
}
function u() {
p && (m >= f && window.setTimeout(a, 1e3 * f), f += g)
}
function d(e) {
var t = $("#ad502-rooms");
if (e.error)
return u(), void 0;
t.html("");
for (var a = e.rooms, r = 0; r < a.length && 2 > r; r++) {
var d = a[r],
p = h + "/rooms/" + d.id,
f = $('<div class="ad502-room"></div>');
f.append($('<h3 class="ad502-room-h3"><span class="ad502-room-title" title="' + o(d.name) + '"><a href="' + p + '">' + o(d.name) + "</a></span></h3>")),
d.messages && d.messages.length > 0 && f.append($('<span title="' + n(d.lastPost) + '" class="ad502-last-message">' + i(d.lastPost) + " - " + l(d.messages[0]) + "</span><br>")),
d.singleImage ? f.append(c(d.id)) : f.append(s(d.users)),
t.append(f)
}
e.activeUsers > 1 ? $("#h-chat-link").text(function (e) {
return 1 == e.num,
e.num + " People Chatting"
}
({
"num" : e.activeUsers
})) : $("#h-chat-link").text("Visit Chat"),
$("#h-chat-link").attr("title", function (e) {
return 1 == e.users && 1 == e.rooms ? e.users + " user active in " + e.rooms + " room the last 60 minutes" : 1 == e.users ? e.users + " user active in " + e.rooms + " rooms the last 60 minutes" : 1 == e.rooms ? e.users + " users active in " + e.rooms + " room the last 60 minutes" : e.users + " users active in " + e.rooms + " rooms the last 60 minutes"
}
({
"users" : e.activeUsers,
"rooms" : e.activeRooms
})),
u()
}
var h,
p,
f = 180,
g = 30,
m = 480,
v = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
return /^\/questions\/\d+/i.test(window.location.pathname) && (m = 0), {
"init" : function (t) {
if (h = t.chatUrl, p = t.reloadUrl, t.tagBased) {
var n = e();
if (!n)
return;
p && (p += (/\?/.test(p) ? "&" : "?") + "tags=" + encodeURIComponent(n))
}
null === t.preloadData ? a() : d(t.preloadData, null, null)
}
}
}
(), StackExchange.helpers.noDiacritics = function () {
var e = {
"à åáâäãåąɐᵄᶛ" : "a",
"æǣǽᴂᵆ" : "ae",
"çćčĉ" : "c",
"đƍðÐ" : "d",
"èéêëęǝᴈᵌ" : "e",
"â…Ž" : "f",
"ğĝᵷ" : "g",
"ĥɥʮᶣ" : "h",
"ìíîïıᴉᵎ" : "i",
"ĵ" : "j",
"Êž" : "k",
"Å‚" : "l",
"ɯɰᵚᶭᴟ" : "m",
"ñń" : "n",
"òóôõöøő" : "o",
"œɶᴔ" : "oe",
"řɹɺɻʴʵ" : "r",
"śşšŝ" : "s",
"ß" : "ss",
"ʇ" : "t",
"Þ" : "th",
"ùúûüŭů" : "u",
"ʌᶺ" : "v",
"ʍ" : "w",
"ýŸÿʎ" : "y",
"żźž" : "z"
};
return function (t) {
for (var n in e)
e.hasOwnProperty(n) && (t = t.replace(new RegExp("[" + n + "]", "g"), e[n]));
return t
}
}
(), StackExchange.question = function () {
function e() {
var e = "hashchange.highlightDestination";
$(window).off(e).on(e, function () {
var e = window.location.href;
if (!(e.indexOf("#") < 0)) {
var t = decodeURI(e).match(/#(\d+|comment(\d+)_(\d+))/i);
t && (t[2] ? p(t[2], t[3]) : h(t[1]))
}
}).trigger(e)
}
var t,
n,
i,
o = function () {
return $("div.share-tip a[id^='link-post-']")
},
a = function (e, t) {
return e ? function (e) {
return "share link to this question on " + e.socialNetwork
}
({
"socialNetwork" : t
}) : function (e) {
return "share link to this answer on " + e.socialNetwork
}
({
"socialNetwork" : t
})
},
r = function (e, t, n, i, o, r) {
return $("<a>", {
"id" : "share-" + i + "-" + e,
"class" : "share-" + i,
"title" : a(t, n),
"text" : o,
"data-svc" : r
})
},
s = function (e, t) {
var n = null != e;
e || (e = $("div.question div.post-menu a.short-link"));
var i = e.closest(".post-menu, .help-menu");
if (e.hasClass("share-link"))
i.find(".close-share-tip").click();
else {
e.addClass("share-link");
var o = e.attr("id").substring("link-post-".length),
a = e.closest(".col-section").length ? "section" : e.closest("div.question").length ? "question" : "answer",
s = e.closest("div.question").length,
c = "http://" + document.location.host + e.attr("href"),
l = ("answer" == a ? "Answer:" : "") + $("#question-header a").text(),
u = '<div class="share-tip" style="display:none">' + (s ? "share a link to this question" : "share a link to this answer") + '<input type="text" style="display:block; width:292px;" value="' + c + '">';
StackExchange.options.site.enableSocialMediaInSharePopup && (u += $("<div>", {
"id" : "share-icons"
}).append(r(o, s, "Google+", "gp", "share [g+]", 1)).append(r(o, s, "Facebook", "fb", "share [fb]", 2)).append(r(o, s, "Twitter", "tw", "share [tw]", 3)).prop("outerHTML")),
StackExchange.gps.track("share.show", {
"location" : s ? 1 : 2
}),
u += '<a class="close-share-tip" style="float:right">close</a></div>';
var d = $(u);
if (StackExchange.options.site.enableSocialMediaInSharePopup) {
var h = "2";
StackExchange.share.gplus($("#share-gp-" + o, d), c, l, h),
StackExchange.share.facebook($("#share-fb-" + o, d), c, l, h),
StackExchange.share.twitter($("#share-tw-" + o, d), c, l, h),
$("#share-icons a", d).click(function () {
d.fadeOutAndRemove(),
StackExchange.gps.track("share.click", {
"location" : s ? 1 : 2,
"service" : $(this).data("svc")
})
})
}
t && d.find(".close-share-tip").before('<a id="link-post-' + o + '" style="float:left">cite</a>'),
d.appendTo(i).fadeIn(n ? "fast" : 0).bind("removing", function () {
e.removeClass("share-link")
}).find(".close-share-tip").click(function () {
d.fadeOutAndRemove()
}).end().find("input[type=text]").select()
}
},
c = function (e) {
var t = $("#post-form h2:first"),
n = t.wrap("<div />").parent(),
i = n.wrap("<div />").parent(),
o = $("<div />").prependTo(i),
a = i.height(),
r = $("<div />"),
s = $(e),
c = parseInt(t.css("margin-bottom")),
l = $("#content"),
u = $("#wmd-input").outerWidth(),
d = 1e3,
h = l.offset().left > t.offset().left - 5 && "visible" != l.css("overflow-x");
r.css({
"height" : 0,
"overflowY" : "hidden"
}).appendTo(n).append(s),
i.css({
"height" : a,
"position" : "relative"
}),
n.css({
"position" : "absolute",
"bottom" : -c,
"width" : u
}),
o.addClass("answer-help-background").css({
"position" : "absolute",
"bottom" : -c,
"height" : 0,
"width" : u
}),
h && (o.css("left", 0), n.animate({
"paddingLeft" : 5
}, d)),
r.animate({
"height" : s.height() + c + 10
}, d),
o.animate({
"height" : s.height() + c + 10 + a
}, d),
$("<div style='float:right;margin-top:10px;'><a href='#'>ok</a></div>").hide().prependTo(n).fadeIn(1e3).find("a").one("click", function (e) {
var i = $(this).parent();
setTimeout(function () {
i.remove()
}, 1),
r.animate({
"height" : 0
}, d, function () {
r.add(o).remove(),
t.unwrap().unwrap(),
t.text("Your Answer")
}),
o.animate({
"height" : 0
}, d),
h && n.animate({
"paddingLeft" : 0
}, d),
e.preventDefault()
})
},
l = function () {
$.get("/posts/answer-help").then(c)
},
u = function () {
$.get("/posts/answer-ban-warning").then(c).then(function () {
var e = $("#post-form h2:first");
e.text("WAIT!"),
$("#qualityBanWarningShown").val("true")
})
},
d = function (e) {
var t = e ? e.closest(".question") : $(".question"),
n = t.data("questionid");
if (!n)
throw new Error("getQuestionId could not find an id");
return n
},
h = function (e) {
f($(".answer[data-answerid=" + e + "]"))
},
p = function (e, t) {
var n = "#comment-" + e,
i = $(n);
i.length ? f(i) : StackExchange.comments.loadAll($("#comments-link-" + t)).done(function () {
f($(n))
})
},
f = function (e) {
var n = i;
e.css({
"backgroundColor" : t
}).animate({
"backgroundColor" : n
}, 2e3, "linear", function () {
$(this).css("background-color", "")
}),
e.is(".comment") && e[0].scrollIntoView(!0)
},
g = function (e) {
e = e || {},
$(".post-menu a.short-link").live("click", function (t) {
return t.ctrlKey || t.metaKey ? void 0 : (s($(this), e.showCitation), !1)
}),
$(".bottom-share-links a").live("click", function () {
var e = $(this).attr("href"),
t = null;
e && e.length && (e.indexOf("%3fsgp%3d") >= 0 ? t = 1 : e.indexOf("%3fsfb%3d") >= 0 ? t = 2 : e.indexOf("%3fstw%3d") >= 0 ? t = 3 : e.indexOf("%3fsem%3d") >= 0 && (t = 4)),
t && StackExchange.gps.track("share.click", {
"location" : 3,
"service" : t
}, !0)
});
var t = $(".bottom-notice");
t && t.length && !t.data("bn") && t.data("loc") && t.data("bn", "bn").find("a").live("click", function () {
var e = 0,
n = t.data("loc"),
i = $(this).attr("href");
$(this).hasClass("post-tag") ? e = 1 : /\/ask$/.test(i) ? e = 2 : /\/tags$/.test(i) ? e = 4 : /\/unanswered$/.test(i) ? e = 5 : (/\/questions$/.test(i) || /\/questions[?\/]/.test(i)) && (e = 3),
StackExchange.gps.track("next_action.click", {
"type" : e,
"location" : n
}, !0)
})
},
m = function (e, t, n, i) {
var o,
a,
r = document.title,
s = 0;
e.attr("autocomplete", "off"),
i = i || function () {};
var c = function (c) {
var l = e.val();
if (!("" == l || l == o && c !== !0 || StackExchange.options.site.newTitleSearchBoxEnabled && $(".title-float-selected:visible").length > 0)) {
for (var u = l.split(" "), d = 0, h = 0; h < u.length; h++)
$.trim(u[h]).length > 0 && d++;
var p = (new Date).getTime(),
f = (p - s) / 1e3;
(c === !0 || !(3 > d || 5 > f) || e.hasClass("edit-field-overlayed")) && (s = p, o = l, n && (document.title = l ? l + " - " + n : r), t.empty(), StackExchange.helpers.addSpinner(t), a && a.fadeOutAndRemove(), $.ajax({
"url" : "/search/titles",
"dataType" : "json",
"data" : {
"title" : l
},
"success" : function (e) {
e && e.content && (t.html(e.content), setTimeout(function () {
i(t.find(".answer-link a").attr("target", "_blank"))
}, 1))
},
"complete" : function () {
StackExchange.helpers.removeSpinner(t)
}
}))
}
},
l = !1;
return t.mouseenter(function () {
l = !0
}).mouseleave(function () {
l = !1
}),
e.keyup(c).blur(function () {
var e = function () {
s = 0,
c()
};
l ? t.one("mouseleave", e) : e()
}),
function (e) {
s = 0,
c(e)
}
};
return {
"initTitleSearch" : m,
"showShareTip" : s,
"getQuestionId" : d,
"initShareLinks" : g,
"canViewVoteCounts" : function () {
return n
},
"init" : function (a) {
n = a.canViewVoteCounts,
StackExchange.question.fullInit ? StackExchange.question.fullInit(a) : StackExchange.question.bindAnonymousVoteDisclaimers(),
StackExchange.comments.init({
"autoShowCommentHelp" : a.autoShowCommentHelp
}),
g(a),
a.showAnswerBanWarning && $("#wmd-input").one("focus", u),
a.showAnswerHelp && !a.showAnswerBanWarning && $("#wmd-input").one("focus", l),
a.showCitation && o().live("click", function () {
var e = $(this).closest(".post-menu");
e.find(".close-share-tip").click(),
citation.show($(this))
}),
i = a.backgroundColor,
t = a.highlightColor,
e()
}
}
}
(), StackExchange.question.bindAnonymousVoteDisclaimers = function () {
function e(e) {
var t = $(this),
n = t.closest("div.vote"),
i = t.prop("className"),
o = /vote-up/.test(i),
a = /vote-down/.test(i),
r = /star/.test(i),
s = t.closest(".answer").length;
if (e.preventDefault(), o || a) {
if (StackExchange.options.inReadOnly)
return n.showErrorMessage("Voting isn't available in read-only mode.", {
"transient" : !0
}), void 0;
var c = n.find("input").val();
if (StackExchange.options.isMobile) {
StackExchange.helpers.fireAndForget("/posts/popup/anon-vote/" + c + "?voteTypeId=" + (o ? 2 : 3));
var l = "Thank you for your feedback.<br />" + (s ? function (e) {
return "Please " + e.startAnchor + "log in or register" + e.endAnchor + " to vote for this answer."
}
({
"startAnchor" : '<a href="/users/login?returnurl=' + escape(document.location) + '">',
"endAnchor" : "</a>"
}) : function (e) {
return "Please " + e.startAnchor + "log in or register" + e.endAnchor + " to vote for this question."
}
({
"startAnchor" : '<a href="/users/login?returnurl=' + escape(document.location) + '">',
"endAnchor" : "</a>"
}));
StackExchange.helpers.showMessage(t, l, {
"type" : "info",
"position" : {
"my" : "left top",
"at" : "right center"
},
"css" : {
"margin-left" : "-10px"
}
})
} else {
var u = "anon-vote-popup-" + c;
if (n.is(":working") || $("." + u).length)
return;
n.data("working", !0),
$(".anon-vote-popup").fadeOutAndRemove(),
StackExchange.helpers.removeMessages();
var d = $('<div class="anon-vote-popup popup">' + function (e) {
return "Sending feedback" + e.nbsp
}
({
"nbsp" : "&nbsp;"
}) + "</div>").addClass(u).addSpinner();
d.appendTo("body").center().fadeIn("fast"),
StackExchange.using("gps", function () {
StackExchange.gps.track("vote_popup.show")
}),
$.ajax({
"type" : "POST",
"url" : "/posts/popup/anon-vote/" + c + "?voteTypeId=" + (o ? 2 : 3),
"dataType" : "html",
"success" : function (e) {
d.html(e)
},
"error" : function () {
d.remove()
},
"complete" : function () {
n.data("working", !1)
}
})
}
} else if (r) {
if (StackExchange.options.inReadOnly)
return n.showErrorMessage("Favoriting isn't available in read-only mode.", {
"transient" : !0
}), void 0;
$(".anon-vote-popup").fadeOutAndRemove();
var l = s ? function (e) {
return "Please " + e.startAnchor + "log in or register" + e.endAnchor + " to favorite this answer."
}
({
"startAnchor" : '<a href="/users/login?returnurl=' + escape(document.location) + '">',
"endAnchor" : "</a>"
}) : function (e) {
return "Please " + e.startAnchor + "log in or register" + e.endAnchor + " to favorite this question."
}
({
"startAnchor" : '<a href="/users/login?returnurl=' + escape(document.location) + '">',
"endAnchor" : "</a>"
});
StackExchange.helpers.showMessage(t, l, {
"type" : "info",
"position" : {
"my" : "left top",
"at" : "right center"
},
"css" : {
"margin-left" : "-10px"
}
})
}
}
$(".vote-up-off, .vote-down-off, .star-off:not(.disabled)").each(function () {
var t = $(this);
t.data("bound-anonymous") || (t.data("bound-anonymous", !0), t.click(e))
}),
StackExchange.question.bindFetchAcceptedAnswerDates()
}, StackExchange.question.bindFetchAcceptedAnswerDates = function () {
$(".load-accepted-answer-date").hover(function () {
var e = $(this);
if (!e.is(":working")) {
e.working(!0);
var t = e.closest(".answer").data("answerid");
if (!t)
return e.attr("title", ""), void 0;
var n = "/posts/" + t + "/accepted-answer-date";
$.get(n, function (t) {
e.attr("title", t)
})
}
})
}, StackExchange.comments = function () {
function e(e, t) {
this.postId = e,
this.jDiv = t,
this.jtBody = t.find(" > table > tbody"),
this.jCommentsLink = $("#comments-link-" + e)
}
function t(e) {
var t = n($("#comments-" + e)),
i = t.jCommentsLink,
o = t.jtBody,
a = o.data("remaining-comments-count") || 0;
a++,
i.data("comments-count", a),
i.attr("title", "expand to show all comments on this post, or add one of your own"),
t.setCommentsMenu(a),
i.removeClass("disabled-link"),
o.data("remaining-comments-count", a),
i.show().fadeTo("fast", .7).fadeTo("fast", 1)
}
function n(t) {
var n = t.constructor === $ ? t : $(t),
i = n.closest(".question, .answer, div[id^='post-']").find(".comments"),
o = i.attr("id").replace(/^comments-/, "");
if (c[o])
return c[o];
var a = new e(o, i);
return c[o] = a,
a
}
function i(e) {
var t = $(this),
i = t.closest(".question, .answer, div[id^='post-']"),
a = i.find(".comments"),
r = a.find(" > table > tbody"),
s = 0 == r.data("remaining-comments-count"),
c = t.hasClass("disabled-link"),
l = t.parent(),
u = l.data("rep");
s && l.data("anon") && (StackExchange.options.isMobile ? StackExchange.helpers.showMessage(l, function (e) {
return "Commenting requires an account with " + e.rep + " reputation"
}
({
"rep" : u
}), {
"type" : "info",
"position" : {
"dimissible" : !0,
"my" : "left top",
"at" : "right center"
}
}) : o(l.attr("id").replace("comments-link-", ""))),
s && l.data("reg") && StackExchange.helpers.showMessage(l, function (e) {
return "You must have " + e.linkStart + e.rep + " reputation" + e.linkEnd + " to comment"
}
({
"rep" : u,
"linkStart" : "<a href='/help/privileges/comment'>",
"linkEnd" : "</a>"
}), {
"type" : "info",
"position" : {
"dimissible" : !0,
"my" : "left top",
"at" : "right center"
}
}),
(l.data("anon") || l.data("reg")) && StackExchange.using("gps", function () {
StackExchange.gps.track("comment_popup.show")
}),
t.hasClass("js-show-link") && StackExchange.using("gps", function () {
StackExchange.gps.track("comment.show")
});
var d = !1;
if (t.hasClass("js-add-link")) {
d = !0;
var h = "other";
i.hasClass("question") ? h = "question" : i.hasClass("answer") && (h = "answer");
var p = s ? "all_shown" : "hidden";
StackExchange.using("gps", function () {
StackExchange.gps.track("comment.add", {
"location" : h,
"type" : p
})
})
}
c || (e.preventDefault(), n(this).addShow(!1, d))
}
function o(e) {
var t = "anon-vote-popup-" + e;
if (!$("." + t).length) {
$(".anon-vote-popup").fadeOutAndRemove(),
StackExchange.helpers.removeMessages();
var n = $('<div class="anon-vote-popup popup">' + function (e) {
return "Loading" + e.nbsp
}
({
"nbsp" : "&nbsp;"
}) + "</div>").addClass(t).addSpinner();
n.appendTo("body").center().fadeIn("fast"),
$.ajax({
"type" : "POST",
"url" : "/posts/popup/anon-comment/" + e,
"dataType" : "html",
"success" : function (e) {
n.html(e)
},
"error" : function () {
n.remove()
}
})
}
}
function a(e) {
var t = e && e.post || document;
c = {},
$(t).off("click", "a.js-add-link", i).on("click", "a.js-add-link", i),
$(t).off("click", "a.js-show-link", i).on("click", "a.js-show-link", i),
t == document && s()
}
function r(t) {
for (var n in t)
t.hasOwnProperty(n) && (e.prototype[n] = t[n])
}
function s() {
if (0 != $(".question[data-questionid]").length) {
var e = StackExchange.question.getQuestionId();
$(".comment .comment-date > span").each(function () {
var t = $(this),
n = t.closest(".answer"),
i = n && n.length ? n.data("answerid") : 0,
o = t.closest(".comment").attr("id").substr("comment-".length),
a = i ? i : e,
r = "#comment" + o + "_" + a;
location.href.indexOf("/questions/") > 0 ? t.wrap('<a class="comment-link" href="{hash}"></a>'.formatUnicorn({
"hash" : r
})) : t.wrap('<a class="comment-link" href="/q/{pid}/{hash}"></a>'.formatUnicorn({
"hash" : r,
"pid" : a
}))
})
}
}
var c = {},
l = function () {};
return e.prototype = {
"checkDiscussion" : l,
"ensureInput" : l,
"saveEditingComments" : l,
"restoreEditingComments" : l,
"isInputShown" : function () {
var e = this.jDiv.find('form[id^="add-comment-"]');
return e.children().length && e.is(":visible")
},
"commentsShown" : function () {
this.jtBody.data("remaining-comments-count", 0)
},
"addShow" : function (e, t) {
var n = this,
i = this.loadAllComments().done(function () {
n.checkDiscussion()
});
if (t) {
var o = this.ensureInput();
o && !e && o.focus()
}
i.done(function () {
o && o.length > 0 && n.jCommentsLink.hide()
})
},
"ajax" : function (e, t, n, i) {
n && !i && StackExchange.helpers.addSpinner(n, {
"margin-left" : "10px"
});
var o = this;
return $.ajax(e).fail(function (e) {
var a = e.responseText;
(!a || a.indexOf("<html") >= 0) && (a = t || "An error occured"),
StackExchange.helpers.showErrorMessage(n || o.jDiv, a, {
"transient" : 409 == e.status
}),
n && !i && StackExchange.helpers.removeSpinner()
}).done(StackExchange.helpers.removeSpinner).promise()
},
"setCommentsMenu" : function (e) {
var t = "",
n = "";
e > 0 && (n = function (e) {
return 1 == e.count ? "show <b>" + e.count + "</b> more comment" : "show <b>" + e.count + "</b> more comments"
}
({
"count" : e
})),
this.isInputShown() || !this.jtBody.data("cansee") && !this.jtBody.data("canpost") || (t = "add a comment"),
t.length || n || !this.jtBody.data("comments-unavailable") || (t = "comments disabled on deleted / locked posts / reviews"),
StackExchange.options.inReadOnly && (t = ""),
this.jtBody.data("addlink-disabled") && this.jCommentsLink.find("a").addClass("disabled-link");
var i = this.jCommentsLink.find(".js-add-link"),
o = this.jCommentsLink.find(".js-show-link");
i.html(t),
o.html(n),
t.length ? i.removeClass("dno") : i.addClass("dno"),
n.length ? o.removeClass("dno") : o.addClass("dno"),
t.length && n.length ? this.jCommentsLink.find(".js-link-separator").removeClass("dno") : this.jCommentsLink.find(".js-link-separator").addClass("dno"),
this.jtBody.data("addlink-disabled") && (i.addClass("disabled-link"), o.addClass("disabled-link"))
},
"showComments" : function (e, t) {
this.saveEditingComments(t),
this.jtBody.html(e),
this.restoreEditingComments(),
this.setCommentsMenu(0),
"undefined" != typeof MathJax && MathJax.Hub.Queue(["Typeset", MathJax.Hub]),
s(),
this.commentsShown()
},
"loadAllComments" : function (e, t) {
this.jDiv.removeClass("dno");
var n = 0 == this.jtBody.data("remaining-comments-count");
if (!e && n)
return $.Deferred().resolve().promise();
var i = this;
return this.ajax({
"type" : "GET",
"url" : "/posts/" + this.postId + "/comments" + (t || ""),
"dataType" : "html"
}, "An error occurred while fetching comments").done(function (e) {
i.showComments(e)
}).promise()
}
}, {
"init" : a,
"loadAll" : function (e, t) {
return n(e).loadAllComments(!0, t)
},
"realtimeMessage" : t,
"extendPostUi" : r,
"uiForPost" : n
}
}
(), StackExchange.share = function () {
function e(e, t, n) {
window.open(e, t, n) || (window.location.href = e)
}
function t(e, t, n) {
n = "undefined" != typeof n ? n : "1",
t += "=" + n;
var i = e.indexOf("?"),
o = e.indexOf("#");
return -1 == i ? -1 == o ? e + "?" + t : e.substring(0, o) + "?" + t + e.substring(o) : -1 == o ? e + "&" + t : e.substring(0, o) + "&" + t + e.substring(o)
}
return {
"gplus" : function (n, i, o, a) {
i = t(i, "sgp", a),
n.click(function () {
e("https://plus.google.com/share?url=" + encodeURIComponent(i), "sharegplus", "toolbar=1,status=1,resizable=1,scrollbars=1,width=600,height=500")
})
},
"twitter" : function (n, i, o, a) {
i = t(i, "stw", a);
var r = 117;
o.length > r && (o = o.substring(0, r - 3) + "..."),
n.click(function () {
e("http://twitter.com/share?url=" + encodeURIComponent(i) + "&ref=twitbtn&text=" + encodeURIComponent(o), "sharetwitter", "toolbar=1,status=1,resizable=1,scrollbars=1,width=800,height=526")
})
},
"facebook" : function (n, i, o, a) {
i = t(i, "sfb", a),
n.click(function () {
e("http://www.facebook.com/sharer.php?u=" + encodeURIComponent(i) + "&ref=fbshare&t=" + encodeURIComponent(o), "sharefacebook", "toolbar=1,status=1,resizable=1,scrollbars=1,width=626,height=436")
})
}
}
}
(), $.fn.extend({
"postId" : function () {
var e = this.first();
return e.hasClass("answer") && e.hasClass("question") || (e = e.closest(".answer, .question")),
parseInt(e.find(".vote input")[0].value)
}
}), StackExchange.newsletterAd = function () {
function e(e) {
var t = $('<div id="lightbox-panel" class="popup newsletter-popup" style="display:block"></div>').append($("<div />", {
"class" : "popup-close"
}).append("<a>&times;</a>", {
"title" : "close this popup (or hit Esc)"
})).append(e);
$('<div id="lightbox"></div>').appendTo($("body")).css("height", $(document).height()).fadeIn("fast"),
t.appendTo($("body")).center().fadeIn("fast").find(".popup-close").click(function () {
$("#lightbox, #lightbox-panel").fadeOutAndRemove()
})
}
function t() {
var t = StackExchange.options.site.name,
n = $(['<div style="text-align: left;">', '<h2 style="margin-bottom: 15px;">', function (e) {
return "Subscribe to the " + e.site + " weekly newsletter"
}
({
"site" : t
}), "</h2>", '<p><strong><a href="/users/login?returnurl=/newsletter/signup/redirect">', function (e) {
return "Create an account on " + e.site + e.endAnchor + " or " + e.loginAnchor + "log in" + e.endAnchor + " if you already have one."
}
({
"site" : t,
"loginAnchor" : '<a href="/users/login?returnurl=/newsletter/signup/redirect">',
"endAnchor" : "</a>"
}), "</strong></p>", '<form><label for="newsletter-email-input">', "Or, send newsletter emails to:", "</label> ", $("<input>", {
"type" : "text",
"id" : "newsletter-email-input",
"maxlength" : "100",
"title" : "your email address"
}).prop("outerHTML"), " ", $("<input>", {
"type" : "submit",
"id" : "newsletter-email-submit",
"value" : "Subcribe"
}).prop("outerHtml"), "</form>", $("#newsletter-ad .privacy-policy-agreement").parent().html(), "</div>"].join(""));
n.find("form").submit(function () {
var e = $(this),
t = e.find("#newsletter-email-input"),
n = e.find("#newsletter-email-submit"),
i = $.trim(t.val());
return 0 == i.length ? !1 : (StackExchange.helpers.addSpinner(e), $.ajax({
"url" : "/newsletter/signup/anon",
"type" : "POST",
"dataType" : "json",
"data" : {
"email" : i
},
"success" : function (i) {
"confirmed" != i.status || i.error ? "unconfirmed" != i.status || i.error ? e.showErrorMessage(i.error || function (e) {
return "there was a problem signing up for the newsletter" + e.br + "please try again later"
}
({
"br" : "<br />"
})) : (t.attr("disabled", !0), n.replaceWith('<span style="line-height: 120%; text-align: center;"><strong>Subscribed!</strong></span>'), e.append("<br /><br/><p><em>Please click the link in the confirmation email to activate your subscription.</em></p>"), $("#newsletter-signup-container").replaceWith('<span style="line-height: 120%;"><strong>Success!</strong> Please click the link in the confirmation email to activate your subscription.</span>')) : (t.attr("disabled", !0), n.replaceWith('<span style="line-height: 120%; text-align: center;"><strong>Subscribed!</strong></span>'), $("#newsletter-signup-container").replaceWith('<div style="line-height: 200%; text-align: center;"><strong>Subscribed!</strong></div>'))
},
"error" : function () {
e.showErrorMessage(function (e) {
return "there was a problem signing up for the newsletter" + e.br + "please try again later"
}
({
"br" : "<br />"
}))
},
"complete" : function () {
StackExchange.helpers.removeSpinner(e)
}
}), !1)
}),
e(n)
}
function n() {
$("#newsletter-signup").click(function () {
var e = $(this);
return StackExchange.options.user.isAnonymous ? (t(), !1) : (StackExchange.helpers.addSpinner("#newsletter-signup-container"), $.ajax({
"url" : "/newsletter/signup",
"type" : "POST",
"dataType" : "json",
"success" : function (t) {
t.url ? window.location.href = t.url : "confirmed" == t.status ? $("#newsletter-signup-container").replaceWith('<div style="line-height: 200%; text-align: center;"><strong>Subscribed!</strong></div>') : "unconfirmed" == t.status ? $("#newsletter-signup-container").replaceWith('<span style="line-height: 120%;"><strong>Success!</strong> Please click the link in the confirmation email to activate your subscription.</span>') : e.parent().showErrorMessage(function (e) {
return "there was a problem signing up for the newsletter" + e.br + "please try again later"
}
({
"br" : "<br />"
}))
},
"error" : function () {
e.parent().showErrorMessage(function (e) {
return "there was a problem signing up for the newsletter" + e.br + "please try again later"
}
({
"br" : "<br />"
}))
},
"complete" : function () {
StackExchange.helpers.removeSpinner("#newsletter-signup-container")
}
}), void 0)
}),
$("#newsletter-preview").click(function () {
var t = $(window).height(),
n = Math.min(600, t - 100),
i = ['<div id="newsleter-preview-pane" style="overflow: hidden; width: 660px; height: ', n, 'px;">', '<iframe src="', $(this).attr("href"), '&suppressPromotion=true" width="660" height="', n, '" frameborder="0"></iframe>', "</div>"].join("");
return e(i),
!1
})
}
return {
"init" : n,
"loader" : function (e, t) {
var e = t || e,
n = $(".newuser-greeting");
$.ajax({
"url" : "/newsletter/targetted/ajax",
"data" : {
"domain" : e
},
"success" : function (e) {
$("#newsletter-ad").remove(),
n.empty().append($(e))
},
"complete" : function () {
n.attr("class", "").attr("style", "")
}
}),
t || (window.sessionStorage.tNewsletter = e + "-continued")
}
}
}
(), function (e, t, n, i) {
var o = !("selectionStart" in e("<input type='text' />")[0]);
e.fn.caret = function (e, a) {
var r,
s,
c = this[0];
if ("object" == typeof e && "number" == typeof e.start && "number" == typeof e.end)
r = e.start, s = e.end;
else if ("number" == typeof e && "number" == typeof a)
r = e, s = a;
else if ("string" == typeof e)
(r = c.value.indexOf(e)) > -1 ? s = r + e[t] : r = null;
else if ("[object RegExp]" === Object.prototype.toString.call(e)) {
var l = e.exec(c.value);
null != l && (r = l.index, s = r + l[0][t])
}
if ("undefined" != typeof r) {
if (o) {
var u = this[0].createTextRange();
u.collapse(!0),
u.moveStart("character", r),
u.moveEnd("character", s - r),
u.select()
} else
this[0].selectionStart = r, this[0].selectionEnd = s;
return this[0].focus(),
this
}
if (o) {
var d = document.selection;
if ("textarea" != this[0].tagName.toLowerCase()) {
var h = this.val(),
p = d[n]()[i]();
p.moveEnd("character", h[t]);
var f = "" == p.text ? h[t] : h.lastIndexOf(p.text);
p = d[n]()[i](),
p.moveStart("character", -h[t]);
var g = p.text[t]
} else {
var p = d[n](),
m = p[i]();
m.moveToElementText(this[0]),
m.setEndPoint("EndToEnd", p);
var f = m.text[t] - p.text[t],
g = f + p.text[t]
}
} else
var f = c.selectionStart, g = c.selectionEnd;
var v = c.value.substring(f, g);
return {
"start" : f,
"end" : g,
"text" : v,
"replace" : function (e) {
return c.value.substring(0, f) + e + c.value.substring(g, c.value[t])
}
}
}
}
(jQuery, "length", "createRange", "duplicate"), StackExchange.captcha = function () {
function e(e, t) {
function n() {
$("#lightbox, #lightbox-panel").fadeOutAndRemove()
}
var i = $(['<div id="lightbox-panel" class="popup captcha-popup" style="display: block; text-align: left;">', '<div class="popup-close">', $("<a>", {
"title" : "close this popup (or hit Esc)",
"text" : "×"
}).prop("outerHTML"), "</div>", e, "</div>"].join("")),
o = i.find("form:first");
$('<div id="lightbox"></div>').appendTo($("body")).css("height", $(document).height()).fadeIn("fast"),
i.appendTo($("body")).center().fadeIn("fast").find(".popup-close").click(n),
$.getScript("https://www.google.com/recaptcha/api/js/recaptcha_ajax.js", function () {
Recaptcha.create(StackExchange.options.site.recaptchaPublicKey, "recaptcha", {
"theme" : "clean",
"lang" : StackExchange.options.site.recaptchaAudioLang,
"custom_translations" : {
"visual_challenge" : "Get a visual challenge",
"audio_challenge" : "Get an audio challenge",
"refresh_btn" : "Get a new challenge",
"instructions_visual" : "Type the text:",
"instructions_audio" : "Type what you hear:",
"help_btn" : "Help",
"play_again" : "Play sound again",
"cant_hear_this" : "Download sound as MP3",
"incorrect_try_again" : "Incorrect. Try again.",
"image_alt_text" : "reCAPTCHA challenge image",
"privacy_and_terms" : "Privacy & Terms"
},
"callback" : Recaptcha.focus_response_field
}),
StackExchange.helpers.enableSubmitButton(o),
o.submit(function () {
return StackExchange.helpers.disableSubmitButton(o),
o.find('input[type="submit"]').addSpinnerAfter(),
$.ajax({
"url" : "/captcha",
"type" : "POST",
"dataType" : "json",
"data" : o.serialize(),
"success" : function (e) {
e.captchaError ? (StackExchange.helpers.removeSpinner(), StackExchange.helpers.enableSubmitButton(o), o.find(".form-error").html(e.captchaError), Recaptcha.reload()) : (n(), t(e))
},
"error" : function () {
StackExchange.helpers.removeSpinner(),
StackExchange.helpers.enableSubmitButton(o),
StackExchange.helpers.showErrorMessage(o, "An error occurred submitting the CAPTCHA")
}
}),
!1
})
})
}
return {
"init" : e
}
}
(), StackExchange.gps = function () {
function e(e) {
return g ? !0 : (g = !0, e && t() ? (c(), a(), n(".tagged-questions-page, .questions-page, .tags-page", ".js-gps-related-tags .post-tag", "related_tags.click", ", item_type:1"), n(".question-page", ".js-gps-related-questions .spacer", "related_questions.click"), n(".question-page .post-taglist", ".post-tag", "question_tags.click", ", location:1"), n(".question-page #sidebar .tagged", ".post-tag", "question_tags.click", ", location:2"), i(), !0) : (StackExchange.gps.track = function (e, t, n, i) {
i && i()
}, delete StackExchange._gps_track, !1))
}
function t() {
if (!window.localStorage)
return !1;
try {
if (window.localStorage["gps-probe"] = "1", "1" != window.localStorage["gps-probe"])
return !1;
window.localStorage.removeItem("gps-probe")
} catch (e) {
return !1
}
return !0
}
function n(e, t, n, i) {
$(e).find(t).each(function (e) {
$(this).addClass("js-gps-track").data("gps-track", n + "({ position:" + (e + 1) + i + " })")
})
}
function i(e) {
$(e || document).find(".js-gps-track").off("click.gps").one("click.gps", function () {
var e = $.trim($(this).data("gps-track"));
if (e)
for (var t = o(e), n = 0; n < t.length; n++) {
var i = t[n];
r(i[0], i[1], !0)
}
})
}
function o(e) {
for (var t = [], n = e.match(/([a-z._]+)(\([^)]+\))?/gi), i = 0; i < n.length; i++) {
var o = n[i];
if (o.indexOf("{") < 0)
t.push([o, {}
]);
else {
for (var a = o.match(/([a-z._]+)\s*\(\s*\{([^}]+)\}\s*\)/i), r = a[1], s = $.trim(a[2]), c = s.match(/[^,]+/gi), l = {}, u = 0; u < c.length; u++) {
var d = c[u],
h = d.indexOf(":"),
p = $.trim(d.substr(0, h)),
f = $.trim(d.substr(h + 1)),
g = parseInt(f);
l[p] = 0 / 0 != g ? g : f
}
t.push([r, l])
}
}
return t
}
function a(e) {
var t = l();
if (t.length > 0) {
for (var n = (new Date).getTime(), i = [], o = 0; o < t.length && i.length < 20; o++) {
var a = t[o],
r = n - a.now;
0 > r || r > 36e5 ? d(a) : i.push(a)
}
i.length > 0 ? h(i, e) : e && e()
}
}
function r(e, t, n, i) {
var o = {
"evt" : e,
"properties" : t || {},
"now" : (new Date).getTime()
};
u(o),
navigator && navigator.sendBeacon && (n = !1),
n ? (i && i(), window.setTimeout(a, 1e4)) : a(i)
}
function s(e) {
e && StackExchange.options && StackExchange.options.user && (e.properties && !e.properties.user_type && (e.properties.user_type = StackExchange.options.user.user_type), !e.ab && StackExchange.options.user.ab && (e.ab = StackExchange.options.user.ab))
}
function c() {
StackExchange._gps_track && ($.each(StackExchange._gps_track, function (e, t) {
u(t)
}), delete StackExchange._gps_track)
}
function l() {
var e = localStorage[f];
return e ? JSON.parse(e) : []
}
function u(e) {
s(e);
var t,
n = localStorage[f];
if (n) {
var i = JSON.parse(n);
i.push(e),
t = JSON.stringify(i)
} else
t = JSON.stringify([e]);
p("addToPending " + JSON.stringify(e)),
localStorage[f] = t
}
function d(e) {
var t = localStorage[f];
if (t) {
for (var n = JSON.parse(t), i = JSON.stringify(e), o = -1, a = 0; a < n.length; a++) {
var r = JSON.stringify(n[a]);
if (i == r) {
o = a;
break
}
}
if (-1 != o)
return n.splice(o, 1), 0 == n.length ? (localStorage.removeItem(f), void 0) : (localStorage[f] = JSON.stringify(n), void 0)
}
}
function h(e, t) {
$.isArray(e) || (e = [e]);
for (var n = 0; n < e.length; n++) {
var i = JSON.stringify(e[n]);
m[i] && (e.splice(n, 1), n--)
}
for (var n = 0; n < e.length; n++) {
var i = JSON.stringify(e[n]);
m[i] = !0
}
var o = JSON.stringify(e);
if (navigator && navigator.sendBeacon)
try {
if (p("sending (beacon): " + o), navigator && navigator.sendBeacon("/gps/event", o)) {
for (var n = 0; n < e.length; n++) {
d(e[n]);
var i = JSON.stringify(e[n]);
delete m[i]
}
return t && t(),
void 0
}
} catch (a) {
p(a)
}
p("sending (AJAX): " + o),
$.ajax({
"type" : "POST",
"url" : "/gps/event",
"data" : o,
"success" : function () {
for (var t = 0; t < e.length; t++)
d(e[t])
},
"complete" : function () {
for (var n = 0; n < e.length; n++) {
var i = JSON.stringify(e[n]);
delete m[i]
}
t && t()
}
})
}
function p(e) {
StackExchange.options.enableLogging && console.log("gps: " + e)
}
var f = "gps-pending",
g = !1,
m = {};
return {
"init" : e,
"track" : r,
"sendPending" : a,
"bindTrackClicks" : i
}
}
(), StackExchange.openid = function () {
function e(e) {
e && StackExchange.gps.track("openid.click", {
"openid_provider" : e,
"location" : l
}, !0),
StackExchange.gps.track("signup.start", {
"location" : "question_page"
}, !0)
}
function t(t, n) {
var u = decodeURIComponent(n);
0 === u.indexOf("/questions/") && (l = "question_page"),
"/questions/ask" === u && (l = "question_ask");
var d = $(t),
h = d.find(".new-login-left"),
p = d.find(".new-login-right"),
f = h.find(".show-more-options");
f.click(function () {
return f.hide(),
p.show(),
!1
});
var g = p.find(".hide-more-options");
g.click(function () {
return f.show(),
p.hide(),
!1
}),
d.removeClass("dno"),
i(d, p);
var m = h.find(".google-login");
StackExchange.options.site.useGoogleOAuth2 ? m.click(function () {
e("Google"),
r(d)
}) : m.click(function () {
e("Google"),
o(d, "google")
});
var v = h.find(".facebook-login");
v.click(function () {
e("Facebook"),
a(d)
});
var b = h.find(".stackexchange-login");
b.click(s(function () {
e("Stack Exchange"),
StackExchange.navPrevention.stop(),
window.location = "/users/signup?returnUrl=" + encodeURIComponent(u)
})),
d.find(".submit-openid").click(function () {
c(d, u)
})
}
function n(t, n, i, s, u) {
var d = decodeURIComponent(n);
l = i;
var h = t.find(".google-login");
StackExchange.options.site.useGoogleOAuth2 ? h.click(function () {
e("Google"),
r(t)
}) : h.click(function () {
e("Google"),
o(t, "google")
});
var p = t.find(".facebook-login");
p.click(function () {
e("Facebook"),
a(t)
});
var f = t.find(".stackexchange-login");
f.click(function () {
e("Stack Exchange"),
window.location = "/users/signup?returnUrl=" + encodeURIComponent(d)
}),
t.find(".submit-openid").click(function () {
c(t, d, s, u)
})
}
function i(e, t) {
var n = t.find(".option-extra-fields");
n.hide();
var i = t.find(".yahoo-button");
i.click(function () {
n.hide(),
o(e, "yahoo")
});
var a = function (i) {
var a = "." + i + "-option";
n.show(),
n.find("> div:not(" + a + ")").hide(),
n.find(a + ", .extra-field-container").show(),
t.find(".extra-field").val("").focus();
var r = t.find(".extra-field-submit");
r.unbind("click"),
r.click(function () {
o(e, i, t.find(".extra-field").val())
})
},
r = t.find(".blogger-button");
r.click(function () {
a("blogger")
});
var s = t.find(".aol-button");
s.click(function () {
a("aol")
})
}
function o(e, t, n) {
var i = u[t];
n && (i = i.replace("{username}", n)),
e.find(".use-facebook").val(""),
e.find(".use-google-oauth2").val(""),
e.find(".manual-openid").val(i),
e.find(".submit-openid").click()
}
function a(e) {
e.find(".use-facebook").val("true"),
e.find(".use-google-oauth2").val(""),
e.find(".manual-openid").val(""),
e.find(".submit-openid").click()
}
function r(e) {
e.find(".use-google-oauth2").val("true"),
e.find(".use-facebook").val(""),
e.find(".manual-openid").val(""),
e.find(".submit-openid").click()
}
function s(e) {
return function () {
StackExchange.using("editor", function () {
StackExchange.cardiologist.ensureDraftSaved(e)
})
}
}
function c(e, t, n, i) {
var o = e.find(".manual-openid").val(),
a = e.find(".use-facebook").val(),
r = e.find(".use-google-oauth2").val();
s(function () {
var e = !!StackExchange.options.site.isChildMeta,
s = (e ? StackExchange.options.site.parentUrl : "") + "/users/authenticate?returnurl=" + encodeURIComponent(t),
c = $('<form method="post" action="' + s + '"></form>');
if (o) {
var l = $('<input type="hidden" name="openid_identifier" />');
c.append(l),
l.val(o)
} else {
var u = $('<input type="hidden" name="oauth_version" />'),
d = $('<input type="hidden" name="oauth_server" />');
c.append(u),
c.append(d),
u.val("2.0"),
a ? d.val("https://www.facebook.com/dialog/oauth") : r && d.val("https://accounts.google.com/o/oauth2/auth")
}
c.append("<input type='hidden' name='fkey' value='" + StackExchange.options.user.fkey + "' />"),
n && i && ($('<input type="hidden" name="anon_vote_type" />').val(n).appendTo(c), $('<input type="hidden" name="anon_vote_hash" />').val(i).appendTo(c)),
StackExchange.navPrevention.stop(),
c.hide().appendTo("body").submit()
})()
}
var l = "unknown",
u = {
"yahoo" : "http://yahoo.com/",
"google" : "https://www.google.com/accounts/o8/id",
"aol" : "http://openid.aol.com/{username}",
"blogger" : "http://{username}.blogspot.com/"
};
return {
"initPostLogin" : t,
"initAnonPopup" : n
}
}
(), StackExchange.loggedIn = {}, StackExchange.tagPreferences = function () {
function e(e) {
return e = e.replace(/#/g, "ñ").replace(/\+/g, "ç").replace(/\./g, "û"),
/\*/.test(e) ? "div.tags:regex(class, t-" + e.replace(/\*/g, ".*") + ")" : "div.t-" + e
}
function t(e, t, n) {
var i = "";
"undefined" != typeof forUserId && (i = forUserId),
$.post("/users/save-preference", {
"fkey" : StackExchange.options.user.fkey,
"key" : e,
"value" : t,
"forUserId" : i
}, n)
}
var n = [],
i = $('<table><tr><td class="vt"><input type="text" id="interestingTag" name="interestingTag"></td> <td class="vt"><input id="interestingAdd" type="button" value="Add"></td> </tr></table>'),
o = $('<table><tr><td class="vt"><input type="text" id="ignoredTag" name="ignoredTag"></td> <td class="vt"><input id="ignoredAdd" type="button" value="Add"></td> </tr></table>'),
a = function (t, n) {
return t.map(function (e, t) {
return $(t).text()
}).filter(function (e, t) {
if (!n)
return !0;
var i;
/\*/.test(t) && (i = new RegExp(t.replace(/([.+])/g, "\\$1").replace(/\*/g, ".*")));
for (var e = 0; e < n.length; e++) {
var o = n[e];
if (t === o)
return !1;
if (i && i.test(o))
return !1
}
return !0
}).map(function (t, n) {
return e(n)
}).get().join(",")
},
r = function (e, n, i, o, a, r) {
for (var c = $(e).val(), l = sanitizeAndSplitTags(c, !0), d = !1, h = 0; h < l.length; h++)
if (0 != $.trim(l[h]).length) {
if ($(n).children().each(function () {
return $(this).text() == l[h] ? ($(this).fadeTo(500, .1).fadeTo(500, 1), d = !0, void 0) : void 0
}), !d) {
var p = encodeURIComponent(l[h]),
f = $("<a>").attr({
"id" : l[h],
"href" : "/questions/tagged/" + p,
"class" : o,
"title" : function (e) {
return "show questions tagged '" + e.tag + "'"
}
({
"tag" : l[h]
})
}).text(l[h]);
$(n).append(f),
$(n).append(" "),
s(i)
}
d = !1
}
$(e).val(""),
a && $(e).focus(),
r || t(i, $(n).text()),
u()
},
s = function (e) {
var n = 20 == e ? "#interestingTags > .post-tag:last" : 25 == e ? "#ignoredTags > .post-tag:last" : 40 == e ? "#interestingTags > .post-tag" : 45 == e ? "#ignoredTags > .post-tag, #remainingIgnored > .post-tag" : "#interestingTags > .post-tag, #ignoredTags > .post-tag",
i = function (e) {
var n = $(e.target),
i = n.closest(".post-tag"),
o = i.closest("div"),
a = o.is("#ignoredTags") ? 25 : o.is("#interestingTags") ? 20 : -1;
return -1 === a ? console.log("removeTag: unknown container. Stopping execution. '" + o.text() + "'") : (i.remove(), t(a, o.text()), u()),
!1
};
$("<span>").addClass("delete-tag").attr("title", "remove this tag").appendTo($(n)).click(i)
},
c = function () {
return $("#hideIgnoredTrue").is(":checked") ? !0 : $("#hideIgnoredFalse").is(":checked") ? !1 : $("#hideIgnored").is(":checked")
},
l = function (e) {
var t = $("#ignoredTags > a, #remainingIgnored > a");
if (c()) {
var n = a(t, !0);
if (n.length > 0)
return $(e).find(n).length > 0
}
},
u = function (e, t) {
if (t)
for (var i = 0; i < t.length; i++)
- 1 == n.indexOf(t[i]) && n.push(t[i]);
t = n;
var o = $("#ignoredTags > a, #remainingIgnored > a"),
r = $("#interestingTags > a");
if (!e || 0 != o.length || 0 != r.length) {
$("div.question-summary").removeClass("tagged-ignored tagged-ignored-hidden tagged-interesting");
var s = a(o, t),
l = a(r, t);
if (s.length > 0) {
var u = c() ? "tagged-ignored-hidden" : "tagged-ignored";
$(s).closest("div.question-summary").addClass(u)
}
l.length > 0 && $(l).closest("div.question-summary").addClass("tagged-interesting")
}
},
d = function (e, t) {
var n,
i = $("#tag-menu");
"favorite" == t && (n = $("#ignoredTags a").filter(function () {
return $(this).text() == e
}), n.add(n.next()).remove(), $("#interestingTag").val(e), r("#interestingTag", "#interestingTags", 20, "post-tag", !1, !0)),
"ignore" == t && (n = $("#interestingTags a").filter(function () {
return $(this).text() == e
}), n.add(n.next()).remove(), $("#ignoredTag").val(e), r("#ignoredTag", "#ignoredTags", 25, "post-tag", !1, !0)),
"clear" == t && (n = $("#ignoredTags a").filter(function () {
return $(this).text() == e
}), n.add(n.next()).remove(), n = $("#interestingTags a").filter(function () {
return $(this).text() == e
}), n.add(n.next()).remove(), u()),
StackExchange.helpers.addSpinner(i),
$.ajax({
"type" : "POST",
"url" : "/tags/" + encodeURIComponent(e) + "/favorite",
"data" : {
"action" : t,
"fkey" : StackExchange.options.user.fkey
},
"dataType" : "html",
"success" : function (t) {
p(i.html($("" + t)), e)
},
"error" : function () {},
"complete" : StackExchange.helpers.removeSpinner
})
},
h = function (e, t) {
var n = $("#tag-menu");
StackExchange.helpers.addSpinner(n),
$.ajax({
"type" : "POST",
"url" : "/tags/" + encodeURIComponent(e) + "/subscription",
"data" : {
"unsubscribe" : t,
"fkey" : StackExchange.options.user.fkey
},
"dataType" : "html",
"success" : function (t) {
p(n.html($("" + t)), e)
},
"error" : function () {},
"complete" : StackExchange.helpers.removeSpinner
})
},
p = function (e, t) {
e.find(".tm-se-subscription").click(function () {
h(t, $(this).hasClass("tm-se-unsubscribe"))
}).end().find(".tm-favorite, .tm-favorite-clear, .tm-favorite-ignore").click(function () {
$(this).hasClass("tm-favorite") ? d(t, "ignore") : $(this).hasClass("tm-favorite-clear") ? d(t, "favorite") : $(this).hasClass("tm-favorite-ignore") && d(t, "clear")
})
},
f = function (e) {
e && s(40),
$("#add-interesting").append(i);
i.find("#interestingAdd").unbind("click").bind("click", function () {
r("#interestingTag", "#interestingTags", 20, "post-tag user-tag", !0),
$("#tag-subscriptions").removeClass("dno")
});
StackExchange.using("tagAutocomplete", function () {
bindTagFilterAutoComplete("#interestingTag")
}),
S()
},
g = function (e) {
$("#tag-pref-prefs").removeClass("dno"),
e && s(45),
$("#add-ignored").append(o);
o.find("#ignoredAdd").unbind("click").bind("click", function () {
r("#ignoredTag", "#ignoredTags", 25, "post-tag user-tag", !0)
});
StackExchange.using("tagAutocomplete", function () {
bindTagFilterAutoComplete("#ignoredTag")
}),
S()
},
m = function (e) {
if ($.contains(document.documentElement, e.target) && !$(e.target).closest("#interesting-tags").length) {
var t = $("#interestingTags > .post-tag").length > 0,
n = $("#ignoredTags > .post-tag, #remainingIgnored > .post-tag").length > 0;
t ? b() : v(),
n ? x() : w(),
$("#interesting-tags .delete-tag").remove(),
T(),
$(document).off("click", m)
}
},
v = function () {
$("#add-interesting table").remove(),
$("#edit-interesting").removeClass("dno"),
$("#tag-subscriptions").removeClass("dno").addClass("dno"),
$("#addInterestingTag").removeClass("dno")
},
b = function () {
$("#add-interesting table").remove(),
$("#edit-interesting").removeClass("dno"),
$("#tag-subscriptions").removeClass("dno").addClass("dno"),
$("#addInterestingTag").removeClass("dno").addClass("dno")
},
w = function () {
$("#add-ignored table").remove(),
$("#edit-ignored").removeClass("dno").addClass("dno"),
$("#addIgnoredTag").removeClass("dno")
},
x = function () {
$("#add-ignored table").remove(),
$("#edit-ignored").removeClass("dno"),
$("#addIgnoredTag").removeClass("dno").addClass("dno")
},
y = function () {
$("#showRemainingIgnored").addClass("dno"),
$("#remainingIgnored").removeClass("dno")
},
k = function () {
$("#addInterestingTag").on("click", function () {
$(this).addClass("dno"),
f(!1)
}),
$("#addIgnoredTag").on("click", function () {
$(this).addClass("dno"),
g(!1)
}),
$("#edit-interesting").on("click", function () {
$(this).addClass("dno"),
$("#addInterestingTag").addClass("dno"),
$("#tag-subscriptions, #ignored-wrapper").removeClass("dno"),
$("#edit-ignored").length || g(!0),
f(!0)
}),
$("#edit-ignored").on("click", function () {
$(this).addClass("dno"),
g(!0)
}),
$("#showRemainingIgnored").on("click", function () {
y()
})
},
S = function () {
$(document).on("click", m)
},
C = !1,
E = function () {
C = !0
},
T = function () {
C && $("#addIgnoredTag, #edit-ignored, #addInterestingTag, #edit-interesting, #showRemainingIgnored").trigger("click")
};
return {
"applyPrefs" : u,
"isIgnored" : l,
"forceEditMode" : E,
"init" : function () {
StackExchange.tagmenu.init(p),
0 != $("#interestingTags").length && (k(), S(), $("#hideIgnored, #hideIgnoredTrue, #hideIgnoredFalse").click(function () {
t(30, c()),
u()
}), T())
}
}
}
(), StackExchange.question.fullInit = function (e) {
if (window.votesCast = e.votesCast, StackExchange.vote.init(e.questionId), StackExchange.question.bindSuggestedEditPopupLinks(), StackExchange.vote_bounty.init(e), /^#autocomment/.test(window.location.hash)) {
var t = $(".comments-link:first"),
n = "#comment-" + window.location.hash.substring(12),
i = function () {
var t = $(n),
i = $("<span><b>Trivial answer converted to comment</b></span>");
t.find(".comment-date").append($("<br>")).append(i),
t.css({
"backgroundColor" : e.highlightColor
}),
t.animate({
"backgroundColor" : e.backgroundColor
}, 2e3, "linear", function () {
$(this).css("background-color", "")
}),
$(n)[0].scrollIntoView(!0)
};
e.totalCommentCount && e.shownCommentCount && e.totalCommentCount != e.shownCommentCount ? StackExchange.comments.loadAll(t).done(i) : i()
}
}, StackExchange.question.bindSuggestedEditPopupLinks = function () {
function e(e) {
var t = e.parent(),
n = e.attr("id").substring("edit-pending-".length);
e.data("working") || (e.data("working", !0).addSpinnerAfter({
"padding" : "3px 0"
}), $.ajax({
"type" : "GET",
"url" : "/review/suggested-edit-popup/" + n,
"dataType" : "html",
"success" : function (e) {
var n = $(['<div id="lightbox-panel" class="popup popup-suggested-edit no-auto-close" style="display: block;">', '<div class="popup-controls">', '<div class="handle"></div>', '<div class="popup-close"><a title="close this popup (or hit Esc)">&times;</a></div>', "</div>", '<div class="suggested-edit-container">', e, "</div>", "</div>"].join("")),
i = $(window).height(),
o = (n.find(".popup-suggested-edit").css({
"max-height" : i - 100
}), $('<div id="lightbox" class="no-esc-remove"/>').appendTo($("body")).css("height", $(document).height()).fadeIn("fast"));
n.appendTo(t).css("height", "600px").center().css("height", "").fadeIn("fast");
var a = function () {
var e = $.Event("suggestedEditPopupClose");
n.trigger(e),
e.isDefaultPrevented() || (StackExchange.helpers.closePopups(n), StackExchange.helpers.closePopups(o))
},
r = function (e) {
return 27 == e.which ? (a(), !1) : void 0
},
s = function () {
return a(),
!1
};
$(document).bind("keydown", r),
o.mousedown(s),
n.find(".popup-close").click(s),
n.bind("popupClose", function () {
$(document).unbind("keydown", r)
}),
StackExchange.helpers.bindMovablePopups()
},
"error" : function (e) {
t.showErrorMessage(e.responseText && e.responseText.length < 200 ? e.responseText : "Unable to load suggested edit - please try again")
},
"complete" : function () {
StackExchange.helpers.removeSpinner(),
e.removeData("working")
}
}))
}
$('div.post-menu a[id^="edit-pending-"]').each(function () {
$(this).unbind("click").click(function () {
return e($(this)),
!1
})
})
}, StackExchange.vote = function () {
var e = StackExchange.helpers,
t = {
"informModerator" : -1,
"undoMod" : 0,
"acceptedByOwner" : 1,
"upMod" : 2,
"downMod" : 3,
"offensive" : 4,
"favorite" : 5,
"close" : 6,
"reopen" : 7,
"bountyClose" : 9,
"deletion" : 10,
"undeletion" : 11,
"spam" : 12
},
n = "View upvote and downvote totals",
i = function (e) {
var t = e ? e.closest("div.vote") : $("div.vote"),
n = $("body.read-only").length > 0,
i = t.hasClass("vote-election-primary");
t.find(".vote-up-off, .vote-down-off").each(function () {
var e,
t,
o,
a,
r = $(this);
if (n)
e = "Voting is disabled while the site is in readonly mode";
else {
if (t = r.hasClass("vote-up-off"), o = (t ? f : g)(r), a = r.closest(".answer").length > 0, i)
return;
e = a ? t ? "This answer is useful" : "This answer is not useful" : t ? "This question shows research effort; it is useful and clear" : "This question does not show any research effort; it is unclear or not useful",
e += StackExchange.loggedIn && o ? " (click again to undo)" : ""
}
r.attr("title", e)
})
},
o = function (e) {
e || (e = "div.vote"),
$(e).find(".vote-up-off").unbind("click").click(function () {
l($(this))
}),
$(e).find(".vote-down-off").unbind("click").click(function () {
u($(this))
})
},
a = function (e) {
var t = e ? e.closest("div.vote") : $("div.vote");
return t.find(".vote-up-off, .vote-down-off").unbind("click")
},
r = function (e) {
$.each(e, function () {
var e = $("div.vote:has(input[value=" + this.PostId + "])");
switch (this.VoteTypeId) {
case t.upMod:
e.find(".vote-up-off").addClass("vote-up-on");
break;
case t.downMod:
e.find(".vote-down-off").addClass("vote-down-on");
break;
case t.favorite:
e.find(".star-off").addClass("star-on"),
e.find("div.favoritecount b").addClass("favoritecount-selected");
break;
default:
StackExchange.debug.log("site.vote.js > highlightExistingVotes has no case for " + this.VoteTypeId)
}
}),
votesCast = null
},
s = function (e) {
$.ajax({
"type" : "GET",
"url" : "/posts/" + e + "/votes",
"dataType" : "json",
"success" : r
})
},
c = function (e) {
null == window.votesCast ? s(e) : r(window.votesCast),
o(),
i()
},
l = function (e) {
var n = e.parent().find(".vote-up-off"),
i = e.parent().find(".vote-down-off"),
o = f(n),
a = g(i),
r = o ? -1 : a ? 2 : 1;
x(e, r),
w(n, i),
o || n.addClass("vote-up-on"),
y(e, o ? t.undoMod : t.upMod)
},
u = function (e) {
var n = e.parent().find(".vote-up-off"),
i = e.parent().find(".vote-down-off"),
o = g(i),
a = f(n),
r = o ? 1 : a ? -2 : -1;
x(e, r),
w(n, i),
o || i.addClass("vote-down-on"),
y(e, o ? t.undoMod : t.downMod)
},
d = function () {
return $("div.vote a[id^='vote-accepted-']")
},
h = function () {
return $("div.post-menu a[id^='protect-post-']")
},
p = function () {
return $("div.post-menu a[id^='unprotect-post-']")
},
f = function (e) {
return e.hasClass("vote-up-on")
},
g = function (e) {
return e.hasClass("vote-down-on")
},
m = function (e) {
return e.hasClass("star-on")
},
v = function (e) {
return e.closest("div.vote").find("input[name=_id_]").val()
},
b = function (e) {
return e.closest("div.vote").find("input[name=_ltu_]").val()
},
w = function (e, t) {
e.removeClass("vote-up-on"),
t.removeClass("vote-down-on")
},
x = function (e, t) {
var n,
i = e.siblings("span.vote-count-post");
if (i.find(".vote-count-separator").length > 0) {
var o = parseInt(i.children(":first").text(), 10),
a = Math.abs(parseInt(i.children(":last").text(), 10));
n = o - a,
D(i)
} else
n = parseInt(i.text(), 10);
i.text(n + t)
},
y = function (e, t) {
a(e);
var n = v(e);
k(e, n, t, S, {
"ltu" : b(e)
}, null)
},
k = function (e, t, n, i, o, a) {
var r = function (n) {
n.Warning ? confirm(n.Message) ? (c.ignoreWarnings = "true", u()) : a && a() : (i(e, t, n), a && a())
},
s = e.data("vote-stub");
if (s)
return setTimeout(function () {
r(s)
}, 0), void 0;
var c = {
"fkey" : StackExchange.options.user.fkey
};
if (o)
for (var l in o)
c[l] = o[l];
var u = function () {
$.ajax({
"type" : "POST",
"url" : "/posts/" + t + "/vote/" + n,
"data" : c,
"dataType" : "json",
"success" : r,
"error" : function () {
e.parent().showErrorMessage("An error has occurred - please retry your request."),
a && a()
}
})
};
u()
},
S = function (e, n, a) {
if (a.Success) {
if (a.Message && e.parent().showInfoMessage(a.Message), a.ShowShareTip) {
var r = $(e).closest(".question,.answer").find('div.post-menu a:contains("link")');
StackExchange.question.showShareTip(r)
}
a.LastVoteTypeId == t.upMod ? $(document).trigger("upVote", n) : a.LastVoteTypeId == t.downMod ? $(document).trigger("downVote", n) : $(document).trigger("undoVote", n)
} else
window.console && window.console.firebug && (!a.Message || a.Message.length < 5) ? e.parent().showErrorMessage("FireBug seems to be enabled, which can sometimes interfere with voting;<br>please refresh the page to see if your vote was processed.<br><br>If this persists, consider disabling FireBug for this site.") : (a.Message ? e.parent().showErrorMessage(a.Message, {
"transient" : !0
}) : e.parent().showErrorMessage("An error has occurred - please retry your request."), w(e, e), e.parent().find("span.vote-count-post").text(a.NewScore), a.LastVoteTypeId && C(e, a.LastVoteTypeId));
o(e.parent()),
i(e)
},
C = function (e, n) {
var i,
o;
n == t.upMod ? (i = ".vote-up-off", o = "vote-up-on") : n == t.downMod && (i = ".vote-down-off", o = "vote-down-on"),
i && e.closest("div.vote").find(i).addClass(o)
},
E = function () {
$(".star-off:not(.disabled)").live("click", function (e) {
T($(this)),
e.preventDefault()
})
},
T = function (e) {
if (!e.data("loading")) {
e.data("loading", !0);
var n = v(e) || e.siblings("input[type=hidden][name=_id_]").val(),
i = e.parent().find("div.favoritecount b"),
o = parseInt("0" + i.text().replace(/^\s+|\s+$/g, ""), 10),
a = function () {
m(e) ? (e.removeClass("star-on"), i.removeClass("favoritecount-selected").text(--o <= 0 ? "" : o)) : (e.addClass("star-on"), i.addClass("favoritecount-selected").text(++o))
};
a(),
k(e, n, t.favorite, function (t, n, i) {
e.data("loading", !1),
i.Success || (a(), e.parent().showErrorMessage(i.Message))
})
}
},
I = function (e, t) {
$("div.post-menu *[id^='delete-post-'], table.flagged-posts *[id^='delete-post-']").unbind("click").die("click").live("click", function (n) {
n.preventDefault(),
P($(this), e, t)
}).unbind("hover").die("hover").live("hover", function () {
var e = $(this);
if (e.hasClass("load-tooltip-on-hover")) {
e.removeClass("load-tooltip-on-hover");
var t = e.attr("id").substring("delete-post-".length),
n = "/posts/" + t + "/delete-tooltip";
$.get(n, function (t) {
e.attr("title", t)
})
}
})
},
M = function (e, n, i, o) {
e.loadPopup({
"url" : "/posts/{postId}/fancy-deletion-prompt".formatUnicorn({
"postId" : n
}),
"loaded" : function (a) {
StackExchange.helpers.bindMovablePopups(),
$(a).find("a").each(function (e, t) {
var n = $(t).attr("href");
n && n.length > 1 && $(t).attr("target", "__blank")
}),
$(a).find(".cancel-delete").click(function (e) {
return StackExchange.helpers.closePopups(".popup"),
e.preventDefault(),
!1
}),
$(a).find(".delete-question").click(function (a) {
return StackExchange.helpers.closePopups(".popup"),
k(e, n, t.deletion, i, o),
a.preventDefault(),
!1
})
}
})
},
P = function (e, n, i) {
var o = e.attr("id").substring("delete-post-".length),
a = e.text().indexOf("undelete") > -1,
r = e.data(a ? "undelete-prompt" : "delete-prompt");
r || (r = StackExchange.options.user.isModerator ? "" : a ? "Vote to undelete this post?" : "Vote to delete this post?");
var s = a ? !1 : !!e.data("fancy-delete"),
c = n || A;
return s ? (M(e, o, c, i), void 0) : (confirm(r) && k(e, o, a ? t.undeletion : t.deletion, c, i), void 0)
},
A = function (t, n, i) {
var o = t.text().indexOf("undelete") > -1;
if (i && i.Success)
if (t.html(i.Message), t.addClass("load-tooltip-on-hover"), i.NewScore < 0) {
var a = $(".question:has(a[id='delete-post-" + n + "'])").length > 0,
r = a ? ".question, div.answer" : "#answer-" + n;
q($(r), !o)
} else
t.parent().showInfoMessage(o ? "Your undelete vote has been recorded" : "Your delete vote has been recorded");
else {
var s = i && i.Message ? i.Message : o ? "A problem occurred during undeletion" : "A problem occurred during deletion";
e.showErrorMessage(t.parent(), s)
}
},
q = function (e, t) {
t ? ($("div.question-status:has(span:contains('delete'))").show(), e.addClass("deleted-answer").find("a[id^='delete-post-']").addClass("deleted-post").end().find("div[id^='comments-']").addClass("comments-container-deleted").end().find("div[id^='comments-link-']>a").addClass("comments-link-deleted")) : document.location.reload(!0)
},
_ = function () {
var e = $(this),
n = e.attr("id").substring("vote-accepted-".length),
i = d();
e.is(":working") || (e.parent().addSpinner(), i.working(!0), k(e, n, t.acceptedByOwner, function (n, o, a) {
a.Success ? (i.removeClass("vote-accepted-on"), parseInt(a.Message, 10) == t.acceptedByOwner && e.addClass("vote-accepted-on")) : e.parent().showErrorMessage(a.Message, {
"transient" : a.Transient
}),
e.parent().removeSpinner(),
i.working(!1).trigger("update")
}))
},
O = function () {
var e = $(this),
t = e.hasClass("vote-accepted-on") ? "unaccept" : "accept";
e.attr("title", e.data("title-" + t)).text(e.data("verb-" + t))
},
j = !1,
L = function (e) {
return e.closest("div.vote").children('input[type="hidden"]').val()
},
R = function (e) {
if (!j) {
j = !0;
var t = L(e);
e.addSpinner(),
$.ajax({
"type" : "GET",
"url" : "/posts/{postId}/vote-counts".formatUnicorn({
"postId" : t
}),
"dataType" : "json",
"success" : function (t) {
StackExchange.helpers.removeMessages();
var n = '<div style="color:green">' + t.up + '</div><div class="vote-count-separator"></div><div style="color:maroon">' + t.down + "</div>";
e.html(n).unbind("click").data("bound", !1).css("cursor", "default").attr("title", function (e) {
return 1 == e.upCount && 1 == e.downCount ? e.upCount + " up / " + e.downCount + " down" : 1 == e.upCount ? e.upCount + " up / " + e.downCount + " down" : (1 == e.downCount, e.upCount + " up / " + e.downCount + " down")
}
({
"upCount" : Math.abs(+t.up),
"downCount" : Math.abs(+t.down)
}))
},
"error" : function (t) {
e.removeSpinner().parent().showErrorMessage(t.responseText && t.responseText.length < 100 ? t.responseText : "An error occurred during vote count fetch", {
"transient" : 409 == t.status
})
},
"complete" : function () {
j = !1
}
})
}
},
D = function (e) {
(e || $(".vote-count-post")).not(".mobile-vote-count").not(":data(bound)").filter(function () {
return L($(this))
}).attr("title", n).css("cursor", "pointer").click(function () {
R($(this))
}).data("bound", !0)
},
B = function (e) {
c(e),
h().unbind("click").click(function (e) {
e.preventDefault();
var t = this.id.substring("protect-post-".length);
return confirm("Are you sure you want to protect this question?") && $.ajax({
"type" : "POST",
"url" : "/question/protect",
"data" : {
"id" : t,
"fkey" : StackExchange.options.user.fkey
},
"success" : function () {
location.reload(!0)
}
}),
!1
}),
p().unbind("click").click(function (e) {
e.preventDefault();
var t = this.id.substring("unprotect-post-".length);
return confirm("Are you sure you want to unprotect this question?") && $.ajax({
"type" : "POST",
"url" : "/question/unprotect",
"data" : {
"id" : t,
"fkey" : StackExchange.options.user.fkey
},
"success" : function () {
location.reload(!0)
}
}),
!1
}),
StackExchange.vote_closingAndFlagging.init(),
E()
};
return {
"init" : function (e) {
var t = !StackExchange.options.user.isRegistered;
t ? StackExchange.question.bindAnonymousVoteDisclaimers() : B(e),
d().not(":data(bound)").on({
"click" : _,
"update" : O
}).data("bound", !0).trigger("update"),
StackExchange.question.bindFetchAcceptedAnswerDates(),
StackExchange.question.canViewVoteCounts() && D(),
I()
},
"up" : l,
"down" : u,
"vote_init" : c,
"favorite_init" : E,
"delete_init" : I,
"bindFetchVoteCounts" : D,
"highlightExistingVotes" : r,
"submit" : k,
"voteTypeIds" : t,
"getPostId" : v
}
}
(), StackExchange.vote_closingAndFlagging = function () {
function e() {
T = I = M = P = null
}
function t(t, i) {
e(),
T = t.data("questionid"),
I = t,
t.data("isclosed") ? (i || confirm("Nominate this question for reopening?")) && g() : n(!0)
}
function n(e) {
$("#popup-close-question").remove();
var t = I.closest(".post-menu");
0 == t.length && (t = I.parent()),
I.data("isclosed") === !1 && I.addSpinnerAfter({
"padding" : "0 3px"
});
var n = {};
C && C.reviewTaskIdGetter && (n.reviewTaskId = C.reviewTaskIdGetter());
var o = $.ajax({
"type" : "GET",
"url" : "/flags/questions/{questionId}/close/popup".formatUnicorn({
"questionId" : T
}),
"dataType" : "html",
"data" : n
}).done(function (n) {
M = $(n).elementNodesOnly(),
M.appendTo(t),
i(),
C && C.closeShowPopup ? C.closeShowPopup(M, I) : e && M.center().fadeIn("fast"),
StackExchange.helpers.bindMovablePopups()
}).fail(function (e) {
e.responseText ? t.showErrorMessage(e.responseText, {
"transient" : 409 == e.status
}) : t.showErrorMessage("Unable to load popup - please try again")
}).always(function () {
StackExchange.helpers.removeSpinner()
});
return o
}
function i() {
M.find(".popup-close").click(function () {
StackExchange.helpers.closePopups(".popup")
}),
M.on("popupClose", function () {
P && P.remove()
}),
M.find("input[type=radio]").click(r),
$("#close-question-form").submit(function (e) {
return e.preventDefault(),
f(),
!1
}),
$(".retract-close-vote").click(function () {
x($(this))
}),
$(".action-list a").attr("target", "_blank"),
o(),
a()
}
function o() {
var e = $(".close-as-duplicate-pane"),
t = e.find("#search-text");
e.on("show", function () {
$("#search-text").focus(),
$("#close-question-form .popup-submit").enable($("#original-question-id").val())
}).addClass("handles-submit-button-enabling"),
t.helpOverlay().typeWatch({
"highlight" : !1,
"wait" : 750,
"captureLength" : -1,
"callback" : function () {
h(t)
}
})
}
function a() {
var e = M.find(".off-topic-other-comment-container"),
t = e.find("textarea"),
n = e.closest("li").find("input[type=radio]"),
i = $.trim(t.val()),
o = function () {
return $.trim(t.val()) != i
},
a = function (e) {
var n = e && o();
t.is(":focus") && M.find(".popup-submit").enable(n)
};
t.charCounter({
"target" : e.find(".text-counter"),
"min" : 30,
"max" : 500,
"setIsValid" : a
}),
n.click(function () {
e.show(),
t.focus();
var n = t.val();
t.val("").val(n)
}),
t.focus(function () {
n.is(":checked") || n.attr("checked", "checked")
})
}
function r() {
var e = $(this),
t = e.closest("li");
if (!t.hasClass("action-selected")) {
var n = M.find(".popup-subpane").filter(function () {
var t = e.data("subpane-name");
return t && t == $(this).data("subpane-name")
}),
i = M.find(".popup-submit");
n.length ? (s(n, $(".popup-active-pane"), !0), n.hasClass("handles-submit-button-enabling") || i.disable()) : (i.enable(), M.find(".popup-active-pane li.action-selected").removeClass("action-selected"), t.addClass("action-selected"))
}
}
function s(e, t, n) {
if (M.find(".popup-active-pane").removeClass("popup-active-pane").hide(), M.find(".popup-title").html(e.data("title")), n) {
var i = t.data("breadcrumb") || t.data("title");
l(i, function () {
s(t, e, !1),
c(e)
})
}
c(e),
e.addClass("popup-active-pane").show().trigger("show").asyncLoad()
}
function c(e) {
e.find("input[type=radio]:checked").removeAttr("checked"),
e.find("li.action-selected").removeClass("action-selected"),
M.find(".popup-submit").disable()
}
function l(e, t) {
var n = $(".popup-title-container .popup-breadcrumbs"),
i = $("<span>").addClass("breadcrumb");
$("<a>").text(e).click(function () {
i.nextAll().andSelf().remove(),
t()
}).appendTo(i),
$("<span>").addClass("arrow").html("&gt;").appendTo(i),
i.appendTo(n)
}
function u() {
l("Flagging", function () {
M.hide(),
P.fadeIn("fast"),
s(M.find("#pane-main"), M.find(".popup-active-pane"), !1)
})
}
function d(e) {
var t = e.find(".list-originals");
return 0 == t.children().length ? (t.hide(), void 0) : (t.show(), p(t, !0), styleCode(), t.find(".item").click(function () {
var e = $(this).find(" .post-link > a").addSpinner({
"padding-left" : "3px"
}),
t = $("#search-text").hideHelpOverlay().val(e.attr("href"));
return h(t, e),
!1
}).hover(function () {
$(this).toggleClass("hover")
}), void 0)
}
function h(e, t) {
var n = e.closest(".popup-subpane"),
i = n.find(".preview"),
o = n.find(".list-container"),
a = n.find(".search-errors").empty(),
r = $("#original-question-id"),
s = n.closest("#popup-close-question").find(".popup-submit");
if (s.disable(), i.html("").hide(), 0 != $.trim(e.val()).length) {
t || n.find(".search-spinner").addSpinner();
var c = {
"q" : e.val()
};
C && C.reviewTaskIdGetter && (c.reviewTaskId = C.reviewTaskIdGetter()),
$.ajax({
"type" : "GET",
"url" : "/posts/popup/close/search-originals/" + $("#popup-close-question").data("questionid"),
"data" : c,
"dataType" : "html"
}).done(function (e) {
var t = $(e).elementNodesOnly().mathjax();
if (t.hasClass("show-original"))
o.hide(), p(t), i.empty().append(t).show(), t.find(".question .show-title a").attr("target", "_blank"), t.find(".post-tag").addClass("user-tag"), r.val(t.find(".question").data("questionid")), s.enable();
else {
if (!t.hasClass("list-originals"))
throw "these are not the results you were looking for";
o.empty().append(t).show(),
d(o)
}
}).fail(function (e) {
var t = e.responseText && e.responseText.length < 100 ? e.responseText : "An error occurred while searching; please try again";
a.text(t),
s.disable(),
r.val(""),
n.find(".navi-container .instructions").remove()
}).always(function () {
StackExchange.helpers.removeSpinner()
})
}
}
function p(e, t) {
var n = $(".close-as-duplicate-pane .original-display").find(".navi-container"),
i = e.find(".navi"),
o = $("#search-text");
if (t)
n.empty();
else {
var a = n.find(".navi");
if (1 != a.length)
return;
a.empty(),
$("<a>").text(a.data("abbr")).click(function () {
a.html(a.data("text")).siblings().remove(),
n.siblings(".preview").hide(),
n.siblings(".list-container").show(),
$("#original-question-id").val(""),
$("#popup-close-question").find(".popup-submit").disable(),
$(".close-as-duplicate-pane").find(".search-errors").empty(),
o.val(a.data("search-text")).focus()
}).appendTo(a)
}
i.data("search-text", o.val()).text(i.data("text")).prependTo(n)
}
function f() {
var e = M.find(".popup-submit");
if (!e.attr("disabled")) {
$(".remaining-votes").addSpinner({
"position" : "absolute",
"margin" : "18px 0 0 3px"
}),
e.disable();
var t = function (e, t) {
return M.find(e + ' input[type=radio][name="' + t + '"]:checked').val()
};
return C && C.closeSubmitting && C.closeSubmitting() === !1 ? (M.find(".popup-close").click(), void 0) : ($.ajax({
"type" : "POST",
"url" : "/flags/questions/{questionId}/close/add".formatUnicorn({
"questionId" : T
}),
"dataType" : "json",
"data" : {
"fkey" : StackExchange.options.user.fkey,
"closeReasonId" : t("#pane-main", "close-reason"),
"duplicateOfQuestionId" : $("#original-question-id").val(),
"closeAsOffTopicReasonId" : t(".close-as-off-topic-pane", "close-as-off-topic-reason"),
"belongsOnBaseHostAddress" : t(".migration-pane", "migration"),
"offTopicOtherText" : M.find(".off-topic-other-comment-container textarea").val(),
"offTopicOtherCommentId" : M.find(".close-as-off-topic-pane input[type=radio]:checked").data("other-comment-id"),
"originalOffTopicOtherText" : M.find('.off-topic-other-comment-container input[name="original_text"]').val()
}
}).done(function (e) {
m(e)
}).fail(function () {
I.parent().showErrorMessage("An error occurred; please try again")
}).always(function () {
M.find(".popup-close").click()
}), void 0)
}
}
function g() {
I.is(":working") || (I.working(!0).addSpinner({
"margin" : "0 3px"
}), $.ajax({
"type" : "POST",
"url" : "/flags/questions/{questionId}/reopen/add".formatUnicorn({
"questionId" : T
}),
"dataType" : "json",
"data" : {
"fkey" : StackExchange.options.user.fkey
}
}).done(function (e) {
m(e)
}).fail(function () {
I.working(!1).parent().showErrorMessage("An error occurred; please try again")
}).always(function () {
StackExchange.helpers.removeSpinner()
}))
}
function m(e) {
e.isClose = "QuestionClose" == e.FlagType,
e.isRecommendClose = "QuestionRecommendClose" == e.FlagType,
e.isReopen = "QuestionReopen" == e.FlagType,
e.verb = e.isRecommendClose ? "flag" : e.isReopen ? "reopen" : "close";
var t = I;
e.isClose && I.is('[class*="flag-post-"]') && (t = I.parent().find("a[class*='close-question']")),
e.Success ? v(e, t) : w(e, t)
}
function v(e, t) {
if (!(C && C.closeCallback && C.closeCallback(t, e, e.isRecommendClose))) {
var n = function () {
var e = window.location.href.splitOnLast("#")[0],
t = "noredirect=1";
e.indexOf(t) < 0 && (e += (e.indexOf("?") < 0 ? "?" : "&") + "noredirect=1"),
window.location.href = e
};
return e.ResultChangedState ? (n(), void 0) : ("Duplicate" != e.CloseReason && e.CloseAsOffTopicReasonId != A || 0 != t.closest(".mod-post-header").length || StackExchange.comments.loadAll(t), e.Tooltip && t.attr("title", e.Tooltip), e.Message ? (b(e, t), void 0) : (n(), void 0))
}
}
function b(e, t) {
if (t.parent().showInfoMessage(e.Message), !e.isRecommendClose && e.Count > 0) {
t = t.closest(".post-menu").find(".close-question-link");
var n = t.find(".existing-flag-count");
0 == n.length && (t.text(t.text() + " "), n = $('<span class="existing-flag-count">').appendTo(t)),
n.text(e.Count)
}
}
function w(e, t) {
var n = e.Message;
if (!n)
switch (e.verb) {
case "flag":
n = "A problem occurred when trying to flag";
break;
case "reopen":
n = "A problem occurred when trying to reopen";
break;
case "close":
n = "A problem occurred when trying to close"
}
C && C.closeErrorCallback && C.closeErrorCallback(n) || (t.parent().showErrorMessage(n), e.RefreshClient && setTimeout(function () {
location.reload(!0)
}, 2500))
}
function x(e) {
!e.is(":disabled") && confirm("Are you sure (you cannot vote again after retracting)?") && (e.disable().addSpinnerBefore({
"position" : "absolute",
"margin" : "18px 0 0 -25px"
}), $.ajax({
"type" : "POST",
"url" : "/flags/questions/{questionId}/close/retract".formatUnicorn({
"questionId" : T
}),
"dataType" : "json",
"data" : {
"fkey" : StackExchange.options.user.fkey
}
}).done(function (e) {
b(e, I)
}).fail(function () {
I.parent().showErrorMessage("An error occurred; please try again")
}).always(function () {
M.find(".popup-close").click()
}))
}
function y(t) {
e(),
T = t.data("postid"),
I = t;
var n = {};
C && C.reviewTaskIdGetter && (n.reviewTaskId = C.reviewTaskIdGetter()),
t.loadPopup({
"url" : "/flags/posts/{postId}/popup".formatUnicorn({
"postId" : T
}),
"loaded" : k,
"data" : n,
"hideDescriptions" : !1,
"subformShow" : _,
"dontCenter" : C && C.flagShowPopup
})
}
function k(e) {
P = e,
q(),
P.find(".js-flag-load-close").unbind("click").click(function () {
E ? E(P, $(this)) : O($(this))
}),
P.find("form").submit(function (e) {
return e.preventDefault(),
j(),
!1
}),
S(),
C && C.flagShowPopup ? C.flagShowPopup(e, I) : StackExchange.helpers.bindMovablePopups()
}
function S() {
P.find(".action-list > .disabled-action").each(function () {
var e = $(this);
e.find("input[type=radio]").attr("disabled", "disabled"),
e.find(".action-name").addClass("disabled-button")
})
}
var C,
E,
T,
I,
M,
P,
A = 3,
q = function () {
var e = P.find(".popup-submit"),
t = P.find('textarea[name="otherText"]'),
n = P.find('input[value="PostOther"]');
t.focus(function () {
t.hideHelpOverlay(),
n.is(":checked") || n.attr("checked", "checked")
}).charCounter({
"min" : 10,
"max" : 500,
"setIsValid" : function (t) {
n.is(":checked") && e.enable(t)
}
}),
n.click(function () {
t.focus()
})
},
_ = function (e) {
if (e.is(".mod-attention-subform")) {
var t = e.find('textarea[name="otherText"]').helpOverlay();
e.find('input[value="PostOther"]:checked').length > 0 ? t.focus() : 0 == e.find("input:radio:checked").length && e.closest(".popup").find(".popup-submit").disable()
}
},
O = function (e) {
var t = P.fadeOut("fast").promise();
M || (e.siblings(".action-name").addSpinner({
"margin" : "0 5px"
}), t = n(!1)),
t.done(function () {
u(),
e.is(".js-flag-load-close-duplicate") && M.find("input[value=Duplicate]").click(),
M.center().fadeIn("fast")
}),
P.find(".popup-submit").disable(),
e.removeAttr("checked"),
P.find(".action-list li").trigger("hide-action")
},
j = function () {
P.find(".popup-submit").disable().siblings(".spinner-container").addSpinner();
var e = P.find('input[name="top-form"]:checked').val(),
t = "";
return "PostOther" == e && (t = P.find('textarea[name="otherText"]').val()),
C && C.flagSubmitting && C.flagSubmitting() === !1 ? (StackExchange.helpers.closePopups(".popup"), void 0) : ($.ajax({
"type" : "POST",
"url" : "/flags/posts/{postId}/add/{flagType}".formatUnicorn({
"postId" : T,
"flagType" : e
}),
"dataType" : "json",
"data" : {
"fkey" : StackExchange.options.user.fkey,
"otherText" : t
}
}).always(function () {
StackExchange.helpers.closePopups(".popup")
}).done(function (e) {
C && C.flagCallback && C.flagCallback(I, e) || (e.ResultChangedState ? location.reload(!0) : e.Message && (e.Success ? I.parent().showInfoMessage(e.Message) : I.parent().showErrorMessage(e.Message)))
}).fail(function (e) {
var t = e.responseText && e.responseText.length < 100 ? e.responseText : "An error occurred during flagging";
I.parent().showErrorMessage(t)
}), void 0)
};
return {
"close_afterLoadListOriginals" : d,
"updateCloseLinkCount" : b,
"init" : function (e) {
C || (C = e);
var n = ".close-question-link, .close-question-button",
i = function (e, n) {
e.preventDefault(),
t($(this), !!n)
};
$("body").off("click", n).on("click", n, i);
var o = ".flag-post-link, .flag-post-button",
a = function (e) {
e.preventDefault(),
y($(this))
};
$("body").off("click", o).on("click", o, a)
}
}
}
(), function () {
function e(e, t) {
this.commentId = e,
this.jComment = t,
this.postUi = s(t)
}
function t(t) {
var n = t.constructor === $ ? t : $(t),
i = n.hasClass("comment") ? n : n.closest(".comment"),
o = i.attr("id").replace(/^comment-/, "");
return new e(o, i)
}
function n(t) {
for (var n in t)
t.hasOwnProperty(n) && (e.prototype[n] = t[n])
}
function i(e, t, n) {
/Android/.test(navigator.userAgent) && $(t, e).bind("touchstart", function (e) {
var t = $(e.target);
if (!t.is(n))
return !0;
var i = t.data("events");
return i && i.click && i.click.length ? !0 : (t.click(function () {}).attr("data-nothing-to-see-here", "X"), !0)
})
}
function o(e, n, o) {
$(".comments", e).delegate(n, "click", function () {
t(this)[o]()
}),
i(e, ".comments", n)
}
var a,
r = StackExchange.comments,
s = r.uiForPost;
r.extendPostUi({
"ensureInput" : function () {
var e = this.jDiv.find('form[id^="add-comment-"]'),
t = this;
return e.children().length ? (e.add(e.prev()).show(), e.find("textarea")) : l(e, "Add Comment", !1, function () {
t.submitNewComment()
})
},
"saveEditingComments" : function (e) {
var n = this.editingComments = [];
this.jDiv.find("form[id^='edit-comment-']:visible").each(function () {
var i = t(this);
if (i.commentId !== e) {
var o = $(this).find("textarea");
n.push([i.commentId, o.val()])
}
})
},
"restoreEditingComments" : function () {
if (this.editingComments) {
$.each(this.editingComments, function (e, n) {
var i = n[0],
o = n[1],
a = $("#comment-" + i);
a.length && t(a).edit(o, !0)
}),
delete this.editingComments
}
},
"commentsShown" : function () {
try {
var e = this.jDiv.find("form[id^='add-comment-'] textarea:focus");
e.length && StackExchange.comments.tabCompleter.init(e),
this.jtBody.data("remaining-comments-count", 0)
} catch (t) {}
},
"submitNewComment" : function () {
var e = this.jDiv.find('form[id^="add-comment-"]'),
t = e.find("textarea"),
n = this,
i = e.find('input[type="submit"]').parent();
this.ajax({
"type" : "POST",
"url" : "/posts/" + this.postId + "/comments",
"dataType" : "html",
"data" : {
"comment" : t.val(),
"fkey" : StackExchange.options.user.fkey
}
}, "An error occurred during comment submission", i).done(function (i) {
t.val("").keyup().blur(),
StackExchange.helpers.enableSubmitButton(e),
e.add(e.prev()).hide(),
n.showComments(i),
n.jCommentsLink.show(),
$(document).trigger("comment", n.postId)
}).fail(function () {
StackExchange.helpers.enableSubmitButton(e)
})
},
"checkDiscussion" : function () {
var e = this.jDiv.find("tr.is-comment-discussion"),
t = this;
if (e.length) {
e.remove();
var n = this.jDiv.find(".comment-form");
if (!n.find(".discussion-info").length) { {
$("<div style='margin:12px 0 3px; font-weight:bold' class='discussion-info'>" + function (e) {
return "Please avoid extended discussions in comments. Would you like to " + e.aStart + "automatically move this discussion to chat?"
}
({
"aStart" : "<a href='#'>"
}) + "</a></div>").find("a").click(function (e) {
$(this).unbind("click"),
e.preventDefault(),
t.ajax({
"url" : "/posts/" + t.postId + "/move-discussion-to-chat",
"data" : {
"fkey" : StackExchange.options.user.fkey
},
"type" : "POST"
}, "An error occurred when trying to move the discussion to chat", n).done(function (e) {
e.success ? window.location.href = e.message : StackExchange.helpers.showErrorMessage(n, e.message)
})
}).end().prependTo(n)
}
e.remove()
}
}
}
}),
e.prototype = {
"undoVoteUp" : function () {
if (confirm("Are you sure you want to undo your upvote on this comment? You will not be able to upvote it again.")) {
var e = this.jComment.find(".comment-up-on").addClass("comment-up comment-up-off").removeClass("comment-up-on comment-up-undo"),
t = this;
this.submitVote(0).done(function (n) {
return n.Success ? (e.closest("tr").siblings("tr").show(), t.renderScore(n.NewScore), e[0].title = "this comment adds something useful to the post", $(document).trigger("undoUpVoteComment", t.postUi.postId), void 0) : (e.removeClass("comment-up-off comment-up").addClass("comment-up-on"), void 0)
}).fail(function (t) {
409 === t.status && e.addClass("comment-up-undo"),
e.removeClass("comment-up").addClass("comment-up-on")
})
}
},
"voteUp" : function () {
var e = this.jComment.find(".comment-up").addClass("comment-up-on").removeClass("comment-up"),
t = this;
this.submitVote(2).done(function (n) {
return n.Success ? (e.removeClass("comment-up-off"), e.addClass("comment-up-undo"), t.renderScore(n.NewScore), e[0].title = "you've voted for this as a useful comment (click again to undo)", $(document).trigger("upVoteComment", t.postUi.postId), void 0) : (e.removeClass("comment-up-on").addClass("comment-up"), void 0)
}).fail(function () {
e.removeClass("comment-up-on").addClass("comment-up")
})
},
"delete" : function () {
var e = this;
confirm("Really delete this comment?") && this.submitVote(10).done(function (t) {
var n = e.postUi.jDiv.find("textarea");
t.Success && (0 !== e.jComment.siblings(".comment").length || n.is(":visible") || e.jComment.closest(".comments").addClass("dno"), e.jComment.remove())
})
},
"flag" : function () {
function e(e) {
var n = e.find('textarea[name="other-text"]').charCounter({
"min" : 6,
"max" : 200,
"setIsValid" : function () {
r()
}
}),
i = e.find('input[name="comment-flag-type"]'),
o = i.filter('[value="' + n.data("flag-type") + '"]'),
a = e.find(".text-counter"),
r = function () {
var t = i.filter(":checked").length > 0;
if (o.is(":checked")) {
var r = !n.is(":visible"),
s = n.show().val().length;
a.show(),
t = s >= 6 && 200 >= s,
r && n.focus()
} else
n.hide(), a.hide();
e.find(".popup-submit").enable(t)
};
i.click(r),
r(),
e.find("form").submit(function () {
var a = i.filter(":checked").val(),
r = o.is(":checked") ? n.val() : "";
return e.fadeOutAndRemove(),
t.submitFlag(a, r).done(function (e) {
if (!e.Success)
return e.Message && t.jComment.find(".comment-flag").closest("td").showErrorMessage(e.Message), void 0;
if (e.ResultChangedState)
t.jComment.remove();
else {
var n = t.jComment.find(".comment-up"),
i = $("<div/>").addClass("comment-flag").addClass("flag-on").addClass("comment-flag-indicator");
i[0].title = "you've flagged this comment as unconstructive, offensive, or spam",
i.text("flag"),
n.length ? (n.replaceWith(i), t.jComment.find("a.comment-flag").fadeOutAndRemove()) : t.jComment.find("a.comment-flag").replaceWith(i)
}
}),
!1
})
}
var t = this;
this.jComment.find(".comment-flag").loadPopup({
"url" : "/flags/comments/{commentId}/popup".formatUnicorn({
"commentId" : this.commentId
}),
"loaded" : e
})
},
"submitFlag" : function (e, t) {
var n = this.jComment.find(".comment-actions"),
i = {
"type" : "POST",
"url" : "/flags/comments/{commentId}/add/{flagTypeId}".formatUnicorn({
"commentId" : this.commentId,
"flagTypeId" : e
}),
"data" : {
"fkey" : StackExchange.options.user.fkey,
"otherText" : t
},
"dataType" : "json"
};
return this.postUi.ajax(i, "An error occurred during flagging", n, !0)
},
"edit" : function (e, t) {
var n = this.jComment,
i = n.find('form[id^="edit-comment-"]'),
o = this;
if (i.length) {
n.find(" > td > *").not(i).hide(),
n.find("td:last").addClass("comment-form"),
StackExchange.options.isMobile && i.addClass("mobile-comment-form");
var a = l(i, "Save Edits", !0, function () {
o.submitEdit()
});
a.val(e || i.find("div").text()),
a.trigger("charCounterUpdate"),
i.show(),
t || a.focus()
}
},
"cancelEdit" : function () {
var e = this.jComment,
t = e.find('form[id^="edit-comment-"]');
StackExchange.options.isMobile ? (t.children("*:not(.dno)").remove(), e.find("td:last").removeClass("mobile-comment-form")) : t.children("table").remove(),
t.hide(),
t.unbind("submit"),
e.find("td:last").removeClass("comment-form"),
e.find(" > td > *").not(t).show()
},
"submitEdit" : function () {
var e = this.jComment.find('form[id^="edit-comment-"]'),
t = e.find("textarea"),
n = t.val(),
i = this;
this.postUi.ajax({
"type" : "POST",
"url" : "/posts/comments/" + this.commentId + "/edit",
"dataType" : "html",
"data" : {
"comment" : n,
"fkey" : StackExchange.options.user.fkey
}
}, "An error occurred during comment submission", e).done(function (e) {
i.postUi.showComments(e, i.commentId)
}).fail(function () {
StackExchange.helpers.enableSubmitButton(e)
})
},
"submitVote" : function (e, t) {
var n = this.jComment.find("td:first"),
i = {
"fkey" : StackExchange.options.user.fkey
};
if (t)
for (var o in t)
i[o] = t[o];
var a = {
"type" : "POST",
"url" : "/posts/comments/" + this.commentId + "/vote/" + e,
"dataType" : "json",
"data" : i,
"success" : function (e) {
!e.Success && e.Message && StackExchange.helpers.showErrorMessage(n, e.Message)
}
};
return this.postUi.ajax(a, "An error occurred during voting", n, !0)
},
"renderScore" : function (e) {
var t = "";
if (e && e > 0) {
var n = 5 > e ? "" : 15 >= e ? "warm" : 30 >= e ? "hot" : "supernova";
t += '<span title="number of \'useful comment\' votes received" class="' + n + '">' + e + "</span>"
}
this.jComment.find(".comment-score").html(t)
}
};
var c = function (e) {
e.find("textarea").keyup(function (t) {
13 != t.which || t.shiftKey || $(this).prev("#tabcomplete:visible").length || e.submit()
}).keypress(function (e) {
return 13 != e.which || e.shiftKey ? void 0 : !1
})
},
l = function (e, n, i, o) {
var r;
r = e.hasClass("mobile-comment-form") ? '<textarea name="comment" rows="2"></textarea><br/><input type="submit" value="' + n + '"/>' + (i ? ' <a tabindex="0" class="edit-comment-cancel">cancel</a>' : "") : '<table><tr><td><textarea name="comment" cols="68" rows="3"></textarea></td><td><input tabindex="0" type="submit" value="' + n + '"/>' + (i ? '<a tabindex="0" class="edit-comment-cancel">cancel</a>' : "") + '<br/><a tabindex="0" class="comment-help-link">help</a></td></tr><tr><td colspan="2"><span class="text-counter"></span><span class="form-error"></span></td></tr></table>',
e.append(r),
e.find("textarea").attr("placeholder", e.data("placeholdertext")),
i && e.find(".edit-comment-cancel").click(function () {
t(e).cancelEdit()
});
var s = !1,
l = function (e) {
s = e
},
d = e.find("textarea");
return d.charCounter({
"min" : 15,
"max" : 600,
"setIsValid" : l
}).focus(function () {
StackExchange.comments.tabCompleter.init($(this))
}),
e.find(".comment-help-link").click(u),
a && d.one("focus", u),
e.submit(function () {
return s ? (StackExchange.helpers.disableSubmitButton(e), o(e)) : e.find("span.text-counter").animate({
"opacity" : 0
}, 100, function () {
$(this).animate({
"opacity" : 1
}, 100)
}),
!1
}),
StackExchange.options.desc || c(e),
d
},
u = function (e) {
var t,
n = $(this).closest("tbody"),
i = n.find(".comment-help-link"),
o = $(".comment-help", n);
if ("click" == e.type)
t = 0 == o.length || !o.is(":visible"), t || (u.manualOnly = !0);
else {
if (u.manualOnly)
return;
t = !0
}
var a = function () {
i.text(t ? "hide help" : "help")
};
if (o.length > 0)
return t ? o.slideDown(a) : o.slideUp(a), void 0;
if (t) {
var r = $("<tr />").appendTo(n),
s = $("<td colspan='2' />").appendTo(r);
if (u.helpText)
s.html(u.helpText), $(".comment-help", s).slideDown(a);
else {
if (u.inProgress)
return;
u.inProgress = !0,
StackExchange.helpers.addSpinner(i),
s.load("/posts/comment-help", function (e) {
u.helpText = e,
StackExchange.helpers.removeSpinner(),
$(".comment-help", this).slideDown(a),
u.inProgress = !1
})
}
}
},
d = r.init;
r.init = function (e) {
d(e),
a = e && e.autoShowCommentHelp;
var t = e && e.post || document;
o(t, ".comment-up", "voteUp"),
o(t, ".comment-delete", "delete"),
o(t, "a.comment-flag", "flag"),
o(t, ".comment-edit", "edit"),
o(t, ".comment-up-undo", "undoVoteUp"),
$("form.comment-form-expanded", t).each(function () {
s(this).addShow(!0, !0)
})
},
r.extendCommentUi = n
}
(), StackExchange.comments.tabCompleter = function () {
function e(e) {
return StackExchange.helpers.noDiacritics(e.replace(/ /g, "").toLowerCase())
}
function t(e) {
var t = $("#tabcomplete");
t.empty(),
e.length > 5 || !e.length || $.each(e, function (e, n) {
var i = $("<li/>").text(n).appendTo(t);
n.toLowerCase() == u.toLowerCase() && i.addClass("chosen")
})
}
function n() {
var e = l.caret().start,
t = l.val(),
n = !1;
if (/@[^\s!?();:+"].*@/.test(t)) {
if (!/`/.test(t))
return null;
n = !0
}
var i = t.substring(e).search(/[\s!?();:+"\[\]\\]/);
-1 == i && (i = t.length - e);
var o = t.substring(0, e + i).match(/@[^\s!?();:+"\[\]\\]*$/);
if (!o)
return null;
var a = o[0].substr(1),
r = e + i,
s = r - a.length;
return n && /@[^\s!?();:+"]/.test(t.substr(0, s - 1)) ? null : {
"start" : s,
"pos" : e,
"end" : r,
"name" : a
}
}
function i(e) {
var t = n();
if (t.name === e)
return l.is(":focus") || l.focus(), void 0;
var i = l.val();
l.val(i.substring(0, t.start) + e + i.substring(t.end));
var o = t.start + e.length;
l.caret(o, o)
}
function o(e) {
var t,
n;
if (9 == e.which) {
if (n = $("#tabcomplete li"), !n.length)
return;
var o = n.filter(".chosen").removeClass("chosen"),
a = e.shiftKey ? o.prev() : o.next();
a.length || (a = e.shiftKey ? n.last() : n.first()),
t = a.addClass("chosen").text()
} else {
if (27 != e.which)
return;
if (n = $("#tabcomplete li"), !n.length)
return;
t = u,
u = null
}
e.preventDefault(),
i(t)
}
function a(i) {
if (i.which)
switch (i.which) {
case 9:
case 16:
case 17:
case 18:
case 220:
return
}
var o = n();
if (!o)
return u = null, t([]), void 0;
if (u != o.name) {
var a = [];
u = o.name;
var r;
r = o.name ? new RegExp("^" + e(o.name).replace(/\./g, "\\."), "i") : /^\W/;
for (var s = c.length, l = 0; s > l; l++) {
var d = c[l],
h = d.name,
p = o.name ? e(h) : h;
p.match(r) && a.push(h.replace(/ /g, ""))
}
t(a)
}
}
function r(e) {
return e ? parseInt(e.replace(/^\/users\/(\d+)\/.*$/, "$1"), 10) || null : null
}
function s(e) {
if (!StackExchange.options.isMobile) {
var t = e.closest("div.comments"),
n = t.closest(".question, .answer").find(".post-signature:last .user-details a[href^='/users/']"),
i = r(n.attr("href")),
s = [];
t.find("a.comment-user").each(function (e, t) {
var n = t.firstChild;
if (3 !== n.nodeType)
return StackExchange.debug.log("unexpected structure in comment owner link"), void 0;
var i = n.nodeValue,
o = r($(t).attr("href"));
o !== StackExchange.options.user.userId && s.push({
"id" : o,
"name" : i
})
}),
c = [];
for (var d = {}, h = s.length - 1; h >= 0; h--) {
var p = s[h];
d[p.id] || (c.push(p), d[p.id] = !0)
}
if ($("#tabcomplete").remove(), l && l.unbind($.browser.opera ? "keypress" : "keydown", o).unbind("keyup click", a), 0 === c.length || 1 === c.length && c[0].id === i)
return l = null, void 0;
l = e,
u = null,
$("<ul id='tabcomplete' />").insertBefore(e),
e.bind("keydown", o).bind("keyup click", a)
}
}
var c,
l,
u = null;
return $("#tabcomplete > li").live("mousedown", function () {
var e = $(this);
return e.parent().find("li.chosen").removeClass("chosen"),
i(e.addClass("chosen").text()),
!1
}), {
"init" : s
}
}
(), StackExchange.inlineEditing = {
"init" : function () {
function e(e, t, n, i) {
t.fadeIn(n, i),
e.hide()
}
$(".post-menu .edit-post").live("click", function (t) {
if (!(t.ctrlKey || t.altKey || t.metaKey || t.shiftKey)) {
var n = $(this),
i = n.closest(".question, .answer");
if (1 == n.data("handling-event"))
return !1;
n.data("handling-event", 1),
i.find("#edit-tags-cancel").length && StackExchange.inlineTagEditing.restoreCurrentTags(!0),
$("#show-editor-button").hide(),
n.addSpinner();
var o = "",
a = i.hasClass("answer");
a && (o = " class='answer'");
var r = i.find(".postcell,.answercell"),
s = r.find("> *"),
c = $('<div class="inline-editor"/>').hide().appendTo(r);
return c.load(n.attr("href") + "-inline", function (t, o) {
var l;
if (c.find("[tabindex]").each(function () {
$(this).attr("tabindex", parseInt($(this).attr("tabindex") - 20))
}), StackExchange.helpers.removeSpinner(), i.offset().top < $(window).scrollTop() && $("html, body").animate({
"scrollTop" : $(i).offset().top - 55
}, 200), "error" == o)
StackExchange.helpers.showErrorMessage(r, "The post could not be loaded"), c.remove(), n.data("handling-event", 0);
else {
e(s, c, 300);
var u = function (t) {
if (StackExchange.navPrevention) {
if (!StackExchange.navPrevention.confirm("You have started editing this post. Abandon this edit?"))
return !1;
StackExchange.navPrevention.stop()
}
return $("#show-editor-button").show(),
n.data("handling-event", 0),
e(c, t, 300, function () {
c.remove()
}),
t.offset().top < $(window).scrollTop() && $("html, body").animate({
"scrollTop" : $(i).offset().top - 55
}, 200),
!1
},
d = function () {
v.unbind("keyup", h),
x.trigger(l)
},
h = function () {
return x.trigger(v[0].value),
!0
};
c.find(".cancel-edit").click(function () {
d(),
u(s)
});
var p = StackExchange.helpers.DelayedReaction(function (e) {
$.ajax({
"type" : "POST",
"data" : {
"hide" : e
},
"url" : "/user/save-pref/hide-preview-for-inline-editing"
})
}, 1e3, {
"sliding" : !0
}),
f = c.find(".hide-preview");
f.click(function () {
var e = c.find(".wmd-preview"),
t = e.is(":visible");
return t ? (e.slideUp(), f.text("show preview")) : (e.slideDown(), f.text("hide preview")),
p.trigger(t),
!1
});
var g = c.find('input[type="submit"]'),
m = (g.attr("id").replace("submit-button", ""), c.find("form")),
v = c.find("#title"),
b = $("#question-header a"),
w = v.data("question-state-suffix");
w = w ? " " + w : "",
l = v.val();
var x = StackExchange.helpers.DelayedReaction(function (e) {
"undefined" != typeof e && (b.text(e + w), "undefined" != typeof MathJax && MathJax.Hub.Queue(["Typeset", MathJax.Hub, b[0]]))
}, {
"sliding" : !0
});
v.keyup(h),
c.find("#title,.wmd-input,#tagnames,.edit-comment").keydown(function (e) {
return e.ctrlKey === !0 && 13 == e.keyCode ? (m.submit(), !1) : 27 == e.keyCode ? (d(), u(s), !1) : void 0
}),
StackExchange.using("postValidation", function () {
StackExchange.postValidation.initOnBlurAndSubmit(m, a ? 2 : 1, "edit", !1, function (e) {
var t = e.html,
n = $(t).hide();
r.replaceWith(n),
a || $("#question-header a").text(e.title),
$("html").trigger("inline-edit-complete", [n, e.title]),
styleCode(),
u(n)
})
})
}
}),
!1
}
})
}
}, StackExchange.vote_bounty = function () {
var e,
t = function (t, n, i) {
var o = $(".bounty-vote");
if (i.Success) {
$(".bounty-notification").remove(),
e = !1;
var a = t.closest("td.votecell").parent().find("span.reputation-score:last");
if (i.Message) {
var r = $(i.Message);
a.text(r.text()).attr("title", r.attr("title"))
}
var s = t.closest("div.vote").find(".bounty-award-container");
if (s.length > 1) {
var c = s.filter(":first").find(".bounty-award"),
l = parseInt(c.text(), 10),
u = parseInt(t.text(), 10);
c.text("+" + (l + u)),
o.remove()
} else
t.unbind("mouseenter mouseleave").removeClass("bounty-vote bounty-vote-off"), o.not(t).remove()
} else
StackExchange.helpers.showErrorMessage(t.parent(), i.Message), o.removeClass("disabled")
},
n = function () {
return e ? confirm("Are you sure you want to award your bounty to this answer? THIS CANNOT BE UNDONE!") : !0
},
i = function (e) {
var i = StackExchange.vote.getPostId(e);
n(i) && ($(".bounty-vote").addClass("disabled"), StackExchange.vote.submit(e, i, StackExchange.vote.voteTypeIds.bountyClose, t))
},
o = function () {
$(".bounty-vote").hover(function () {
$(this).removeClass("bounty-vote-off")
}, function () {
$(this).addClass("bounty-vote-off")
}),
$(".bounty-vote:not(.disabled)").live("click", function () {
i($(this))
})
},
a = function (e, t) {
return t = $(t || $(".bounty-link")),
t = t.off("click", r),
e && t.on("click", r),
t
},
r = function () {
var e = a(!1, this);
e.addSpinnerAfter({
"padding" : "0 3px"
});
var t = $(e).closest(".question").find("div.vote input").val();
$.ajax({
"type" : "GET",
"url" : "/posts/bounty/" + t,
"dataType" : "html",
"success" : function (t) {
var n = $(t);
n.appendTo(e.parent()),
n.find(".popup-close").click(function () {
n.fadeOutAndRemove()
}),
n.center().fadeIn("fast")
},
"error" : function () {
e.parent().showErrorMessage("Unable to load popup - please try again")
},
"complete" : function () {
StackExchange.helpers.removeSpinner(),
a(!0, e)
}
})
},
s = function () {
a(!0)
};
return {
"init" : function (t) {
e = !!t.hasOpenBounty,
t.canOpenBounty && s(),
t.hasOpenBounty && o()
}
}
}
();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment