Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
META-INF.web.js.index.js Maven / Gradle / Ivy
top.loginUrl=top.dialogLoginUrl="./login.html";top.timeout=398;top.nologin=399;var contextPath=function(){return location.pathname.substr(0,location.pathname.indexOf("$api"))}();var bapi={data:{},loadApi:function(f,c){$("#result").html("");var e=c,b=$("#api_info").attr("url",c).attr("method",f);var a=c.lastIndexOf("'s")>0?"gets":c.lastIndexOf("$")>0?"aggr":f;b.find(">li.apis").attr("class","apis line_"+a);var d=c.lastIndexOf("'s")>0?"[批量获取]":c.lastIndexOf("$")>0?"[统计分析]":"get"==f?"[单条获取]":"post"==f?"[新增]":"put"==f?"[修改]":"delete"==f?"[删除]":"";$.get(contextPath+"uris/"+e,{method:f},function(l){var i=location.origin+contextPath+c;bapi.data=$.store(l.data.method+":"+i)||{};b.find(".method").text(l.data.method);b.find(".uri input[name=url]").val(i+(bapi.data.__search||"")).attr("content_type",l.data.type).attr("content-path",location.origin+contextPath);b.find(".title").text(l.data.title||d);b.find(".describe").html(l.data.title+";"+l.data.describe+" ");b.find("[name=cache]").text(l.data.cache||"-");b.find("[name=search]").text(l.data.search||"-");b.find("[name=describe]").text(l.data.describe||"-");b.data("describe",l.data.describe||"-");b.data("title",l.data.title||d||"-");if(l.data.dic){b.find("[name=sdic]").text("字典详情");b.find("[name=dic]").text(bapi.formatJson(l.data.dic))}var j=$("#fields");$("textarea",j).val(bapi.data.fields!==undefined?bapi.data.fields:"");$(":text[name=pageno]",j).val(bapi.data.pageno!==undefined?bapi.data.pageno:"");$(":text[name=pagesize]",j).val(bapi.data.pagesize!==undefined?bapi.data.pagesize:"");if(bapi.data.isjson){delete bapi.data.isjson;delete bapi.data.pageno;delete bapi.data.pagesize;delete bapi.data.fields;delete bapi.data.__search;var o=$("textarea[name=jsondata]");o.val(bapi.formatJson(bapi.data)).removeAttr("disabled");$(":checkbox[name=data_type]").attr("checked",true)}if("get"==f){$("a[target=dialog]",j).attr("url","./sel_fields.shtml?method="+f+"&uri="+c)}else{j.hide()}var p=$("#api_params"),g=p.find(".template").html(),k=p.find(".body");p.find("h4").css("cursor","pointer").click(function(){$(this).parent().parent().toggleClass("show")});var m=[];if(c.lastIndexOf("'s")>0){$("#pagebar").show()}else{$("#pagebar").hide()}l.data.params=l.data.params||[];l.data.params.sort(function(t,s){return t.index-s.index});var n=false;var h={};$.each(l.data.params||[],function(s,t){if("delete"==f){}if(t.name=="parent_id"&&f=="get"){n=true}t.serial=s+1;if(t.dic){t.sdic="字典详情";if(typeof(t.dic)=="object"){h[t.name]=t.dic;t.dict=true}t.dic=bapi.formatJson(t.dic);t.dictkey=t.name}if(t.setting){t.tset="配置详情";t.setting=bapi.formatJson(t.setting)}if(t.pk){t.type+="(PK)"}else{if(t.uk){t.type+="(UK)"}}t.pname=t.name;if(t.required){t.nonul=f=="post"&&t.pk&&t.defval?"":(f=="put"||f=="delete")&&!t.pk?"":f=="get"&&(c.indexOf("'s")>0||c.endsWith("$"))?"":f=="get"&&!t.pk?"":"*"}t.redborder=t.nonul?"border: 1px red solid;":"";if(bapi.data[t.name]!==undefined){t.__value=bapi.data[t.name]}var u=g.bind(t);m.push(u)});if(n){var q={name:"layer",pname:"layer",title:"获取层数",type:"integer",describe:"获取树的层级,默认为0,不获取子节点",required:false,length:0,serial:l.data.params.length+1};l.data.params.push(q);var r=g.bind(q);m.push(r)}k.html(m.join(""));k.find("td[type=file],td[type=bytes]").each(function(){var t=$(this),s=t.attr("name");t.children().attr("type","file").attr("multiple","multiple").change(function(){k.find(":checkbox[name="+this.name+"]")[0].checked=true})});bapi.bindDict(k,h);bapi.initDictParams(k);bapi.selectFields(p);p.find(":checkbox[name=select_all]").change(function(){var s=$(this).parent().parent().parent().siblings("tbody.body");s.find(":checkbox").prop("checked",this.checked)});p.find("tfoot.other-param").hide();if("get"==f){bapi.bindRelations(l.data.relations)}})},getSelFields:function(){return $("#fields textarea[name=fields]").val()},selFields:function(a){$("#fields textarea").val(a)},bindRelations:function(b,a,c){var d=a||$("#relations_params");$.each(b||{},function(h,n){var o=$("#api_params").clone(true);o.find("em[name='nonulInfo']").remove();var e=o.find(".template").html(),j=o.find(".body");o.removeAttr("id").removeClass("show");j.html("");var m=[];var p={};if(typeof(n)=="string"){o.find("h4").text("扩展数据["+h+"]:"+n);o.find("table").remove();d.append(o);return}else{p=n._define;delete n._define;o.find("h4 .title").text(p._desc+"扩展数据["+h+"]:"+p._title)}var l=1,g=[];var f={};$.each(n||{},function(k,i){i.serial=l++;if(i.dic){i.sdic="字典详情";if(typeof(i.dic)=="object"){f[i.name]=i.dic;i.dict=true}i.dic=bapi.formatJson(i.dic);i.dictkey=i.name}if(i.setting){i.tset="配置";i.setting=bapi.formatJson(i.setting)}if(i.pk){i.type+="(PK)"}else{if(i.uk){i.type+="(UK)"}}i.pname=i.name;i.parentKey=c;i.name=h+"."+i.name;if(c){i.name=c+"."+i.name}if(bapi.data[i.name]!==undefined){i.__value=bapi.data[i.name]}g.push(i)});g.sort(function(k,i){return i.index-k.index});$.each(g,function(k,q){q.serial=k+1;var r=e.bind(q);m.push(r)});j.html(m.join("")).attr("id","_type_"+(c?c+"."+h:h)).attr("_type",p._type);o.find(":checkbox[name='select_all']").attr("group",c?c+"."+h:h);o.find("h4>input[name=alias]").attr("name",(c?c+"."+h:h)+".alias").attr("id",(c?c+"."+h:h).replace(".","_")+"_alias");o.find("tfoot.other-param").show();bapi.bindDict(j,f);bapi.initDictParams(j);o.find("tfoot.other-param a").attr("parent_key",c?c+"."+h:h).click(function(){var i=$(this);$.get(contextPath+"uris/"+p._api,{method:"get"},function(q){var k=o.find("tfoot.other-param>tr>td");k.empty();bapi.bindRelations(q.data.relations,k,i.attr("parent_key"))})});d.append(o);bapi.selectFields(o,c?c+"."+h:h)})},selectFields:function(b,c){var e=top.dialog?top.dialog.get(window):null;if(e){var g=e.options.$("textarea[name=fields]").val();if(g){let grp,alias,field;let arr=g.trim().replace(/\[/g,"(").replace(/\]/g,")").split(",");for(var d=0;d1){let a=tmp[0].split("->");grp=a[0];alias=a.length>1?a[1]:null;field=tmp[1]}else{field=tmp[0]}if(c&&!(c==grp)){continue}field=grp?grp+"."+field:field;var a=grp,h=alias;if(field.endsWith(")")){field=field.substr(0,field.length-1);grp=alias=null}if(field.endsWith(".*")){b.find(":checkbox[name^='"+a+".']").prop("checked",true);b.find(":checkbox[group='"+a+"']").prop("checked",true)}else{if(field.endsWith("*")){b.find(":checkbox[name^='"+a+"']").prop("checked",true)}else{b.find(":checkbox[name='"+field+"']").prop("checked",true)}}if(h){b.find("h4>input[name='"+a+".alias']").val(h)}}}b.find(":checkbox[name=select_all]").change(function(){var i=$(this).parent().parent().parent().siblings("tbody.body");i.find("tr>td>:checkbox").prop("checked",this.checked)});var f;b.find(":checkbox").change(function(){if(this.name=="select_all"){f=setTimeout(function(){var j=e.call(true);e.oncall(j)},1)}else{var i=e.call(true);e.oncall(i)}})}},initDictParams:function(b){var a=$("textarea[name=jsondata]");b.find("select").change(function(){var c=this.value,d=b.find(":checkbox[name='"+this.name+"']");if(c.trim().length==0){d[0].checked=false}else{d[0].checked=true}});b.find(":input:not(:checkbox[otype=sel])").focus(function(){b.find(":checkbox[name='"+this.name+"']")[0].checked=true}).change(function(){var d=this.value.trim(),i=b.find(":checkbox[name='"+this.name+"'][otype=sel]");if(this.type=="checkbox"){var f=[],h=$(this).parent().parent();h.find(":checkbox[name='"+this.name+"']:checked").each(function(){f.push(this.value)});if(h.attr("type")=="bit"){d=0;f.forEach(function(e){d+=parseInt(e)});d=d.toString(2)}else{d=f.join(",")}}i.val(d);if(d.length==0){i[0].checked=false;try{var c=JSON.parse(a.val());delete c[this.name];a.val(bapi.formatJson(c))}catch(g){console.error(g)}}else{i[0].checked=true;try{var c=JSON.parse(a.val());c[this.name]=d.trim();a.val(bapi.formatJson(c))}catch(g){console.error(g)}}}).blur(function(){var c=this.value;if(!c||c.trim().length==0){b.find(":checkbox[name='"+this.name+"']")[0].checked=false}});b.find(":checkbox[otype=data]").click(function(){var d=b.find(":checked[name='"+this.name+"'][otype=data]"),g=b.find(":checkbox[name='"+this.name+"'][otype=sel]");var f=[],c=$(this).parent().parent().attr("type")=="bit";d.each(function(){f.push(this.value)});if(c){var e=0;$.each(f,function(j,h){e=e|parseInt(h)});g.val(new Number(e).toString(2))}else{g.val(f.join(","))}if(d.length==0){g[0].checked=false}else{g[0].checked=true}})},bindDict:function(b,a){b.find("td[dict=true]").each(function(){var i=$(this),c=i.attr("name"),f=i.attr("pname"),h=i.attr("defval");var e=a[f||c];if(!e||!e.items||e.items.length==0||Object.keys(e.items).length==0){return}var l=i.find("input").val(),j=i.find("input").attr("title");if(e.single){var k="请选择"+j+" {dictItems} ";var d=[];$.each(e.items,function(m,n){var o=""+m+":"+n.name+" ";d.push(o)});i.html(k.replace("{dictItems}",d.join("")));i.children().val(l)}else{var d=[],g=l?i.attr("type")=="bit"?function(){var n=[],m=1;var o=parseInt(l,2);while(m<=o){if((m&o)>0){n.push(m)}m=m*2}return n}():l.split(","):[];$.each(e.items,function(m,n){var o=" "+n.value+":"+n.name+" ";d.push(o)});i.html(d.join(""));if(g.length>0){i.find(":checkbox").val(g)}}})},loadData:function(){var u=$("#api_info"),g=u.find("input[name=url]").val(),s=u.find("input[name=url]").attr("content_type");method=u.attr("method");var t=location.pathname.startsWith("/$api")?"_localhost":location.pathname.replaceAll(/\/(.*)\/\$api(.*)/,"$1")||"";var y=$.store(t+"_history_api")||{},k=u.attr("method"),i=u.attr("url").replaceAll("/|'",".");y[k+":"+i]={url:u.attr("url"),method:k,title:u.data("title"),describe:u.data("describe"),time:new Date().getTime()};$.each(y,function(z,e){var A=top.tabbar.bar||top.tabbar.get(window).bar;e.open=A.children("[key='"+z+"']").length>0});$.store(t+"_history_api",y);if(method=="get"&&s&&s.startsWith("image")){$("#result").html(' ');return}var b=method=="post"?$.post:method=="put"?$.put:method=="delete"?$.del:$.get;var x={};var p=$("input:checked[name=data_type]").val();if(p){var d=$("textarea[name=jsondata]").val().trim();if(d){try{x=JSON.parse(d)}catch(v){alert(v.message)}}}else{$("#api_params,#relations_params").find("input:checked[otype=sel]").each(function(){x[this.name]=this.value})}var n=$("#fields textarea").val();if(n&&n.trim()){x.fields=n.trim()}var w=$("#pagebar input[name=pageno]").val(),q=$("#pagebar input[name=pagesize]").val();if(w){x.pageno=parseInt(w)||1}if(q){x.pagesize=parseInt(q)||20}var o=null;$("#api_params").find("input:checked").each(function(){var z=$(this).parent().parent().find(":file[name='"+this.name+"']")[0];if(!z){return}if(o==null){o=new FormData()}for(var e=0;e0){x.__search=g.substring(g.indexOf("?"));g=g.substring(0,g.indexOf("?"))}else{if(g.indexOf("?")>0){x.__search=g.substring(g.indexOf("#"));g=g.substring(0,g.indexOf("#"))}}x.isjson=p;$.store(method+":"+g,x)};var c={};$("#_headers").children(":not(.template)").each(function(){var e=$(this);c[e.find("[name=hname]").text()]=e.find("[name=hvalue]").text()});var f=new Date().getTime();var m={url:g,data:o?o:x,headers:c,success:h,complete:l};b(m);if(method=="post"||method=="put"){$("#req_params1").html(JSON.stringify(x));$("#req_params").html(bapi.formatJson(x))}else{var a=[];$.each(x||{},function(e,z){a.push(e+"="+z);$("#req_params1").html(a.join("&"));$("#req_params").html(a.join(" "))})}},formatJson:function(g){if(!g){return""}var d="\t";var a=JSON.stringify(g,null,d);return a;var f="";for(var b=0;b1){var e=a.charAt(b-1);if(d!=e&&d==c){f+=" "}}f+=c}a="";for(var b=0;b"}}return a},beautifyFields:function(){var a=$("#json_fields").val();var b=JSON.parse(a);var c=bapi.formatJson(b);$("#json_fields").val(c)},beautifyResult:function(){var a=$("#result").html();var b=JSON.parse(a);var c=bapi.formatJson(b);$("#result").html(c)},beautifyJsondata:function(){var a=$("textarea[name=jsondata]").val();var b=JSON.parse(a);var c=bapi.formatJson(b);$("textarea[name=jsondata]").val(c)},smallResult:function(){$("#result").toggleClass("result-auto")},smallParams:function(){var a=$("#req_params");a.toggleClass("params-auto");if(a.is(".params-auto")){$("#req_params1").show()}else{$("#req_params1").hide()}},addHeader:function(c){var b=$("#_headers");var a=b.find(".template").html();a=a.bind(c);var c=$(""+a+" ");c.find("i").click(function(){c.remove()});b.append(c)},addParam:function(d){$(":checkbox[name=data_type]").click();var a=$("textarea[name=jsondata]");var b=JSON.parse(a.val());b[d.hname]=d.hvalue;var c=bapi.formatJson(b);a.val(c)}};$(function(){$.ajaxSetup({timeout:30*1000});var c=$.getParam("method"),b=$.getParam("uri");if(c&&b){bapi.loadApi(c,b)}var a=$("#api_params,#relations_params");$(":checkbox[name=data_type]").change(function(){var e=$("textarea[name=jsondata]");if(this.checked){e.removeAttr("disabled").focus();var d=e.val();if(!d){var f={};a.find("input[otype=sel]:checked").each(function(){f[this.name]=this.value}).find("input").attr("disabled","disabled");e.val(JSON.stringify(f))}}else{var d=e.val();if(d=="{}"){e.val("")}e.attr("disabled","disabled");a.find("input").removeAttr("disabled")}});$("textarea[name=jsondata]").change(function(){try{var d=JSON.parse(this.value);$.each(d||{},function(g,e){a.find(":input[name='"+g+"']").val(e);var h=a.find(":checkbox[name='"+g+"'][otype=sel]");if(h.length>0){h[0].checked=true}})}catch(f){console.error(f)}});$.ajaxSetup({error:function(d){$("#result").html(JSON.stringify(d))}});$.error=function(d){$("#result").html(JSON.stringify(d));clearTimeout(bapi.timeout);bapi.timeout=null;$("#result_time").text("请求异常!")}});