-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJSONBuilder.min.js
1 lines (1 loc) · 1.92 KB
/
JSONBuilder.min.js
1
var oJSONBuilder=function(s,t){$(function(){if(0==$(".js-ldr").length?$("body").append("<div class='js-ldr'></div>"):$(".js-ldr").fadeIn(100),t.assets){if(t.assets.jsPre)for(var e=0;e<t.assets.jsPre.length;e++)$.isArray(t.assets.jsPre[e])?$.getScript(t.assets.jsPre[e][0]).done(function(){window[t.assets.jsPre[e][1]]()}):$.getScript(t.assets.jsPre[e]);if(t.assets.cssPre)for(var e=0;e<t.assets.cssPre.length;e++){var a=$("head")[0],r=document.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t.assets.cssPre[e],a.appendChild(r)}}if("table"==t.structure.type)for(var n=t.structure.prop,e=0;e<t.structure.data.length;e++){var o=t.structure.data[e];o.prop.class&&n.class&&(o.prop.class+=" "+n.class);var d="<table ";$.each($.extend({},n,o.prop),function(s,t){d+=s+"='"+t+"' "}),d+=">";for(var i="<thead><tr >",c=0;c<o.headers.length;c++)i+="<th>"+o.headers[c]+"</th>";i+="</tr></thead>";for(var l="<tbody>",c=0;c<o.content.length;c++){l+="<tr>";for(var f=0;f<o.content[c].length;f++){var p=o.content[c][f];if("undefined"!=typeof p.type){var h="<input ";$.each(p,function(s,t){h+=s+"='"+t+"' "}),h+=" />",l+="<td>"+h+"</td>"}else if("undefined"!=typeof p.tag){var u="<"+p.tag+" ";$.each(p.prop,function(s,t){u+=s+"='"+t+"' "}),u+=">",$.each(p.options,function(s){u+="<option value='"+p.options[s].value+"'>"+p.options[s].name+"</option>"}),u+="</"+p.tag+">",l+="<td>"+u+"</td>"}else l+="<td>"+p+"</td>"}l+="</tr>"}l+="<tbody>",d=d+i+l+"</tbody>",$(s)[0].innerHTML+=d}if(t.assets){if(t.assets.jsPost)for(var e=0;e<t.assets.jsPost.length;e++)$.isArray(t.assets.jsPost[e])?$.getScript(t.assets.jsPost[e][0]).done(function(){window[t.assets.jsPost[e][1]]()}):$.getScript(t.assets.jsPost[e]);if(t.assets.cssPost)for(var e=0;e<t.assets.cssPost.length;e++){var a=$("head")[0],r=document.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=t.assets.cssPost[e],a.appendChild(r)}$(".js-ldr").delay(500).fadeOut(50)}else $(".js-ldr").fadeOut(50)})};