html摇晃的桃子代码,index.html

绿柔网络 配娘api

content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">

配娘

data-am-collapse="{target: '#collapse-head'}">导航切换

class="am-icon-bars">

   API接口管理系统   

{arg.name}{arg.required}{arg.defaultValue}{arg.desc}
{returnValue.name}{returnValue.desc}

{arg.name}

{api.name}

接口地址 方法 描述

{api.url} {api.method} {api.desc}

参数说明

参数名称 必须默认值 描述

{api.args}

返回值

参数名称 描述

{api.returnValues}

演示

{api.forms}

© 2014 AllMobilize, Inc. Licensed under

href="http://opensource.org/licenses/MIT" target="_blank">MIT license

. by the AmazeUI Team.

(function(){

var temp = $("#content-template").html(), //html 模版

argTemp = $("#arg-template").html(), //参数模版

returnValueTemp = $("#returnValue-template").html(), //返回值默认

formTemp=$("#form-template").html() //表单模版

;

var html='';

/**

* 复制字符串

* @param str 字符串

* @param num 复制数量

* @returns {string}

*/

function repeat(str,num){

var n='';

for(var i=0;i

n+=str;

}

return n;

}

/**

* 获取返回值

* @param obj 返回值对象

* @param tempstr 返回值字符串

* @param depth 深度

* @returns {string|XML|*}

*/

function getReturnValues(obj,tempstr,depth){

depth = depth || 0;

var rn = obj.name || "",rd=obj.desc || "";

if(depth !=0 ){

rn && (rn = repeat(" ",depth*3)+rn);

}

tempstr += returnValueTemp.replace("{returnValue.name}",rn)

.replace("{returnValue.desc}",rd);

if(obj.sub){

if(obj.sub instanceof Array){

obj.sub.forEach(function(subRv){

var _depth = depth+1;

tempstr = getReturnValues(subRv,tempstr,_depth);

});

}else if(obj.sub instanceof Object){

for(var i in obj.sub){

var _depth = depth+1;

tempstr += returnValueTemp.replace("{returnValue.name}",repeat(" ",_depth*3)+i)

.replace("{returnValue.desc}","");

if(obj.sub[i] instanceof Array){

_depth = _depth+1;

obj.sub[i].forEach(function(sr){

tempstr = getReturnValues(sr,tempstr,_depth)

})

}

}

return tempstr;

}

}

return tempstr;

}

/**

* 绘制网页

* @param data

*/

function render(data){

var category={};

data.forEach(function(d,index){

if(!category[d.category])category[d.category]={};

category[d.category][d.name]="";

//参数,返回值,表单字符串

var args = '',returnValues='',forms='';

d.args && d.args.forEach(function(a,i){

args+=argTemp.replace("{arg.name}", a.name)

.replace("{arg.required}", a.required || true)

.replace("{arg.defaultValue}", a.defaultValue || "")

.replace("{arg.desc}", a.desc || "");

forms += formTemp.replace(/\{arg\.name\}/g, a.name)

.replace(/\{arg\.id\}/g,a.name+"_"+i+"_"+index)

.replace("{arg.type}", a.type || "text")

.replace("{arg.desc}", a.desc || "")

});

d.returnValues && d.returnValues.forEach(function(rv){

returnValues = getReturnValues(rv,returnValues);

});

html += temp.replace("{api.name}", d.name)

.replace("{api.id}", (d.category || "")+"_"+ (d.name || ""))

.replace("{api.url}", d.url)

.replace("{api.method}", d.method || "get")

.replace("{api.desc}", d.desc || "")

.replace("

{api.args}", args )

.replace("

{api.returnValues}", returnValues)

.replace("{api.forms}",forms)

.replace("{api.target}", d.target || "")

.replace("{api.enctype}", d.enctype || "application/x-www-form-urlencoded")

.replace("{api.action}", d.url)

});

renderSidebar(category);

$("#api-content").html(html);

bindListener();

}

function renderSidebar(category){

var sidebar = '';

for(var c in category){

sidebar+='

'+c+'';

if(category[c]){

for(var sc in category[c]){

if(sc){

sidebar+='

'+sc+'';

}

}

}

}

$("#sidebar").html(sidebar);

}

function bindListener(){

$(".am-form").submit(function(){

$.ajax({

url:$(this).attr("action"),

type:$(this).attr("method") || "get",

dataType:"json",

data:$(this).serialize(),

success:function(rs){

$("#pre").html(new JSONFormat().parse(rs))

$("#modal").modal({width:900,height:600})

$(".icon").click(function(){

var $n = $(this).next();

if($(this).hasClass("ex")){

$n.hide();

$(this).removeClass("ex").addClass("co");

}else{

$n.show();

$(this).removeClass("co").addClass("ex");

}

});

}

});

return false;

});

}

//加载数据

$.get("api.json",{}, function (rs) {

render(rs);

},"json")

})();

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值