1 Star 0 Fork 16

152040135211_qjg/jsonFormater

forked from leo108/jsonFormater 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo.html 3.51 KB
一键复制 编辑 原始数据 按行查看 历史
leo108 提交于 2014-06-18 23:36 . add demo pic
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>json格式化及高亮</title>
<meta name="description" content="json,格式化,高亮"/>
<meta name="keywords" content="json,格式化,高亮"/>
<script src="http://runjs.cn/js/sandbox/jquery/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="jsonFormater.js" type="text/javascript"></script>
<link href="jsonFormater.css" type="text/css" rel="stylesheet"/>
<link href="demo.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div class="HeadersRow">
<div id="HeaderTitle"> JSON格式化及高亮 &nbsp;by&nbsp;<a targe='_blank' href="http://leo108.com/">leo108</a>&nbsp;核心代码参考<a target="_blank" href='http://tmxk.org/c/json/'>天马行空工作室</a></div>
<h3 id="HeaderSubTitle">JSON格式化及高亮:</h3>
<textarea id="RawJson">{"number":1,"array":[],"null":null,"string":"leo108","boolean":true,"obj":{},"level1":{"level2":{"level3":{"level4":{"level5":{"level6":{"level7":{"level8":{}}}}}}}}}</textarea>
</div>
<div id="ControlsRow">
<input type="Button" value="格式化" id='format'/>
<span id="TabSizeHolder">
缩进量
<select id="TabSize">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</span>
<input type="checkbox" id="QuoteKeys" checked='checked' />
<label for="QuoteKeys">
引号
</label>&nbsp;
<input type="checkbox" id="CollapsibleView" checked='checked' />
<label for="CollapsibleView">
显示控制
</label>
<span id="CollapsibleViewDetail">
<a href="javascript:void(0);" id="expandAll">展开</a>
<a href="javascript:void(0);" id="collapseAll">叠起</a>
<a href="javascript:void(0);" class="expand" data-level="3">2级</a>
<a href="javascript:void(0);" class="expand" data-level="4">3级</a>
<a href="javascript:void(0);" class="expand" data-level="5">4级</a>
<a href="javascript:void(0);" class="expand" data-level="6">5级</a>
<a href="javascript:void(0);" class="expand" data-level="7">6级</a>
<a href="javascript:void(0);" class="expand" data-level="8">7级</a>
<a href="javascript:void(0);" class="expand" data-level="9">8级</a>
</span>
</div>
<div id="Canvas" class="Canvas"></div>
<script type="application/javascript">
$(document).ready(function () {
var format = function () {
var options = {
dom: '#Canvas',
isCollapsible: $('#CollapsibleView').prop('checked'),
quoteKeys: $('#QuoteKeys').prop('checked'),
tabSize: $('#TabSize').val()
};
window.jf = new JsonFormater(options);
jf.doFormat($('#RawJson').val());
};
$('#format').click(function () {
format();
});
$('#expandAll').click(function () {
window.jf.expandAll();
});
$('#collapseAll').click(function () {
window.jf.collapseAll();
});
$('#TabSize, #CollapsibleView, #QuoteKeys').change(function () {
format();
});
$('.expand').click(function () {
var level = $(this).data('level');
window.jf.collapseLevel(level);
});
});
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/geekqjg/jsonFormater.git
git@gitee.com:geekqjg/jsonFormater.git
geekqjg
jsonFormater
jsonFormater
master

搜索帮助