You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
3.3 KiB
51 lines
3.3 KiB
/**
|
|
* Minified by jsDelivr using Terser v3.14.1.
|
|
* Original file: /npm/jquery.json-viewer@1.4.0/json-viewer/jquery.json-viewer.js
|
|
*
|
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
*/
|
|
!function (s) {
|
|
function e(s) {
|
|
return s instanceof Object && Object.keys(s).length > 0
|
|
}
|
|
|
|
s.fn.jsonViewer = function (l, a) {
|
|
return a = Object.assign({}, {
|
|
collapsed: !1,
|
|
rootCollapsable: !0,
|
|
withQuotes: !1,
|
|
withLinks: !0
|
|
}, a), this.each(function () {
|
|
var t = function s(l, a) {
|
|
var t = "";
|
|
if ("string" == typeof l) l = l.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """), a.withLinks && /^(https?:\/\/|ftps?:\/\/)?([a-z0-9%-]+\.){1,}([a-z0-9-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:\/?#[\]@!$&'()*+,;=%]+)?)?$/i.test(l) ? t += '<a href="' + l + '" class="json-string" target="_blank">' + l + "</a>" : t += '<span class="json-string">"' + (l = l.replace(/"/g, "\\"")) + '"</span>'; else if ("number" == typeof l) t += '<span class="json-literal">' + l + "</span>"; else if ("boolean" == typeof l) t += '<span class="json-literal">' + l + "</span>"; else if (null === l) t += '<span class="json-literal">null</span>'; else if (l instanceof Array) if (l.length > 0) {
|
|
t += '[<ol class="json-array">';
|
|
for (var n = 0; n < l.length; ++n) t += "<li>", e(l[n]) && (t += '<a href class="json-toggle"></a>'), t += s(l[n], a), n < l.length - 1 && (t += ","), t += "</li>";
|
|
t += "</ol>]"
|
|
} else t += "[]"; else if ("object" == typeof l) {
|
|
var o = Object.keys(l).length;
|
|
if (o > 0) {
|
|
for (var i in t += '{<ul class="json-dict">', l) if (Object.prototype.hasOwnProperty.call(l, i)) {
|
|
t += "<li>";
|
|
var r = a.withQuotes ? '<span class="json-string">"' + i + '"</span>' : i;
|
|
e(l[i]) ? t += '<a href class="json-toggle">' + r + "</a>" : t += r, t += ": " + s(l[i], a), --o > 0 && (t += ","), t += "</li>"
|
|
}
|
|
t += "</ul>}"
|
|
} else t += "{}"
|
|
}
|
|
return t
|
|
}(l, a);
|
|
a.rootCollapsable && e(l) && (t = '<a href class="json-toggle"></a>' + t), s(this).html(t), s(this).addClass("json-document"), s(this).off("click"), s(this).on("click", "a.json-toggle", function () {
|
|
var e = s(this).toggleClass("collapsed").siblings("ul.json-dict, ol.json-array");
|
|
if (e.toggle(), e.is(":visible")) e.siblings(".json-placeholder").remove(); else {
|
|
var l = e.children("li").length, a = l + (l > 1 ? " items" : " item");
|
|
e.after('<a href class="json-placeholder">' + a + "</a>")
|
|
}
|
|
return !1
|
|
}), s(this).on("click", "a.json-placeholder", function () {
|
|
return s(this).siblings("a.json-toggle").click(), !1
|
|
}), 1 == a.collapsed && s(this).find("a.json-toggle").click()
|
|
})
|
|
}
|
|
}(jQuery);
|
|
//# sourceMappingURL=/sm/2eabfda485458aa3aa101e518dd23623b568b299b2883e2315ffe59e7b2e718b.map
|
|
|