anncic-api 3.4.3 → 3.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config.default.js +1 -1
- package/dist/config/config.production.js +1 -1
- package/dist/configuration.js +1 -1
- package/dist/decorator/Action.js +1 -1
- package/dist/decorator/ActionApitest.js +1 -1
- package/dist/decorator/Intercept.js +1 -1
- package/dist/exception/ApiError.js +1 -1
- package/dist/helper/getAppsConfig.js +1 -1
- package/dist/helper/getRoutes.js +1 -1
- package/dist/index.js +1 -1
- package/dist/service/ApiService.js +1 -1
- package/dist/service/ApitestService.js +1 -1
- package/dist/service/ExcelService.js +1 -1
- package/dist/types/action.js +1 -1
- package/dist/types/common.js +1 -1
- package/dist/types/intercept.js +1 -1
- package/index.d.ts +32 -32
- package/package.json +8 -8
- package/public/apitest.js +945 -945
- package/public/config.js +94 -94
- package/public/index.html +109 -109
- package/public/style/apitest.css +128 -128
- package/public/style/bootstrap/bootstrap.css +6799 -6799
- package/public/style/bootstrap/bootstrap.js +2363 -2363
- package/public/style/bootstrap.css +6798 -6798
- package/public/style/jquery/jquery.min.js +6 -6
- package/public/style/pinyin.js +45 -45
- package/public/style/pretty-json/backbone-min.js +1 -1
- package/public/style/pretty-json/pretty-json-min.js +334 -334
- package/public/style/pretty-json/pretty-json.css +47 -47
- package/public/style/pretty-json/underscore-min.js +5 -5
- package/public/style/pretty-json.css +47 -47
|
@@ -1,334 +1,334 @@
|
|
|
1
|
-
/*
|
|
2
|
-
License here,
|
|
3
|
-
I dont think too much about licence
|
|
4
|
-
just feel free to do anything you want... :-)
|
|
5
|
-
*/
|
|
6
|
-
var PrettyJSON = {
|
|
7
|
-
view: {},
|
|
8
|
-
tpl: {}
|
|
9
|
-
};
|
|
10
|
-
PrettyJSON.util = {
|
|
11
|
-
isObject: function(v) {
|
|
12
|
-
return Object.prototype.toString.call(v) === '[object Object]';
|
|
13
|
-
},
|
|
14
|
-
pad: function(str, length) {
|
|
15
|
-
str = String(str);
|
|
16
|
-
while (str.length < length) str = '0' + str;
|
|
17
|
-
return str;
|
|
18
|
-
},
|
|
19
|
-
dateFormat: function(date, f) {
|
|
20
|
-
f = f.replace('YYYY', date.getFullYear());
|
|
21
|
-
f = f.replace('YY', String(date.getFullYear()).slice( - 2));
|
|
22
|
-
f = f.replace('MM', PrettyJSON.util.pad(date.getMonth() + 1, 2));
|
|
23
|
-
f = f.replace('DD', PrettyJSON.util.pad(date.getDate(), 2));
|
|
24
|
-
f = f.replace('HH24', PrettyJSON.util.pad(date.getHours(), 2));
|
|
25
|
-
f = f.replace('HH', PrettyJSON.util.pad((date.getHours() % 12), 2));
|
|
26
|
-
f = f.replace('MI', PrettyJSON.util.pad(date.getMinutes(), 2));
|
|
27
|
-
f = f.replace('SS', PrettyJSON.util.pad(date.getSeconds(), 2));
|
|
28
|
-
return f;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
PrettyJSON.tpl.Node = '' + '<span class="node-container">' + '<span class="node-top node-bracket" />' + '<span class="node-content-wrapper">' + '<ul class="node-body" />' + '</span>' + '<span class="node-down node-bracket" />' + '</span>';
|
|
33
|
-
PrettyJSON.tpl.Leaf = '' + '<span class="leaf-container">' + '<span class="<%= type %>" ondblclick="selectPrettySpan(this,event);"><%=data%></span><span><%= coma %></span>' + '</span>';//asinw edit
|
|
34
|
-
PrettyJSON.view.Node = Backbone.View.extend({
|
|
35
|
-
tagName: 'span',
|
|
36
|
-
data: null,
|
|
37
|
-
level: 1,
|
|
38
|
-
path: '',
|
|
39
|
-
type: '',
|
|
40
|
-
size: 0,
|
|
41
|
-
isLast: true,
|
|
42
|
-
rendered: false,
|
|
43
|
-
events: {
|
|
44
|
-
'click .node-bracket': 'collapse',
|
|
45
|
-
'mouseover .node-container': 'mouseover',
|
|
46
|
-
'mouseout .node-container': 'mouseout'
|
|
47
|
-
},
|
|
48
|
-
initialize: function(opt) {
|
|
49
|
-
this.options = opt;
|
|
50
|
-
this.data = this.options.data;
|
|
51
|
-
this.level = this.options.level || this.level;
|
|
52
|
-
this.path = this.options.path;
|
|
53
|
-
this.isLast = _.isUndefined(this.options.isLast) ? this.isLast: this.options.isLast;
|
|
54
|
-
this.dateFormat = this.options.dateFormat;
|
|
55
|
-
var m = this.getMeta();
|
|
56
|
-
this.type = m.type;
|
|
57
|
-
this.size = m.size;
|
|
58
|
-
this.childs = [];
|
|
59
|
-
this.render();
|
|
60
|
-
if (this.level == 1)
|
|
61
|
-
this.show();
|
|
62
|
-
},
|
|
63
|
-
getMeta: function() {
|
|
64
|
-
var val = {
|
|
65
|
-
size: _.size(this.data),
|
|
66
|
-
type: _.isArray(this.data) ? 'array': 'object',
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
return val;
|
|
70
|
-
},
|
|
71
|
-
elements: function() {
|
|
72
|
-
this.els = {
|
|
73
|
-
container: $(this.el).find('.node-container'),
|
|
74
|
-
contentWrapper: $(this.el).find('.node-content-wrapper'),
|
|
75
|
-
top: $(this.el).find('.node-top'),
|
|
76
|
-
ul: $(this.el).find('.node-body'),
|
|
77
|
-
down: $(this.el).find('.node-down')
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
render: function() {
|
|
81
|
-
this.tpl = _.template(PrettyJSON.tpl.Node);
|
|
82
|
-
$(this.el).html(this.tpl);
|
|
83
|
-
this.elements();
|
|
84
|
-
var b = this.getBrackets();
|
|
85
|
-
this.els.top.html(b.top);
|
|
86
|
-
this.els.down.html(b.bottom);
|
|
87
|
-
this.hide();
|
|
88
|
-
return this;
|
|
89
|
-
},
|
|
90
|
-
renderChilds: function() {
|
|
91
|
-
var keyDescList = {};//axing add
|
|
92
|
-
if (this.data['modelType'] && getDescriptionsInModel)
|
|
93
|
-
{
|
|
94
|
-
keyDescList = getDescriptionsInModel(this.data['modelType']);
|
|
95
|
-
}
|
|
96
|
-
var count = 1;
|
|
97
|
-
|
|
98
|
-
if( this.data ){
|
|
99
|
-
for(var key in this.data){
|
|
100
|
-
var val = this.data[key];
|
|
101
|
-
var isLast = (count == this.size);
|
|
102
|
-
count = count + 1;
|
|
103
|
-
var path = (this.type == 'array') ? this.path + '[' + key + ']': this.path + '.' + key;
|
|
104
|
-
var opt = {
|
|
105
|
-
key: key,
|
|
106
|
-
data: val,
|
|
107
|
-
parent: this,
|
|
108
|
-
path: path,
|
|
109
|
-
level: this.level + 1,
|
|
110
|
-
dateFormat: this.dateFormat,
|
|
111
|
-
isLast: isLast
|
|
112
|
-
};
|
|
113
|
-
var child = (PrettyJSON.util.isObject(val) || _.isArray(val)) ? new PrettyJSON.view.Node(opt) : new PrettyJSON.view.Leaf(opt);
|
|
114
|
-
child.on('mouseover',
|
|
115
|
-
function(e, path) {
|
|
116
|
-
this.trigger("mouseover", e, path);
|
|
117
|
-
},
|
|
118
|
-
this);
|
|
119
|
-
child.on('mouseout',
|
|
120
|
-
function(e) {
|
|
121
|
-
this.trigger("mouseout", e);
|
|
122
|
-
},
|
|
123
|
-
this);
|
|
124
|
-
var li = $('<li/>');
|
|
125
|
-
if (keyDescList[key])//axing add
|
|
126
|
-
{
|
|
127
|
-
li.attr('title',keyDescList[key]);
|
|
128
|
-
li.tooltip({'placement':'left','delay': { "show": 0, "hide": 0 }});
|
|
129
|
-
}
|
|
130
|
-
var colom = ' : ';
|
|
131
|
-
var left = $('<span' + ( typeof(val) == 'string' ? ' ondblclick="previewThisData(this,event);" el-string="'+encodeURIComponent(val)+'"':'')+ '/>');
|
|
132
|
-
var right = $('<span />').append(child.el); (this.type == 'array') ? left.html('') : left.html(key + colom);
|
|
133
|
-
left.append(right);
|
|
134
|
-
li.append(left);
|
|
135
|
-
this.els.ul.append(li);
|
|
136
|
-
child.parent = this;
|
|
137
|
-
this.childs.push(child);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
isVisible: function() {
|
|
142
|
-
return this.els.contentWrapper.is(":visible");
|
|
143
|
-
},
|
|
144
|
-
collapse: function(e) {
|
|
145
|
-
e.stopPropagation();
|
|
146
|
-
this.isVisible() ? this.hide() : this.show();
|
|
147
|
-
this.trigger("collapse", e);
|
|
148
|
-
},
|
|
149
|
-
show: function() {
|
|
150
|
-
if (!this.rendered) {
|
|
151
|
-
this.renderChilds();
|
|
152
|
-
this.rendered = true;
|
|
153
|
-
}
|
|
154
|
-
this.els.top.html(this.getBrackets().top);
|
|
155
|
-
this.els.contentWrapper.show();
|
|
156
|
-
this.els.down.show();
|
|
157
|
-
},
|
|
158
|
-
hide: function() {
|
|
159
|
-
var b = this.getBrackets();
|
|
160
|
-
this.els.top.html(b.close);
|
|
161
|
-
this.els.contentWrapper.hide();
|
|
162
|
-
this.els.down.hide();
|
|
163
|
-
},
|
|
164
|
-
getBrackets: function() {
|
|
165
|
-
var v = {
|
|
166
|
-
top: '{',
|
|
167
|
-
bottom: '}',
|
|
168
|
-
close: '{ ... }'
|
|
169
|
-
};
|
|
170
|
-
if (this.type == 'array') {
|
|
171
|
-
v = {
|
|
172
|
-
top: '[',
|
|
173
|
-
bottom: ']',
|
|
174
|
-
close: '[ ... ]'
|
|
175
|
-
};
|
|
176
|
-
};
|
|
177
|
-
v.bottom = (this.isLast) ? v.bottom: v.bottom + ',';
|
|
178
|
-
v.close = (this.isLast) ? v.close: v.close + ',';
|
|
179
|
-
return v;
|
|
180
|
-
},
|
|
181
|
-
mouseover: function(e) {
|
|
182
|
-
e.stopPropagation();
|
|
183
|
-
this.trigger("mouseover", e, this.path);
|
|
184
|
-
},
|
|
185
|
-
mouseout: function(e) {
|
|
186
|
-
e.stopPropagation();
|
|
187
|
-
this.trigger("mouseout", e);
|
|
188
|
-
},
|
|
189
|
-
expandAll: function() {
|
|
190
|
-
_.each(this.childs,
|
|
191
|
-
function(child) {
|
|
192
|
-
if (child instanceof PrettyJSON.view.Node) {
|
|
193
|
-
child.show();
|
|
194
|
-
child.expandAll();
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
this);
|
|
198
|
-
this.show();
|
|
199
|
-
},
|
|
200
|
-
collapseAll: function() {
|
|
201
|
-
_.each(this.childs,
|
|
202
|
-
function(child) {
|
|
203
|
-
if (child instanceof PrettyJSON.view.Node) {
|
|
204
|
-
child.hide();
|
|
205
|
-
child.collapseAll();
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
this);
|
|
209
|
-
if (this.level != 1)
|
|
210
|
-
this.hide();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
selectPrettySpan = function(_this,e){//asinw add
|
|
214
|
-
var range, selection;
|
|
215
|
-
if (window.getSelection && document.createRange) {
|
|
216
|
-
selection = window.getSelection();
|
|
217
|
-
range = document.createRange();
|
|
218
|
-
range.selectNodeContents(_this);
|
|
219
|
-
selection.removeAllRanges();
|
|
220
|
-
selection.addRange(range);
|
|
221
|
-
} else if (document.selection && document.body.createTextRange) {
|
|
222
|
-
range = document.body.createTextRange();
|
|
223
|
-
range.moveToElementText(_this);
|
|
224
|
-
range.select();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
hidePrettyImg = function(_this,e){//asinw add
|
|
228
|
-
var imgDiv = document.getElementById('pretty_img_div');
|
|
229
|
-
if (imgDiv)
|
|
230
|
-
{
|
|
231
|
-
imgDiv.style.display='none';
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
showPrettyImg = function(_this,e){//asinw add
|
|
235
|
-
var link = _this.innerHTML;
|
|
236
|
-
if (link.match(/(image|jpg|jpeg|png|gif)/g))
|
|
237
|
-
{
|
|
238
|
-
var imgDiv = document.getElementById('pretty_img_div');
|
|
239
|
-
if (!imgDiv)
|
|
240
|
-
{
|
|
241
|
-
imgDiv = document.createElement('div');
|
|
242
|
-
imgDiv.setAttribute('id','pretty_img_div');
|
|
243
|
-
imgDiv.style.cssText = 'position:absolute;border:1px solid #333;background:#f7f5d1;padding:1px;color:#333;display:none;z-index:9999;';
|
|
244
|
-
document.body.appendChild(imgDiv);
|
|
245
|
-
}
|
|
246
|
-
imgDiv.style.top = (e.pageY+20) + "px";
|
|
247
|
-
imgDiv.style.right = (document.body.clientWidth - e.pageX + 20) + "px";
|
|
248
|
-
imgDiv.innerHTML = '<img src="'+link+'"/>';
|
|
249
|
-
imgDiv.style.display = 'block';
|
|
250
|
-
}
|
|
251
|
-
return false;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
previewThisData = function(_this,e){
|
|
255
|
-
var eTarget = (e.target)?e.target:e.srcElement;
|
|
256
|
-
if (eTarget == _this)
|
|
257
|
-
{
|
|
258
|
-
var s = decodeURIComponent(_this.getAttribute ('el-string'));
|
|
259
|
-
if (s.match(/^<.*?>[\s\S]*<.*?>$/g))
|
|
260
|
-
{
|
|
261
|
-
OpenWindow = window.open("", "newwin", "height=220,width=470,toolbar=no,scrollbars=" + scroll + ",menubar=no");;
|
|
262
|
-
OpenWindow.document.write(s) ;
|
|
263
|
-
OpenWindow.document.close() ;
|
|
264
|
-
self.name = "main";
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
PrettyJSON.view.Leaf = Backbone.View.extend({
|
|
270
|
-
tagName: 'span',
|
|
271
|
-
data: null,
|
|
272
|
-
level: 0,
|
|
273
|
-
path: '',
|
|
274
|
-
type: 'string',
|
|
275
|
-
isLast: true,
|
|
276
|
-
events: {
|
|
277
|
-
"mouseover .leaf-container": "mouseover",
|
|
278
|
-
"mouseout .leaf-container": "mouseout"
|
|
279
|
-
},
|
|
280
|
-
initialize: function(opt) {
|
|
281
|
-
this.options = opt;
|
|
282
|
-
this.data = this.options.data;
|
|
283
|
-
this.level = this.options.level;
|
|
284
|
-
this.path = this.options.path;
|
|
285
|
-
this.type = this.getType();
|
|
286
|
-
this.dateFormat = this.options.dateFormat;
|
|
287
|
-
this.isLast = _.isUndefined(this.options.isLast) ? this.isLast: this.options.isLast;
|
|
288
|
-
this.render();
|
|
289
|
-
},
|
|
290
|
-
getType: function() {
|
|
291
|
-
var m = 'string';
|
|
292
|
-
var d = this.data;
|
|
293
|
-
if (_.isNumber(d)) m = 'number';
|
|
294
|
-
else if (_.isBoolean(d)) m = 'boolean';
|
|
295
|
-
else if (_.isDate(d)) m = 'date';
|
|
296
|
-
return m;
|
|
297
|
-
},
|
|
298
|
-
getState: function() {
|
|
299
|
-
var coma = this.isLast ? '': ',';
|
|
300
|
-
var state = {
|
|
301
|
-
data: this.data,
|
|
302
|
-
level: this.level,
|
|
303
|
-
path: this.path,
|
|
304
|
-
type: this.type,
|
|
305
|
-
coma: coma
|
|
306
|
-
};
|
|
307
|
-
return state;
|
|
308
|
-
},
|
|
309
|
-
render: function() {
|
|
310
|
-
var state = this.getState();
|
|
311
|
-
if (state.type == "date" && this.dateFormat) {
|
|
312
|
-
state.data = PrettyJSON.util.dateFormat(this.data, this.dateFormat);
|
|
313
|
-
}
|
|
314
|
-
else if (typeof(state.data) == "string" )//asinw add
|
|
315
|
-
{
|
|
316
|
-
state.data = state.data.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');//转义使html代码无效
|
|
317
|
-
state.data = state.data.replace(/((http[^ ,"']+|data:image[^ "']+))/g,function(link){
|
|
318
|
-
return '<a target=_blank '+(link.match(/(image|jpg|jpeg|png|gif)/g)?'onmouseover="showPrettyImg(this,event)" onmouseout="hidePrettyImg(this,event)" style="color:gray;"':'')+' href="'+link+'" >'+link+'</a>';
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
this.tpl = _.template(PrettyJSON.tpl.Leaf, state);
|
|
322
|
-
$(this.el).html(this.tpl);
|
|
323
|
-
return this;
|
|
324
|
-
},
|
|
325
|
-
mouseover: function(e) {
|
|
326
|
-
e.stopPropagation();
|
|
327
|
-
var path = this.path + ' : <span class="' + this.type + '"><b>' + this.data + '</b></span>';
|
|
328
|
-
this.trigger("mouseover", e, path);
|
|
329
|
-
},
|
|
330
|
-
mouseout: function(e) {
|
|
331
|
-
e.stopPropagation();
|
|
332
|
-
this.trigger("mouseout", e);
|
|
333
|
-
}
|
|
334
|
-
});
|
|
1
|
+
/*
|
|
2
|
+
License here,
|
|
3
|
+
I dont think too much about licence
|
|
4
|
+
just feel free to do anything you want... :-)
|
|
5
|
+
*/
|
|
6
|
+
var PrettyJSON = {
|
|
7
|
+
view: {},
|
|
8
|
+
tpl: {}
|
|
9
|
+
};
|
|
10
|
+
PrettyJSON.util = {
|
|
11
|
+
isObject: function(v) {
|
|
12
|
+
return Object.prototype.toString.call(v) === '[object Object]';
|
|
13
|
+
},
|
|
14
|
+
pad: function(str, length) {
|
|
15
|
+
str = String(str);
|
|
16
|
+
while (str.length < length) str = '0' + str;
|
|
17
|
+
return str;
|
|
18
|
+
},
|
|
19
|
+
dateFormat: function(date, f) {
|
|
20
|
+
f = f.replace('YYYY', date.getFullYear());
|
|
21
|
+
f = f.replace('YY', String(date.getFullYear()).slice( - 2));
|
|
22
|
+
f = f.replace('MM', PrettyJSON.util.pad(date.getMonth() + 1, 2));
|
|
23
|
+
f = f.replace('DD', PrettyJSON.util.pad(date.getDate(), 2));
|
|
24
|
+
f = f.replace('HH24', PrettyJSON.util.pad(date.getHours(), 2));
|
|
25
|
+
f = f.replace('HH', PrettyJSON.util.pad((date.getHours() % 12), 2));
|
|
26
|
+
f = f.replace('MI', PrettyJSON.util.pad(date.getMinutes(), 2));
|
|
27
|
+
f = f.replace('SS', PrettyJSON.util.pad(date.getSeconds(), 2));
|
|
28
|
+
return f;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
PrettyJSON.tpl.Node = '' + '<span class="node-container">' + '<span class="node-top node-bracket" />' + '<span class="node-content-wrapper">' + '<ul class="node-body" />' + '</span>' + '<span class="node-down node-bracket" />' + '</span>';
|
|
33
|
+
PrettyJSON.tpl.Leaf = '' + '<span class="leaf-container">' + '<span class="<%= type %>" ondblclick="selectPrettySpan(this,event);"><%=data%></span><span><%= coma %></span>' + '</span>';//asinw edit
|
|
34
|
+
PrettyJSON.view.Node = Backbone.View.extend({
|
|
35
|
+
tagName: 'span',
|
|
36
|
+
data: null,
|
|
37
|
+
level: 1,
|
|
38
|
+
path: '',
|
|
39
|
+
type: '',
|
|
40
|
+
size: 0,
|
|
41
|
+
isLast: true,
|
|
42
|
+
rendered: false,
|
|
43
|
+
events: {
|
|
44
|
+
'click .node-bracket': 'collapse',
|
|
45
|
+
'mouseover .node-container': 'mouseover',
|
|
46
|
+
'mouseout .node-container': 'mouseout'
|
|
47
|
+
},
|
|
48
|
+
initialize: function(opt) {
|
|
49
|
+
this.options = opt;
|
|
50
|
+
this.data = this.options.data;
|
|
51
|
+
this.level = this.options.level || this.level;
|
|
52
|
+
this.path = this.options.path;
|
|
53
|
+
this.isLast = _.isUndefined(this.options.isLast) ? this.isLast: this.options.isLast;
|
|
54
|
+
this.dateFormat = this.options.dateFormat;
|
|
55
|
+
var m = this.getMeta();
|
|
56
|
+
this.type = m.type;
|
|
57
|
+
this.size = m.size;
|
|
58
|
+
this.childs = [];
|
|
59
|
+
this.render();
|
|
60
|
+
if (this.level == 1)
|
|
61
|
+
this.show();
|
|
62
|
+
},
|
|
63
|
+
getMeta: function() {
|
|
64
|
+
var val = {
|
|
65
|
+
size: _.size(this.data),
|
|
66
|
+
type: _.isArray(this.data) ? 'array': 'object',
|
|
67
|
+
|
|
68
|
+
};
|
|
69
|
+
return val;
|
|
70
|
+
},
|
|
71
|
+
elements: function() {
|
|
72
|
+
this.els = {
|
|
73
|
+
container: $(this.el).find('.node-container'),
|
|
74
|
+
contentWrapper: $(this.el).find('.node-content-wrapper'),
|
|
75
|
+
top: $(this.el).find('.node-top'),
|
|
76
|
+
ul: $(this.el).find('.node-body'),
|
|
77
|
+
down: $(this.el).find('.node-down')
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
render: function() {
|
|
81
|
+
this.tpl = _.template(PrettyJSON.tpl.Node);
|
|
82
|
+
$(this.el).html(this.tpl);
|
|
83
|
+
this.elements();
|
|
84
|
+
var b = this.getBrackets();
|
|
85
|
+
this.els.top.html(b.top);
|
|
86
|
+
this.els.down.html(b.bottom);
|
|
87
|
+
this.hide();
|
|
88
|
+
return this;
|
|
89
|
+
},
|
|
90
|
+
renderChilds: function() {
|
|
91
|
+
var keyDescList = {};//axing add
|
|
92
|
+
if (this.data['modelType'] && getDescriptionsInModel)
|
|
93
|
+
{
|
|
94
|
+
keyDescList = getDescriptionsInModel(this.data['modelType']);
|
|
95
|
+
}
|
|
96
|
+
var count = 1;
|
|
97
|
+
|
|
98
|
+
if( this.data ){
|
|
99
|
+
for(var key in this.data){
|
|
100
|
+
var val = this.data[key];
|
|
101
|
+
var isLast = (count == this.size);
|
|
102
|
+
count = count + 1;
|
|
103
|
+
var path = (this.type == 'array') ? this.path + '[' + key + ']': this.path + '.' + key;
|
|
104
|
+
var opt = {
|
|
105
|
+
key: key,
|
|
106
|
+
data: val,
|
|
107
|
+
parent: this,
|
|
108
|
+
path: path,
|
|
109
|
+
level: this.level + 1,
|
|
110
|
+
dateFormat: this.dateFormat,
|
|
111
|
+
isLast: isLast
|
|
112
|
+
};
|
|
113
|
+
var child = (PrettyJSON.util.isObject(val) || _.isArray(val)) ? new PrettyJSON.view.Node(opt) : new PrettyJSON.view.Leaf(opt);
|
|
114
|
+
child.on('mouseover',
|
|
115
|
+
function(e, path) {
|
|
116
|
+
this.trigger("mouseover", e, path);
|
|
117
|
+
},
|
|
118
|
+
this);
|
|
119
|
+
child.on('mouseout',
|
|
120
|
+
function(e) {
|
|
121
|
+
this.trigger("mouseout", e);
|
|
122
|
+
},
|
|
123
|
+
this);
|
|
124
|
+
var li = $('<li/>');
|
|
125
|
+
if (keyDescList[key])//axing add
|
|
126
|
+
{
|
|
127
|
+
li.attr('title',keyDescList[key]);
|
|
128
|
+
li.tooltip({'placement':'left','delay': { "show": 0, "hide": 0 }});
|
|
129
|
+
}
|
|
130
|
+
var colom = ' : ';
|
|
131
|
+
var left = $('<span' + ( typeof(val) == 'string' ? ' ondblclick="previewThisData(this,event);" el-string="'+encodeURIComponent(val)+'"':'')+ '/>');
|
|
132
|
+
var right = $('<span />').append(child.el); (this.type == 'array') ? left.html('') : left.html(key + colom);
|
|
133
|
+
left.append(right);
|
|
134
|
+
li.append(left);
|
|
135
|
+
this.els.ul.append(li);
|
|
136
|
+
child.parent = this;
|
|
137
|
+
this.childs.push(child);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
isVisible: function() {
|
|
142
|
+
return this.els.contentWrapper.is(":visible");
|
|
143
|
+
},
|
|
144
|
+
collapse: function(e) {
|
|
145
|
+
e.stopPropagation();
|
|
146
|
+
this.isVisible() ? this.hide() : this.show();
|
|
147
|
+
this.trigger("collapse", e);
|
|
148
|
+
},
|
|
149
|
+
show: function() {
|
|
150
|
+
if (!this.rendered) {
|
|
151
|
+
this.renderChilds();
|
|
152
|
+
this.rendered = true;
|
|
153
|
+
}
|
|
154
|
+
this.els.top.html(this.getBrackets().top);
|
|
155
|
+
this.els.contentWrapper.show();
|
|
156
|
+
this.els.down.show();
|
|
157
|
+
},
|
|
158
|
+
hide: function() {
|
|
159
|
+
var b = this.getBrackets();
|
|
160
|
+
this.els.top.html(b.close);
|
|
161
|
+
this.els.contentWrapper.hide();
|
|
162
|
+
this.els.down.hide();
|
|
163
|
+
},
|
|
164
|
+
getBrackets: function() {
|
|
165
|
+
var v = {
|
|
166
|
+
top: '{',
|
|
167
|
+
bottom: '}',
|
|
168
|
+
close: '{ ... }'
|
|
169
|
+
};
|
|
170
|
+
if (this.type == 'array') {
|
|
171
|
+
v = {
|
|
172
|
+
top: '[',
|
|
173
|
+
bottom: ']',
|
|
174
|
+
close: '[ ... ]'
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
v.bottom = (this.isLast) ? v.bottom: v.bottom + ',';
|
|
178
|
+
v.close = (this.isLast) ? v.close: v.close + ',';
|
|
179
|
+
return v;
|
|
180
|
+
},
|
|
181
|
+
mouseover: function(e) {
|
|
182
|
+
e.stopPropagation();
|
|
183
|
+
this.trigger("mouseover", e, this.path);
|
|
184
|
+
},
|
|
185
|
+
mouseout: function(e) {
|
|
186
|
+
e.stopPropagation();
|
|
187
|
+
this.trigger("mouseout", e);
|
|
188
|
+
},
|
|
189
|
+
expandAll: function() {
|
|
190
|
+
_.each(this.childs,
|
|
191
|
+
function(child) {
|
|
192
|
+
if (child instanceof PrettyJSON.view.Node) {
|
|
193
|
+
child.show();
|
|
194
|
+
child.expandAll();
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
this);
|
|
198
|
+
this.show();
|
|
199
|
+
},
|
|
200
|
+
collapseAll: function() {
|
|
201
|
+
_.each(this.childs,
|
|
202
|
+
function(child) {
|
|
203
|
+
if (child instanceof PrettyJSON.view.Node) {
|
|
204
|
+
child.hide();
|
|
205
|
+
child.collapseAll();
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
this);
|
|
209
|
+
if (this.level != 1)
|
|
210
|
+
this.hide();
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
selectPrettySpan = function(_this,e){//asinw add
|
|
214
|
+
var range, selection;
|
|
215
|
+
if (window.getSelection && document.createRange) {
|
|
216
|
+
selection = window.getSelection();
|
|
217
|
+
range = document.createRange();
|
|
218
|
+
range.selectNodeContents(_this);
|
|
219
|
+
selection.removeAllRanges();
|
|
220
|
+
selection.addRange(range);
|
|
221
|
+
} else if (document.selection && document.body.createTextRange) {
|
|
222
|
+
range = document.body.createTextRange();
|
|
223
|
+
range.moveToElementText(_this);
|
|
224
|
+
range.select();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
hidePrettyImg = function(_this,e){//asinw add
|
|
228
|
+
var imgDiv = document.getElementById('pretty_img_div');
|
|
229
|
+
if (imgDiv)
|
|
230
|
+
{
|
|
231
|
+
imgDiv.style.display='none';
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
showPrettyImg = function(_this,e){//asinw add
|
|
235
|
+
var link = _this.innerHTML;
|
|
236
|
+
if (link.match(/(image|jpg|jpeg|png|gif)/g))
|
|
237
|
+
{
|
|
238
|
+
var imgDiv = document.getElementById('pretty_img_div');
|
|
239
|
+
if (!imgDiv)
|
|
240
|
+
{
|
|
241
|
+
imgDiv = document.createElement('div');
|
|
242
|
+
imgDiv.setAttribute('id','pretty_img_div');
|
|
243
|
+
imgDiv.style.cssText = 'position:absolute;border:1px solid #333;background:#f7f5d1;padding:1px;color:#333;display:none;z-index:9999;';
|
|
244
|
+
document.body.appendChild(imgDiv);
|
|
245
|
+
}
|
|
246
|
+
imgDiv.style.top = (e.pageY+20) + "px";
|
|
247
|
+
imgDiv.style.right = (document.body.clientWidth - e.pageX + 20) + "px";
|
|
248
|
+
imgDiv.innerHTML = '<img src="'+link+'"/>';
|
|
249
|
+
imgDiv.style.display = 'block';
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
previewThisData = function(_this,e){
|
|
255
|
+
var eTarget = (e.target)?e.target:e.srcElement;
|
|
256
|
+
if (eTarget == _this)
|
|
257
|
+
{
|
|
258
|
+
var s = decodeURIComponent(_this.getAttribute ('el-string'));
|
|
259
|
+
if (s.match(/^<.*?>[\s\S]*<.*?>$/g))
|
|
260
|
+
{
|
|
261
|
+
OpenWindow = window.open("", "newwin", "height=220,width=470,toolbar=no,scrollbars=" + scroll + ",menubar=no");;
|
|
262
|
+
OpenWindow.document.write(s) ;
|
|
263
|
+
OpenWindow.document.close() ;
|
|
264
|
+
self.name = "main";
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
PrettyJSON.view.Leaf = Backbone.View.extend({
|
|
270
|
+
tagName: 'span',
|
|
271
|
+
data: null,
|
|
272
|
+
level: 0,
|
|
273
|
+
path: '',
|
|
274
|
+
type: 'string',
|
|
275
|
+
isLast: true,
|
|
276
|
+
events: {
|
|
277
|
+
"mouseover .leaf-container": "mouseover",
|
|
278
|
+
"mouseout .leaf-container": "mouseout"
|
|
279
|
+
},
|
|
280
|
+
initialize: function(opt) {
|
|
281
|
+
this.options = opt;
|
|
282
|
+
this.data = this.options.data;
|
|
283
|
+
this.level = this.options.level;
|
|
284
|
+
this.path = this.options.path;
|
|
285
|
+
this.type = this.getType();
|
|
286
|
+
this.dateFormat = this.options.dateFormat;
|
|
287
|
+
this.isLast = _.isUndefined(this.options.isLast) ? this.isLast: this.options.isLast;
|
|
288
|
+
this.render();
|
|
289
|
+
},
|
|
290
|
+
getType: function() {
|
|
291
|
+
var m = 'string';
|
|
292
|
+
var d = this.data;
|
|
293
|
+
if (_.isNumber(d)) m = 'number';
|
|
294
|
+
else if (_.isBoolean(d)) m = 'boolean';
|
|
295
|
+
else if (_.isDate(d)) m = 'date';
|
|
296
|
+
return m;
|
|
297
|
+
},
|
|
298
|
+
getState: function() {
|
|
299
|
+
var coma = this.isLast ? '': ',';
|
|
300
|
+
var state = {
|
|
301
|
+
data: this.data,
|
|
302
|
+
level: this.level,
|
|
303
|
+
path: this.path,
|
|
304
|
+
type: this.type,
|
|
305
|
+
coma: coma
|
|
306
|
+
};
|
|
307
|
+
return state;
|
|
308
|
+
},
|
|
309
|
+
render: function() {
|
|
310
|
+
var state = this.getState();
|
|
311
|
+
if (state.type == "date" && this.dateFormat) {
|
|
312
|
+
state.data = PrettyJSON.util.dateFormat(this.data, this.dateFormat);
|
|
313
|
+
}
|
|
314
|
+
else if (typeof(state.data) == "string" )//asinw add
|
|
315
|
+
{
|
|
316
|
+
state.data = state.data.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');//转义使html代码无效
|
|
317
|
+
state.data = state.data.replace(/((http[^ ,"']+|data:image[^ "']+))/g,function(link){
|
|
318
|
+
return '<a target=_blank '+(link.match(/(image|jpg|jpeg|png|gif)/g)?'onmouseover="showPrettyImg(this,event)" onmouseout="hidePrettyImg(this,event)" style="color:gray;"':'')+' href="'+link+'" >'+link+'</a>';
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
this.tpl = _.template(PrettyJSON.tpl.Leaf, state);
|
|
322
|
+
$(this.el).html(this.tpl);
|
|
323
|
+
return this;
|
|
324
|
+
},
|
|
325
|
+
mouseover: function(e) {
|
|
326
|
+
e.stopPropagation();
|
|
327
|
+
var path = this.path + ' : <span class="' + this.type + '"><b>' + this.data + '</b></span>';
|
|
328
|
+
this.trigger("mouseover", e, path);
|
|
329
|
+
},
|
|
330
|
+
mouseout: function(e) {
|
|
331
|
+
e.stopPropagation();
|
|
332
|
+
this.trigger("mouseout", e);
|
|
333
|
+
}
|
|
334
|
+
});
|