\n\n"
}), e = e.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, function(e, t, n) {
var i = t.length;
return "" + a(n) + "\n\n"
})
}
function f(e, t) {
e += "~0";
var n = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
return B ? e = e.replace(n, function(e, n, i) {
var r = n,
o = i.search(/[*+-]/g) > -1 ? "ul" : "ol",
a = m(r, o, t);
return a = a.replace(/\s+$/, ""), a = "<" + o + ">" + a + "" + o + ">\n"
}) : (n = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g, e = e.replace(n, function(e, t, n, i) {
var r = t,
o = n,
a = i.search(/[*+-]/g) > -1 ? "ul" : "ol",
s = m(o, a);
return s = r + "<" + a + ">\n" + s + "" + a + ">\n"
})), e = e.replace(/~0/, "")
}
function m(e, t, n) {
B++, e = e.replace(/\n{2,}$/, "\n"), e += "~0";
var i = $[t],
r = new RegExp("(^[ \\t]*)(" + i + ")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1(" + i + ")[ \\t]+))", "gm"),
s = !1;
return e = e.replace(r, function(e, t, i, r) {
var l = r,
c = /\n\n$/.test(l),
u = c || l.search(/\n{2,}/) > -1;
return u || s ? l = o(I(l), !0) : (l = f(I(l), !0), l = l.replace(/\n$/, ""), n || (l = a(l))), s = c, "
" + l + "
\n"
}), e = e.replace(/~0/g, ""), B--, e
}
function g(e) {
return e += "~0", e = e.replace(/(?:\n\n|^\n?)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g, function(e, t, n) {
var i = t,
r = n;
return i = y(I(i)), i = N(i), i = i.replace(/^\n+/g, ""), i = i.replace(/\n+$/g, ""), i = "
" + i + "\n
", "\n\n" + i + "\n\n" + r
}), e = e.replace(/~0/, "")
}
function v(e) {
return e = e.replace(/(^\n+|\n+$)/g, ""), "\n\n~K" + (O.push(e) - 1) + "K\n\n"
}
function b(e) {
return e = e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function(e, t, n, i) {
var r = i;
return r = r.replace(/^([ \t]*)/g, ""), r = r.replace(/[ \t]*$/g, ""), r = y(r), r = r.replace(/:\/\//g, "~P"), t + "" + r + ""
})
}
function y(e) {
return e = e.replace(/&/g, "&"), e = e.replace(//g, ">"), e = L(e, "*_{}[]\\", !1)
}
function x(e) {
return e = e.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g, "$1$3$4"), e = e.replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g, "$1$3$4")
}
function w(e) {
return e = e.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, function(e, t) {
var n = t;
return n = n.replace(/^[ \t]*>[ \t]?/gm, "~0"), n = n.replace(/~0/g, ""), n = n.replace(/^[ \t]+$/gm, ""), n = o(n), n = n.replace(/(^|\n)/g, "$1 "), n = n.replace(/(\s*
[^\r]+?<\/pre>)/gm, function(e, t) {
var n = t;
return n = n.replace(/^ /gm, "~0"), n = n.replace(/~0/g, "")
}), v("
\n" + n + "\n
")
})
}
function S(e, t) {
e = e.replace(/^\n+/g, ""), e = e.replace(/\n+$/g, "");
for(var n = e.split(/\n{2,}/g), i = [], r = /~K(\d+)K/, o = n.length, s = 0; o > s; s++) {
var l = n[s];
r.test(l) ? i.push(l) : /\S/.test(l) && (l = a(l), l = l.replace(/^([ \t]*)/g, "
"), l += "
", i.push(l))
}
if(!t) {
o = i.length;
for(var s = 0; o > s; s++)
for(var c = !0; c;) c = !1, i[s] = i[s].replace(/~K(\d+)K/g, function(e, t) {
return c = !0, O[t]
})
}
return i.join("\n\n")
}
function C(e) {
return e = e.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&"), e = e.replace(/<(?![a-z\/?!]|~D)/gi, "<")
}
function _(e) {
return e = e.replace(/\\(\\)/g, M), e = e.replace(/\\([`*_{}\[\]()>#+-.!])/g, M)
}
function k(e, t, n, i) {
if(t) return e;
if(")" !== i.charAt(i.length - 1)) return "<" + n + i + ">";
for(var r = i.match(/[()]/g), o = 0, a = 0; a < r.length; a++) "(" === r[a] ? 0 >= o ? o = 1 : o++ : o--;
var s = "";
if(0 > o) {
var l = new RegExp("\\){1," + -o + "}$");
i = i.replace(l, function(e) {
return s = e, ""
})
}
if(s) {
var c = i.charAt(i.length - 1);
U.test(c) || (s = c + s, i = i.substr(0, i.length - 1))
}
return "<" + n + i + ">" + s
}
function T(e) {
e = e.replace(H, k);
var t = function(e, t) {
return '' + R.plainLinkText(t) + ""
};
return e = e.replace(/<((https?|ftp):[^'">\s]+)>/gi, t)
}
function E(e) {
return e = e.replace(/~E(\d+)E/g, function(e, t) {
var n = parseInt(t);
return String.fromCharCode(n)
})
}
function I(e) {
return e = e.replace(/^(\t|[ ]{1,4})/gm, "~0"), e = e.replace(/~0/g, "")
}
function N(e) {
if(!/\t/.test(e)) return e;
var t, n = [" ", " ", " ", " "],
i = 0;
return e.replace(/[\n\t]/g, function(e, r) {
return "\n" === e ? (i = r + 1, e) : (t = (r - i) % 4, i = r + 1, n[t])
})
}
function D(e) {
if(!e) return "";
e.length;
return e.replace(z, function(e) {
return "~D" == e ? "%24" : ":" == e ? ":" : "%" + e.charCodeAt(0).toString(16)
})
}
function L(e, t, n) {
var i = "([" + t.replace(/([\[\]\\])/g, "\\$1") + "])";
n && (i = "\\\\" + i);
var r = new RegExp(i, "g");
return e = e.replace(r, M)
}
function M(e, t) {
var n = t.charCodeAt(0);
return "~E" + n + "E"
}
var A = {};
this.setOptions = function(e) {
A = e
};
var R = this.hooks = new n;
R.addNoop("plainLinkText"), R.addNoop("preConversion"), R.addNoop("postNormalization"), R.addNoop("preBlockGamut"), R.addNoop("postBlockGamut"), R.addNoop("preSpanGamut"), R.addNoop("postSpanGamut"), R.addNoop("postConversion");
var P, F, O, B;
this.makeHtml = function(n) {
if(P) throw new Error("Recursive call to converter.makeHtml");
return P = new i, F = new i, O = [], B = 0, n = R.preConversion(n), n = n.replace(/~/g, "~T"), n = n.replace(/\$/g, "~D"), n = n.replace(/\r\n/g, "\n"), n = n.replace(/\r/g, "\n"), n = "\n\n" + n + "\n\n", n = N(n), n = n.replace(/^[ \t]+$/gm, ""), n = R.postNormalization(n), n = t(n), n = e(n), n = o(n), n = E(n), n = n.replace(/~D/g, "$$"), n = n.replace(/~T/g, "~"), n = R.postConversion(n), O = F = P = null, n
};
var j = function(e) {
return o(e)
}, $ = {
ol: "\\d+[.]",
ul: "[*+-]"
}, q = "[-A-Z0-9+&@#/%?=~_|[\\]()!:,.;]",
G = "[-A-Z0-9+&@#/%=~_|[\\])]",
H = new RegExp('(="|<)?\\b(https?|ftp)(://' + q + "*" + G + ")(?=$|\\W)", "gi"),
U = new RegExp(G, "i"),
z = /(?:["'*()[\]:]|~D)/g
}
}(), define("libs/Markdown.Converter", function() {}), function() {
function e(e) {
return e.replace(/^\s+|\s+$/g, "")
}
function t(e) {
return e.replace(/\s+$/g, "")
}
function n(e) {
return e.replace(new RegExp("^(\\t|[ ]{1,4})", "gm"), "")
}
function i(e, t) {
return -1 != e.indexOf(t)
}
function r(e, t) {
return e.replace(/<[^>]*>?/gi, function(e) {
return e.match(t) ? e : ""
})
}
function o(e, t) {
for(var n = {}, i = 0; i < e.length; i++) n[e[i]] = e[i];
for(i = 0; i < t.length; i++) n[t[i]] = t[i];
var r = [];
for(var o in n) n.hasOwnProperty(o) && r.push(n[o]);
return r
}
function a(e) {
return "" != e.charAt(0) && (e = "" + e), "" != e.charAt(e.length - 1) && (e += ""), e
}
function s(e) {
return "" == e.charAt(0) && (e = e.substr(1)), "" == e.charAt(e.length - 1) && (e = e.substr(0, e.length - 1)), e
}
function l(e, t) {
return r(c(e, t), m)
}
function c(e, t) {
var n = t.blockGamutHookCallback(e);
return n = p(n), n = n.replace(/~D/g, "$$").replace(/~T/g, "~"), n = t.previousPostConversion(n)
}
function u(e) {
return e.replace(/\\\|/g, "~I").replace(/\\:/g, "~i")
}
function d(e) {
return e.replace(/~I/g, "|").replace(/~i/g, ":")
}
function p(e) {
return e = e.replace(/~E(\d+)E/g, function(e, t) {
var n = parseInt(t);
return String.fromCharCode(n)
})
}
function h(e) {
return e.toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "")
}
function f(e, t) {
var n = t;
return n = n.replace(/&\#8220;/g, '"'), n = n.replace(/&\#8221;/g, '"'), n = n.replace(/&\#8216;/g, "'"), n = n.replace(/&\#8217;/g, "'"), n = n.replace(/&\#8212;/g, "---"), n = n.replace(/&\#8211;/g, "--"), n = n.replace(/&\#8230;/g, "...")
}
var m = new RegExp(["^(<\\/?(a|abbr|acronym|applet|area|b|basefont|", "bdo|big|button|cite|code|del|dfn|em|figcaption|", "font|i|iframe|img|input|ins|kbd|label|map|", "mark|meter|object|param|progress|q|ruby|rp|rt|s|", "samp|script|select|small|span|strike|strong|", "sub|sup|textarea|time|tt|u|var|wbr)[^>]*>|", "<(br)\\s?\\/?>)$"].join(""), "i");
Array.indexOf || (Array.prototype.indexOf = function(e) {
for(var t = 0; t < this.length; t++)
if(this[t] == e) return t;
return -1
}), Markdown.Extra = function() {
this.converter = null, this.hashBlocks = [], this.footnotes = {}, this.usedFootnotes = [], this.attributeBlocks = !1, this.googleCodePrettify = !1, this.highlightJs = !1, this.tableClass = "", this.tabWidth = 4
}, Markdown.Extra.init = function(e, t) {
var n = new Markdown.Extra,
r = [],
o = [],
a = [],
s = ["unHashExtraBlocks"];
return t = t || {}, t.extensions = t.extensions || ["all"], i(t.extensions, "all") && (t.extensions = ["tables", "fenced_code_gfm", "def_list", "attr_list", "footnotes", "smartypants", "strikethrough", "newlines"]), o.push("wrapHeaders"), i(t.extensions, "attr_list") && (r.push("hashFcbAttributeBlocks"), o.push("hashHeaderAttributeBlocks"), s.push("applyAttributeBlocks"), n.attributeBlocks = !0), i(t.extensions, "fenced_code_gfm") && (o.push("fencedCodeBlocks"), r.push("fencedCodeBlocks")), i(t.extensions, "tables") && o.push("tables"), i(t.extensions, "def_list") && o.push("definitionLists"), i(t.extensions, "footnotes") && (r.push("stripFootnoteDefinitions"), o.push("doFootnotes"), s.push("printFootnotes")), i(t.extensions, "smartypants") && s.push("runSmartyPants"), i(t.extensions, "strikethrough") && a.push("strikethrough"), i(t.extensions, "newlines") && a.push("newlines"), e.hooks.chain("postNormalization", function(e) {
return n.doTransform(r, e) + "\n"
}), e.hooks.chain("preBlockGamut", function(e, t) {
return n.blockGamutHookCallback = t, e = u(e), e = n.doTransform(o, e) + "\n", e = d(e)
}), e.hooks.chain("postSpanGamut", function(e) {
return n.doTransform(a, e)
}), n.previousPostConversion = e.hooks.postConversion, e.hooks.chain("postConversion", function(e) {
return e = n.doTransform(s, e), n.hashBlocks = [], n.footnotes = {}, n.usedFootnotes = [], e
}), "highlighter" in t && (n.googleCodePrettify = "prettify" === t.highlighter, n.highlightJs = "highlight" === t.highlighter), "table_class" in t && (n.tableClass = t.table_class), n.converter = e, n
}, Markdown.Extra.prototype.doTransform = function(e, t) {
for(var n = 0; n < e.length; n++) t = this[e[n]](t);
return t
}, Markdown.Extra.prototype.hashExtraBlock = function(e) {
return "\n
~X" + (this.hashBlocks.push(e) - 1) + "X
\n"
}, Markdown.Extra.prototype.hashExtraInline = function(e) {
return "~X" + (this.hashBlocks.push(e) - 1) + "X"
}, Markdown.Extra.prototype.unHashExtraBlocks = function(e) {
function t() {
var i = !1;
e = e.replace(/(?:
)?~X(\d+)X(?:<\/p>)?/g, function(e, t) {
i = !0;
var r = parseInt(t, 10);
return n.hashBlocks[r]
}), i === !0 && t()
}
var n = this;
return t(), e
}, Markdown.Extra.prototype.wrapHeaders = function(e) {
function t(e) {
return "\n" + e + "\n"
}
return e = e.replace(/^.+[ \t]*\n=+[ \t]*\n+/gm, t), e = e.replace(/^.+[ \t]*\n-+[ \t]*\n+/gm, t), e = e.replace(/^\#{1,6}[ \t]*.+?[ \t]*\#*\n+/gm, t)
};
var g = "\\{[ \\t]*((?:[#.][-_:a-zA-Z0-9]+[ \\t]*)+)\\}",
v = new RegExp("^(#{1,6}.*#{0,6})[ \\t]+" + g + "[ \\t]*(?:\\n|0x03)", "gm"),
b = new RegExp("^(.*)[ \\t]+" + g + "[ \\t]*\\n(?=[\\-|=]+\\s*(?:\\n|0x03))", "gm"),
y = new RegExp("^(```[ \\t]*[^{\\s]*)[ \\t]+" + g + "[ \\t]*\\n(?=([\\s\\S]*?)\\n```[ \\t]*(\\n|0x03))", "gm");
Markdown.Extra.prototype.hashHeaderAttributeBlocks = function(e) {
function t(e, t, i) {
return "
~XX" + (n.hashBlocks.push(i) - 1) + "XX
\n" + t + "\n"
}
var n = this;
return e = e.replace(v, t), e = e.replace(b, t)
}, Markdown.Extra.prototype.hashFcbAttributeBlocks = function(e) {
function t(e, t, i) {
return "
~XX" + (n.hashBlocks.push(i) - 1) + "XX
\n" + t + "\n"
}
var n = this;
return e.replace(y, t)
}, Markdown.Extra.prototype.applyAttributeBlocks = function(e) {
var t = this,
n = new RegExp('
~XX(\\d+)XX
[\\s]*(?:<(h[1-6]|pre)(?: +class="(\\S+)")?(>[\\s\\S]*?\\2>))', "gm");
return e = e.replace(n, function(e, n, i, r, a) {
if(!i) return "";
for(var s = parseInt(n, 10), l = t.hashBlocks[s], c = l.match(/#[^\s#.]+/g) || [], u = c[0] ? ' id="' + c[0].substr(1, c[0].length - 1) + '"' : "", d = l.match(/\.[^\s#.]+/g) || [], p = 0; p < d.length; p++) d[p] = d[p].substr(1, d[p].length - 1);
var h = "";
return r && (d = o(d, [r])), d.length > 0 && (h = ' class="' + d.join(" ") + '"'), "<" + i + u + h + a
})
}, Markdown.Extra.prototype.tables = function(t) {
function n(t, n, r, o) {
n = n.replace(/^ *[|]/m, ""), r = r.replace(/^ *[|]/m, ""), o = o.replace(/^ *[|]/gm, ""), n = n.replace(/[|] *$/m, ""), r = r.replace(/[|] *$/m, ""), o = o.replace(/[|] *$/gm, ""), alignspecs = r.split(/ *[|] */), align = [];
for(var a = 0; a < alignspecs.length; a++) {
var s = alignspecs[a];
align[a] = s.match(/^ *-+: *$/m) ? ' style="text-align:right;"' : s.match(/^ *:-+: *$/m) ? ' style="text-align:center;"' : s.match(/^ *:-+ *$/m) ? ' style="text-align:left;"' : ""
}
var c = n.split(/ *[|] */),
u = c.length,
d = i.tableClass ? ' class="' + i.tableClass + '"' : "",
p = ["
\n", "\n", "
\n"].join("");
for(a = 0; u > a; a++) {
var h = l(e(c[a]), i);
p += ["
", h, "
\n"].join("")
}
p += "
\n\n";
var f = o.split("\n");
for(a = 0; a < f.length; a++)
if(!f[a].match(/^\s*$/)) {
for(var m = f[a].split(/ *[|] */), g = u - m.length, v = 0; g > v; v++) m.push("");
for(p += "
\n", v = 0; u > v; v++) {
var b = l(e(m[v]), i);
p += ["
", b, "
\n"].join("")
}
p += "
\n"
}
return p += "
\n", i.hashExtraBlock(p)
}
var i = this,
r = new RegExp(["^", "[ ]{0,3}", "[|]", "(.+)\\n", "[ ]{0,3}", "[|]([ ]*[-:]+[-| :]*)\\n", "(", "(?:[ ]*[|].*\\n?)*", ")", "(?:\\n|$)"].join(""), "gm"),
o = new RegExp(["^", "[ ]{0,3}", "(\\S.*[|].*)\\n", "[ ]{0,3}", "([-:]+[ ]*[|][-| :]*)\\n", "(", "(?:.*[|].*\\n?)*", ")", "(?:\\n|$)"].join(""), "gm");
return t = t.replace(r, n), t = t.replace(o, n)
}, Markdown.Extra.prototype.stripFootnoteDefinitions = function(e) {
var t = this;
return e = e.replace(/\n[ ]{0,3}\[\^(.+?)\]\:[ \t]*\n?([\s\S]*?)\n{1,2}((?=\n[ ]{0,3}\S)|$)/g, function(e, n, i) {
return n = h(n), i += "\n", i = i.replace(/^[ ]{0,3}/g, ""), t.footnotes[n] = i, "\n"
})
}, Markdown.Extra.prototype.doFootnotes = function(e) {
var t = this;
if(t.isConvertingFootnote === !0) return e;
var n = 0;
return e = e.replace(/\[\^(.+?)\]/g, function(e, i) {
var r = h(i),
o = t.footnotes[r];
if(void 0 === o) return e;
n++, t.usedFootnotes.push(r);
var a = '' + n + "";
return t.hashExtraInline(a)
})
}, Markdown.Extra.prototype.printFootnotes = function(e) {
var t = this;
if(0 === t.usedFootnotes.length) return e;
e += '\n\n
\n\n\n\n';
for(var n = 0; n < t.usedFootnotes.length; n++) {
var i = t.usedFootnotes[n],
r = t.footnotes[i];
t.isConvertingFootnote = !0;
var o = l(r, t);
delete t.isConvertingFootnote, e += '
"
}, Markdown.Extra.prototype.fencedCodeBlocks = function(e) {
function t(e) {
return e = e.replace(/&/g, "&"), e = e.replace(//g, ">"), e = e.replace(/~D/g, "$$"), e = e.replace(/~T/g, "~")
}
var n = this;
return e = e.replace(/(?:^|\n)```[ \t]*(\S*)[ \t]*\n([\s\S]*?)\n```[ \t]*(?=\n)/g, function(e, i, r) {
var o = i,
a = r,
s = n.googleCodePrettify ? ' class="prettyprint"' : "",
l = "";
o && (l = n.googleCodePrettify || n.highlightJs ? ' class="language-' + o + '"' : ' class="' + o + '"');
var c = ["
", t(a), "
"].join("");
return n.hashExtraBlock(c)
})
}, Markdown.Extra.prototype.educatePants = function(e) {
var t = this,
n = "",
i = 0;
e.replace(/(?:)|(<)([a-zA-Z1-6]+)([^\n]*?>)([\s\S]*?)(<\/\2>)/g, function(r, o, a, s, l, c, u) {
var d = e.substring(i, u);
return n += t.applyPants(d), t.smartyPantsLastChar = n.substring(n.length - 1), i = u + r.length, o ? (/code|kbd|pre|script|noscript|iframe|math|ins|del|pre/i.test(a) ? t.smartyPantsLastChar = l.substring(l.length - 1) : l = t.educatePants(l), void(n += o + a + s + l + c)) : void(n += r)
});
var r = e.substring(i);
return n += t.applyPants(r), t.smartyPantsLastChar = n.substring(n.length - 1), n
}, Markdown.Extra.prototype.applyPants = function(e) {
return e = e.replace(/---/g, "—").replace(/--/g, "–"), e = e.replace(/\.\.\./g, "…").replace(/\.\s\.\s\./g, "…"), e = e.replace(/``/g, "“").replace(/''/g, "”"), /^'$/.test(e) ? /\S/.test(this.smartyPantsLastChar) ? "’" : "‘" : /^"$/.test(e) ? /\S/.test(this.smartyPantsLastChar) ? "”" : "“" : (e = e.replace(/^'(?=[!"#\$\%'()*+,\-.\/:;<=>?\@\[\\]\^_`{|}~]\B)/, "’"), e = e.replace(/^"(?=[!"#\$\%'()*+,\-.\/:;<=>?\@\[\\]\^_`{|}~]\B)/, "”"), e = e.replace(/"'(?=\w)/g, "“‘"), e = e.replace(/'"(?=\w)/g, "‘“"), e = e.replace(/'(?=\d{2}s)/g, "’"), e = e.replace(/(\s| |--|&[mn]dash;|&\#8211;|&\#8212;|&\#x201[34];)'(?=\w)/g, "$1‘"), e = e.replace(/([^\s\[\{\(\-])'/g, "$1’"), e = e.replace(/'(?=\s|s\b)/g, "’"), e = e.replace(/'/g, "‘"), e = e.replace(/(\s| |--|&[mn]dash;|&\#8211;|&\#8212;|&\#x201[34];)"(?=\w)/g, "$1“"), e = e.replace(/([^\s\[\{\(\-])"/g, "$1”"), e = e.replace(/"(?=\s)/g, "”"), e = e.replace(/"/gi, "“"))
}, Markdown.Extra.prototype.runSmartyPants = function(e) {
return this.smartyPantsLastChar = "", e = this.educatePants(e), e = e.replace(/(<([a-zA-Z1-6]+)\b([^\n>]*?)(\/)?>)/g, f)
}, Markdown.Extra.prototype.definitionLists = function(t) {
var n = new RegExp(["(\\x02\\n?|\\n\\n)", "(?:", "(", "(", "[ ]{0,3}", "((?:[ \\t]*\\S.*\\n)+)", "\\n?", "[ ]{0,3}:[ ]+", ")", "([\\s\\S]+?)", "(", "(?=\\0x03)", "|", "(?=", "\\n{2,}", "(?=\\S)", "(?!", "[ ]{0,3}", "(?:\\S.*\\n)+?", "\\n?", "[ ]{0,3}:[ ]+", ")", "(?!", "[ ]{0,3}:[ ]+", ")", ")", ")", ")", ")"].join(""), "gm"),
i = this;
return t = a(t), t = t.replace(n, function(t, n, r) {
var o = e(i.processDefListItems(r));
return o = "
\n" + o + "\n
", n + i.hashExtraBlock(o) + "\n\n"
}), s(t)
}, Markdown.Extra.prototype.processDefListItems = function(i) {
var r = this,
o = new RegExp(["(\\x02\\n?|\\n\\n+)", "(", "[ ]{0,3}", "(?![:][ ]|[ ])", "(?:\\S.*\\n)+?", ")", "(?=\\n?[ ]{0,3}:[ ])"].join(""), "gm"),
u = new RegExp(["\\n(\\n+)?", "(", "[ ]{0,3}", "[:][ ]+", ")", "([\\s\\S]+?)", "(?=\\n*", "(?:", "\\n[ ]{0,3}[:][ ]|", "
|\\x03", ")", ")"].join(""), "gm");
return i = a(i), i = i.replace(/\n{2,}(?=\\x03)/, "\n"), i = i.replace(o, function(t, n, i) {
for(var o = e(i).split("\n"), a = "", s = 0; s < o.length; s++) {
var c = o[s];
c = l(e(c), r), a += "\n
" + c + "
"
}
return a + "\n"
}), i = i.replace(u, function(e, i, o, a) {
return i || a.match(/\n{2,}/) ? (a = Array(o.length + 1).join(" ") + a, a = n(a) + "\n\n", a = "\n" + c(a, r) + "\n") : (a = t(a), a = l(n(a), r)), "\n
Allows StackEdit to interpret LaTeX mathematical expressions.
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\nMore info'
}), define("text!libs/mathjax_config.js", [], function() {
return 'MathJax.Hub.Config({\n skipStartupTypeset: true,\n "HTML-CSS": {\n preferredFont: "TeX",\n availableFonts: [\n "STIX",\n "TeX"\n ],\n linebreaks: {\n automatic: true\n },\n EqnChunk: 10,\n imageFont: null\n },\n tex2jax: <%= tex2jax || \'{ inlineMath: [["$","$"],["\\\\\\\\\\\\\\\\(","\\\\\\\\\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\\\\\[","\\\\\\\\]"]], processEscapes: true }\' %>,\n TeX: $.extend({\n noUndefined: {\n attributes: {\n mathcolor: "red",\n mathbackground: "#FFEEEE",\n mathsize: "90%"\n }\n },\n Safe: {\n allow: {\n URLs: "safe",\n classes: "safe",\n cssIDs: "safe",\n styles: "safe",\n fontsize: "all"\n }\n }\n }, <%= tex %>),\n messageStyle: "none"\n});\n'
}), define("libs/mathjax_init", ["settings", "text!libs/mathjax_config.js"], function(e, t) {
var n = document.createElement("script");
n.type = "text/x-mathjax-config", n.innerHTML = _.template(t, {
tex: e.extensionSettings.mathJax ? e.extensionSettings.mathJax.tex : "undefined",
tex2jax: e.extensionSettings.mathJax ? e.extensionSettings.mathJax.tex2jax : void 0
}), document.getElementsByTagName("head")[0].appendChild(n)
}), define("extensions/mathJax", ["utils", "classes/Extension", "text!html/mathJaxSettingsBlock.html", "mathjax"], function(e, t, n) {
function i(e, t, n) {
var i = u.slice(e, t + 1).join("").replace(/&/g, "&").replace(//g, ">");
for(x.Browser.isMSIE && (i = i.replace(/(%[^\n]*)\n/g, "$1 \n")); t > e;) u[t] = "", t--;
u[e] = "@@" + m.length + "@@", n && (i = n(i)), m.push(i), d = p = h = null
}
function r(e) {
d = p = h = null, m = [];
var t;
/`/.test(e) ? (e = e.replace(/~/g, "~T").replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, function(e) {
return e.replace(/\$/g, "~D")
}), t = function(e) {
return e.replace(/~([TD])/g, function(e, t) {
return {
T: "~",
D: "$"
}[t]
})
}) : t = function(e) {
return e
}, u = w(e.replace(/\r\n?/g, "\n"), S);
for(var n = 1, r = u.length; r > n; n += 2) {
var o = u[n];
"@" === o.charAt(0) ? (u[n] = "@@" + m.length + "@@", m.push(o)) : d ? p == y && "\n" == o.charAt(0) ? (h && (n = h, i(d, n, t)), d = p = h = null, f = 0) : o === p ? f ? h = n : i(d, n, t) : o.match(/\n.*\n/) ? (h && (n = h, i(d, n, t)), d = p = h = null, f = 0) : "{" === o ? f++ : "}" === o && f && f-- : o === y || "$$" === o ? (d = n, p = o, f = 0) : "begin" === o.substr(1, 5) && (d = n, p = "\\end" + o.substr(6), f = 0)
}
return h && i(d, h, t), t(u.join(""))
}
function o(e) {
return e = e.replace(/@@(\d+)@@/g, function(e, t) {
return m[t]
}), m = null, e
}
function a() {
v = !1, x.cancelTypeset = !1, x.Queue(["Typeset", x, b]), x.Queue(c)
}
function s() {
v || (v = !0, x.Cancel(), x.Queue(a))
}
var l = new t("mathJax", "MathJax", !0);
l.settingsBlock = n, l.defaultConfig = {
tex: "{}",
tex2jax: '{ inlineMath: [["$","$"],["\\\\\\\\(","\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\[","\\\\]"]], processEscapes: true }'
}, l.onLoadSettings = function() {
e.setInputValue("#input-mathjax-config-tex", l.config.tex), e.setInputValue("#input-mathjax-config-tex2jax", l.config.tex2jax)
}, l.onSaveSettings = function(t, n) {
t.tex = e.getInputJsValue("#input-mathjax-config-tex", n), t.tex2jax = e.getInputJsValue("#input-mathjax-config-tex2jax", n)
}, l.onPagedownConfigure = function(e) {
b = document.getElementById("preview-contents");
var t = e.getConverter();
t.hooks.chain("preConversion", r), t.hooks.chain("postConversion", o)
};
var c;
l.onAsyncPreview = function(e) {
c = e, s()
};
var u, d, p, h, f, m, g = !1,
v = !1,
b = null,
y = "$",
x = MathJax.Hub;
x.Queue(function() {
g = !0, x.processUpdateTime = 50, x.Config({
"HTML-CSS": {
EqnChunk: 10,
EqnChunkFactor: 1
},
SVG: {
EqnChunk: 10,
EqnChunkFactor: 1
}
})
});
var w, S = /(\$\$?|\\(?:begin|end)\{[a-z]*\*?\}|\\[\\{}$]|[{}]|(?:\n\s*)+|@@\d+@@)/i;
return w = 3 === "aba".split(/(b)/).length ? function(e, t) {
return e.split(t)
} : function(e, t) {
var n, i = [];
if(!t.global) {
n = t.toString();
var r = "";
n = n.replace(/^\/(.*)\/([im]*)$/, function(e, t, n) {
return r = n, t
}), t = RegExp(n, r + "g")
}
for(var o = t.lastIndex = 0; n = t.exec(e);) i.push(e.substring(o, n.index)), i.push.apply(i, n.slice(1)), o = n.index + n[0].length;
return i.push(e.substring(o)), i
},
function() {
var e = MathJax.Hub;
if(!e.Cancel) {
e.cancelTypeset = !1, e.Register.StartupHook("HTML-CSS Jax Config", function() {
var t = MathJax.OutputJax["HTML-CSS"],
n = t.Translate;
t.Augment({
Translate: function(i, r) {
if(e.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(t, i, r)
}
})
}), e.Register.StartupHook("SVG Jax Config", function() {
var t = MathJax.OutputJax.SVG,
n = t.Translate;
t.Augment({
Translate: function(i, r) {
if(e.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(t, i, r)
}
})
}), e.Register.StartupHook("TeX Jax Config", function() {
var t = MathJax.InputJax.TeX,
n = t.Translate;
t.Augment({
Translate: function(i, r) {
if(e.cancelTypeset || r.cancelled) throw Error("MathJax Canceled");
return n.call(t, i, r)
}
})
});
var t = e.processError;
e.processError = function(n, i, r) {
return "MathJax Canceled" !== n.message ? t.call(e, n, i, r) : (MathJax.Message.Clear(0, 0), i.jaxIDs = [], i.jax = {}, i.scripts = [], i.i = i.j = 0, i.cancelled = !0, null)
}, e.Cancel = function() {
this.cancelTypeset = !0
}
}
}(), l
}), define("text!html/partialRenderingSettingsBlock.html", [], function() {
return "
Renders modified sections only.
\n
\n Note: Document sections are based on title elements (h1, h2...). Therefore if\n your document does not contain any title, performance will not be increased.\n
"
}), define("extensions/partialRendering", ["underscore", "crel", "extensions/markdownExtra", "classes/Extension", "text!html/partialRenderingSettingsBlock.html"], function(e, t, n, i, r) {
function o() {
var t = [],
n = "\n";
if(m = !1, e.each(g, function(e) {
var i = '\n\n\n' + e.text + "\n\n";
f && (i = i.replace(/^```.*\n[\s\S]*?\n```|\n[ ]{0,3}\[\^(.+?)\]\:[ \t]*\n?([\s\S]*?)\n{1,2}((?=\n[ ]{0,3}\S)|$)/gm, function(e, t) {
return t ? (m = !0, n += e.replace(/^\s*\n/gm, "") + "\n", "") : e
})), i = i.replace(/^```.*\n[\s\S]*?\n```|^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*(\S+?)>?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm, function(e, t) {
return t ? (n += e.replace(/^\s*\n/gm, "") + "\n", "") : e
}), t.push({
id: e.id,
text: i + "\n"
})
}), y = [], b = [], d = void 0, x === !0 || u != n) return x = !1, u = n, b = v, v = t, void(y = t);
var i = v.length;
e.some(v, function(e, n) {
return n >= t.length || e.text != t[n].text ? (i = n, !0) : void 0
});
var r = -v.length;
e.some(v.slice().reverse(), function(e, n) {
return n >= t.length || e.text != t[t.length - n - 1].text ? (r = -n, !0) : void 0
}), i - r > v.length && (r = i - v.length);
var o = v.slice(0, i);
y = t.slice(i, t.length + r);
var a = v.slice(v.length + r, v.length);
d = e.first(a), b = v.slice(i, v.length + r), v = o.concat(y).concat(a)
}
function a(e) {
var t = e.id.substring(3);
w[t] = e
}
function s() {
function n(n) {
for(var i = t("div", {
id: "wmd-preview-section-" + n.id,
"class": "wmd-preview-section preview-content"
}), o = !1; r;) {
var s = r.nextSibling,
l = "se-preview-section-delimiter" == r.className;
if(o === !0 && "DIV" == r.tagName && l) break;
o = !0, "DIV" == r.tagName && "footnotes" == r.className ? e.each(r.querySelectorAll("ol > li"), a) : l || i.appendChild(r), r = s
}
return i
}
e.each(b, function(e) {
var t = document.getElementById("wmd-preview-section-" + e.id);
h.removeChild(t)
});
var i = document.getElementById("wmd-preview"),
r = i.firstChild,
o = document.createDocumentFragment();
e.each(y, function(e) {
o.appendChild(n(e))
}), i.innerHTML = "";
var s = p;
void 0 !== d && (s = document.getElementById("wmd-preview-section-" + d.id)), h.insertBefore(o, s), p.innerHTML = "";
var l = [];
if(m === !0) {
var c = t("ol");
e.each(h.querySelectorAll("a.footnote"), function(e, t) {
e.textContent = t + 1;
var n = e.id.substring(6);
l.push(n);
var i = w[n];
i && c.appendChild(i.cloneNode(!0))
}), l.length > 0 && p.appendChild(t("div", {
"class": "footnotes"
}, t("hr"), c)), w = e.pick(w, l)
}
}
var l = new i("partialRendering", "Partial Rendering", !0);
l.settingsBlock = r;
var c, u, d, p, h, f = !1,
m = !1,
g = [],
v = [],
b = [],
y = [],
x = !1,
w = {};
return l.onSectionsCreated = function(e) {
g = e
}, l.onPagedownConfigure = function(t) {
c = t.getConverter(), c.hooks.chain("preConversion", function() {
o();
var t = e.map(y, function(e) {
return e.text
});
return t.push(u + "\n\n"), t.join("")
}), t.hooks.chain("onPreviewRefresh", function() {
s()
})
}, l.onInit = function() {
n.enabled && e.some(n.config.extensions, function(e) {
return "footnotes" == e
}) && (f = !0)
}, l.onReady = function() {
p = t("div", {
id: "wmd-preview-section-footnotes",
"class": "preview-content"
}), h = document.getElementById("preview-contents"), h.appendChild(p)
}, l.onFileSelected = function() {
x = !0
}, l
}), define("extensions/markdownSectionParser", ["underscore", "extensions/markdownExtra", "extensions/mathJax", "extensions/partialRendering", "classes/Extension", "crel"], function(e, t, n, i, r, o) {
function a(e, t) {
function n(e, t) {
var n = o.substring(a, t);
u.push({
id: ++h,
text: n,
textWithFrontMatter: i + n
}), i = ""
}
if(e === p) {
var i = (p.frontMatter || {})._frontMatter || "",
r = t.substring(i.length),
o = r + "\n\n";
u = [];
var a = 0;
o.replace(d, function(e, t) {
n(a, t), a = t
}), n(a, r.length), s.onSectionsCreated(u)
}
}
var s, l = new r("markdownSectionParser", "Markdown section parser");
l.onEventMgrCreated = function(e) {
s = e
};
var c, u = [],
d = "^.+[ \\t]*\\n=+[ \\t]*\\n+|^.+[ \\t]*\\n-+[ \\t]*\\n+|^\\#{1,6}[ \\t]*.+?[ \\t]*\\#*\\n+";
l.onPagedownConfigure = function(r) {
t.enabled && e.some(t.config.extensions, function(e) {
return "fenced_code_gfm" == e
}) && (d = "^```.*\\n[\\s\\S]*?\\n```|" + d), n.enabled && (d = "^[ \\t]*\\n\\$\\$[\\s\\S]*?\\$\\$|" + d, d = "^[ \\t]*\\n\\\\\\\\[[\\s\\S]*?\\\\\\\\]|" + d, d = "^[ \\t]*\\n\\\\?\\\\begin\\{[a-z]*\\*?\\}[\\s\\S]*?\\\\end\\{[a-z]*\\*?\\}|" + d), d = new RegExp(d, "gm");
var a = r.getConverter();
i.enabled || (a.hooks.chain("preConversion", function() {
return e.reduce(u, function(e, t) {
return e + '\n\n\n' + t.text + "\n\n"
}, "")
}), r.hooks.chain("onPreviewRefresh", function() {
function e() {
for(var e = o("div", {
"class": "wmd-preview-section preview-content"
}), t = !1; n;) {
var i = n.nextSibling,
r = "se-preview-section-delimiter" == n.className;
if(t === !0 && "DIV" == n.tagName && r) break;
t = !0, r || e.appendChild(n), n = i
}
return e
}
var t = document.getElementById("wmd-preview"),
n = t.firstChild,
i = document.createDocumentFragment();
u.forEach(function(t) {
i.appendChild(e(t))
}), c.innerHTML = "", c.appendChild(t), c.appendChild(i)
}))
}, l.onReady = function() {
c = document.getElementById("preview-contents")
};
var p;
l.onFileSelected = function(e) {
p = e
};
var h = 0;
return l.onFileOpen = a, l.onContentChanged = a, l
}), define("text!html/buttonMarkdownSyntax.html", [], function() {
return '\n
\n
Markdown syntax
\n \n
\n
Phrase Emphasis
\n\n
*italic* **bold**\n_italic_ __bold__\n
\n\n
Links
\n\n
Inline:
\n\n
An [example](http://url.com/ "Title")\n
\n\n
Reference-style labels (titles are optional):
\n\n
An [example][id]. Then, anywhere\nelse in the doc, define the link:\n\n [id]: http://example.com/ "Title"\n
> Email-style angle brackets\n> are used for blockquotes.\n\n> > And, they can be nested.\n\n> #### Headers in blockquotes\n>\n> * You can quote a list.\n> * Etc.\n
\n\n
Code Spans
\n\n
`<code>` spans are delimited\nby backticks.\n\nYou can include literal backticks\nlike `` `this` ``.\n
\n\n
Preformatted Code Blocks
\n\n
Indent every line of a code block by at least 4 spaces or 1 tab.
\n\n
This is a normal paragraph.\n\n This is a preformatted\n code block.\n
\n'
}), define("extensions/buttonMarkdownSyntax", ["jquery", "classes/Extension", "text!html/buttonMarkdownSyntax.html"], function(e, t, n) {
var i = new t("buttonMarkdownSyntax", 'Button "Markdown syntax', !0, !0);
return i.settingsBlock = '
Adds a "Markdown syntax" button over the preview.
', i.onCreatePreviewButton = function() {
return n
}, i
}), define("extensions/googleAnalytics", ["jquery", "underscore", "constants", "utils", "classes/Extension", "settings"], function(e, t, n, i, r, o) {
function a() {
i.currentTime - d > 18e4 && (_gaq.push(["_trackPageview"]), d = i.currentTime)
}
var s = new r("googleAnalytics", "Google Analytics", !0);
s.settingsBlock = "
Sends anonymous statistics about usage and errors to help improve StackEdit.
";
var l = !1,
c = !1;
window._gaq = [];
var u = function() {
if(l === !1 && c === !1) {
var t = "/ga.js";
location.search.match(/(\?|&)console/) && (t = "/u/ga_debug.js"), e.ajax({
url: "https://ssl.google-analytics.com" + t,
dataType: "script"
}).done(function() {
l = !0
})
}
}, d = 0;
s.onPeriodicRun = function() {
a()
}, s.onReady = function() {
_gaq.push(["_setAccount", n.GOOGLE_ANALYTICS_ACCOUNT_ID]), a(), _gaq.push(["_trackEvent", "About", "version", n.VERSION]), _gaq.push(["_trackEvent", "Settings", "layoutOrientation", "" + o.layoutOrientation]), _gaq.push(["_trackEvent", "Settings", "theme", "" + window.theme]), _gaq.push(["_trackEvent", "Settings", "lazyRendering", "" + o.lazyRendering]), _gaq.push(["_trackEvent", "Settings", "editorFontFamily", "" + o.editorFontFamily]), _gaq.push(["_trackEvent", "Settings", "editorFontSize", "" + o.editorFontSize]), _gaq.push(["_trackEvent", "Settings", "defaultContent backlink", "" + (-1 !== o.defaultContent.indexOf(n.MAIN_URL))]), _gaq.push(["_trackEvent", "Settings", "commitMsg backlink", "" + (-1 !== o.commitMsg.indexOf(n.MAIN_URL))]), _gaq.push(["_trackEvent", "Settings", "sshProxy unchanged", "" + (o.sshProxy == n.SSH_PROXY_URL)]), t.each(o.extensionSettings, function(e, t) {
_gaq.push(["_trackEvent", "Extensions", t + " enabled", "" + (e.enabled === !0)])
}), window.onerror = function(e, t, n) {
_gaq.push(["_trackEvent", "Error", e, t + ":" + n + i.formatEventList()])
}, u()
}, s.onOfflineChanged = function(e) {
c = e, u()
};
var p = 0;
return s.onSyncRunning = function(e) {
e === !0 && (p = (new Date).getTime())
}, s.onPublishRunning = function(e) {
e === !0 && (p = (new Date).getTime())
}, s.onSyncSuccess = function() {
var e = (new Date).getTime();
_gaq.push(["_trackTiming", "Sync", "SyncTime", e - p])
}, s.onSyncImportSuccess = function(e, t) {
_gaq.push(["_trackEvent", "Sync", "SyncImport"]), _gaq.push(["_trackEvent", "Sync", "SyncImport provider", t.providerId])
}, s.onSyncExportSuccess = function(e, t) {
_gaq.push(["_trackEvent", "Sync", "SyncExport"]), _gaq.push(["_trackEvent", "Sync", "SyncExport provider", t.provider.providerId])
}, s.onPublishSuccess = function(e) {
var n = (new Date).getTime();
_gaq.push(["_trackTiming", "Publish", "PublishSuccess", n - p]), t.each(e.publishLocations, function(e) {
_gaq.push(["_trackEvent", "Publish", "PublishSuccess provider", e.provider.providerId])
})
}, s.onNewPublishSuccess = function(e, t) {
_gaq.push(["_trackEvent", "Publish", "NewPublish provider", t.provider.providerId])
}, s.onError = function(e) {
!t.isString(e) && e.message && _gaq.push(["_trackEvent", "Error", "message", e.message + i.formatEventList()])
}, s
}), define("extensions/twitter", ["jquery", "underscore", "constants", "utils", "classes/Extension"], function(e, t, n, i, r) {
var o = new r("twitter", "Twitter", !1, !0),
a = !1,
s = !1,
l = function() {
a === !1 && s === !1 && e.ajax({
url: "https://platform.twitter.com/widgets.js",
dataType: "script"
}).done(function() {
a = !0
})
};
return o.onReady = function() {
l()
}, o.onOfflineChanged = function(e) {
s = e, l()
}, o.onTweet = function() {
a && window.twttr.widgets.load()
}, o
}), define("text!html/dialogAbout.html", [], function() {
return '
\n'
}), define("extensions/dialogManagePublication", ["jquery", "underscore", "classes/Extension", "text!html/dialogManagePublicationLocation.html"], function(e, t, n, i) {
var r, o = new n("dialogManagePublication", 'Dialog "Manage publication"', !1, !0);
o.onEventMgrCreated = function(e) {
r = e
};
var a, s, l, c = function(e) {
if(void 0 === e || e === a) {
l.toggleClass("hide", 0 === t.size(a.publishLocations));
var n = t.reduce(a.publishLocations, function(e, n) {
var r = t.omit(n, "provider", "publishIndex", "sharingLink");
return r.password && (r.password = "********"), r = JSON.stringify(r).replace(/{|}|"/g, "").replace(/,/g, ", "), e + t.template(i, {
publishAttributes: n,
publishDesc: r
})
}, "");
s.innerHTML = n
}
};
return o.onFileSelected = function(e) {
a = e, c(e)
}, o.onNewPublishSuccess = c, o.onPublishRemoved = c, o.onReady = function() {
var t = document.querySelector(".modal-manage-publish");
s = t.querySelector(".publish-list"), l = e(document.querySelectorAll(".show-already-published")), e(s).on("click", ".remove-button", function() {
var t = e(this),
n = a.publishLocations[t.data("publishIndex")];
a.removePublishLocation(n), r.onPublishRemoved(a, n)
})
}, o
}), define("text!html/dialogManageSynchronizationLocation.html", [], function() {
return '
\n \n \n \n
\n \n
\n
\n'
}), define("extensions/dialogManageSynchronization", ["jquery", "underscore", "classes/Extension", "text!html/dialogManageSynchronizationLocation.html"], function(e, t, n, i) {
var r, o = new n("dialogManageSynchronization", 'Dialog "Manage synchronization"', !1, !0);
o.onEventMgrCreated = function(e) {
r = e
};
var a;
o.onSynchronizerCreated = function(e) {
a = e
};
var s, l, c, u = function(e) {
if(void 0 === e || e === s) {
c.toggleClass("hide", 0 === t.size(s.syncLocations));
var n = t.reduce(s.syncLocations, function(e, n) {
return e + t.template(i, {
syncAttributes: n,
syncDesc: n.id || n.path
})
}, "");
l.innerHTML = n
}
};
return o.onFileSelected = function(e) {
s = e, u(e)
}, o.onSyncExportSuccess = u, o.onSyncRemoved = u, o.onReady = function() {
var t = document.querySelector(".modal-manage-sync");
l = t.querySelector(".sync-list"), c = e(document.querySelectorAll(".show-already-synchronized")), e(l).on("click", ".remove-button", function() {
var t = e(this),
n = s.syncLocations[t.data("syncIndex")];
s.removeSyncLocation(n), r.onSyncRemoved(s, n)
})
}, o
}), define("text!html/dialogManageSharingLocation.html", [], function() {
return '
\n \n
\n
\n \n
\n'
}), define("extensions/dialogManageSharing", ["jquery", "underscore", "classes/Extension", "text!html/dialogManageSharingLocation.html"], function(e, t, n, i) {
var r, o = new n("dialogManageSharing", 'Button "Share"', !1, !0);
o.onEventMgrCreated = function(e) {
r = e
};
var a, s, l, c, u = function(e) {
if(void 0 === e || e === a) {
var n = t.reduce(a.publishLocations, function(e, n) {
return n.sharingLink && (e += t.template(i, {
link: n.sharingLink,
title: a.title
})), e
}, "");
s.innerHTML = n, r.onTweet(), l.toggleClass("hide", 0 === n.length), c.toggleClass("hide", 0 !== n.length)
}
};
return o.onFileSelected = function(e) {
a = e, u(e)
}, o.onNewPublishSuccess = function(t, n) {
u(t), n.sharingLink && (e(".modal").modal("hide"), e(".modal-manage-sharing").modal("show"))
}, o.onPublishRemoved = u, o.onReady = function() {
var t = document.querySelector(".modal-manage-sharing");
s = t.querySelector(".share-list"), l = e(t.querySelectorAll(".msg-share-list")), c = e(t.querySelectorAll(".msg-no-share"))
}, o
}), function() {
var e = this,
t = {}, n = !1;
"undefined" != typeof module && module.exports ? (module.exports = t, e.toMarkdown = t, n = !0) : e.toMarkdown = t, t.converter = function(e) {
e && e.elements && $.isArray(e.elements) && (c = c.concat(e.elements)), this.makeMd = function(e, t) {
var r;
if(n) {
var o = require("jsdom");
o.env({
html: e,
scripts: ["http://code.jquery.com/jquery-1.6.4.min.js"],
done: function(n, r) {
"function" == typeof t && t(i(e, r.$))
}
})
} else r = i(e, $);
return r
}
};
var i = function(e, t) {
e = e.replace(/(\d+)\. /g, "$1\\. ");
var n = t(""),
i = n.html(e);
i.find("*:not(pre, code)").contents().filter(function() {
return 3 === this.nodeType && /^\s+$/.test(this.nodeValue)
}).remove();
for(var r = [], o = 0, s = c.length; s > o; o++) r.push(c[o].selector);
for(r = r.join(","); i.find(r).length;)
for(var o = 0, s = c.length; s > o; o++) $matches = i.find(c[o].selector + ':not(:has("' + r + '"))'), $matches.each(function(e, n) {
var i = t(n);
i.before(c[o].replacement(i.html(), i)).remove()
});
return a(i.html())
}, r = function(e) {
return e.replace(/^[\n\r\f]+|[\n\r\f]+$/g, "")
}, o = function(e) {
return String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"')
}, a = function(e) {
return e = e.replace(/^[\t\r\n]+|[\t\r\n]+$/g, ""), e = e.replace(/\n\s+\n/g, "\n\n"), e = e.replace(/\n{3,}/g, "\n\n"), e = o(e)
}, s = function(e) {
return e = r(e), e ? "**" + e + "**" : ""
}, l = function(e) {
return e = r(e), e ? "_" + e + "_" : ""
}, c = [{
selector: "p",
replacement: function(e) {
return e = $.trim(e), e ? "\n\n" + e + "\n\n" : ""
}
}, {
selector: "br",
replacement: function() {
return "\n"
}
}, {
selector: "h1,h2,h3,h4,h5,h6",
replacement: function(e, t) {
e = $.trim(e);
for(var n = t.prop("nodeName").charAt(1), i = "", r = 0; n > r; r++) i += "#";
return e ? "\n\n" + i + " " + e + "\n\n" : ""
}
}, {
selector: "hr",
replacement: function() {
return "\n\n* * *\n\n"
}
}, {
selector: "a[href]",
replacement: function(e, t) {
if(e) {
e = r(e);
var n = t.attr("href"),
i = t.attr("title") || "";
return "[" + e + "](" + n + (i ? ' "' + i + '"' : "") + ")"
}
return !1
}
}, {
selector: "b",
replacement: s
}, {
selector: "strong",
replacement: s
}, {
selector: "i",
replacement: l
}, {
selector: "em",
replacement: l
}, {
selector: "code",
replacement: function(e) {
return e = r(e), e ? "`" + e + "`" : ""
}
}, {
selector: "img",
replacement: function(e, t) {
var n = t.attr("alt") || "",
i = t.attr("src") || "",
r = t.attr("title") || "";
return "![" + n + "](" + i + (r ? ' "' + r + '"' : "") + ")"
}
}, {
selector: "pre",
replacement: function(e) {
return /^\s*\`/.test(e) ? (e = e.replace(/\`/g, ""), " " + e.replace(/\n/g, "\n ")) : ""
}
}, {
selector: "li",
replacement: function(e, t) {
e = e.replace(/^\s+|\s+$/, "").replace(/\n/gm, "\n ");
var n = "* ",
i = "",
r = t.parent(),
o = r.contents().filter(function() {
return 1 === this.nodeType && "LI" === this.nodeName || 3 === this.nodeType
}),
a = o.index(t) + 1;
return n = r.is("ol") ? a + ". " : "* ", a == o.length && (t.parents("li").length || (i = "\n"), e = e.replace(/\s+$/, ""), t.unwrap()), n + e + i + "\n"
}
}, {
selector: "blockquote",
replacement: function(e) {
return e = e = $.trim(e).replace(/\n{3,}/g, "\n\n"), e = e.replace(/\n/g, "\n> "), "> " + e
}
}]
}(), define("toMarkdown", ["jquery"], function(e) {
return function() {
var t;
return t || e.toMarkdown
}
}(this)), define("extensions/dialogOpenHarddrive", ["jquery", "underscore", "constants", "utils", "classes/Extension", "toMarkdown"], function(e, t, n, i, r, o) {
function a(i) {
i.stopPropagation(), i.preventDefault();
var r = (i.dataTransfer || i.target).files;
e(".modal-import-harddrive-markdown, .modal-import-harddrive-html").modal("hide"), t.each(r, function(t) {
if(!e(i.target).is("#wmd-input *") || !t.name.match(/.(jpe?g|png|gif)$/i)) {
var r = new FileReader;
r.onload = function(e) {
return function(t) {
var n = t.target.result;
if(n.match(/\uFFFD/)) return void p.onError(e.name + " is a binary file.");
if(n = h ? h(n) : n, void 0 === n) return void p.onError(e.name + " is not a valid HTML file.");
var i = e.name,
r = i.lastIndexOf(".");
i = -1 !== r ? i.substring(0, r) : i;
var o = u.createFile(i, n);
u.selectFile(o)
}
}(t);
var o = t.slice(0, n.IMPORT_FILE_MAX_CONTENT_SIZE);
r.readAsText(o)
}
})
}
function s(e) {
h = void 0, a(e)
}
function l(e) {
h = m, a(e)
}
function c(e) {
e.stopPropagation(), e.preventDefault(), e.dataTransfer.dropEffect = "copy"
}
var u, d = new r("dialogOpenHarddrive", 'Dialog "Open from"');
d.onFileMgrCreated = function(e) {
u = e
};
var p;
d.onEventMgrCreated = function(e) {
p = e
};
var h, f, m = function(e) {
return f.makeMd(e)
};
return d.onReady = function() {
f = new o.converter, e("#input-file-import-harddrive-markdown").change(s), e("#dropzone-import-harddrive-markdown, #wmd-input").each(function() {
this.addEventListener("dragover", c, !1), this.addEventListener("drop", s, !1)
}), e("#input-file-import-harddrive-html").change(l), e("#dropzone-import-harddrive-html").each(function() {
this.addEventListener("dragover", c, !1), this.addEventListener("drop", l, !1)
}), e(".action-convert-html").click(function(e) {
var t = i.getInputTextValue("#input-convert-html", e);
if(void 0 !== t) {
if(t = f.makeMd(t), void 0 === t) return void p.onError("Invalid HTML code.");
var n = u.createFile(void 0, t);
u.selectFile(n)
}
})
}, d
}), define("extensions/documentTitle", ["jquery", "underscore", "classes/Extension"], function(e, t, n) {
var i, r, o = new n("documentTitle", "Document Title"),
a = t.debounce(function(t) {
if(t === i) {
var n = i.title;
document.title = "StackEdit – " + n, r.html(i.composeTitle()), e(".file-title").text(n), e(".input-file-title").val(n)
}
}, 50);
return o.onFileSelected = function(e) {
i = e, a(e)
}, o.onTitleChanged = a, o.onSyncExportSuccess = a, o.onSyncRemoved = a, o.onNewPublishSuccess = a, o.onPublishRemoved = a, o.onReady = a, o.onReady = function() {
r = e(".file-title-navbar"), r.hover(function() {
var e = r[0].scrollWidth - r.outerWidth();
r.stop(!0, !0).animate({
scrollLeft: e
}, 15 * e, "linear")
}, function() {
r.stop(!0, !0).scrollLeft(0)
}).click(function() {
r.stop(!0, !0).scrollLeft(0)
})
}, o
}), define("classes/FileDescriptor", ["underscore", "utils", "storage"], function(e, t, n) {
function i(e, t, i, r) {
this.fileIndex = e, this._title = t || n[e + ".title"], this._editorScrollTop = parseInt(n[e + ".editorScrollTop"]) || 0, this._editorStart = parseInt(n[e + ".editorEnd"]) || 0, this._editorEnd = parseInt(n[e + ".editorEnd"]) || 0, this._previewScrollTop = parseInt(n[e + ".previewScrollTop"]) || 0, this._selectTime = parseInt(n[e + ".selectTime"]) || 0, this._discussionList = JSON.parse(n[e + ".discussionList"] || "{}"), this.syncLocations = i || {}, this.publishLocations = r || {}, Object.defineProperty(this, "title", {
get: function() {
return this._title
},
set: function(e) {
this._title = e, n[this.fileIndex + ".title"] = e
}
}), Object.defineProperty(this, "content", {
get: function() {
return n[this.fileIndex + ".content"]
},
set: function(e) {
n[this.fileIndex + ".content"] = e
}
}), Object.defineProperty(this, "editorScrollTop", {
get: function() {
return this._editorScrollTop
},
set: function(e) {
this._editorScrollTop = e, n[this.fileIndex + ".editorScrollTop"] = e
}
}), Object.defineProperty(this, "editorStart", {
get: function() {
return this._editorStart
},
set: function(e) {
this._editorStart = e, n[this.fileIndex + ".editorStart"] = e
}
}), Object.defineProperty(this, "editorEnd", {
get: function() {
return this._editorEnd
},
set: function(e) {
this._editorEnd = e, n[this.fileIndex + ".editorEnd"] = e
}
}), Object.defineProperty(this, "previewScrollTop", {
get: function() {
return this._previewScrollTop
},
set: function(e) {
this._previewScrollTop = e, n[this.fileIndex + ".previewScrollTop"] = e
}
}), Object.defineProperty(this, "selectTime", {
get: function() {
return this._selectTime
},
set: function(e) {
this._selectTime = e, n[this.fileIndex + ".selectTime"] = e
}
}), Object.defineProperty(this, "discussionList", {
get: function() {
return this._discussionList
},
set: function(e) {
this._discussionList = e, n[this.fileIndex + ".discussionList"] = JSON.stringify(e)
}
}), Object.defineProperty(this, "discussionListJSON", {
get: function() {
return n[this.fileIndex + ".discussionList"] || "{}"
},
set: function(e) {
this._discussionList = JSON.parse(e), n[this.fileIndex + ".discussionList"] = e
}
})
}
return i.prototype.addSyncLocation = function(e) {
t.storeAttributes(e), t.appendIndexToArray(this.fileIndex + ".sync", e.syncIndex), this.syncLocations[e.syncIndex] = e
}, i.prototype.removeSyncLocation = function(e) {
t.removeIndexFromArray(this.fileIndex + ".sync", e.syncIndex), delete this.syncLocations[e.syncIndex]
}, i.prototype.addPublishLocation = function(e) {
t.storeAttributes(e), t.appendIndexToArray(this.fileIndex + ".publish", e.publishIndex), this.publishLocations[e.publishIndex] = e
}, i.prototype.removePublishLocation = function(e) {
t.removeIndexFromArray(this.fileIndex + ".publish", e.publishIndex), delete this.publishLocations[e.publishIndex]
}, i.prototype.composeTitle = function() {
var t = [];
return e.chain(this.syncLocations).sortBy(function(e) {
return e.provider.providerId
}).each(function(e) {
t.push('')
}), 0 !== e.size(this.syncLocations) && t.push(''), e.chain(this.publishLocations).sortBy(function(e) {
return e.provider.providerId
}).each(function(e) {
t.push('')
}), 0 !== e.size(this.publishLocations) && t.push(''), t.push(e.escape(this.title)), t.join("")
}, i
}), define("fileSystem", ["underscore", "utils", "classes/FileDescriptor", "storage"], function(e, t, n, i) {
var r = {};
return t.retrieveIndexArray("file.list").forEach(function(e) {
r[e] = new n(e)
}), Object.keys(i).forEach(function(e) {
var t = e.match(/(file\.\S+?)\.\S+/);
t && !r.hasOwnProperty(t[1]) && i.removeItem(e)
}), r
}), define("text!html/documentSelectorSettingsBlock.html", [], function() {
return '
Allows toggling document with keyboard shortcuts.
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
'
}), define("extensions/documentSelector", ["jquery", "underscore", "crel", "utils", "classes/Extension", "mousetrap", "fileSystem", "text!html/documentSelectorSettingsBlock.html"], function(e, t, n, i, r, o, a, s) {
var l = new r("documentSelector", "Document Selector", !0);
l.settingsBlock = s, l.defaultConfig = {
orderBy: "mru",
shortcutPrevious: "Ctrl+[",
shortcutNext: "Ctrl+]"
}, l.onLoadSettings = function() {
i.setInputValue("#select-document-selector-orderby", l.config.orderBy), i.setInputValue("#input-document-selector-shortcut-previous", l.config.shortcutPrevious), i.setInputValue("#input-document-selector-shortcut-next", l.config.shortcutNext)
}, l.onSaveSettings = function(e, t) {
e.orderBy = i.getInputValue("#select-document-selector-orderby"), e.shortcutPrevious = i.getInputTextValue("#input-document-selector-shortcut-previous", t), e.shortcutNext = i.getInputTextValue("#input-document-selector-shortcut-next", t)
};
var c;
l.onFileMgrCreated = function(e) {
c = e
};
var u, d, p, h, f, m, g, v = ['
"].join(""),
n = t.chain(w).sortBy(function(e) {
return e.title.toLowerCase()
}).reduce(function(e, n) {
return e + t.template(k, {
fileDesc: n
})
}, "").value();
n = n && '
' + n + "
", e += '
' + n + "
", t.chain(s).sortBy(function(e) {
return e.name.toLowerCase()
}).each(function(n) {
var i = t.chain(n.fileList).sortBy(function(e) {
return e.title.toLowerCase()
}).reduce(function(e, n) {
return e + t.template(k, {
fileDesc: n
})
}, "").value();
i = i && '
' + i + "
", e += t.template(_, {
folderDesc: n,
fileListHtml: i,
id: n.folderIndex.replace(".", "")
})
}), v.innerHTML = e
}
}, 50);
return h.onFileCreated = L, h.onFileDeleted = L, h.onSyncExportSuccess = L, h.onSyncRemoved = L, h.onNewPublishSuccess = L, h.onPublishRemoved = L, h.onFoldersChanged = L, h.onTitleChanged = function(t) {
m !== !1 && (e(v).find('[data-file-index="' + t.fileIndex + '"] .name').html(t.composeTitle()).removeClass("hide"), e(v.querySelectorAll(".input-rename")).addClass("hide"))
}, h.onReady = function() {
g = document.querySelector(".modal-document-manager"), v = g.querySelector(".list-group.document-list"), S = e(g.querySelectorAll(".document-count")), C = e(g.querySelectorAll(".folder-count")), b = g.querySelector(".list-group.selected-document-list");
var o = g.querySelector(".list-group.select-folder-list");
e(g).on("show.bs.modal", function() {
m = !0, L(), setTimeout(function() {
e(v.querySelectorAll(".root-folder")).click()
}, 250)
}).on("hide.bs.modal", function() {
m = !1, v.innerHTML = ""
}), e(g.querySelectorAll(".action-create-folder")).click(function() {
var o;
do o = "folder." + i.randomString(); while (t.has(s, o));
r[o + ".name"] = n.DEFAULT_FOLDER_NAME;
var l = new a(o, n.DEFAULT_FOLDER_NAME);
i.appendIndexToArray("folder.list", o), s[o] = l, f.onFoldersChanged(), setTimeout(function() {
var t = e(g.querySelector('[data-folder-index="' + o + '"] .button-rename')).click();
g.scrollTop += t.offset().top - 50
}, 60)
}), e(g.querySelectorAll(".action-select-all")).click(function() {
e(v.querySelectorAll('input[type="checkbox"]')).prop("checked", !0).change()
}), e(g.querySelectorAll(".action-unselect-all")).click(function() {
e(v.querySelectorAll('input[type="checkbox"]')).prop("checked", !1).change()
});
var p = e(g.querySelectorAll(".action-delete-items")).click(function() {
x.hasClass("disabled") || (c(), u())
});
x = p.parent(), e(g.querySelectorAll(".action-delete-items-confirm")).click(function() {
d(), e(g.querySelectorAll(".document-list")).removeClass("hide"), e(g.querySelectorAll(".confirm-delete, .selected-document-list")).addClass("hide")
});
var h = e(g.querySelectorAll(".action-move-items")).click(function() {
if(!y.hasClass("disabled")) {
c();
var n = ['', '
Generates a table of contents when a [TOC] marker is found.
\n
\n
\n \n
\n \n \n
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n
\n \n
'
}), define("extensions/toc", ["jquery", "underscore", "utils", "classes/Extension", "text!html/buttonToc.html", "text!html/tocSettingsBlock.html"], function(e, t, n, i, r, o) {
function a(e, t, n) {
this.tagName = e, this.anchor = t, this.text = n, this.children = []
}
function s(e, n) {
function i() {
void 0 !== r && (r.children.length > 0 && (r.children = s(r.children, n + 1)), l.push(r))
}
n = n || 1;
var r, o = "H" + n,
l = [];
return t.each(e, function(e) {
e.tagName != o ? n !== c.config.maxDepth && (void 0 === r && (r = new a), r.children.push(e)) : (i(), r = e)
}), i(), l
}
function l() {
function e(e) {
for(var r = e.id || n.slugify(e.textContent) || "title", o = r, a = 0; t.has(i, o);) o = r + "-" + ++a;
return i[o] = !0, e.id = o, o
}
var i = {}, r = [];
return t.each(u.querySelectorAll("h1, h2, h3, h4, h5, h6"), function(t) {
r.push(new a(t.tagName, e(t), t.textContent))
}), r = s(r), '
\n
\n' + r.join("") + "
\n
\n"
}
var c = new i("toc", "Table of Contents", !0);
c.settingsBlock = o, c.defaultConfig = {
marker: "\\[(TOC|toc)\\]",
maxDepth: 6,
button: !0
}, c.onLoadSettings = function() {
n.setInputValue("#input-toc-marker", c.config.marker), n.setInputValue("#input-toc-maxdepth", c.config.maxDepth), n.setInputChecked("#input-toc-button", c.config.button)
}, c.onSaveSettings = function(e, t) {
e.marker = n.getInputRegExpValue("#input-toc-marker", t), e.maxDepth = n.getInputIntValue("#input-toc-maxdepth"), e.button = n.getInputChecked("#input-toc-button")
}, c.onCreatePreviewButton = function() {
return c.config.button ? r : void 0
}, a.prototype.childrenToString = function() {
if(0 === this.children.length) return "";
var e = "
\n";
return t.each(this.children, function(t) {
e += t.toString()
}), e += "
\n"
}, a.prototype.toString = function() {
var e = "
";
return this.anchor && this.text && (e += '' + this.text + ""), e += this.childrenToString() + "
\n"
};
var u;
return c.onPagedownConfigure = function(e) {
u = document.getElementById("preview-contents");
var n = new RegExp("^\\s*" + c.config.marker + "\\s*$");
e.hooks.chain("onPreviewRefresh", function() {
var e = document.querySelectorAll(".table-of-contents, .toc"),
i = l();
t.each(u.getElementsByTagName("p"), function(e) {
n.test(e.innerHTML) && (e.innerHTML = i)
}), t.each(e, function(e) {
e.innerHTML = i
})
})
}, c.onReady = function() {
var t = !0;
e(".preview-panel").on("hide.layout.toggle", function() {
t = !1
}).on("shown.layout.toggle", function() {
t = !0
}), e(".extension-preview-buttons .table-of-contents").on("click", "a", function(e) {
!t && e.preventDefault()
})
}, c
}), define("extensions/emailConverter", ["classes/Extension"], function(e) {
var t = new e("emailConverter", "Markdown Email", !0);
return t.settingsBlock = "
Converts email adresses in the form <email@example.com> into clickable links.
\n Note: The mapping between Markdown and HTML is based on the\n position of the title elements (h1, h2...) in the page. Therefore if\n your document does not contain any title, the mapping will be linear and\n consequently less accurate.\n
"
}), define("extensions/scrollSync", ["jquery", "underscore", "classes/Extension", "text!html/scrollSyncSettingsBlock.html"], function(e, t, n, i) {
function r(e, n, i) {
var r, o = t.find(n, function(t, n) {
return r = n, e < t.endOffset
});
if(void 0 !== o) {
var a = (e - o.startOffset) / (o.height || 1),
s = i[r];
return s.startOffset + s.height * a
}
}
function o(e, t, n, i, r) {
function o() {
var l = Date.now(),
c = (l - s) / 200;
if(1 > c) {
var u = t + a * Math.cos((1 - c) * Math.PI / 2);
e.scrollTop = u, i(u), p = setTimeout(o, 1)
} else h = void 0, e.scrollTop = n, setTimeout(r, 100)
}
h && (clearTimeout(p), h()), h = r;
var a = n - t,
s = Date.now();
o()
}
var a = new n("scrollSync", "Scroll Sync", !0, !0);
a.settingsBlock = i;
var s;
a.onSectionsCreated = function(e) {
s = e
};
var l, c, u, d, p, h, f = [],
m = [],
g = t.debounce(function() {
f = [];
var e, n;
t.each(l.querySelectorAll(".wmd-input-section"), function(t) {
if(void 0 === e) return void(e = 0);
t = t.firstChild;
var n = t.offsetTop;
f.push({
startOffset: e,
endOffset: n,
height: n - e
}), e = n
}), n = l.scrollHeight, f.push({
startOffset: e,
endOffset: n,
height: n - e
}), m = [];
var i;
t.each(c.querySelectorAll(".wmd-preview-section"), function(e) {
if(void 0 === i) return void(i = 0);
var t = e.offsetTop;
m.push({
startOffset: i,
endOffset: t,
height: t - i
}), i = t
}), n = c.scrollHeight, m.push({
startOffset: i,
endOffset: n,
height: n - i
}), u = -10, d = -10, S()
}, 500),
v = !0,
b = !1,
y = !1,
x = !1,
w = !1,
S = t.throttle(function() {
if(v && 0 !== f.length && f.length === m.length) {
var e = l.scrollTop;
0 > e && (e = 0);
var n, i = c.scrollTop;
if(b === !0) {
if(Math.abs(e - u) <= 9) return;
if(b = !1, u = e, n = r(e, f, m), n = t.min([n, c.scrollHeight - c.offsetHeight]), Math.abs(n - i) <= 9) return void(d = i);
o(c, i, n, function(e) {
w = !0, d = e
}, function() {
w = !1
})
} else if(y === !0) {
if(Math.abs(i - d) <= 9) return;
if(y = !1, d = i, n = r(i, m, f), n = t.min([n, l.scrollHeight - l.offsetHeight]), Math.abs(n - e) <= 9) return void(u = e);
o(l, e, n, function(e) {
x = !0, u = e
}, function() {
x = !1
})
}
}
}, 100);
a.onLayoutResize = function() {
b = !0, g()
}, a.onFileClosed = function() {
f = []
};
var C = !1;
a.onReady = function() {
c = document.querySelector(".preview-container"), l = document.querySelector("#wmd-input"), e(c).scroll(function() {
w === !1 && C === !1 && (y = !0, b = !1, S()), C = !1
}), e(l).scroll(function() {
x === !1 && (b = !0, y = !1, S())
}), e(".preview-panel").on("hide.layout.toggle", function() {
v = !1
}).on("shown.layout.toggle", function() {
v = !0
}), e(".extension-preview-buttons .table-of-contents").on("click", "a", function(e) {
e.preventDefault();
var t = this.hash,
n = c.querySelector(t);
if(n) {
var i = n.getBoundingClientRect().top - c.getBoundingClientRect().top + c.scrollTop;
c.scrollTop = i;
var o = r(i, m, f);
l.scrollTop = o
}
})
};
var _, k;
return a.onPagedownConfigure = function(e) {
_ = document.getElementById("preview-contents"), e.getConverter().hooks.chain("postConversion", function(e) {
return k = _.offsetHeight, _.style.height = k + "px", e
})
}, a.onPreviewFinished = function() {
_.style.removeProperty("height");
var e = _.offsetHeight;
b = !0, k > e && (C = !0), g()
}, a
}), define("text!html/buttonSyncSettingsBlock.html", [], function() {
return '
Adds a "Synchronize documents" button in the navigation bar.
\n
\n
\n \n
\n ms\n
\n
\n
\n \n
\n \n
\n
\n
'
}), define("extensions/buttonSync", ["jquery", "underscore", "crel", "utils", "classes/Extension", "mousetrap", "text!html/buttonSyncSettingsBlock.html"], function(e, t, n, i, r, o, a) {
var s = new r("buttonSync", 'Button "Synchronize"', !1, !0);
s.settingsBlock = a, s.defaultConfig = {
syncPeriod: 18e4,
syncShortcut: "mod+s"
}, s.onLoadSettings = function() {
i.setInputValue("#input-sync-period", s.config.syncPeriod), i.setInputValue("#input-sync-shortcut", s.config.syncShortcut)
}, s.onSaveSettings = function(e, t) {
e.syncPeriod = i.getInputIntValue("#input-sync-period", t, 0), e.syncShortcut = i.getInputTextValue("#input-sync-shortcut", t)
};
var l;
s.onSynchronizerCreated = function(e) {
l = e
};
var c, u = !1,
d = !1,
p = function() {
void 0 !== c && (u === !0 || l.hasSync() === !1 || d ? c.addClass("disabled") : c.removeClass("disabled"))
}, h = 0;
return s.onPeriodicRun = function() {
!s.config.syncPeriod || h + s.config.syncPeriod > i.currentTime || l.sync() && (h = i.currentTime)
}, s.onCreateButton = function() {
var t = n("a", {
"class": "btn btn-success button-synchronize",
title: "Force synchronization Ctrl/Cmd+S"
}, n("i", {
"class": "icon-refresh"
}));
return c = e(t), c.click(function() {
c.hasClass("disabled") || l.sync() && (h = i.currentTime)
}), t
}, s.onReady = p, s.onFileCreated = p, s.onFileDeleted = p, s.onSyncImportSuccess = p, s.onSyncExportSuccess = p, s.onSyncRemoved = p, s.onSyncRunning = function(e) {
u = e, p()
}, s.onOfflineChanged = function(e) {
d = e, p()
}, s.onReady = function() {
o.bind(s.config.syncShortcut, function(e) {
l.sync() && (h = i.currentTime), e.preventDefault()
}), e(".action-force-synchronization").click(function() {
l.sync() && (h = i.currentTime)
})
}, s
}), define("extensions/buttonPublish", ["jquery", "underscore", "crel", "classes/Extension"], function(e, t, n, i) {
function r() {
void 0 !== o && (c === !0 || u === !1 || d === !0 ? o.addClass("disabled") : o.removeClass("disabled"))
}
var o, a, s, l = new i("buttonPublish", 'Button "Publish"'),
c = !1,
u = !1,
d = !1;
l.onPublisherCreated = function(e) {
s = e
}, l.onCreateButton = function() {
var t = n("a", {
"class": "btn btn-success button-publish",
title: "Update document publication"
}, n("i", {
"class": "icon-upload"
}));
return o = e(t).click(function() {
o.hasClass("disabled") || s.publish()
}), t
}, l.onPublishRunning = function(e) {
c = e, r()
}, l.onOfflineChanged = function(e) {
d = e, r()
};
var p = function() {
u = 0 === t.size(a.publishLocations) ? !1 : !0, r()
};
return l.onFileSelected = function(e) {
a = e, p()
}, l.onReady = function() {
e(".action-update-publication").click(s.publish)
}, l.onPublishRemoved = p, l.onNewPublishSuccess = p, l
}), define("text!html/buttonStat.html", [], function() {
return '\n
Tip: You can use a\n YAML front matter to specify the title of your page.
\n
Interpreted variables:title.
\n
\n
\n
About URL: For newly created page , Blogger API will append a generated number to the url like about-me-1234.html, if you deeply care about your URL naming, you should first create the page on Blogger and then update them with StackEdit specifying the pageId when publishing.\n
\n
About page visibility: Blogger API does not respect published status for pages.When publishing the page to Blogger, the page will be live but not added to the page listing. You should arrange the page listing from Blogger dashboard.\n
\n
\n
\n \n
\n
\n
\n\n\n
\n
\n
\n\n
\n \n
Publication
\n
\n
\n
\n "" is published on the following\n location(s):\n
\n \n
\n Note: Removing a publish location will not delete the actual publication.\n
\n
\n \n
\n
\n
\n\n\n
\n
\n
\n\n
\n \n
Sharing
\n
\n
\n
\n "" can be shared using the following link(s):\n
\n \n
No sharing link yet!\n
\n
To collaborate on this document, use Google Drive\n or Dropbox synchronization from the menu.\n
\n
To share a frozen version of this document within StackEdit, just publish it as a Gist in\n Markdown format from the menu.\n
\n
\n Tip: You can open any URL within StackEdit using viewer#!url=.\n
Ctrl/Cmd+H",
headingexample: "Heading",
hr: "Horizontal Rule Ctrl/Cmd+R",
undo: "Undo - Ctrl/Cmd+Z",
redo: "Redo - Ctrl/Cmd+Y",
help: "Markdown Editing Help"
}, v = "http://",
b = "http://";
Markdown.Editor = function(e, i, s) {
s = s || {}, "function" == typeof s.handler && (s = {
helpButton: s
}), s.strings = s.strings || {}, s.helpButton && (s.strings.help = s.strings.help || s.helpButton.title);
var l = function(e) {
return s.strings[e] || g[e]
};
i = i || "";
var c = this.hooks = new Markdown.HookCollection;
c.addNoop("onPreviewRefresh"), c.addNoop("postBlockquoteCreation"), c.addFalse("insertImageDialog"), c.addFalse("insertLinkDialog"), this.getConverter = function() {
return e
};
var u, p, h = this;
this.run = function() {
if(!u) {
u = new t(i);
var f, m = new a(c, l),
g = new r(e, u, function() {
c.onPreviewRefresh()
});
s.undoManager ? (p = s.undoManager, p.onButtonStateChange = function() {
f.setUndoRedoButtonStates()
}, f && f.setUndoRedoButtonStates()) : /\?noundo/.test(d.location.href) || (p = new n(function() {
g.refresh(), f && f.setUndoRedoButtonStates()
}, u), this.textOperation = function(e) {
p.setCommandMode(), e(), h.refreshPreview()
}), f = new o(i, u, p, g, m, s.helpButton, l), f.setUndoRedoButtonStates(); {
h.refreshPreview = function() {
g.refresh(!0)
}
}
h.undoManager = p, h.uiManager = f
}
}
}, e.prototype.findTags = function(e, t) {
var n, i = this;
e && (n = l.extendRegExp(e, "", "$"), this.before = this.before.replace(n, function(e) {
return i.startTag = i.startTag + e, ""
}), n = l.extendRegExp(e, "^", ""), this.selection = this.selection.replace(n, function(e) {
return i.startTag = i.startTag + e, ""
})), t && (n = l.extendRegExp(t, "", "$"), this.selection = this.selection.replace(n, function(e) {
return i.endTag = e + i.endTag, ""
}), n = l.extendRegExp(t, "^", ""), this.after = this.after.replace(n, function(e) {
return i.endTag = e + i.endTag, ""
}))
}, e.prototype.trimWhitespace = function(e) {
var t, n, i = this;
e ? t = n = "" : (t = function(e) {
return i.before += e, ""
}, n = function(e) {
return i.after = e + i.after, ""
}), this.selection = this.selection.replace(/^(\s*)/, t).replace(/(\s*)$/, n)
}, e.prototype.skipLines = function(e, t, n) {
void 0 === e && (e = 1), void 0 === t && (t = 1), e++, t++;
var i, r;
if(navigator.userAgent.match(/Chrome/) && "X".match(/()./), this.selection = this.selection.replace(/(^\n*)/, ""), this.startTag = this.startTag + p.$1, this.selection = this.selection.replace(/(\n*$)/, ""), this.endTag = this.endTag + p.$1, this.startTag = this.startTag.replace(/(^\n*)/, ""), this.before = this.before + p.$1, this.endTag = this.endTag.replace(/(\n*$)/, ""), this.after = this.after + p.$1, this.before) {
for(i = r = ""; e--;) i += "\\n?", r += "\n";
n && (i = "\\n*"), this.before = this.before.replace(new p(i + "$", ""), r)
}
if(this.after) {
for(i = r = ""; t--;) i += "\\n?", r += "\n";
n && (i = "\\n*"), this.after = this.after.replace(new p(i, ""), r)
}
}, l.isVisible = function(e) {
return window.getComputedStyle ? "none" !== window.getComputedStyle(e, null).getPropertyValue("display") : e.currentStyle ? "none" !== e.currentStyle.display : void 0
}, l.addEvent = function(e, t, n) {
e.attachEvent ? e.attachEvent("on" + t, n) : e.addEventListener(t, n, !1)
}, l.removeEvent = function(e, t, n) {
e.detachEvent ? e.detachEvent("on" + t, n) : e.removeEventListener(t, n, !1)
}, l.fixEolChars = function(e) {
return e = e.replace(/\r\n/g, "\n"), e = e.replace(/\r/g, "\n")
}, l.extendRegExp = function(e, t, n) {
(null === t || void 0 === t) && (t = ""), (null === n || void 0 === n) && (n = "");
var i, r = e.toString();
return r = r.replace(/\/([gim]*)$/, function(e, t) {
return i = t, ""
}), r = r.replace(/(^\/|\/$)/g, ""), r = t + r + n, new p(r, i)
}, c.getTop = function(e, t) {
var n = e.offsetTop;
if(!t)
for(; e = e.offsetParent;) n += e.offsetTop;
return n
}, c.getHeight = function(e) {
return e.offsetHeight || e.scrollHeight
}, c.getWidth = function(e) {
return e.offsetWidth || e.scrollWidth
}, c.getPageSize = function() {
var e, t, n, i;
self.innerHeight && self.scrollMaxY ? (e = d.body.scrollWidth, t = self.innerHeight + self.scrollMaxY) : d.body.scrollHeight > d.body.offsetHeight ? (e = d.body.scrollWidth, t = d.body.scrollHeight) : (e = d.body.offsetWidth, t = d.body.offsetHeight), self.innerHeight ? (n = self.innerWidth, i = self.innerHeight) : d.documentElement && d.documentElement.clientHeight ? (n = d.documentElement.clientWidth, i = d.documentElement.clientHeight) : d.body && (n = d.body.clientWidth, i = d.body.clientHeight);
var r = Math.max(e, n),
o = Math.max(t, i);
return [r, o, n, i]
}, u.createBackground = function() {
var e = d.createElement("div"),
t = e.style;
e.className = "wmd-prompt-background", t.position = "absolute", t.top = "0", t.zIndex = "1000", m.isIE ? t.filter = "alpha(opacity=50)" : t.opacity = "0.5";
var n = c.getPageSize();
return t.height = n[1] + "px", m.isIE ? (t.left = d.documentElement.scrollLeft, t.width = d.documentElement.clientWidth) : (t.left = "0", t.width = "100%"), d.body.appendChild(e), e
}, u.prompt = function(e, t, n) {
var i, r;
void 0 === t && (t = "");
var o = function(e) {
var t = e.charCode || e.keyCode;
27 === t && a(!0)
}, a = function(e) {
l.removeEvent(d.body, "keydown", o);
var t = r.value;
return e ? t = null : (t = t.replace(/^http:\/\/(https?|ftp):\/\//, "$1://"), /^(?:https?|ftp):\/\//.test(t) || (t = "http://" + t)), i.parentNode.removeChild(i), n(t), !1
}, s = function() {
i = d.createElement("div"), i.className = "wmd-prompt-dialog", i.style.padding = "10px;", i.style.position = "fixed", i.style.width = "400px", i.style.zIndex = "1001";
var n = d.createElement("div");
n.innerHTML = e, n.style.padding = "5px", i.appendChild(n);
var s = d.createElement("form"),
u = s.style;
s.onsubmit = function() {
return a(!1)
}, u.padding = "0", u.margin = "0", u.cssFloat = "left", u.width = "100%", u.textAlign = "center", u.position = "relative", i.appendChild(s), r = d.createElement("input"), r.type = "text", r.value = t, u = r.style, u.display = "block", u.width = "80%", u.marginLeft = u.marginRight = "auto", s.appendChild(r);
var p = d.createElement("input");
p.type = "button", p.onclick = function() {
return a(!1)
}, p.value = "OK", u = p.style, u.margin = "10px", u.display = "inline", u.width = "7em";
var h = d.createElement("input");
h.type = "button", h.onclick = function() {
return a(!0)
}, h.value = "Cancel", u = h.style, u.margin = "10px", u.display = "inline", u.width = "7em", s.appendChild(p), s.appendChild(h), l.addEvent(d.body, "keydown", o), i.style.top = "50%", i.style.left = "50%", i.style.display = "block", m.isIE_5or6 && (i.style.position = "absolute", i.style.top = d.documentElement.scrollTop + 200 + "px", i.style.left = "50%"), d.body.appendChild(i), i.style.marginTop = -(c.getHeight(i) / 2) + "px", i.style.marginLeft = -(c.getWidth(i) / 2) + "px"
};
setTimeout(function() {
s();
var e = t.length;
if(void 0 !== r.selectionStart) r.selectionStart = 0, r.selectionEnd = e;
else if(r.createTextRange) {
var n = r.createTextRange();
n.collapse(!1), n.moveStart("character", -e), n.moveEnd("character", e), n.select()
}
r.focus()
}, 0)
};
var y = a.prototype;
y.prefixes = "(?:\\s{4,}|\\s*>|\\s*-\\s+|\\s*\\d+\\.|=|\\+|-|_|\\*|#|\\s*\\[[^\n]]+\\]:)", y.unwrap = function(e) {
var t = new p("([^\\n])\\n(?!(\\n|" + this.prefixes + "))", "g");
e.selection = e.selection.replace(t, "$1 $2")
}, y.wrap = function(e, t) {
this.unwrap(e);
var n = new p("(.{1," + t + "})( +|$\\n?)", "gm"),
i = this;
e.selection = e.selection.replace(n, function(e, t) {
return new p("^" + i.prefixes, "").test(e) ? e : t + "\n"
}), e.selection = e.selection.replace(/\s+$/, "")
}, y.doBold = function(e, t) {
return this.doBorI(e, t, 2, this.getString("boldexample"))
}, y.doItalic = function(e, t) {
return this.doBorI(e, t, 1, this.getString("italicexample"))
}, y.doBorI = function(e, t, n, i) {
e.trimWhitespace(), e.selection = e.selection.replace(/\n{2,}/g, "\n");
var r = /(\**$)/.exec(e.before)[0],
o = /(^\**)/.exec(e.after)[0],
a = Math.min(r.length, o.length);
if(a >= n && (2 != a || 1 != n)) e.before = e.before.replace(p("[*]{" + n + "}$", ""), ""), e.after = e.after.replace(p("^[*]{" + n + "}", ""), "");
else if(!e.selection && o) {
e.after = e.after.replace(/^([*_]*)/, ""), e.before = e.before.replace(/(\s?)$/, "");
var s = p.$1;
e.before = e.before + o + s
} else {
e.selection || o || (e.selection = i);
var l = 1 >= n ? "*" : "**";
e.before = e.before + l, e.after = l + e.after
}
}, y.stripLinkDefs = function(e, t) {
return e = e.replace(/^[ ]{0,3}\[(\d+)\]:[ \t]*\n?[ \t]*(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|$)/gm, function(e, n, i, r, o) {
return t[n] = e.replace(/\s*$/, ""), r ? (t[n] = e.replace(/["(](.+?)[")]$/, ""), r + o) : ""
})
}, y.addLinkDef = function(e, t) {
var n = 0,
i = {};
e.before = this.stripLinkDefs(e.before, i), e.selection = this.stripLinkDefs(e.selection, i), e.after = this.stripLinkDefs(e.after, i);
var r = "",
o = /(\[)((?:\[[^\]]*\]|[^\[\]])*)(\][ ]?(?:\n[ ]*)?\[)(\d+)(\])/g,
a = function(e) {
n++, e = e.replace(/^[ ]{0,3}\[(\d+)\]:/, " [" + n + "]:"), r += "\n" + e
}, s = function(e, t, r, l, c, u) {
return r = r.replace(o, s), i[c] ? (a(i[c]), t + r + l + n + u) : e
};
e.before = e.before.replace(o, s), t ? a(t) : e.selection = e.selection.replace(o, s);
var l = n;
return e.after = e.after.replace(o, s), e.after && (e.after = e.after.replace(/\n*$/, "")), e.after || (e.selection = e.selection.replace(/\n*$/, "")), e.after += "\n\n" + r, l
}, y.doLinkOrImage = function(e, t, n) {
e.trimWhitespace(), e.findTags(/\s*!?\[/, /\][ ]?(?:\n[ ]*)?(\(.*?\))?/);
var i;
if(!(e.endTag.length > 1 && e.startTag.length > 0)) {
if(e.selection = e.startTag + e.selection + e.endTag, e.startTag = e.endTag = "", /\n\n/.test(e.selection)) return void this.addLinkDef(e, null);
var r = this,
o = function(o) {
i.parentNode.removeChild(i), null !== o && (e.selection = (" " + e.selection).replace(/([^\\](?:\\\\)*)(?=[[\]])/g, "$1\\").substr(1), e.startTag = n ? "![" : "[", e.endTag = "](" + s(o) + ")", e.selection || (e.selection = r.getString(n ? "imagedescription" : "linkdescription"))), t()
};
return i = u.createBackground(), n ? this.hooks.insertImageDialog(o) || u.prompt(this.getString("imagedialog"), v, o) : this.hooks.insertLinkDialog(o) || u.prompt(this.getString("linkdialog"), b, o), !0
}
e.startTag = e.startTag.replace(/!?\[/, ""), e.endTag = "", this.addLinkDef(e, null)
}, y.doAutoindent = function(e) {
var t = this,
n = !1;
e.before = e.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/, "\n\n"), e.before = e.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/, "\n\n"), e.before = e.before.replace(/(\n|^)[ \t]+\n$/, "\n\n"), e.selection || /^[ \t]*(?:\n|$)/.test(e.after) || (e.after = e.after.replace(/^[^\n]*/, function(t) {
return e.selection = t, ""
}), n = !0), /(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]+.*\n$/.test(e.before) && t.doList && t.doList(e), /(\n|^)[ ]{0,3}>[ \t]+.*\n$/.test(e.before) && t.doBlockquote && t.doBlockquote(e), /(\n|^)(\t|[ ]{4,}).*\n$/.test(e.before) && t.doCode && t.doCode(e), n && (e.after = e.selection + e.after, e.selection = "")
}, y.doBlockquote = function(e) {
e.selection = e.selection.replace(/^(\n*)([^\r]+?)(\n*)$/, function(t, n, i, r) {
return e.before += n, e.after = r + e.after, i
}), e.before = e.before.replace(/(>[ \t]*)$/, function(t, n) {
return e.selection = n + e.selection, ""
}), e.selection = e.selection.replace(/^(\s|>)+$/, ""), e.selection = e.selection || this.getString("quoteexample");
var t, n = "",
i = "";
if(e.before) {
for(var r = e.before.replace(/\n$/, "").split("\n"), o = !1, a = 0; a < r.length; a++) {
var s = !1;
t = r[a], o = o && t.length > 0, /^>/.test(t) ? (s = !0, !o && t.length > 1 && (o = !0)) : s = /^[ \t]*$/.test(t) ? !0 : o, s ? n += t + "\n" : (i += n + t, n = "\n")
}
/(^|\n)>/.test(n) || (i += n, n = "")
}
e.startTag = n, e.before = i, e.after && (e.after = e.after.replace(/^\n?/, "\n")), e.after = e.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/, function(t) {
return e.endTag = t, ""
});
var l = function(t) {
var n = t ? "> " : "";
e.startTag && (e.startTag = e.startTag.replace(/\n((>|\s)*)\n$/, function(e, t) {
return "\n" + t.replace(/^[ ]{0,3}>?[ \t]*$/gm, n) + "\n"
})), e.endTag && (e.endTag = e.endTag.replace(/^\n((>|\s)*)\n/, function(e, t) {
return "\n" + t.replace(/^[ ]{0,3}>?[ \t]*$/gm, n) + "\n"
}))
};
/^(?![ ]{0,3}>)/m.test(e.selection) ? (this.wrap(e, f.lineLength - 2), e.selection = e.selection.replace(/^/gm, "> "), l(!0), e.skipLines()) : (e.selection = e.selection.replace(/^[ ]{0,3}> ?/gm, ""), this.unwrap(e), l(!1), !/^(\n|^)[ ]{0,3}>/.test(e.selection) && e.startTag && (e.startTag = e.startTag.replace(/\n{0,2}$/, "\n\n")), !/(\n|^)[ ]{0,3}>.*$/.test(e.selection) && e.endTag && (e.endTag = e.endTag.replace(/^\n{0,2}/, "\n\n"))), e.selection = this.hooks.postBlockquoteCreation(e.selection), /\n/.test(e.selection) || (e.selection = e.selection.replace(/^(> *)/, function(t, n) {
return e.startTag += n, ""
}))
}, y.doCode = function(e) {
var t = /\S[ ]*$/.test(e.before),
n = /^[ ]*\S/.test(e.after);
if(!n && !t || /\n/.test(e.selection)) {
e.before = e.before.replace(/[ ]{4}$/, function(t) {
return e.selection = t + e.selection, ""
});
var i = 1,
r = 1;
/(\n|^)(\t|[ ]{4,}).*\n$/.test(e.before) && (i = 0), /^\n(\t|[ ]{4,})/.test(e.after) && (r = 0), e.skipLines(i, r), e.selection ? /^[ ]{0,3}\S/m.test(e.selection) ? /\n/.test(e.selection) ? e.selection = e.selection.replace(/^/gm, " ") : e.before += " " : e.selection = e.selection.replace(/^(?:[ ]{4}|[ ]{0,3}\t)/gm, "") : (e.startTag = " ", e.selection = this.getString("codeexample"))
} else e.trimWhitespace(), e.findTags(/`/, /`/), e.startTag || e.endTag ? e.endTag && !e.startTag ? (e.before += e.endTag, e.endTag = "") : e.startTag = e.endTag = "" : (e.startTag = e.endTag = "`", e.selection || (e.selection = this.getString("codeexample")))
}, y.doList = function(e, t, n) {
var i = /(\n|^)(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*$/,
r = /^\n*(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/,
o = "-",
a = 1,
s = function() {
var e;
return n ? (e = " " + a + ". ", a++) : e = " " + o + " ", e
}, l = function(e) {
return void 0 === n && (n = /^\s*\d/.test(e)), e = e.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm, function() {
return s()
})
};
if(e.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/, null), !e.before || /\n$/.test(e.before) || /^\n/.test(e.startTag) || (e.before += e.startTag, e.startTag = ""), e.startTag) {
var c = /\d+[.]/.test(e.startTag);
if(e.startTag = "", e.selection = e.selection.replace(/\n[ ]{4}/g, "\n"), this.unwrap(e), e.skipLines(), c && (e.after = e.after.replace(r, l)), n == c) return
}
var u = 1;
e.before = e.before.replace(i, function(e) {
return /^\s*([*+-])/.test(e) && (o = p.$1), u = /[^\n]\n\n[^\n]/.test(e) ? 1 : 0, l(e)
}), e.selection || (e.selection = this.getString("litem"));
var d = s(),
h = 1;
e.after = e.after.replace(r, function(e) {
return h = /[^\n]\n\n[^\n]/.test(e) ? 1 : 0, l(e)
}), e.trimWhitespace(!0), e.skipLines(u, h, !0), e.startTag = d;
var m = d.replace(/./g, " ");
this.wrap(e, f.lineLength - m.length), e.selection = e.selection.replace(/\n/g, "\n" + m)
}, y.doHeading = function(e) {
if(e.selection = e.selection.replace(/\s+/g, " "), e.selection = e.selection.replace(/(^\s+|\s+$)/g, ""), !e.selection) return e.startTag = "## ", e.selection = this.getString("headingexample"), void(e.endTag = " ##");
var t = 0;
e.findTags(/#+[ ]*/, /[ ]*#+/), /#+/.test(e.startTag) && (t = p.lastMatch.length), e.startTag = e.endTag = "", e.findTags(null, /\s?(-+|=+)/), /=+/.test(e.endTag) && (t = 1), /-+/.test(e.endTag) && (t = 2), e.startTag = e.endTag = "", e.skipLines(1, 1);
var n = 0 == t ? 2 : t - 1;
if(n > 0) {
var i = n >= 2 ? "-" : "=",
r = e.selection.length;
for(r > f.lineLength && (r = f.lineLength), e.endTag = "\n"; r--;) e.endTag += i
}
}, y.doHorizontalRule = function(e) {
e.startTag = "----------\n", e.selection = "", e.skipLines(2, 1, !0)
}
}(), define("pagedown", function() {}), define("core", ["jquery", "underscore", "crel", "editor", "layout", "constants", "utils", "storage", "settings", "eventMgr", "text!html/bodyIndex.html", "text!html/bodyViewer.html", "text!html/tooltipSettingsTemplate.html", "storage", "pagedown"], function(e, t, n, i, r, o, a, s, l, c, u, d, p) {
function h() {
C = !0, _ = !0;
var e = a.currentTime;
e > T + 1e3 && (T = e, c.onUserActive())
}
function f() {
return a.currentTime - T > o.USER_IDLE_THRESHOLD && (_ = !1), _ && k
}
function m() {
if(C !== !1 && k !== !1) {
void 0 === w && (w = a.randomString(), s.frontWindowId = w);
var t = s.frontWindowId;
t != w && (k = !1, void 0 !== x && clearInterval(x), e(".modal").modal("hide"), e(".modal-non-unique").modal("show"), window.close())
}
}
function g() {
E === !0 && (E = !1, c.onOfflineChanged(!1))
}
function v() {
E === !0 && navigator.onLine === !0 && I + o.CHECK_ONLINE_PERIOD < a.currentTime && (I = a.currentTime, e.ajax({
url: "//www.google.com/jsapi",
timeout: o.AJAX_TIMEOUT,
dataType: "script"
}).done(function() {
g()
}))
}
function b() {
a.setInputRadio("radio-layout-orientation", l.layoutOrientation), a.setInputValue(N, window.theme), N.change(), a.setInputChecked("#input-settings-lazy-rendering", l.lazyRendering), a.setInputRadio("radio-settings-editor-font-class", l.editorFontClass), a.setInputValue("#input-settings-font-size", l.fontSizeRatio), a.setInputValue("#input-settings-max-width", l.maxWidthRatio), a.setInputValue("#input-settings-cursor-focus", l.cursorFocusRatio), a.setInputValue("#textarea-settings-default-content", l.defaultContent), a.setInputRadio("radio-settings-edit-mode", l.editMode), a.setInputValue("#input-settings-publish-commit-msg", l.commitMsg), a.setInputValue("#input-settings-markdown-mime-type", l.markdownMimeType), a.setInputValue("#input-settings-gdrive-multiaccount", l.gdriveMultiAccount), a.setInputChecked("#input-settings-gdrive-full-access", l.gdriveFullAccess), a.setInputChecked("#input-settings-dropbox-full-access", l.dropboxFullAccess), a.setInputChecked("#input-settings-github-full-access", l.githubFullAccess), a.setInputValue("#textarea-settings-publish-template", l.template), a.setInputValue("#textarea-settings-pdf-template", l.pdfTemplate), a.setInputValue("#input-settings-pdf-page-size", l.pdfPageSize), a.setInputValue("#input-settings-ssh-proxy", l.sshProxy), c.onLoadSettings()
}
function y(t) {
var n = {};
n.layoutOrientation = a.getInputRadio("radio-layout-orientation");
var i = a.getInputValue(N);
n.lazyRendering = a.getInputChecked("#input-settings-lazy-rendering"), n.editorFontClass = a.getInputRadio("radio-settings-editor-font-class"), n.fontSizeRatio = a.getInputFloatValue("#input-settings-font-size", t, .1, 10), n.maxWidthRatio = a.getInputFloatValue("#input-settings-max-width", t, .1, 10), n.cursorFocusRatio = a.getInputFloatValue("#input-settings-cursor-focus", t, 0, 1), n.defaultContent = a.getInputValue("#textarea-settings-default-content"), n.editMode = a.getInputRadio("radio-settings-edit-mode"), n.commitMsg = a.getInputTextValue("#input-settings-publish-commit-msg", t), n.gdriveMultiAccount = a.getInputIntValue("#input-settings-gdrive-multiaccount"), n.markdownMimeType = a.getInputValue("#input-settings-markdown-mime-type"), n.gdriveFullAccess = a.getInputChecked("#input-settings-gdrive-full-access"), n.dropboxFullAccess = a.getInputChecked("#input-settings-dropbox-full-access"), n.githubFullAccess = a.getInputChecked("#input-settings-github-full-access"), n.template = a.getInputTextValue("#textarea-settings-publish-template", t), n.pdfTemplate = a.getInputTextValue("#textarea-settings-pdf-template", t), n.pdfPageSize = a.getInputValue("#input-settings-pdf-page-size"), n.sshProxy = a.checkUrl(a.getInputTextValue("#input-settings-ssh-proxy", t), !0), n.extensionSettings = {}, c.onSaveSettings(n.extensionSettings, t), t.isPropagationStopped() || (l.dropboxFullAccess !== n.dropboxFullAccess && s.removeItem("dropbox.lastChangeId"), e.extend(l, n), s.settings = JSON.stringify(l), s.themeV3 = i)
}
var x, w, S = {}, C = !1,
_ = !1,
k = !0,
T = 0,
E = !1,
I = a.currentTime;
S.setOffline = function() {
I = a.currentTime, E === !1 && (E = !0, c.onOfflineChanged(!0))
};
var N, D, L;
return S.initEditor = function(t) {
if(void 0 !== L && c.onFileClosed(L), L = t, void 0 !== D) return i.undoMgr.init(), D.uiManager.setUndoRedoButtonStates();
var n = new Markdown.Converter,
r = {
_DoItalicsAndBold: function(e) {
return e = e.replace(/(\*\*|__)(?=\S)(.+?[*_]*)(?=\S)\1/g, "$2"), e = e.replace(/(\*|_)(?=\S)(.+?)(?=\S)\1/g, "$2")
}
};
n.setOptions(r), D = new Markdown.Editor(n, void 0, {
undoManager: i.undoMgr
}), D.hooks.set("insertLinkDialog", function(t) {
return S.insertLinkCallback = t, a.resetModalInputs(), e(".modal-insert-link").modal(), !0
}), D.hooks.set("insertImageDialog", function(t) {
return S.insertLinkCallback = t, S.catchModal ? !0 : (a.resetModalInputs(), e(".modal-insert-image").modal(), !0)
}), c.onPagedownConfigure(D), D.hooks.chain("onPreviewRefresh", c.onAsyncPreview), D.run(), i.undoMgr.init(), e(".wmd-button-row li").addClass("btn btn-success").css("left", 0).find("span").hide();
var o = e(".wmd-button-group1");
e("#wmd-bold-button").append(e('')).appendTo(o), e("#wmd-italic-button").append(e('')).appendTo(o), o = e(".wmd-button-group2"), e("#wmd-link-button").append(e('')).appendTo(o), e("#wmd-quote-button").append(e('')).appendTo(o), e("#wmd-code-button").append(e('')).appendTo(o), e("#wmd-image-button").append(e('')).appendTo(o), o = e(".wmd-button-group3"), e("#wmd-olist-button").append(e('')).appendTo(o), e("#wmd-ulist-button").append(e('')).appendTo(o), e("#wmd-heading-button").append(e('')).appendTo(o), e("#wmd-hr-button").append(e('')).appendTo(o), o = e(".wmd-button-group5"), e("#wmd-undo-button").append(e('')).appendTo(o), e("#wmd-redo-button").append(e('')).appendTo(o)
}, S.onReady = function() {
document.body.className += " " + l.editMode, document.body.innerHTML = window.viewerMode === !0 ? d : u, a.init(), e(window).on("offline", S.setOffline), e(window).on("online", g), navigator.onLine === !1 && S.setOffline(), e(document).mousemove(h).keypress(h), r.init(), i.init(), x = window.setInterval(function() {
a.updateCurrentTime(), m(), (f() === !0 || window.viewerMode === !0) && (c.onPeriodicRun(), v())
}, 1e3), c.onReady()
}, c.addListener("onReady", function() {
function n(e) {
if(e = e || "default", r != e) {
var t = "less!themes/" + e; - 1 !== window.baseDir.indexOf("-min") && (t = "css!themes/" + e), requirejs.undef(t), require([t]), r = e
}
}
e(".modal").on("shown.bs.modal", function() {
var t = e(this);
setTimeout(function() {
t.find(".btn:first").focus(), t.find("button:first").focus(), t.find("input:enabled:visible:first").focus()
}, 50)
}).on("hidden.bs.modal", function() {
i.focus(), n(window.theme)
}).keyup(function(t) {
13 != t.which || e(t.target).is("textarea") || e(this).find(".modal-footer a:last").click()
}), e(".action-insert-link").click(function(t) {
var n = a.getInputTextValue(e("#input-insert-link"), t);
void 0 !== n && (S.insertLinkCallback(n), S.insertLinkCallback = void 0)
}), e(".action-insert-image").click(function(t) {
var n = a.getInputTextValue(e("#input-insert-image"), t);
void 0 !== n && (S.insertLinkCallback(n), S.insertLinkCallback = void 0)
}), e(".modal-insert-link, .modal-insert-image").on("hidden.bs.modal", function() {
void 0 !== S.insertLinkCallback && (S.insertLinkCallback(null), S.insertLinkCallback = void 0)
}), e(".action-load-settings").click(function() {
b()
}), e(".action-apply-settings").click(function(e) {
y(e), e.isPropagationStopped() || window.location.reload()
}), e(".action-add-google-drive-account").click(function() {
3 !== l.gdriveMultiAccount && (l.gdriveMultiAccount++, s.settings = JSON.stringify(l), window.location.reload())
});
var r = window.theme;
N = e("#input-settings-theme"), N.on("change", function() {
n(this.value)
}), e(".action-import-docs-settings").click(function() {
e("#input-file-import-docs-settings").click()
});
var u;
if(e("#input-file-import-docs-settings").change(function(n) {
var i = (n.dataTransfer || n.target).files;
e(".modal-settings").modal("hide"), t.each(i, function(t) {
var n = new FileReader;
n.onload = function(t) {
return function(n) {
try {
u = JSON.parse(n.target.result);
var i = parseInt(u.version.match(/^v(\d+)$/)[1], 10),
r = parseInt(s.version.match(/^v(\d+)$/)[1], 10);
i > r ? c.onError("Incompatible version. Please upgrade StackEdit.") : e(".modal-import-docs-settings").modal("show")
} catch(o) {
c.onError("Wrong format: " + t.name)
}
e("#input-file-import-docs-settings").val("")
}
}(t), n.readAsText(t)
})
}), e(".action-import-docs-settings-confirm").click(function() {
s.clear();
var e = /^file\.|^folder\.|^publish\.|^settings$|^sync\.|^google\.|^author\.|^themeV3$|^version$/;
t.each(u, function(t, n) {
e.test(n) && (s[n] = t)
}), window.location.reload()
}), e(".action-export-docs-settings").click(function() {
a.saveAs(JSON.stringify(s), "StackEdit local storage.json")
}), e(".action-default-settings").click(function() {
s.removeItem("settings"), s.removeItem("theme"), l.dropboxFullAccess || s.removeItem("dropbox.lastChangeId"), window.location.reload()
}), e(".action-app-reset").click(function() {
s.clear(), window.location.reload()
}), e(".action-reset-input").click(function() {
a.resetModalInputs()
}), a.createTooltip(".tooltip-lazy-rendering", "Disable preview rendering while typing in order to offload CPU. Refresh preview after 500 ms of inactivity."), a.createTooltip(".tooltip-default-content", ["Thanks for supporting StackEdit by adding a backlink in your documents!
", 'NOTE: Backlinks in Stack Exchange Q/A are not welcome.'].join("")), a.createTooltip(".tooltip-template", p), e("div.dropdown-menu").click(function(e) {
e.stopPropagation()
}), e(".modal-non-unique").modal({
backdrop: "static",
keyboard: !1,
show: !1
}), t.each(document.querySelectorAll("img"), function(t) {
var n = e(t),
i = n.data("stackeditSrc");
i && n.attr("src", window.baseDir + "/img/" + i)
}), window.viewerMode === !1) {
var d = t.reduce(o.THEME_LIST, function(e, t, n) {
return e + '"
}, "");
document.getElementById("input-settings-theme").innerHTML = d
}
e(".modal-header").append('Give your feedback ')
}), S
}), define("text!WELCOME.md", [], function() {
return 'Welcome to StackEdit! {#welcome}\n====================\n\n\nHello, I am your first Markdown document within **StackEdit**[^stackedit]. Don\'t delete me, I can be helpful. I can be recovered anyway in the `Utils` tab of the `Settings` dialog.\n\n----------\n\n\nDocuments\n--------------\n\n**StackEdit** stores your documents in your browser, which means all your documents are automatically saved locally and are accessible **offline!**\n\n> **Note:**\n\n> - StackEdit is accessible offline after the application has been loaded for the first time.\n> - Your local documents are not shared between different browsers or computers.\n> - Clearing your browser\'s data may **delete all your local documents!** Make sure your documents are backed up using **Google Drive** or **Dropbox** synchronization (see [ Synchronization](#synchronization) section).\n\n#### Create a document\n\nThe document panel is accessible using button in the navigation bar. You can create a new document by clicking the `New document` sub-menu in the document panel.\n\n#### Switch to another document\n\nAll your local documents are listed in the document panel. You can switch from one to another by clicking a document in the document panel or you can also use Ctrl+[ and Ctrl+] to toggle documents by most recently used.\n\n#### Rename a document\n\nYou can rename the current document by clicking the document title in the navigation bar.\n\n#### Delete a document\n\nYou can delete the current document by clicking the `Delete document` sub-menu in the document panel.\n\n#### Export a document\n\nYou can save the current document to a file using the `Export to disk` sub-menu from the menu panel.\n\n> **Tip:** See [ Publish a document](#publish-a-document) section for a description of the different output formats.\n\n\n----------\n\n\nSynchronization\n--------------------\n\n**StackEdit** can be combined with **Google Drive** and **Dropbox** to have your documents centralized in the *Cloud*. The synchronization mechanism will take care of uploading your modifications or downloading the latest version of your documents.\n\n> **Note:**\n\n> - Full access to **Google Drive** or **Dropbox** is required to be able to import any document in StackEdit. Permission restrictions can be configured in the settings.\n> - Imported documents are downloaded in your browser and are not transmitted to a server.\n> - If you experience problems saving your documents on Google Drive, check and optionally disable browser extensions, such as Disconnect.\n\n#### Open a document\n\nYou can open a document from **Google Drive** or the **Dropbox** by opening the `Synchronize` sub-menu and by clicking `Open from...`. Once opened, any modification in your document will be automatically synchronized with the **Google Drive** / **Dropbox** file.\n\n#### Save a document\n\nYou can save any document by opening the `Synchronize` sub-menu and by clicking `Save on...`. Even if your document is already synchronized with **Google Drive** or **Dropbox**, you can export it to a another location. **StackEdit** can synchronize one document with multiple locations.\n\n#### Synchronize a document\n\nOnce your document is linked to a **Google Drive** or a **Dropbox** file, **StackEdit** will periodically (every 3 minutes) synchronize it by downloading/uploading any modification. Any conflict will be detected, and a local copy of your document will be created as a backup if necessary.\n\nIf you just have modified your document and you want to force the synchronization, click the button in the navigation bar.\n\n> **Note:** The button is disabled when you have no document to synchronize.\n\n#### Manage document synchronization\n\nSince one document can be synchronized with multiple locations, you can list and manage synchronized locations by clicking `Manage synchronization` in the `Synchronize` sub-menu. This will let you remove synchronization locations that are associated to your document.\n\n> **Note:** If you delete the file from **Google Drive** or from **Dropbox**, the document will no longer be synchronized with that location.\n\n----------\n\n\nPublication\n--------------\n\nOnce you are happy with your document, you can publish it on different websites directly from **StackEdit**. As for now, **StackEdit** can publish on **Blogger**, **Dropbox**, **Gist**, **GitHub**, **Google Drive**, **Tumblr**, **WordPress** and on any SSH server.\n\n#### Publish a document\n\nYou can publish your document by opening the `Publish` sub-menu and by choosing a website. In the dialog box, you can choose the publication format:\n\n- Markdown, to publish the Markdown text on a website that can interpret it (**GitHub** for example),\n- HTML, to publish the document converted into HTML (on a blog for example),\n- Template, to have a full control of the output.\n\n> **Note:** The default template is a simple webpage wrapping your document in HTML format. You can customize it in the `Advanced` tab of the `Settings` dialog.\n\n#### Update a publication\n\nAfter publishing, **StackEdit** will keep your document linked to that publication which makes it easy for you to update it. Once you have modified your document and you want to update your publication, click on the button in the navigation bar.\n\n> **Note:** The button is disabled when your document has not been published yet.\n\n#### Manage document publication\n\nSince one document can be published on multiple locations, you can list and manage publish locations by clicking `Manage publication` in the menu. This will let you remove publication locations that are associated to your document.\n\n> **Note:** In some cases, if the file has been removed from the website or the blog, the document will no longer be published on that location.\n\n----------\n\n\nMarkdown Extra\n--------------------\n\n**StackEdit** supports **Markdown Extra**, which extends **Markdown** syntax with some nice features.\n\n> **Tip:** You can disable any **Markdown Extra** feature in the `Extensions` tab of the `Settings` dialog.\n\n> **Note:** You can find more information about **Markdown** syntax [here][2] and **Markdown Extra** extension [here][3].\n\n\n### Tables\n\n**Markdown Extra** has a special syntax for tables:\n\nItem | Value\n-------- | ---\nComputer | $1600\nPhone | $12\nPipe | $1\n\nYou can specify column alignment with one or two colons:\n\n| Item | Value | Qty |\n| :------- | ----: | :---: |\n| Computer | $1600 | 5 |\n| Phone | $12 | 12 |\n| Pipe | $1 | 234 |\n\n\n### Definition Lists\n\n**Markdown Extra** has a special syntax for definition lists too:\n\nTerm 1\nTerm 2\n: Definition A\n: Definition B\n\nTerm 3\n\n: Definition C\n\n: Definition D\n\n > part of definition D\n\n\n### Fenced code blocks\n\nGitHub\'s fenced code blocks[^gfm] are also supported with **Prettify** syntax highlighting:\n\n```\n// Foo\nvar bar = 0;\n```\n\n> **Tip:** To use **Highlight.js** instead of **Prettify**, just configure the `Markdown Extra` extension in the `Settings` dialog.\n\n> **Note:** You can find more information:\n\n> - about **Prettify** syntax highlighting [here][5],\n> - about **Highlight.js** syntax highlighting [here][6].\n\n\n### Footnotes\n\nYou can create footnotes like this[^footnote].\n\n [^footnote]: Here is the *text* of the **footnote**.\n\n\n### SmartyPants\n\nSmartyPants converts ASCII punctuation characters into "smart" typographic punctuation HTML entities. For example:\n\n| | ASCII | HTML |\n ----------------- | ---------------------------- | ------------------\n| Single backticks | `\'Isn\'t this fun?\'` | \'Isn\'t this fun?\' |\n| Quotes | `"Isn\'t this fun?"` | "Isn\'t this fun?" |\n| Dashes | `-- is en-dash, --- is em-dash` | -- is en-dash, --- is em-dash |\n\n\n### Table of contents\n\nYou can insert a table of contents using the marker `[TOC]`:\n\n[TOC]\n\n\n### MathJax\n\nYou can render *LaTeX* mathematical expressions using **MathJax**, as on [math.stackexchange.com][1]:\n\nThe *Gamma function* satisfying $\\Gamma(n) = (n-1)!\\quad\\forall n\\in\\mathbb N$ is via the Euler integral\n\n$$\n\\Gamma(z) = \\int_0^\\infty t^{z-1}e^{-t}dt\\,.\n$$\n\n> **Tip:** Make sure you include **MathJax** into your publications to render mathematical expression properly. Your page/template should include something like this:\n\n```\n\n```\n\n> **Note:** You can find more information about **LaTeX** mathematical expressions [here][4].\n\n\n### UML diagrams\n\nYou can also render sequence diagrams like this:\n\n```sequence\nAlice->Bob: Hello Bob, how are you?\nNote right of Bob: Bob thinks\nBob-->Alice: I am good thanks!\n```\n\nAnd flow charts like this:\n\n```flow\nst=>start: Start\ne=>end\nop=>operation: My Operation\ncond=>condition: Yes or No?\n\nst->op->cond\ncond(yes)->e\ncond(no)->op\n```\n\n> **Note:** You can find more information:\n\n> - about **Sequence diagrams** syntax [here][7],\n> - about **Flow charts** syntax [here][8].\n\n [^stackedit]: [StackEdit](https://stackedit.io/) is a full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.\n\n [^gfm]: **GitHub Flavored Markdown** (GFM) is supported by StackEdit.\n\n\n [1]: http://math.stackexchange.com/\n [2]: http://daringfireball.net/projects/markdown/syntax "Markdown"\n [3]: https://github.com/jmcmanus/pagedown-extra "Pagedown Extra"\n [4]: http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference\n [5]: https://code.google.com/p/google-code-prettify/\n [6]: http://highlightjs.org/\n [7]: http://bramp.github.io/js-sequence-diagrams/\n [8]: http://adrai.github.io/flowchart.js/\n'
}), define("fileMgr", ["jquery", "underscore", "constants", "core", "utils", "storage", "settings", "eventMgr", "fileSystem", "classes/FileDescriptor", "text!WELCOME.md"], function(e, t, n, i, r, o, a, s, l, c, u) {
var d = {};
return d.currentFile = void 0, d.selectFile = function(r) {
if(r = r || d.currentFile, void 0 === r) {
var o = t.size(l);
r = 0 === o ? d.createFile(n.WELCOME_DOCUMENT_TITLE, u) : t.max(l, function(e) {
return e.selectTime || 0
})
}
d.currentFile !== r && (d.currentFile = r, r.selectTime = (new Date).getTime(), s.onFileSelected(r), e(".action-edit-document").toggleClass("hide", r.fileIndex != n.TEMPORARY_FILE_INDEX)), i.initEditor(r)
}, d.createFile = function(e, i, u, d, p) {
if(i = void 0 !== i ? i : a.defaultContent, !e) {
e = n.DEFAULT_FILE_TITLE;
for(var h = 2, f = function(t) {
return t.title == e
}; t.some(l, f);) e = n.DEFAULT_FILE_TITLE + h++
}
var m = n.TEMPORARY_FILE_INDEX;
if(!p)
do m = "file." + r.randomString(); while (t.has(l, m));
d = d || {};
var g = t.reduce(d, function(e, t) {
return r.storeAttributes(t), e + t.syncIndex + ";"
}, ";");
o[m + ".title"] = e, o[m + ".content"] = i, o[m + ".sync"] = g, o[m + ".publish"] = ";";
var v = new c(m, e, d);
return u && (v.discussionListJSON = u), p || (r.appendIndexToArray("file.list", m), l[m] = v, s.onFileCreated(v)), v
}, d.deleteFile = function(e) {
e = e || d.currentFile, e.folder && (e.folder.removeFile(e), s.onFoldersChanged()), r.removeIndexFromArray("file.list", e.fileIndex), delete l[e.fileIndex], d.currentFile === e && (d.currentFile = void 0, d.selectFile()), s.onFileDeleted(e)
}, d.getFileFromSyncIndex = function(e) {
return t.find(l, function(n) {
return t.has(n.syncLocations, e)
})
}, d.getFileFromPublishIndex = function(e) {
return t.find(l, function(n) {
return t.has(n.publishLocations, e)
})
}, s.addListener("onReady", function() {
function t() {
o.addClass("hide"), r.removeClass("hide");
var t = e.trim(o.val()),
n = d.currentFile;
t && t != n.title && (n.title = t, s.onTitleChanged(n)), o.val(n.title), i.focus()
}
var i = e("#wmd-input");
d.selectFile();
var r = e(".file-title-navbar"),
o = e(".input-file-title");
e(".action-create-file").click(function() {
setTimeout(function() {
var e = d.createFile();
d.selectFile(e), r.click()
}, 400)
}), e(".action-remove-file-confirm").click(function() {
e(".modal-remove-file-confirm").modal("show")
}), e(".action-remove-file").click(function() {
d.deleteFile()
}), r.click(function() {
if(window.viewerMode !== !0) {
r.addClass("hide");
var e = o.removeClass("hide");
setTimeout(function() {
e.focus().get(0).select()
}, 10)
}
}), o.blur(function() {
t()
}).keyup(function(e) {
13 == e.keyCode && t(), 27 == e.keyCode && (o.val(""), t())
}), e(".action-open-stackedit").click(function() {
window.location.href = "."
}), e(".action-edit-document").click(function() {
var e = i.val(),
t = d.currentFile.title,
n = d.createFile(t, e);
d.selectFile(n), window.location.href = "."
}), e(".action-welcome-file").click(function() {
var e = d.createFile(n.WELCOME_DOCUMENT_TITLE, u);
d.selectFile(e)
})
}), s.onFileMgrCreated(d), d
}), define("classes/Provider", ["underscore", "utils", "settings", "eventMgr", "fileMgr", "editor", "diff_match_patch_uncompressed", "jsondiffpatch"], function(e, t, n, i, r, o, a, s) {
function l(e, t) {
this.providerId = e, this.providerName = t, this.isPublishEnabled = !0
}
l.prototype.parseDiscussionList = function(t) {
try {
var n = JSON.parse(t);
return e.each(n, function(t, n) {
if(t.discussionIndex != n || !e.isNumber(t.selectionStart) || !e.isNumber(t.selectionEnd)) throw "invalid";
t.commentList && t.commentList.forEach(function(t) {
if(t.author && !e.isString(t.author) || !e.isString(t.content)) throw "invalid"
})
}), n
} catch(i) {}
}, l.prototype.serializeContent = function(e, t) {
return t.length > 2 ? e + "" : e
}, l.prototype.parseContent = function(e) {
var t, n = "{}",
i = /$/.exec(e);
return i && (t = this.parseDiscussionList(i[1])) && (e = e.substring(0, i.index), n = i[1]), {
content: e,
discussionList: t || {},
discussionListJSON: n
}
};
var c = new a;
c.Match_Threshold = 0, c.Patch_DeleteThreshold = 0;
var u = s.create({
objectHash: function(e) {
return JSON.stringify(e)
},
textDiff: {
minLength: 9999999
}
}),
d = "merge" == n.conflictMode;
return l.prototype.syncMerge = function(n, a, s, l, p, h) {
function f(e) {
function t() {
(i[1] || r[1]) && (i[1] && r[1] ? (i[1] = "⧸⧸" + i[1] + "⧸⧸", r[1] += "⧸⧸", n.push(i), n.push(r)) : n.push([0, i[1] + r[1]]), i = [-1, ""], r = [1, ""])
}
var n = [],
i = [-1, ""],
r = [1, ""],
o = 20;
return e.forEach(function(a, s) {
function l() {
return 0 === s || s === e.length - 1
}
var c = a[0],
u = a[1];
if(0 === c)
if(l() || u.length > o) {
if(i[1] || r[1]) {
var d = /\s/.exec(u);
if(d) {
var p = d.index,
h = u.substring(0, p);
u = u.substring(p), i[1] += h, r[1] += h
}
}
if(u) {
for(var f = u.length; f && /\S/.test(u[f - 1]);) f--;
var m = u.substring(f);
u = u.substring(0, f), l() || u.length > o ? (t(), n.push([0, u])) : (i[1] += u, r[1] += u), i[1] += m, r[1] += m
}
} else i[1] += u, r[1] += u;
else -1 === c ? i[1] += u : 1 === c && (r[1] += u)
}), i[1] == r[1] ? n.push([0, r[1]]) : t(), n
}
var m = n.content,
g = n.title,
v = n.discussionListJSON,
b = n.discussionList,
y = t.crc32(m),
x = t.crc32(g),
w = t.crc32(v),
S = t.crc32(s),
C = t.crc32(l),
_ = t.crc32(h),
k = a.contentCRC != y,
T = a.contentCRC != S,
E = m != s && T,
I = E && k;
a.titleCRC = a.titleCRC || x;
var N, D, L = a.titleCRC != x,
M = a.titleCRC != C,
A = g != l && M,
R = A && L,
P = a.discussionListCRC != w,
F = a.discussionListCRC != _,
O = v != h && F,
B = O && P,
j = [],
$ = s,
q = l,
G = p,
H = !1,
U = !1,
z = !1;
if(!d && (I || R || B) || I && void 0 === a.content || R && void 0 === a.title || B && void 0 === a.discussionList) r.createFile(g + " (backup)", m, v), i.onMessage('Conflict detected on "' + g + '". A backup has been created locally.');
else {
if(I) {
var V = a.content;
N = c.diff_main(V, m), c.diff_cleanupSemantic(N), D = c.patch_make(V, N);
var W = c.patch_apply(D, s);
if($ = W[0], !W[1].every(e.identity)) {
N = c.diff_main(m, $), N = f(N), $ = "";
var X;
N.forEach(function(e) {
var t = e[0],
n = e[1];
0 === t || X ? 0 === t && X && (X.selectionEnd = $.length, j.push(X), X = void 0) : X = {
selectionStart: $.length,
type: "conflict"
}, $ += n
}), X && (X.selectionEnd = $.length, j.push(X))
}
}
E && (P && (H = !0), F ? U = !0 : (H = !0, G = b)), B && (z = !0), R && (D = c.patch_make(a.title, g), q = c.patch_apply(D, l)[0])
}
var Q;
if(E) {
var Y = [];
r.currentFile === n && (Q = {
selectionStart: o.selectionMgr.selectionStart,
selectionEnd: o.selectionMgr.selectionEnd
}, Y.push(Q), n.newDiscussion && Y.push(n.newDiscussion)), H && (Y = Y.concat(e.values(b))), O |= o.adjustCommentOffsets(m, $, Y)
}
if(U) {
var K = e.values(p);
o.adjustCommentOffsets(s, $, K)
}
if(z) {
var J = JSON.parse(a.discussionList);
N = u.diff(J, b), u.patch(p, N), e.each(p, function(e, t) {
e || delete p[t]
})
}
return j.length && (O = !0, j.forEach(function(n) {
var i;
do i = t.randomString() + t.randomString(); while (e.has(G, i));
n.discussionIndex = i, G[i] = n
})), A && (n.title = q, i.onTitleChanged(n), i.onMessage('"' + g + '" has been renamed to "' + q + '" on ' + this.providerName + ".")), (E || O) && o.watcher.noWatch(e.bind(function() {
if(E && (r.currentFile === n && (o.setValueNoWatch($), Q && o.selectionMgr.setSelectionStartEnd(Q.selectionStart, Q.selectionEnd)), n.content = $, i.onContentChanged(n, $)), O) {
n.discussionList = G;
var t = u.diff(b, G),
a = !1;
e.each(t, function(t, r) {
e.isArray(t) ? 1 === t.length ? i.onDiscussionCreated(n, G[r]) : i.onDiscussionRemoved(n, b[r]) : a = !0
}), a && i.onCommentsChanged(n)
}
o.undoMgr.currentMode = "sync", o.undoMgr.saveState(), i.onMessage('"' + l + '" has been updated from ' + this.providerName + "."), j.length && i.onMessage('"' + l + '" has conflicts that you have to review.')
}, this)), {
contentCRC: S,
titleCRC: C,
discussionListCRC: _
}
}, l
}), define("classes/AsyncTask", ["underscore", "constants", "utils", "eventMgr"], function(e, t, n, i) {
function r(e) {
this.finished = !1, this.timeout = t.ASYNC_TASK_DEFAULT_TIMEOUT, this.retryCounter = 0, this.runCallbacks = [], this.successCallbacks = [], this.errorCallbacks = [], this.force = e
}
function o() {
if(c === !0) return void(l + u.timeout < n.currentTime && u.error(new Error("A timeout occurred.")));
if(void 0 === u) {
if(0 === s.length || !s[0].force && p === !1) return;
u = s.shift(), l = n.currentTime, d === !1 && (d = !0, i.onAsyncRunning(!0))
}
l <= n.currentTime && (c = !0, u.chain())
}
function a(t, n, r) {
try {
e.each(n, function(e) {
e(r)
})
} finally {
t.finished = !0, u === t && (u = void 0, c = !1), 0 === s.length ? (d = !1, i.onAsyncRunning(!1)) : o()
}
}
var s = [];
r.prototype.onRun = function(e) {
this.runCallbacks.push(e)
}, r.prototype.onSuccess = function(e) {
this.successCallbacks.push(e)
}, r.prototype.onError = function(e) {
this.errorCallbacks.push(e)
};
var l = 0;
r.prototype.chain = function(e) {
if(l = n.currentTime, n.logStackTrace(), this.finished !== !0) {
if(void 0 === this.queue && (this.queue = this.runCallbacks.slice()), void 0 !== e) return void e();
if(0 === this.queue.length) return void a(this, this.successCallbacks);
var t = this.queue.shift();
t()
}
}, r.prototype.error = function(e) {
if(n.logStackTrace(), this.finished !== !0) throw e = e || new Error("Unknown error"), e.message && i.onError(e), a(this, this.errorCallbacks, e), e
};
var c = !1;
r.prototype.retry = function(e, t) {
if(this.finished !== !0) {
if(t = t || 5, this.queue = void 0, this.retryCounter >= t) return void this.error(e);
var i = 1e3 * Math.pow(2, this.retryCounter++);
l = n.currentTime + i, c = !1, o()
}
}, r.prototype.enqueue = function() {
s.push(this), o()
};
var u, d = !1,
p = !1;
return i.addListener("onUserActive", function() {
p = !0
}), i.addListener("onPeriodicRun", o), r
}), define("helpers/dropboxHelper", ["jquery", "underscore", "constants", "core", "utils", "storage", "logger", "settings", "eventMgr", "classes/AsyncTask"], function(e, t, n, i, r, o, a, s, l, c) {
function u(t) {
t.onRun(function() {
return v === !0 ? (f = void 0, void t.error(new Error("Operation not available in offline mode.|stopPublish"))) : void 0 !== f ? void t.chain() : void e.ajax({
url: "libs/dropbox.min.js",
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).done(function() {
f = new Dropbox.Client({
key: s.dropboxFullAccess === !0 ? n.DROPBOX_APP_KEY : n.DROPBOX_RESTRICTED_APP_KEY,
secret: s.dropboxFullAccess === !0 ? n.DROPBOX_APP_SECRET : n.DROPBOX_RESTRICTED_APP_SECRET
}), f.authDriver(new Dropbox.AuthDriver.Popup({
receiverUrl: n.BASE_URL + "html/dropbox-oauth-receiver.html",
rememberUser: !0
})), t.chain()
}).fail(function(e) {
var n = {
status: e.status,
responseText: e.statusText
};
p(n, t)
})
})
}
function d(e) {
e.onRun(function() {
function t() {
r.redirectConfirm("You are being redirected to Dropbox authorization page.", function() {
e.chain(i)
}, function() {
e.error(new Error("Operation canceled."))
})
}
function i() {
o === !1 ? e.timeout = n.ASYNC_TASK_LONG_TIMEOUT : f.reset(), f.authenticate({
interactive: !o
}, function(n, i) {
return i.isAuthenticated() === !0 ? (m = !0, void e.chain()) : o === !0 ? (o = !1, void e.chain(t)) : void e.error(new Error("Access to Dropbox account is not authorized."))
})
}
if(m === !0) return void e.chain();
var o = !0;
e.chain(i)
})
}
function p(e, n) {
var r = !0;
if(e)
if(a.error(e), "string" == typeof e) r = e;
else {
if(r = "Dropbox error (" + e.status + ": " + e.responseText + ").", 401 === e.status || 403 === e.status) return m = !1, r = "Access to Dropbox account is not authorized.", void n.retry(new Error(r), 1);
if(400 === e.status && -1 !== e.responseText.indexOf("oauth_nonce")) return t.each(t.keys(o), function(e) {
0 === e.indexOf("dropbox-auth") && o.removeItem(e)
}), m = !1, void n.retry(new Error(r), 1);
e.status <= 0 && (f = void 0, m = !1, i.setOffline(), r = "|stopPublish")
}
n.error(new Error(r))
}
function h(t) {
t.onRun(function() {
function i() {
r.redirectConfirm("You are being redirected to Dropbox Chooser page.", function() {
t.chain()
}, function() {
t.error(new Error("Operation canceled."))
})
}
return b === !0 ? void t.chain() : void e.ajax({
url: "https://www.dropbox.com/static/api/1/dropbox.js",
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).done(function() {
b = !0, t.chain(i)
}).fail(function(e) {
var n = {
status: e.status,
responseText: e.statusText
};
p(n, t)
})
})
}
var f, m = !1,
g = {}, v = !1;
l.addListener("onOfflineChanged", function(e) {
v = e
}), g.upload = function(e, t, n) {
var i, r = new c;
u(r), d(r), r.onRun(function() {
f.writeFile(e, t, function(t, n) {
return t ? (400 === t.status && (t = 'Could not upload document into path "' + e + '".'), void p(t, r)) : (i = n, void r.chain())
})
}), r.onSuccess(function() {
n(void 0, i)
}), r.onError(function(e) {
n(e)
}), r.enqueue()
}, g.checkChanges = function(e, t) {
var n = [],
i = e || 0,
r = new c;
u(r), d(r), r.onRun(function() {
function e() {
f.pullChanges(i, function(t, o) {
return t ? void p(t, r) : (i = o.cursor(), void 0 !== o.changes && (n = n.concat(o.changes)), void(o.shouldPullAgain ? r.chain(e) : r.chain()))
})
}
r.chain(e)
}), r.onSuccess(function() {
t(void 0, n, i)
}), r.onError(function(e) {
t(e)
}), r.enqueue()
}, g.downloadMetadata = function(e, t) {
var n = [],
i = new c;
u(i), d(i), i.onRun(function() {
function t() {
if(0 === e.length) return void i.chain();
var r = e[0];
f.stat(r, function(r, o) {
return o ? (n.push(o), e.shift(), void i.chain(t)) : void p(r, i)
})
}
i.chain(t)
}), i.onSuccess(function() {
t(void 0, n)
}), i.onError(function(e) {
t(e)
}), i.enqueue()
}, g.downloadContent = function(e, n) {
var i = [],
r = new c;
u(r), d(r), r.onRun(function() {
function n() {
if(0 === e.length) return void r.chain();
var o = e[0];
i.push(o);
var a;
return o.isFile === !0 ? a = o : void 0 !== o.wasRemoved && (a = o.stat), a ? void f.readFile(a.path, function(i, o) {
return t.isString(o) ? (a.content = o, e.shift(), void r.chain(n)) : void p(i, r)
}) : (e.shift(), void r.chain(n))
}
r.chain(n)
}), r.onSuccess(function() {
n(void 0, i)
}), r.onError(function(e) {
n(e)
}), r.enqueue()
};
var b = !1;
return g.picker = function(e) {
var t = [],
i = new c;
i.timeout = n.ASYNC_TASK_LONG_TIMEOUT, u(i), h(i), i.onRun(function() {
var e = {};
e.multiselect = !0, e.linkType = "direct", e.success = function(e) {
for(var n = 0; n < e.length; n++) {
var r = e[n].link;
r = r.replace(/.*\/view\/[^\/]*/, ""), t.push(decodeURI(r))
}
i.chain()
}, e.cancel = function() {
i.chain()
}, Dropbox.choose(e)
}), i.onSuccess(function() {
e(void 0, t)
}), i.onError(function(t) {
e(t)
}), i.enqueue()
}, g
}), define("providers/dropboxProvider", ["underscore", "utils", "storage", "settings", "classes/Provider", "eventMgr", "fileMgr", "helpers/dropboxHelper"], function(e, t, n, i, r, o, a, s) {
function l(e) {
return void 0 === e ? void 0 : e.match(/^[^\\<>:"\|?\*]+$/) ? 0 !== e.indexOf("/") ? "/" + e : e : void o.onError('"' + e + '" contains invalid characters.')
}
function c(e) {
return "sync." + p + "." + encodeURIComponent(e.toLowerCase())
}
function u(e, n, i, r) {
r = r || "{}";
var o = {};
return o.provider = h, o.path = e, o.version = n, o.contentCRC = t.crc32(i), o.discussionListCRC = t.crc32(r), o.syncIndex = c(e), f === !0 && (o.content = i, o.discussionList = r), o
}
function d(t) {
s.downloadMetadata(t, function(t, n) {
t || s.downloadContent(n, function(t, n) {
if(!t) {
var i = [];
e.each(n, function(e) {
var t = h.parseContent(e.content),
n = u(e.path, e.versionTag, t.content, t.discussionListJSON),
r = {};
r[n.syncIndex] = n;
var o = a.createFile(e.name, t.content, t.discussionListJSON, r);
a.selectFile(o), i.push(o)
}), 0 !== i.length && o.onSyncImportSuccess(i, h)
}
})
})
}
var p = "dropbox",
h = new r(p, "Dropbox");
h.defaultPublishFormat = "template";
var f = "merge" == i.conflictMode;
return h.importFiles = function() {
s.picker(function(t, n) {
if(!t && 0 !== n.length) {
var i = [];
e.each(n, function(e) {
var t = c(e),
n = a.getFileFromSyncIndex(t);
return void 0 !== n ? o.onError('"' + n.title + '" was already imported.') : void i.push(e)
}), d(i)
}
})
}, h.exportFile = function(e, n, i, r, d) {
var p = t.getInputTextValue("#input-sync-export-dropbox-path", e);
if(p = l(p), void 0 === p) return d(!0);
var f = c(p),
m = a.getFileFromSyncIndex(f);
if(void 0 !== m) {
var g = m.title;
return o.onError('File path is already synchronized with "' + g + '".'), d(!0)
}
var v = h.serializeContent(i, r);
s.upload(p, v, function(e, t) {
if(e) return d(e);
var n = u(t.path, t.versionTag, i, r);
d(void 0, n)
})
}, h.syncUp = function(e, t, n, i, r, o, a, l) {
if(a.contentCRC == t && a.discussionListCRC == o) return l(void 0, !1);
var c = h.serializeContent(e, r);
s.upload(a.path, c, function(n, s) {
return n ? l(n, !0) : (a.version = s.versionTag, f === !0 && (a.content = e, a.discussionList = r), a.contentCRC = t, a.titleCRC = i, a.discussionListCRC = o, void l(void 0, !0))
})
}, h.syncDown = function(i) {
var r = n[p + ".lastChangeId"];
s.checkChanges(r, function(r, l, u) {
if(r) return i(r);
var d = [];
e.each(l, function(e) {
var t = c(e.path),
n = a.getFileFromSyncIndex(t),
i = n && n.syncLocations[t];
return i ? (e.fileDesc = n, e.syncAttributes = i, e.wasRemoved === !0 ? void d.push(e) : void(i.version != e.stat.versionTag && d.push(e))) : void 0
}), s.downloadContent(d, function(e, r) {
function a() {
if(0 === r.length) return n[p + ".lastChangeId"] = u, i();
var e = r.pop(),
s = e.fileDesc,
l = e.syncAttributes;
if(e.wasRemoved === !0) return o.onError('"' + s.title + '" has been removed from Dropbox.'), s.removeSyncLocation(l), o.onSyncRemoved(s, l);
var c = e.stat,
d = h.parseContent(c.content),
m = d.content,
g = d.discussionListJSON,
v = d.discussionList,
b = h.syncMerge(s, l, m, s.title, v, g);
l.version = c.versionTag, f === !0 && (l.content = m, l.discussionList = v), l.contentCRC = b.contentCRC, l.discussionListCRC = b.discussionListCRC, t.storeAttributes(l), setTimeout(a, 5)
}
return e ? void i(e) : void setTimeout(a, 5)
})
})
}, h.publish = function(e, t, n, i, r) {
var o = l(e.path);
return void 0 === o ? r(!0) : void s.upload(o, i, r)
}, h.newPublishAttributes = function(e) {
var n = {};
return n.path = t.getInputTextValue("#input-publish-dropbox-path", e), e.isPropagationStopped() ? void 0 : n
}, h
}), define("helpers/googleHelper", ["underscore", "jquery", "constants", "core", "utils", "storage", "logger", "settings", "eventMgr", "classes/AsyncTask"], function(e, t, n, i, r, o, a, s, l, c) {
function u(t) {
var n = {
profile: !0
}, i = !0;
e.each((o[t + ".permissions"] || "").split(";"), function(e) {
e && (n[e] = !0)
}), this.setRefreshFlag = function() {
i = !0
}, this.isAuthorized = function(t) {
return i === !1 && e.has(n, t)
}, this.add = function(r) {
n[r] = !0, o[t + ".permissions"] = e.keys(n).join(";"), i = !1
}, this.getListWithNew = function(t) {
var i = e.keys(n);
return e.has(n, t) || i.push(t), i
};
var r = o[t + ".userId"];
this.setUserId = function(e) {
r = e, o[t + ".userId"] = r
}, this.getUserId = function() {
return r
}
}
function d(e) {
e.onRun(function() {
return y === !0 ? (g = !1, e.error(new Error("Operation not available in offline mode.|stopPublish"))) : g === !0 ? e.chain() : (window.delayedFunction = function() {
gapi.load("client", function() {
gapi.client.load("drive", "v2", function() {
g = !0, e.chain()
})
})
}, void t.ajax({
url: "https://apis.google.com/js/api.js?onload=runDelayedFunction",
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).fail(function(t) {
var n = {
code: t.status,
message: t.statusText
};
f(n, e)
}))
})
}
function p(i, o, a) {
var s = v[a];
s || (s = new u(a), v[a] = s), i.onRun(function() {
function a() {
t.ajax({
url: "https://www.googleapis.com/oauth2/v1/tokeninfo",
data: {
access_token: d.access_token
},
timeout: n.AJAX_TIMEOUT,
type: "GET"
}).done(function(e) {
s.getUserId() && s.getUserId() != e.user_id ? u() : (s.setUserId(e.user_id), s.add(o), s.token = d, i.chain())
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
f(t, i)
})
}
function l() {
if(m > 5) return i.error(new Error("Unable to authenticate user " + s.getUserId() + ", please sign in with Google."));
p === !1 && (i.timeout = n.ASYNC_TASK_LONG_TIMEOUT);
var t = e.chain(x).pick(s.getListWithNew(o)).flatten().value();
gapi.auth.authorize({
client_id: n.GOOGLE_CLIENT_ID,
scope: t,
immediate: p,
authuser: p === !1 ? "" : m
}, function(e) {
d = gapi.auth.getToken(), gapi.auth.setToken(h), !e || e.error ? g === !0 && p === !0 ? (p = !1, i.chain(c)) : i.error(new Error("Access to Google account is not authorized.")) : (p === !0 && m++, i.chain(a))
})
}
function c() {
return p === !0 ? i.chain(l) : void r.redirectConfirm("You are being redirected to Google authorization page.", function() {
i.chain(l)
}, function() {
i.error(new Error("Operation canceled."))
})
}
function u() {
return p = !0, s.token && s.isAuthorized(o) ? void i.chain() : (s.getUserId() || (p = !1), void i.chain(c))
}
var d, p, h = gapi.auth.getToken(),
m = 0;
u()
})
}
function h(e, t) {
var n = gapi.auth.getToken(),
i = v[e];
gapi.auth.setToken(i.token), t(), gapi.auth.setToken(n)
}
function f(t, n) {
var r;
if(t)
if(a.error(t), "string" == typeof t) r = t;
else {
if(r = "Google error (" + t.code + ": " + t.message + ").", t.code >= 500 && t.code < 600) return n.retry(new Error(r));
if(401 === t.code || 403 === t.code || "token_refresh_required" == t.code) return e.each(v, function(e) {
e.setRefreshFlag()
}), r = "Access to Google account is not authorized.", n.retry(new Error(r), 1);
(0 === t.code || -1 === t.code) && (g = !1, e.each(v, function(e) {
e.setRefreshFlag()
}), i.setOffline(), r = "|stopPublish")
}
n.error(new Error(r))
}
function m(e) {
e.onRun(function() {
return w === !0 ? e.chain() : void t.ajax({
url: "//www.google.com/jsapi",
data: {
key: n.GOOGLE_API_KEY
},
dataType: "script",
timeout: n.AJAX_TIMEOUT
}).done(function() {
google.load("picker", "1", {
callback: function() {
e.chain()
}
}), w = !0
}).fail(function(t) {
var n = {
code: t.status,
message: t.statusText
};
f(n, e)
})
})
}
var g = !1,
v = {}, b = {}, y = !1;
l.addListener("onOfflineChanged", function(e) {
y = e
});
var x = {
profile: ["https://www.googleapis.com/auth/userinfo.profile"],
gdrive: ["https://www.googleapis.com/auth/drive.install", s.gdriveFullAccess === !0 ? "https://www.googleapis.com/auth/drive" : "https://www.googleapis.com/auth/drive.file"],
blogger: ["https://www.googleapis.com/auth/blogger"],
picasa: ["https://www.googleapis.com/auth/photos"]
};
b.refreshGdriveToken = function(e) {
var t = new c;
d(t);
var n = v[e];
n && n.setRefreshFlag(), p(t, "gdrive", e), t.enqueue()
}, b.upload = function(e, t, n, i, a, l, u, m) {
var g, v = new c;
d(v), p(v, "gdrive", u), v.onRun(function() {
var l = "-------314159265358979323846",
c = "\r\n--" + l + "\r\n",
d = "\r\n--" + l + "--";
a = a || s.markdownMimeType;
var p = {
title: n,
mimeType: a
};
t && (p.parents = [{
kind: "drive#fileLink",
id: t
}]);
var m = "/upload/drive/v2/files",
b = "POST";
e && (m += "/" + e, b = "PUT");
var y = {
"Content-Type": 'multipart/mixed; boundary="' + l + '"'
}, x = r.encodeBase64(i),
w = [c, "Content-Type: application/json\r\n\r\n", JSON.stringify(p), c, "Content-Type: ", a, "\r\n", "Content-Transfer-Encoding: base64\r\n", "\r\n", x, d].join("");
h(u, function() {
var t = gapi.client.request({
path: m,
method: b,
params: {
uploadType: "multipart"
},
headers: y,
body: w
});
t.execute(function(t) {
if(t && t.id) return g = t, g.content = i, v.chain();
var n = t.error;
void 0 !== n && void 0 !== e && (404 === n.code ? n = 'File ID "' + e + '" not found on Google Drive.|removePublish' : 412 === n.code && (o.removeItem(u + ".gdrive.lastChangeId"), n = 'Conflict on file ID "' + e + '". Please restart the synchronization.')), f(n, v)
})
})
}), v.onSuccess(function() {
m(void 0, g)
}), v.onError(function(e) {
m(e)
}), v.enqueue()
}, b.rename = function(e, t, n, i) {
var r, o = new c;
d(o), p(o, "gdrive", n), o.onRun(function() {
var i = {
title: t
};
h(n, function() {
var t = gapi.client.drive.files.patch({
fileId: e,
resource: i
});
t.execute(function(t) {
if(t && t.id) return r = t, o.chain();
var n = t.error;
void 0 !== n && void 0 !== e && 404 === n.code && (n = 'File ID "' + e + '" not found on Google Drive.|removePublish'), f(n, o)
})
})
}), o.onSuccess(function() {
i(void 0, r)
}), o.onError(function(e) {
i(e)
}), o.enqueue()
}, b.checkChanges = function(e, t, n) {
var i = [],
r = e || 0,
o = new c;
d(o), p(o, "gdrive", t), o.onRun(function() {
function e() {
h(t, function() {
var t;
t = gapi.client.drive.changes.list(void 0 === n ? {
startChangeId: r + 1
} : {
pageToken: n
}), t.execute(function(t) {
return t && t.largestChangeId ? (r = t.largestChangeId, n = t.nextPageToken, void 0 !== t.items && (i = i.concat(t.items)), void(void 0 !== n ? o.chain(e) : o.chain())) : f(t.error, o)
})
})
}
var n;
o.chain(e)
}), o.onSuccess(function() {
n(void 0, i, r)
}), o.onError(function(e) {
n(e)
}), o.enqueue()
}, b.downloadMetadata = function(e, i, r, o) {
var a = [],
s = new c;
d(s), o || p(s, "gdrive", i), s.onRun(function() {
function r() {
if(0 === e.length) return s.chain();
var o = e[0],
l = {}, c = v[i];
c && c.token && (l.Authorization = "Bearer " + c.token.access_token), t.ajax({
url: "https://www.googleapis.com/drive/v2/files/" + o,
headers: l,
data: {
key: n.GOOGLE_API_KEY
},
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(t) {
a.push(t), e.shift(), s.chain(r)
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
404 === t.code && (t = 'File ID "' + o + '" not found on Google Drive.'), f(t, s)
})
}
s.chain(r)
}), s.onSuccess(function() {
r(void 0, a)
}), s.onError(function(e) {
r(e)
}), s.enqueue()
}, b.downloadContent = function(e, i, r, o) {
var a = [],
s = new c;
s.timeout = n.ASYNC_TASK_LONG_TIMEOUT, d(s), o || p(s, "gdrive", i), s.onRun(function() {
function r() {
if(0 === e.length) return s.chain();
var o = e[0];
a.push(o);
var l;
if("drive#file" == o.kind ? l = o : "drive#change" == o.kind && (l = o.file), !l) return e.shift(), s.chain(r);
var c = l.downloadUrl;
0 === l.mimeType.indexOf("application/vnd.google-apps.drive-sdk") && (l.isRealtime = !0, c = "https://www.googleapis.com/drive/v2/files/" + l.id + "/realtime");
var u = {}, d = v[i];
d && d.token && (u.Authorization = "Bearer " + d.token.access_token), t.ajax({
url: c,
headers: u,
data: {
key: n.GOOGLE_API_KEY
},
dataType: l.isRealtime ? "json" : "text",
timeout: n.AJAX_TIMEOUT
}).done(function(t) {
l.content = l.isRealtime ? t.data.value.content.value : t, e.shift(), s.chain(r)
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
f(t, s)
})
}
s.chain(r)
}), s.onSuccess(function() {
r(void 0, a)
}), s.onError(function(e) {
r(e)
}), s.enqueue()
}, b.uploadImg = function(e, i, r, o) {
var a, s = "google.picasa0",
l = new c;
d(l), p(l, "picasa", s), l.onRun(function() {
var o = {
Slug: e
};
e.match(/.jpe?g$/i) ? o["Content-Type"] = "image/jpeg" : e.match(/.png$/i) ? o["Content-Type"] = "image/png" : e.match(/.gif$/i) && (o["Content-Type"] = "image/gif");
var c = v[s];
c && c.token && (o.Authorization = "Bearer " + c.token.access_token), t.ajax({
url: n.PICASA_PROXY_URL + "upload/" + r,
headers: o,
data: i,
processData: !1,
dataType: "xml",
timeout: n.AJAX_TIMEOUT,
type: "POST"
}).done(function(e) {
a = e, l.chain()
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
200 == t.code && (t.message = e.responseText), f(t, l)
})
}), l.onSuccess(function() {
o(void 0, a)
}), l.onError(function(e) {
o(e)
}), l.enqueue()
};
var w = !1;
return b.picker = function(e, i, o) {
function a() {
void 0 !== s && (s.setVisible(!1), t(".modal-backdrop, .picker").remove())
}
var s, l = [],
u = new c;
u.timeout = n.ASYNC_TASK_LONG_TIMEOUT, d(u), "doc" == i || "folder" == i ? p(u, "gdrive", o) : (o = "google.picasa0", p(u, "picasa", o)), m(u), u.onRun(function() {
var e = v[o],
c = new google.picker.PickerBuilder;
c.setAppId(n.GOOGLE_DRIVE_APP_ID);
var d;
"doc" == i ? (d = new google.picker.DocsView(google.picker.ViewId.DOCS), d.setParent("root"), d.setIncludeFolders(!0), d.setMimeTypes(["text/x-markdown", "text/plain", "application/octet-stream", "application/vnd.google-apps.drive-sdk." + n.GOOGLE_DRIVE_APP_ID].join(",")), c.enableFeature(google.picker.Feature.NAV_HIDDEN), c.enableFeature(google.picker.Feature.MULTISELECT_ENABLED), c.addView(d), e && e.token && c.setOAuthToken(e.token.access_token)) : "folder" == i ? (d = new google.picker.DocsView(google.picker.ViewId.FOLDERS), d.setParent("root"), d.setIncludeFolders(!0), d.setSelectFolderEnabled(!0), d.setMimeTypes("application/vnd.google-apps.folder"), c.enableFeature(google.picker.Feature.NAV_HIDDEN), c.addView(d), e && e.token && c.setOAuthToken(e.token.access_token)) : "img" == i && (d = new google.picker.PhotosView, d.setType("flat"), c.addView(d), d = new google.picker.PhotosView, d.setType("ofuser"), c.addView(d), c.addView(google.picker.ViewId.PHOTO_UPLOAD), e && e.token && c.setOAuthToken(e.token.access_token)), c.setCallback(function(e) {
(e.action == google.picker.Action.PICKED || e.action == google.picker.Action.CANCEL) && (e.action == google.picker.Action.PICKED && (l = e.docs), a(), u.chain())
}), s = c.build(), t(r.createBackdrop()).on("click.backdrop", function() {
a(), u.chain()
}), s.setVisible(!0)
}), u.onSuccess(function() {
e(void 0, l)
}), u.onError(function(t) {
a(), e(t)
}), u.enqueue()
}, b.uploadBlogger = function(e, i, r, o, a, s, l, u, h) {
var m = "google.blogger0",
g = new c;
d(g), p(g, "blogger", m), g.onRun(function() {
function c() {
var e = "https://www.googleapis.com/blogger/v3/blogs/" + i + "/posts/",
a = {
kind: "blogger#post",
blog: {
id: i
},
labels: o,
title: l,
content: u
};
s && (a.published = s.toISOString());
var c = "POST";
void 0 !== r && (e += r, a.id = r, c = "PUT"), t.ajax({
url: e,
data: JSON.stringify(a),
headers: h,
type: c,
contentType: "application/json",
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(e) {
r = e.id, g.chain(d)
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
404 === t.code && void 0 !== r && (t = "Post " + r + " not found on Blogger.|removePublish"), f(t, g)
})
}
function d() {
var e = "https://www.googleapis.com/blogger/v3/blogs/" + i + "/posts/" + r;
a ? e += "/revert" : (e += "/publish", s && (e += "?publishDate=" + s.toISOString())), t.ajax({
url: e,
headers: h,
type: "POST",
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function() {
g.chain()
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
404 === t.code && (t = "Post " + r + " not found on Blogger.|removePublish"), f(t, g)
})
}
function p() {
return void 0 !== i ? void g.chain(c) : void t.ajax({
url: "https://www.googleapis.com/blogger/v3/blogs/byurl",
data: {
url: e
},
headers: h,
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(e) {
i = e.id, g.chain(c)
}).fail(function(t) {
var n = {
code: t.status,
message: t.statusText
};
404 === n.code && (n = 'Blog "' + e + '" not found on Blogger.|removePublish'), f(n, g)
})
}
var h = {}, b = v[m];
b && b.token && (h.Authorization = "Bearer " + b.token.access_token), g.chain(p)
}), g.onSuccess(function() {
h(void 0, i, r)
}), g.onError(function(e) {
h(e)
}), g.enqueue()
}, b.uploadBloggerPage = function(e, i, r, o, a, s, l, u) {
var h = "google.blogger0",
m = new c;
d(m), p(m, "blogger", h), m.onRun(function() {
function o() {
var e = "https://www.googleapis.com/blogger/v3/blogs/" + i + "/pages/",
o = {
kind: "blogger#page",
blog: {
id: i
},
title: s,
content: l
}, a = "POST";
void 0 !== r && (e += r, o.id = r, a = "PUT"), t.ajax({
url: e,
data: JSON.stringify(o),
headers: c,
type: a,
contentType: "application/json",
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(e) {
r = e.id, m.chain()
}).fail(function(e) {
var t = {
code: e.status,
message: e.statusText
};
404 === t.code && void 0 !== r && (t = "Page " + r + " not found on Blogger.|removePublish"), f(t, m)
})
}
function a() {
return void 0 !== i ? void m.chain(o) : void t.ajax({
url: "https://www.googleapis.com/blogger/v3/blogs/byurl",
data: {
url: e
},
headers: c,
dataType: "json",
timeout: n.AJAX_TIMEOUT
}).done(function(e) {
i = e.id, m.chain(o)
}).fail(function(t) {
var n = {
code: t.status,
message: t.statusText
};
404 === n.code && (n = 'Blog "' + e + '" not found on Blogger.|removePublish'), f(n, m)
})
}
var c = {}, u = v[h];
u && u.token && (c.Authorization = "Bearer " + u.token.access_token), m.chain(a)
}), m.onSuccess(function() {
u(void 0, i, r)
}), m.onError(function(e) {
u(e)
}), m.enqueue()
}, window.delayedFunction = void 0, window.runDelayedFunction = function() {
void 0 !== window.delayedFunction && window.delayedFunction()
}, b
}), define("text!html/dialogExportGdrive.html", [], function() {
return '
\n
\n\n
\n \n
Save on <%= providerName %>
\n
\n
\n
\n This will save "" to your \n Google Drive\n account and keep it synchronized.\n
\n
\n
\n \n
\n
\n \n
\n \n
\n
\n If no folder ID is supplied, the\n file will be created in your root folder. \n
\n
\n
\n \n
\n This will overwrite the existing file\n on the server. \n