-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjQuery.viewSource.min.js
1 lines (1 loc) · 2.35 KB
/
jQuery.viewSource.min.js
1
var htmlEncode; (function (a) { jQuery.fn.viewSource = function (b) { return this.each(function () { a(this).on("click", function () { a.fn.showSource(b) }) }) }, jQuery.fn.showSource = function (b) { var c, d; if (b == undefined || b == "") b = "html"; c = a(b).html(), d = "<div id='viewSource_display'><div id='viewSource_bglayer' style='background: none repeat scroll 0 0 Gray;height: 100%;left: 0;opacity: 0.95;position: fixed;text-align: center;top: 0;width: 100%;z-index: 50;'></div><div id='viewSource_holder' style='background: none repeat scroll 0 0 white;border: 1px solid #D2D2D2;display: block;bottom:1%;left:10%; right:10%;margin-left: auto;margin-right: auto;position: fixed;top: 1%;z-index: 100;'><div id='viewSource_header' style='background-color: #EAEAEA;border-bottom: 1px solid #D2D2D2;padding: 1px;text-align: right;height: 15px;display:block;font-family:Verdana;font-size:8pt;'><span style='text-shadow: Gray 1px 1px 1px;float:left;'>Source</span> <span id='viewSource_close' style='color:red;cursor:pointer;font-weight: bold;font-size:10pt'>x </span></div><div id='viewSource_content' style='height:96.5%; overflow-y:scroll;overflow-x:auto; text-align:left;margin: 5px;'> </div></div></div>"; a("body").append(d), a("#viewSource_content").html("<pre class='prettyprint lang-html'>" + htmlEncode(c, 1, 4) + "</pre>"); try { prettyPrint() } catch (e) { } a("#viewSource_close").click(function () { a("#viewSource_display").fadeOut(400, function () { a("#viewSource_display").remove() }) }) } })(jQuery); htmlEncode = function (a, b, c) { var d, e, f, g, h, i, j, k, l, m; j = function () { g = a.charAt(d), d += 1 }, k = function () { h = h.join(""), b && (h = h.replace(/(^ )|( $)/g, " ")), i.push(h), h = [] }, l = function () { f < " " || f > "~" ? h.push("&#" + f.charCodeAt(0) + ";") : h.push(f) }, c = c >= 0 ? Math.floor(c) : 4, i = [], h = [], d = 0, j(); while (d <= a.length) { f = g, j(); switch (f) { case "<": h.push("<"); break; case ">": h.push(">"); break; case "&": h.push("&"); break; case '"': h.push("""); break; case "'": h.push("'"); break; default: if (b) switch (f) { case "\r": g === "\n" && j(), k(); break; case "\n": k(); break; case "\t": m = c - h.length % c; for (e = 0; e < m; e += 1) h.push(" "); break; default: l() } else l() } } return k(), i = i.join("<br />"), b && (i = i.replace(/ {2}/g, " ")), i }