-
Notifications
You must be signed in to change notification settings - Fork 75
/
index.html
executable file
·306 lines (251 loc) · 11.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE html>
<html>
<head>
<title>Json在线解析</title>
<meta charset="utf-8" />
<meta name="keywords" content="json,json在线解析,json格式化,json格式验证,json数组"/>
<meta name="description" content="一款简洁优雅的在线json解析器,可能是目前最好用的json在线查看工具"/>
<link href="css/hint.min.css" rel="stylesheet">
<!-- <link href="css/diffview.css" rel="stylesheet"> -->
<link href="css/loading.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet">
</head>
<body>
<div id="app">
<div class="side-top">
<a class="logo" href="/">
<span class="on">Json</span><span >on</span>
</a>
<span class="slogan">
「也许」是最好用的JSON格式化验证工具
</span>
<div class="top-right">
<a href="https://github.com/bimohxh/jsonon" target="_blank">
已开源在 GitHub 上
</a>
</div>
</div>
<div :class="'side-left side-view-' + baseview">
<div class="left-panel">
<textarea v-model="jsoncon"></textarea>
<div class="label" v-show="baseview == 'diff'">原 JSON</div>
</div>
<div class="left-panel" v-show="baseview == 'diff'">
<textarea v-model="newjsoncon"></textarea>
<div class="label">新 JSON</div>
</div>
</div>
<div class="splitx" ></div>
<div class="side-right">
<div class="right-inner">
<div class="right-bar">
<div class="pull-left">
<a href="javascript:void(0)" @click="compress()" class="hint--top" data-hint="压缩">
<svg v-bind:class="'icon active-' + (view == 'compress')" >
<use xlink:href="svg/icon.svg#database"></use>
</svg>
</a>
<a href="javascript:void(0)" class="hint--top" data-hint="美化" @click="beauty()">
<svg class="icon">
<use xlink:href="svg/icon.svg#beauty"></use>
</svg>
</a>
<a href="javascript:void(0)" class="hint--top" data-hint="清空" @click="clearAll()">
<svg class="icon">
<use xlink:href="svg/icon.svg#clear"></use>
</svg>
</a>
<a href="javascript:void(0)" class="hint--top" data-hint="导出文本文件" @click="isExportTxtShow = true">
<svg class="icon">
<use xlink:href="svg/icon.svg#export-txt"></use>
</svg>
</a>
<a href="javascript:void(0)" class="hint--top" data-hint="全部展开" @click="expandAll()">
<svg class="icon" >
<use xlink:href="svg/icon.svg#expand"></use>
</svg>
</a>
<a href="javascript:void(0)" class="hint--top" data-hint="全部折叠" @click="collapseAll()">
<svg class="icon" >
<use xlink:href="svg/icon.svg#collapse"></use>
</svg>
</a>
</div>
<div class="pull-right">
<div class="loader" v-show="isSharing">
<div class="ball-pulse-sync">
<div></div>
<div></div>
<div></div>
</div>
</div>
<a class="hint--top save-tool copy-btn" data-hint="分享" href="javascript:void(0)" @click="share" data-clipboard-target="#share-input" v-show="!isSharing">
<svg class="icon">
<use xlink:href="svg/icon.svg#share"></use>
</svg>
</a>
<span class="pop-btn" v-show="historys.length > 0">
<a class="hint--top" data-hint="历史保存" href="javascript:void(0)">
<svg class="icon">
<use xlink:href="svg/icon.svg#record"></use>
</svg>
</a>
<ul class="historys pop">
<li v-for="(his, index) in historys">
<a href="javascript:void(0)" @click="restore(his)" > {{his.name}}</a>
<svg class="icon" @click="remove(his, index)">
<use xlink:href="svg/icon.svg#trash"></use>
</svg>
</li>
</ul>
</span>
<a class="hint--top save-tool" data-hint="保存" href="javascript:void(0)" @click="isSaveShow = true">
<svg class="icon">
<use xlink:href="svg/icon.svg#save"></use>
</svg>
</a>
<span class="pop-btn">
<a class="hint--top" data-hint="换肤" href="javascript:void(0)" @click="isThemeShow = true">
<svg class="icon">
<use xlink:href="svg/icon.svg#theme"></use>
</svg>
</a>
<div class="themes pop">
<div :class="'theme-item ' + (index === checkedTheme)" v-for="(theme, index) in themes" @click="switchTheme(index)">
<span class="theme-color" v-for="color in theme" :style="{backgroundColor: color}" ></span>
</div>
</div>
</span>
</div>
<!-- 用作复制的隐藏文本域 -->
<div style="position: absolute; top: -100000px">
<input id="share-input" :value="shareUrl(shareKey)">
</div>
</div>
<!--格式化视图-->
<div class="right-main" v-show="baseview == 'formater' && view != 'error'">
<!--正常JSON格式化视图-->
<div class="view-code" v-show="view == 'code'">
<vue-outer :jsondata="jsonhtml" isend="true" :theme="theme"></vue-outer>
</div>
<!--空视图-->
<div class="view-code" v-show="view == 'empty'">
</div>
<!--压缩视图-->
<textarea v-show="view == 'compress'">{{compressStr}}</textarea>
</div>
<!--格式化错误视图-->
<div class="view-error" v-show="view == 'error'">
<pre v-cloak>{{error.msg}}</pre>
</div>
<!--diff视图-->
<!-- <div id="diffoutput" v-show="baseview == 'diff' && view != 'error'">
</div> -->
</div>
</div>
<!--弹出保存框-->
<div class="save-box" v-show="isSaveShow">
<svg class="icon close-icon" @click="isSaveShow = false">
<use xlink:href="svg/icon.svg#close"></use>
</svg>
<input type="text" placeholder="请输入辨识名称" v-model="history.name" />
<button @click="save()" >保存</button>
</div>
<!--弹出下载文本框-->
<div class="save-box" v-show="isExportTxtShow">
<svg class="icon close-icon" @click="isExportTxtShow = false">
<use xlink:href="svg/icon.svg#close"></use>
</svg>
<label>.txt</label>
<input type="text" placeholder="请输入辨识名称" v-model="exTxt.name" />
<button @click="exportTxt()">下载</button>
</div>
</div>
<!--用于移动的时候遮住文本域 避免被选中-->
<div class="widnow-cover">
</div>
<!--最外层根结构-->
<script type="text/x-template" id="outer-template">
<ul class="json-item">
<vue-val :val="jsondata" :isend="isend" :theme="theme"></vue-val>
</ul>
</script>
<!--内层每个键值对-->
<script type="text/x-template" id="item-template">
<ul class="json-item">
<vue-val :field="key" :theme="theme" :val="val" :isend="index == objLength(jsondata) - 1" v-for="(val, key, index) in jsondata"></vue-val>
</ul>
</script>
<!--key value 最终的渲染方式-->
<script type="text/x-template" id="val-template">
<div class="keyval">
<template v-if="!isObjectArr(val)">
<span class="key" v-show="field" v-bind:style="{color: theme.key}">"{{field}}": </span>
<span v-bind:class="'val val-' + getTyp(val)" v-bind:style="{color: theme[getTyp(val)]}">
<span v-if="!isaLink(val)">{{formatVal(val)}}</span>
<a v-if="isaLink(val)" :href="val" target="_blank" class="json-link" :style="{color: theme['link-link']}">{{formatVal(val)}}</a>
<span v-if="!isend">,</span>
</span>
</template>
<!--key + 展开折叠ICON-->
<template v-if="isObjectArr(val)">
<span class="key" v-bind:style="{color: theme.key}" v-show="field">"{{field}}": </span>
<vue-expand></vue-expand>
</template>
<!--值为对象时-->
<template v-if="getTyp(val) == 'Object'">
<span class="expand-view">
<span>{</span>
<vue-item :jsondata="val" :theme="theme"></vue-item>
<div class="brace-end">}<span v-if="!isend">,</span></div>
</span>
<span class="fold-view">{{getTyp(val)}}{<label class="ex-alia" @click="expand($event)">{{objLength(val)}}</label>}<span v-if="!isend">,</span></span>
</template>
<!--值为数组时-->
<template v-if="getTyp(val) == 'Array'">
<span class="expand-view">
<span>[</span>
<span class="val">
<vue-outer :jsondata="sub" v-for="(sub, index) in val" :isend="index == val.length - 1" :theme="theme"></vue-outer>
</span>
<div class="brace-end">]<span v-if="!isend">,</span></div>
</span>
<span class="fold-view">{{getTyp(val)}}[<label class="arrlen ex-alia" @click="expand($event)">{{val.length}}</label>]<span v-if="!isend">,</span></span>
</template>
</div>
</script>
<!--展开 折叠的 UI 组件-->
<script type="text/x-template" id="expand-template">
<span class="expand-wraper">
<svg class="icon icon-square icon-square-min" @click="fold($event)" title="折叠">
<use xlink:href="svg/icon.svg#minus-square"></use>
</svg>
<svg class="icon icon-square icon-square-plus" @click="expand($event)" title="展开">
<use xlink:href="svg/icon.svg#plus-square"></use>
</svg>
</span>
</script>
<script src="js/vue.min.js"></script>
<script src="js/jquery.js"></script>
<script src="js/jsonlint.js"></script>
<script src="js/parse.js"></script>
<script src="js/editor.js"></script>
<!-- <script src="js/diffview.js"></script> -->
<script src="js/localforage.min.js"></script>
<script src="js/FileSaver.js"></script>
<script src="js/uuid.js"></script>
<script src="js/clipboard.min.js"></script>
<script src="js/helper.js"></script>
<script src="js/main.js"></script>
<!--访问统计 请换成自己的-->
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?0d088ec0e724b355417b09862c236ea8";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>