sbd-npm 1.3.54 → 1.3.56

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/status.js +619 -0
  3. package/util.js +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.3.54",
3
+ "version": "1.3.56",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js ADDED
@@ -0,0 +1,619 @@
1
+ $(function () {
2
+
3
+ let Status = {
4
+
5
+ tab_token: "status_nav",
6
+ data: {},
7
+
8
+ fetch_data: function () {
9
+ Util.show_loading();
10
+ let active_div = localStorage[Status.tab_token];
11
+ switch (active_div) {
12
+ case "status":
13
+ Status.handle_status();
14
+ break;
15
+ case "process":
16
+ Status.handle_process();
17
+ break;
18
+ case "block_ip":
19
+ Status.handle_block_ip();
20
+ break;
21
+ case "login_log":
22
+ Status.handle_login_log();
23
+ break;
24
+ case "database_table":
25
+ Status.handle_database_table();
26
+ break;
27
+ case "request_headers":
28
+ Status.handle_request_headers();
29
+ break;
30
+ case "environment":
31
+ Status.handle_environment();
32
+ break;
33
+ case "tool":
34
+ Status.handle_tool();
35
+ break;
36
+ case "site_map":
37
+ Status.handle_site_map();
38
+ break;
39
+ }
40
+ Status["data"][active_div] = 1;
41
+ },
42
+
43
+ handle_status: function () {
44
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token], date: $("#ip_date").val()}, function (j) {
45
+ let _html = [];
46
+ if (!$("#start_time").length) {
47
+ _html.push("<tr><th id='start_time' width='25%'>系统时区:</th><td>", Status.map_url(j["timezone"]), "</td>");
48
+ _html.push("<th id='start_time' width='25%'>服务器运行时间:</th><td colspan='3'>", Util.seconds_to_format(j["start_time"]), "(" + j["up_time"] + ")</td></tr>");
49
+ _html.push("<tr><th width='25%'>数据库最后同步时间:</th><td>", Util.seconds_to_format(j["sync_end_time"]), "</td>");
50
+ _html.push("<th width='20%'>数据库句柄更新时间:</th><td colspan='3'>", Util.seconds_to_format(j["db_time"]), "</td></tr>");
51
+ _html.push("<tr><th width='25%'>成交量最后同步时间:</th><td>", Util.seconds_to_format(j["sync_amount_time"]), "</td>");
52
+ _html.push("<th width='20%'>位置数据最后同步时间:</th><td colspan='3'>", Util.seconds_to_format(j["location_time"]), "</td></tr>");
53
+ $("#status_head").prepend(_html.join(""));
54
+ }
55
+ Status.render_ip_daily(j["ip_daily_data"]);
56
+ // 数据库
57
+ $("#db_version").html(j["db_version"]);
58
+ $("#max_files").html(j["max_files"] == "None" ? "--" : j["max_files"]);
59
+ $("#open_ports").html(j["open_ports"].join(", "));
60
+ if (j["mysql_remote_ip"]) {
61
+ let mysql_remote_ip = [];
62
+ j["mysql_remote_ip"].forEach(function (remote_ip) {
63
+ mysql_remote_ip.push(Status.pack_ip_link(remote_ip));
64
+ });
65
+ $("#mysql_remote_ip").prepend(mysql_remote_ip.join("、"));
66
+ }
67
+ _html = [];
68
+ let current_connections = 0, db_ip_array = [];
69
+ j["process_list"].forEach(function (item) {
70
+ let match_ip_data = Util.regexp_match_ip(item["Host"]);
71
+ if (match_ip_data && match_ip_data[0] && $.inArray(match_ip_data[0], db_ip_array) === -1) {
72
+ db_ip_array.push(match_ip_data[0]);
73
+ }
74
+ current_connections++;
75
+ _html.push("<tr>");
76
+ _html.push("<td>", item["Id"], "</td>");
77
+ _html.push("<td>", item["User"], "</td>");
78
+ _html.push("<td>", Status.pack_ip_link(item["Host"]), "</td>");
79
+ _html.push("<td>", item["db"], "</td>");
80
+ _html.push("<td>", item["Command"], "</td>");
81
+ _html.push("<td>", item["Time"], "</td>");
82
+ _html.push("<td>", item["State"], "</td>");
83
+ _html.push("<td>", item["Info"], "</td>");
84
+ _html.push("</tr>");
85
+ });
86
+ $("#max_connections").html("<span class='label label-info'>" + current_connections + "</span> / " + j["max_connections"]);
87
+ Util.render_table_html("process_list", _html);
88
+ if (db_ip_array.length > 0) {
89
+ let din_obj = $("#db_ip_num");
90
+ din_obj.html("(" + db_ip_array.length + ")");
91
+ din_obj.attr("title", db_ip_array.join("\n"));
92
+ }
93
+ if (j["phone_num"]) {
94
+ $("#phone_query_head").attr("title", j["phone_num"]);
95
+ }
96
+ if (j["ip_date"]) {
97
+ let id_obj = $("#ip_date");
98
+ id_obj.val(Util.seconds_to_format(j["ip_date"], "%Y-%m-%d"));
99
+ id_obj.daterangepicker({
100
+ locale: {format: 'YYYY-MM-DD'},
101
+ singleDatePicker: true,
102
+ singleClasses: "picker_2"
103
+ }, function () {
104
+ setTimeout(Status.fetch_data, 123);
105
+ });
106
+ id_obj.parent().attr("title", Util.seconds_to_format(j["ip_date"]));
107
+ }
108
+ Util.hide_tips();
109
+ });
110
+ },
111
+
112
+ render_ip_daily: function(ip_daily_data) {
113
+ let _html = [];
114
+ ip_daily_data.forEach(function (item) {
115
+ _html.push("<tr>");
116
+ _html.push("<td>", Status.pack_ip_link(item["ip"]), "</td>");
117
+ _html.push("<td>", Status.map_url(item['location']), "</td>");
118
+ item["referer"] = item["referer"].replace("?", "?");
119
+ _html.push("<td title='", item["referer"], "'>", Util.pack_html_link("http://" + item["referer"], Util.sub_str(item["referer"], 50)), "</td>");
120
+ _html.push("<td>", item["visit"], "</td>");
121
+ _html.push("<td>", Util.seconds_to_format(item["time"]), "</td>");
122
+ _html.push("</tr>");
123
+ });
124
+ Util.render_table_html("ip_daily_data", _html);
125
+ },
126
+
127
+ pack_ip_link: function(ip) {
128
+ let match_ip_data = Util.regexp_match_ip(ip);
129
+ if (match_ip_data && match_ip_data[0]) {
130
+ ip = Util.pack_html_link(Status.ip_url(match_ip_data[0]), ip);
131
+ }
132
+ return ip;
133
+ },
134
+
135
+ ip_url: function(ip) {
136
+ return "https://www.ip138.com/iplookup.asp?ip=" + ip + "&action=2";
137
+ },
138
+
139
+ handle_process: function () {
140
+ if (!document.getElementById("process_div_body")) {
141
+ Util.init_table_skeleton({
142
+ "element_id": "process_div",
143
+ "caption": '<caption class="text-right" id="process_num"></caption>',
144
+ "head_cols": [
145
+ {"name": "进程ID", "table_sort": 1},
146
+ {"name": "进程名", "table_sort": 1},
147
+ {"name": "用户名", "table_sort": 1},
148
+ {"name": "状态", "table_sort": 1},
149
+ {"name": "实际内存", "table_sort": 1, "title": "resident set size"},
150
+ {"name": "虚拟内存", "table_sort": 1},
151
+ {"name": "启动命令"},
152
+ {"name": "创建时间", "table_sort": 1},
153
+ ]
154
+ });
155
+ }
156
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
157
+ let _html = [], process_num = 0;
158
+ j["data"].forEach(function (item) {
159
+ process_num++;
160
+ _html.push("<tr>");
161
+ _html.push("<td>", item["pid"], "</td>");
162
+ _html.push("<td>", item["name"], "</td>");
163
+ _html.push("<td>", item["username"], "</td>");
164
+ _html.push("<td>", item["status"], "</td>");
165
+ _html.push("<td data-val='", item["rss"], "'>", Util.trans_byte_size(item["rss"]), "</td>");
166
+ _html.push("<td data-val='", item["vms"], "'>", Util.trans_byte_size(item["vms"]), "</td>");
167
+ _html.push("<td title='", item["cmdline"], "'>", Util.sub_str(item["cmdline"], 50), "</td>");
168
+ _html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
169
+ _html.push("</tr>");
170
+ });
171
+ $("#process_div_body").html(_html.join(""));
172
+ $("#process_num").html("共 <span class='label label-info'>" + process_num + "</span> 进程");
173
+ Util.hide_tips();
174
+ });
175
+ },
176
+
177
+ handle_block_ip: function () {
178
+ if (!document.getElementById("block_ip_div_body")) {
179
+ Util.init_table_skeleton({
180
+ "element_id": "block_ip_div",
181
+ "caption": '<caption class="text-right" id="ip_num"></caption>',
182
+ "head_cols": [
183
+ {"name": "序号"},
184
+ {"name": "IP", "tooltip": "IP地址(Internet Protocol Address)是指互联网协议地址"},
185
+ {"name": "位置"},
186
+ ]
187
+ });
188
+ }
189
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
190
+ let _html = [], ip_num = j["num"];
191
+ $("#ip_num").html("共 <span class='label label-info'>" + j["num"] + "</span> 条");
192
+ j["data"].forEach(function (item) {
193
+ _html.push("<tr>");
194
+ _html.push("<td>", ip_num, "</td>");
195
+ _html.push("<td>", Util.pack_html_link(Status.ip_url(item["ip"]), item["ip"]), "</td>");
196
+ _html.push("<td>", Status.map_url(Status.convert_ip_address(item)), "</td>");
197
+ _html.push("</tr>");
198
+ ip_num--;
199
+ });
200
+ Util.render_table_html("block_ip_div_body", _html);
201
+ Util.hide_tips();
202
+ });
203
+ },
204
+
205
+ handle_login_log: function () {
206
+ if (!document.getElementById("login_log_div_body")) {
207
+ Util.init_table_skeleton({
208
+ "element_id": "login_log_div",
209
+ "caption": '<caption class="text-right" id="login_log_num"></caption>',
210
+ "head_cols": [
211
+ {"name": "序号"},
212
+ {"name": "用户"},
213
+ {"name": "终端"},
214
+ {"name": "登录IP"},
215
+ {"name": "IP地址"},
216
+ {"name": "时间"},
217
+ ]
218
+ });
219
+ }
220
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
221
+ let _html = [], login_num = 0;
222
+ j["data"].forEach(function (item) {
223
+ login_num++;
224
+ let cls = item["date"].indexOf('logged in') > -1 ? "danger" : "";
225
+ _html.push("<tr class='", cls, "'>");
226
+ _html.push("<td>", login_num, "</td>");
227
+ _html.push("<td>", item["user"], "</td>");
228
+ _html.push("<td>", item["terminal"], "</td>");
229
+ _html.push("<td>", Status.pack_ip_link(item["ip"]), "</td>");
230
+ _html.push("<td>", Status.map_url(Status.convert_ip_address(item)), "</td>");
231
+ _html.push("<td>", item["date"], "</td>");
232
+ _html.push("</tr>");
233
+ });
234
+ Util.render_table_html("login_log_div_body", _html);
235
+ $("#login_log_num").html("共 <span class='label label-info'>" + login_num + "</span> 条");
236
+ Util.hide_tips();
237
+ });
238
+ },
239
+
240
+ handle_database_table: function () {
241
+ if (!document.getElementById("database_table_div_body")) {
242
+ Util.init_table_skeleton({
243
+ "element_id": "database_table_div",
244
+ "caption": '<caption class="text-right" id="table_num"></caption>',
245
+ "head_cols": [
246
+ {"name": "序号", "table_sort": 1},
247
+ {"name": "表名", "table_sort": 1},
248
+ {"name": "表引擎", "table_sort": 1},
249
+ {"name": "行记录格式"},
250
+ {"name": "数据量", "table_sort": 1},
251
+ {"name": "数据大小", "table_sort": 1, "class": "info"},
252
+ {"name": "索引大小", "table_sort": 1},
253
+ {"name": "最后更新时间", "table_sort": 1},
254
+ {"name": "创建时间", "table_sort": 1},
255
+ {"name": "表注释"},
256
+ ]
257
+ });
258
+ }
259
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
260
+ let _html = [], table_num = 0;
261
+ j["data"].forEach(function (item) {
262
+ table_num++;
263
+ _html.push("<tr>");
264
+ _html.push("<td>", table_num, "</td>");
265
+ _html.push("<td>", item["TABLE_NAME"], "</td>");
266
+ _html.push("<td>", item["ENGINE"], "</td>");
267
+ _html.push("<td>", item["ROW_FORMAT"], "</td>");
268
+ _html.push("<td>", item["TABLE_ROWS"], "</td>");
269
+ _html.push("<td>", item["data_size"], "</td>");
270
+ _html.push("<td>", item["index_size"], "</td>");
271
+ _html.push("<td>", item["UPDATE_TIME"], "</td>");
272
+ _html.push("<td>", item["CREATE_TIME"], "</td>");
273
+ _html.push("<td>", item["TABLE_COMMENT"], "</td>");
274
+ _html.push("</tr>");
275
+ });
276
+ Util.render_table_html("database_table_div_body", _html);
277
+ $("#table_num").html("共 <span class='label label-info'>" + table_num + "</span> 条");
278
+ Util.hide_tips();
279
+ });
280
+ },
281
+
282
+ handle_request_headers: function () {
283
+ if (!document.getElementById("request_headers_div_body")) {
284
+ Util.init_table_skeleton({
285
+ "element_id": "request_headers_div",
286
+ "caption": 'none',
287
+ "head_cols": [
288
+ {"name": "键"},
289
+ {"name": "值"},
290
+ ]
291
+ });
292
+ }
293
+ $.get("/action?action=request_headers", {}, function (j) {
294
+ let _html = [];
295
+ for (let key in j) {
296
+ if (j.hasOwnProperty(key)) {
297
+ _html.push("<tr>");
298
+ _html.push("<td class='text-right'>", key, "</td>");
299
+ _html.push("<td class='text-left' style='word-break: break-all'>", j[key], "</td>");
300
+ _html.push("</tr>");
301
+ }
302
+ }
303
+ _html.push("<tr><td class='text-right'>浏览器代号</td><td class='text-left' style='word-break: break-all'>" + navigator.appCodeName + "</td></tr>");
304
+ _html.push("<tr><td class='text-right'>浏览器名称</td><td class='text-left' style='word-break: break-all'>" + navigator.appName + "</td></tr>");
305
+ _html.push("<tr><td class='text-right'>浏览器版本</td><td class='text-left' style='word-break: break-all'>" + navigator.appVersion + "</td></tr>");
306
+ _html.push("<tr><td class='text-right'>启用Cookies</td><td class='text-left' style='word-break: break-all'>" + navigator.cookieEnabled + "</td></tr>");
307
+ _html.push("<tr><td class='text-right'>硬件平台</td><td class='text-left' style='word-break: break-all'>" + navigator.platform + "</td></tr>");
308
+ if (navigator.systemLanguage) {
309
+ _html.push("<tr><td class='text-right'>系统语言</td><td class='text-left' style='word-break: break-all'>" + navigator.systemLanguage + "</td></tr>");
310
+ }
311
+ Util.render_table_html("request_headers_div_body", _html);
312
+ Util.hide_tips();
313
+ });
314
+ },
315
+
316
+ handle_environment: function () {
317
+ if (!document.getElementById("environment_div_body")) {
318
+ Util.init_table_skeleton({
319
+ "element_id": "environment_div",
320
+ "caption": '<caption class="text-right" id="environment_num"></caption>',
321
+ "head_cols": [
322
+ {"name": "键"},
323
+ {"name": "值"},
324
+ ]
325
+ });
326
+ }
327
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
328
+ let html = [], environment_num = 0;
329
+ j["data"].forEach(function (item) {
330
+ environment_num++;
331
+ html.push("<tr>");
332
+ html.push("<td class='text-right'>", item["key"], "</td>");
333
+ html.push("<td class='text-left' style='word-break: break-all'>", item["val"], "</td>");
334
+ html.push("</tr>");
335
+ });
336
+ Util.render_table_html("environment_div_body", html);
337
+ $("#environment_num").html("共 <span class='label label-info'>" + environment_num + "</span> 条");
338
+ Util.hide_tips();
339
+ });
340
+ },
341
+
342
+ handle_tool: function () {
343
+ let t_obj = $("#timestamp");
344
+ let t_val = t_obj.val();
345
+ if (Util.regexp_date_yyyymmdd(t_val) || Util.regexp_date_yyyy_mm_dd(t_val) || Util.regexp_date_yyyy_mm_dd_hh_mm_ss(t_val)) {
346
+ $("#date_format").val(Util.format_to_second(t_val));
347
+ } else if (/^[1-9]\d{3}$/.test(t_val)) { // 年份的字符串
348
+ $("#date_format").val(Util.format_to_second(t_val + "-01-01"));
349
+ } else if (!/^[\d]+$/.test(t_val)) {
350
+ let now = Util.now();
351
+ t_obj.val(now);
352
+ $("#date_format").val(Util.seconds_to_format(now));
353
+ }
354
+ $("#timestamp_convert").click(function () {
355
+ let t_obj = $("#timestamp");
356
+ let t_val = t_obj.val();
357
+ if (Util.regexp_date_yyyymmdd(t_val) || Util.regexp_date_yyyy_mm_dd(t_val) || Util.regexp_date_yyyy_mm_dd_hh_mm_ss(t_val)) {
358
+ $("#date_format").val(Util.format_to_second(t_val));
359
+ } else if (/^[1-9]\d{3}$/.test(t_val)) { // 年份的字符串
360
+ $("#date_format").val(Util.format_to_second(t_val + "-01-01"));
361
+ } else {
362
+ if (!/^[\d]+$/.test(t_val)) {
363
+ t_val = Util.now();
364
+ t_obj.val(t_val)
365
+ }
366
+ if (t_val.length >= 13) {
367
+ t_val = parseInt(t_val) / 1000;
368
+ }
369
+ $("#date_format").val(Util.seconds_to_format(t_val));
370
+ }
371
+ return false;
372
+ });
373
+ $("#ip_query").click(function () {
374
+ let ip = $("#ip").val().trim();
375
+ if (ip) {
376
+ let match_ip_data = Util.regexp_match_ip(ip);
377
+ if (!match_ip_data) {
378
+ match_ip_data = ip.match(/(([a-zA-Z0-9]+(-[a-zA-Z0-9]+)*\.)+[a-zA-Z]{2,})/);
379
+ }
380
+ if (match_ip_data) {
381
+ Util.show_loading();
382
+ $("#ip").prop('disabled', true);
383
+ $("#ip_query").attr("disabled", true);
384
+ ip = match_ip_data[0];
385
+ $("#ip").val(ip);
386
+ Util.post("/action", {action: "ip_query", ip: ip}, function (j) {
387
+ $("#ip").prop('disabled', false);
388
+ $("#ip_query").attr("disabled", false);
389
+ if (j["ip"]) {
390
+ $("#ip").val(j["ip"]);
391
+ let ip_address = Status.convert_ip_address(j);
392
+ if (ip_address.length > 0) {
393
+ let map_url = Status.map_url(ip_address, "<i class='glyphicon glyphicon-map-marker'></i>");
394
+ $("#ip_result").html(Util.pack_html_link(Status.ip_url(j["ip"]), "<b class='text-success'>" + ip_address + "</b>") + "&nbsp;&nbsp;" + map_url);
395
+ } else {
396
+ $("#ip_result").html(Util.pack_html_link(Status.ip_url(ip), "<b class='text-danger'>找不到结果!</b>"));
397
+ }
398
+ } else {
399
+ $("#ip_result").html(Util.pack_html_link(Status.ip_url(ip), "<b class='text-danger'>找不到结果!</b>"));
400
+ }
401
+ Util.hide_tips();
402
+ });
403
+ } else {
404
+ $("#ip_result").html("<b class='text-danger'>请输入正确的 IP 地址!</b>");
405
+ }
406
+ } else {
407
+ $("#ip_result").html("<b class='text-danger'>请输入要查询的 IP 地址!</b>");
408
+ }
409
+ });
410
+ $("#phone_query").click(function () {
411
+ Status.phone_query();
412
+ });
413
+ $("#md5_encrypt").click(function () {
414
+ let md5 = $("#md5").val();
415
+ if (md5) {
416
+ Util.show_loading();
417
+ $("#md5").prop('disabled', true);
418
+ $("#md5_encrypt").attr("disabled", true);
419
+ Util.post("/action", {action: "md5", md5: md5}, function (md5_result) {
420
+ $("#md5").prop('disabled', false);
421
+ $("#md5_encrypt").attr("disabled", false);
422
+ $("#md5_result").html("<b class='text-success'>" + md5_result + "</b>");
423
+ Util.hide_tips();
424
+ }, "text");
425
+ } else {
426
+ $("#md5_result").html("<b class='text-danger'>不能为空!</b>");
427
+ }
428
+ });
429
+ $("#base64_action").click(function () {
430
+ let base64 = $("#base64").val();
431
+ if (base64) {
432
+ if ($(this).text() === "编 码") {
433
+ $("#base64_result").html("<b class='text-success'>" + Util.base64_encode(base64) + "</b>");
434
+ } else {
435
+ $("#base64_result").html("<b class='text-success'>" + Util.base64_decode(base64) + "</b>");
436
+ }
437
+ } else {
438
+ $("#base64_result").html("<b class='text-danger'>不能为空!</b>");
439
+ }
440
+ });
441
+ $("#base64_ul li a").click(function() {
442
+ $("#base64_action").text($(this).text());
443
+ });
444
+ $("#unicode_convert").click(function () {
445
+ let unicode_str = $("#unicode").val();
446
+ if (unicode_str) {
447
+ try {
448
+ let obj = JSON.parse('{"data": "' + unicode_str + '"}');
449
+ $("#unicode_result").html("<b class='text-success'>" + obj.data + "</b>");
450
+ } catch (error) {
451
+ $("#unicode_result").html("<b class='text-danger'>" + error.message + "</b>");
452
+ }
453
+ } else {
454
+ $("#unicode_result").html("<b class='text-danger'>不能为空!</b>");
455
+ }
456
+ });
457
+ $("#segment_parse").click(function () {
458
+ let segment_str = $("#segment").val();
459
+ if (segment_str) {
460
+ try {
461
+ let segmenter = new Intl.Segmenter("zh-CN", {granularity: "word"});
462
+ let segments = segmenter.segment(segment_str);
463
+ let segment_html = [];
464
+ for (let {segment, index, isWordLike} of segments) {
465
+ if (isWordLike) {
466
+ segment_html.push("<span class='label label-info'>", segment, "</span>&nbsp;");
467
+ }
468
+ }
469
+ $("#segment_result").html(segment_html.join(""));
470
+ } catch (error) {
471
+ $("#segment_result").html("<b class='text-danger'>" + error.message + "</b>");
472
+ }
473
+ } else {
474
+ $("#segment_result").html("<b class='text-danger'>不能为空!</b>");
475
+ }
476
+ });
477
+ $("#color_query").click(function () {
478
+ let width = 300;
479
+ let parent_width = $(this).parent().parent().width();
480
+ if (width < parent_width) {
481
+ let margin_left = Math.round((parent_width - width) / 2);
482
+ $("#color_result").css('width', width + "px");
483
+ $("#color_result").css('margin-left', margin_left + "px");
484
+ } else {
485
+ $("#color_result").css('width', parent_width + "px");
486
+ $("#color_result").css('margin-left', "0px");
487
+ }
488
+ let c_obj = $("#color");
489
+ let color = c_obj.val();
490
+ if (!color.startsWith("#")) {
491
+ color = "#" + color;
492
+ }
493
+ $("#color_result").css('background-color', color);
494
+ if (color.startsWith("#")) {
495
+ c_obj.val(color);
496
+ }
497
+ });
498
+ Util.hide_tips();
499
+ },
500
+
501
+ handle_site_map: function () {
502
+ let _html = [];
503
+ $('.side-menu li a').each(function () {
504
+ let url = $(this).attr("href");
505
+ if (url) {
506
+ let title = $(this).text();
507
+ if (title && title.length > 0) {
508
+ _html.push('<a href="', url, '" class="btn btn-default">', title, '</a>');
509
+ }
510
+ }
511
+ });
512
+ $("#site_map_zone").html(_html.join(""));
513
+ Util.hide_tips();
514
+ },
515
+
516
+ convert_ip_address: function (data) {
517
+ let country = data["country"] ? data["country"] : "";
518
+ let province = data["province"] ? data["province"] : "";
519
+ let city = data["city"] ? data["city"] : "";
520
+ let district = data["district"] ? data["district"] : "";
521
+ let isp = data["isp"] ? (" - " + data["isp"]) : "";
522
+ if (country === province || province === city) {
523
+ province = "";
524
+ }
525
+ if (country === isp) {
526
+ isp = "";
527
+ }
528
+ let ip_address = country + province + city + district + " " + isp;
529
+ return ip_address.trim();
530
+ },
531
+
532
+ phone_query: function() {
533
+ let phone = $("#phone").val().trim();
534
+ if (phone && Util.is_phone(phone)) {
535
+ Util.show_loading();
536
+ $("#phone").prop('disabled', true);
537
+ $("#phone_query").attr("disabled", true);
538
+ Util.post("/action", {action: "phone_query", phone: phone}, function (j) {
539
+ $("#phone").prop('disabled', false);
540
+ $("#phone_query").attr("disabled", false);
541
+ if (j["belong"]) {
542
+ let phone_url = Util.pack_html_link("https://www.ip138.com/mobile.asp?mobile=" + phone + "&action=mobile", "<i class='glyphicon glyphicon-link'></i> ");
543
+ $("#phone_result").html(Status.convert_phone(j) + "&nbsp;&nbsp;" + phone_url);
544
+ $("#phone_result a").addClass("text-success");
545
+ } else {
546
+ $("#phone_result").html(Util.pack_html_link("https://www.ip138.com/mobile.asp?mobile=" + phone + "&action=mobile", "<b class='text-danger'>找不到结果!</b>"));
547
+ }
548
+ Util.hide_tips();
549
+ });
550
+ } else {
551
+ $("#phone_result").html("<b class='text-danger'>不是一个合法的手机号!</b>");
552
+ }
553
+ },
554
+
555
+ convert_phone: function (data) {
556
+ let ret = [];
557
+ if (data["belong"]) {
558
+ ret.push("<b class='text-muted'>归属地</b>: <b class='text-success'>" + Status.map_url(data["belong"]) + "</b>");
559
+ }
560
+ if (data["card_type"]) {
561
+ ret.push("<b class='text-muted'>卡类型</b>: <b class='text-success'>" + data["card_type"] + "</b>");
562
+ }
563
+ return ret.join(", ");
564
+ },
565
+
566
+ map_url: function (location, location_name = "") {
567
+ location_name = location_name === "" ? location : location_name;
568
+ let location_arr = location.split(' ');
569
+ if (location.indexOf("中国") > -1 || location.indexOf("省") > -1 || location.indexOf("市") > -1) {
570
+ let url = Util.map_url(location_arr[0]);
571
+ return url.replace('>' + location_arr[0] + '</a>', '>' + location_name + '</a>');
572
+ }
573
+ return Util.google_map_url(location_arr[0], location_name);
574
+ }
575
+
576
+ };
577
+
578
+ let ip_obj = $('#ip_modal');
579
+ // 此事件在模态框已经显示出来触发
580
+ ip_obj.on('show.bs.modal', function (e) {
581
+ $("#ip_daily_search").click(function() {
582
+ Util.show_loading();
583
+ let payload = {
584
+ active_div: "ip_daily_search",
585
+ ip: $("#search_ip").val(),
586
+ location: $("#search_location").val(),
587
+ referer: $("#search_referer").val()
588
+ };
589
+ Util.post(location.pathname, payload, function (j) {
590
+ Status.render_ip_daily(j["ip_daily_data"]);
591
+ Util.hide_tips();
592
+ });
593
+ $('#ip_modal').modal('hide');
594
+ });
595
+ });
596
+ // 此事件在模态框被隐藏(并且同时在 CSS 过渡效果完成)之后被触发
597
+ ip_obj.on('hidden.bs.modal', function () {
598
+ $("#search_ip").val("");
599
+ $("#search_location").val("");
600
+ $("#search_referer").val("");
601
+ });
602
+
603
+ let request_arguments = Util.request_arguments();
604
+ if (request_arguments["tab"]) {
605
+ localStorage[Status.tab_token] = request_arguments["tab"];
606
+ if (request_arguments["tab"] === "tool" && request_arguments["phone"]) {
607
+ $("#phone").val(request_arguments["phone"]);
608
+ setTimeout(function () {
609
+ Status.phone_query();
610
+ Enterprise.fetch_enterprise_detail(j["unified_code"]);
611
+ }, 1234);
612
+ }
613
+ } else {
614
+ localStorage[Status.tab_token] = "status";
615
+ }
616
+ Util.tab_switch(Status.tab_token, Status.fetch_data);
617
+ Status.fetch_data();
618
+
619
+ });
package/util.js CHANGED
@@ -1012,7 +1012,11 @@ const Util = {
1012
1012
  code_list = code_list.length > 0 ? code_list.join("-") : "all";
1013
1013
  Util.post("/action", {action: "classify_num", code_list: code_list}, function (j) {
1014
1014
  if (j["data"]) {
1015
+ let classify_val = $("#" + classify_id).val();
1015
1016
  Util.render_classify_html(classify_id, j["data"], callback_func);
1017
+ if (classify_val && classify_val !== "0") {
1018
+ $("#" + classify_id).val(classify_val);
1019
+ }
1016
1020
  }
1017
1021
  });
1018
1022
  },