sbd-npm 1.3.54 → 1.3.55

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 (2) hide show
  1. package/package.json +1 -1
  2. package/status.js +613 -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.55",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js ADDED
@@ -0,0 +1,613 @@
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
+ Util.post("/action", {action: "md5", md5: md5}, function (md5_result) {
419
+ $("#md5").prop('disabled', false);
420
+ $("#md5_result").html("<b class='text-success'>" + md5_result + "</b>");
421
+ Util.hide_tips();
422
+ }, "text");
423
+ } else {
424
+ $("#md5_result").html("<b class='text-danger'>不能为空!</b>");
425
+ }
426
+ });
427
+ $("#base64_action").click(function () {
428
+ let base64 = $("#base64").val();
429
+ if (base64) {
430
+ if ($(this).text() === "编 码") {
431
+ $("#base64_result").html("<b class='text-success'>" + Util.base64_encode(base64) + "</b>");
432
+ } else {
433
+ $("#base64_result").html("<b class='text-success'>" + Util.base64_decode(base64) + "</b>");
434
+ }
435
+ } else {
436
+ $("#base64_result").html("<b class='text-danger'>不能为空!</b>");
437
+ }
438
+ });
439
+ $("#base64_ul li a").click(function() {
440
+ $("#base64_action").text($(this).text());
441
+ });
442
+ $("#unicode_convert").click(function () {
443
+ let unicode_str = $("#unicode").val();
444
+ if (unicode_str) {
445
+ try {
446
+ let obj = JSON.parse('{"data": "' + unicode_str + '"}');
447
+ $("#unicode_result").html("<b class='text-success'>" + obj.data + "</b>");
448
+ } catch (error) {
449
+ $("#unicode_result").html("<b class='text-danger'>" + error.message + "</b>");
450
+ }
451
+ } else {
452
+ $("#unicode_result").html("<b class='text-danger'>不能为空!</b>");
453
+ }
454
+ });
455
+ $("#segment_parse").click(function () {
456
+ let segment_str = $("#segment").val();
457
+ if (segment_str) {
458
+ try {
459
+ let segmenter = new Intl.Segmenter("zh-CN", {granularity: "word"});
460
+ let segments = segmenter.segment(segment_str);
461
+ let segment_html = [];
462
+ for (let {segment, index, isWordLike} of segments) {
463
+ if (isWordLike) {
464
+ segment_html.push("<span class='label label-info'>", segment, "</span>&nbsp;");
465
+ }
466
+ }
467
+ $("#segment_result").html(segment_html.join(""));
468
+ } catch (error) {
469
+ $("#segment_result").html("<b class='text-danger'>" + error.message + "</b>");
470
+ }
471
+ } else {
472
+ $("#segment_result").html("<b class='text-danger'>不能为空!</b>");
473
+ }
474
+ });
475
+ $("#color_query").click(function () {
476
+ let width = 300;
477
+ let parent_width = $(this).parent().parent().width();
478
+ if (width < parent_width) {
479
+ let margin_left = Math.round((parent_width - width) / 2);
480
+ $("#color_result").css('width', width + "px");
481
+ $("#color_result").css('margin-left', margin_left + "px");
482
+ } else {
483
+ $("#color_result").css('width', parent_width + "px");
484
+ $("#color_result").css('margin-left', "0px");
485
+ }
486
+ let c_obj = $("#color");
487
+ let color = c_obj.val();
488
+ if (!color.startsWith("#")) {
489
+ color = "#" + color;
490
+ }
491
+ $("#color_result").css('background-color', color);
492
+ if (color.startsWith("#")) {
493
+ c_obj.val(color);
494
+ }
495
+ });
496
+ Util.hide_tips();
497
+ },
498
+
499
+ handle_site_map: function () {
500
+ let _html = [];
501
+ $('.side-menu li a').each(function () {
502
+ let url = $(this).attr("href");
503
+ if (url) {
504
+ let title = $(this).text();
505
+ if (title && title.length > 0) {
506
+ _html.push('<a href="', url, '" class="btn btn-default">', title, '</a>');
507
+ }
508
+ }
509
+ });
510
+ $("#site_map_zone").html(_html.join(""));
511
+ Util.hide_tips();
512
+ },
513
+
514
+ convert_ip_address: function (data) {
515
+ let country = data["country"] ? data["country"] : "";
516
+ let province = data["province"] ? data["province"] : "";
517
+ let city = data["city"] ? data["city"] : "";
518
+ let district = data["district"] ? data["district"] : "";
519
+ let isp = data["isp"] ? (" - " + data["isp"]) : "";
520
+ if (country === province || province === city) {
521
+ province = "";
522
+ }
523
+ if (country === isp) {
524
+ isp = "";
525
+ }
526
+ let ip_address = country + province + city + district + " " + isp;
527
+ return ip_address.trim();
528
+ },
529
+
530
+ phone_query: function() {
531
+ let phone = $("#phone").val().trim();
532
+ if (phone && Util.is_phone(phone)) {
533
+ Util.show_loading();
534
+ $("#phone").prop('disabled', true);
535
+ $("#phone_query").attr("disabled", true);
536
+ Util.post("/action", {action: "phone_query", phone: phone}, function (j) {
537
+ $("#phone").prop('disabled', false);
538
+ $("#phone_query").attr("disabled", false);
539
+ if (j["belong"]) {
540
+ let phone_url = Util.pack_html_link("https://www.ip138.com/mobile.asp?mobile=" + phone + "&action=mobile", "<i class='glyphicon glyphicon-link'></i> ");
541
+ $("#phone_result").html(Status.convert_phone(j) + "&nbsp;&nbsp;" + phone_url);
542
+ $("#phone_result a").addClass("text-success");
543
+ } else {
544
+ $("#phone_result").html(Util.pack_html_link("https://www.ip138.com/mobile.asp?mobile=" + phone + "&action=mobile", "<b class='text-danger'>找不到结果!</b>"));
545
+ }
546
+ Util.hide_tips();
547
+ });
548
+ } else {
549
+ $("#phone_result").html("<b class='text-danger'>不是一个合法的手机号!</b>");
550
+ }
551
+ },
552
+
553
+ convert_phone: function (data) {
554
+ let ret = [];
555
+ if (data["belong"]) {
556
+ ret.push("<b class='text-muted'>归属地</b>: <b class='text-success'>" + Status.map_url(data["belong"]) + "</b>");
557
+ }
558
+ if (data["card_type"]) {
559
+ ret.push("<b class='text-muted'>卡类型</b>: <b class='text-success'>" + data["card_type"] + "</b>");
560
+ }
561
+ return ret.join(", ");
562
+ },
563
+
564
+ map_url: function (location, location_name = "") {
565
+ location_name = location_name === "" ? location : location_name;
566
+ let location_arr = location.split(' ');
567
+ if (location.indexOf("中国") > -1 || location.indexOf("省") > -1 || location.indexOf("市") > -1) {
568
+ let url = Util.map_url(location_arr[0]);
569
+ return url.replace('>' + location_arr[0] + '</a>', '>' + location_name + '</a>');
570
+ }
571
+ return Util.google_map_url(location_arr[0], location_name);
572
+ }
573
+
574
+ };
575
+
576
+ let ip_obj = $('#ip_modal');
577
+ // 此事件在模态框已经显示出来触发
578
+ ip_obj.on('show.bs.modal', function (e) {
579
+ $("#ip_daily_search").click(function() {
580
+ Util.show_loading();
581
+ let data = {active_div: "ip_daily_search", ip: $("#search_ip").val(), location: $("#search_location").val(), referer: $("#search_referer").val()};
582
+ Util.post(location.pathname, data, function (j) {
583
+ Status.render_ip_daily(j["ip_daily_data"]);
584
+ Util.hide_tips();
585
+ });
586
+ $('#ip_modal').modal('hide');
587
+ });
588
+ });
589
+ // 此事件在模态框被隐藏(并且同时在 CSS 过渡效果完成)之后被触发
590
+ ip_obj.on('hidden.bs.modal', function () {
591
+ $("#search_ip").val("");
592
+ $("#search_location").val("");
593
+ $("#search_referer").val("");
594
+ Util.hide_tips();
595
+ });
596
+
597
+ let request_arguments = Util.request_arguments();
598
+ if (request_arguments["tab"]) {
599
+ localStorage[Status.tab_token] = request_arguments["tab"];
600
+ if (request_arguments["tab"] === "tool" && request_arguments["phone"]) {
601
+ $("#phone").val(request_arguments["phone"]);
602
+ setTimeout(function () {
603
+ Status.phone_query();
604
+ Enterprise.fetch_enterprise_detail(j["unified_code"]);
605
+ }, 1234);
606
+ }
607
+ } else {
608
+ localStorage[Status.tab_token] = "status";
609
+ }
610
+ Util.tab_switch(Status.tab_token, Status.fetch_data);
611
+ Status.fetch_data();
612
+
613
+ });