sbd-npm 1.4.53 → 1.4.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 (3) hide show
  1. package/package.json +1 -1
  2. package/status.js +36 -13
  3. package/util.js +17 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.53",
3
+ "version": "1.4.55",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/status.js CHANGED
@@ -154,10 +154,33 @@ $(function () {
154
154
  }
155
155
  html.push("<td title='", item["referer"], "'>", Util.pack_html_link("http://" + item["referer"], Util.substring(item["referer"], 50)), "</td>");
156
156
  html.push("<td>", item["visit"], "</td>");
157
- html.push("<td>", Util.seconds_to_format(item["time"]), "</td>");
157
+ if (item["is_block"] === 1) {
158
+ html.push("<td>", Util.seconds_to_format(item["time"]), "</td>");
159
+ } else {
160
+ let match_ip_data = Util.regexp_match_ip(item["ip"]);
161
+ html.push("<td><a href='#' class='block_ip' data-val='", ((match_ip_data && match_ip_data[0]) ? match_ip_data[0] : item["ip"]), "'>", Util.seconds_to_format(item["time"]), "</a></td>");
162
+ }
158
163
  html.push("</tr>");
159
164
  });
160
165
  Util.render_table_html("ip_daily_data", html);
166
+ $("#ip_daily_data .block_ip").each(function() {
167
+ $(this).click(function() {
168
+ let ip = $(this).attr("data-val");
169
+ if (confirm("是否确定要屏蔽IP “ " + ip + " ” ?")) {
170
+ Util.show_loading();
171
+ Util.post(location.pathname, {"active_div": "block_ip", "ip": ip}, function (j) {
172
+ Util.hide_tips();
173
+ if (j["code"] === 1) {
174
+ Util.show_tips("IP “ " + ip + " ” 已加到屏蔽队列中", 4567, "alert-success");
175
+ } else if (j["code"] === 2) {
176
+ Util.show_tips("IP “ " + ip + " ” 已在屏蔽队列中", 4567, "alert-success");
177
+ } else {
178
+ Util.show_tips("屏蔽IP “ " + ip + " ” 失败", 4567, "alert-danger");
179
+ }
180
+ });
181
+ }
182
+ });
183
+ });
161
184
  },
162
185
 
163
186
  pack_ip_link: function(ip) {
@@ -237,9 +260,9 @@ $(function () {
237
260
  ]
238
261
  });
239
262
  }
240
- Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
263
+ Util.post(location.pathname, {active_div: "get_block_ip"}, function (j) {
241
264
  let html = [], ip_num = j["num"];
242
- $("#ip_num").html("共 <span class='label label-info'>" + j["num"] + "</span> 条(" + j["total_ip_num"] + ")&nbsp;");
265
+ $("#ip_num").html("共 <span class='label label-info'>" + ip_num + "</span> 条(" + j["total_ip_num"] + ")&nbsp;");
243
266
  j["data"].forEach(function (item) {
244
267
  html.push("<tr>");
245
268
  html.push("<td>", ip_num, "</td>");
@@ -513,7 +536,7 @@ $(function () {
513
536
  Util.show_loading();
514
537
  $("#task_tips").html("");
515
538
  Util.post(location.pathname, {active_div: "task_add", "task_content": task_content, machine_id: $("#task_machines").val()}, function (j) {
516
- if (j["code"] && j["code"] === 1) {
539
+ if (j["code"] === 1) {
517
540
  Status.task_status = 1;
518
541
  $("#task_add").html('任务处理中...').removeClass("btn-default").addClass("btn-warning");
519
542
  if (!document.getElementById("task_result")) {
@@ -531,10 +554,10 @@ $(function () {
531
554
  }
532
555
  } else {
533
556
  Status.task_status = 0;
534
- if (j["code"] && j["code"] === 2) {
557
+ if (j["code"] === 2) {
535
558
  let do_content = j["do_content"] ? ("(" + j["do_content"] + ")") : "";
536
559
  $("#task_tips").html("<b class='text-danger'>已添加新任务" + do_content + "在处理中!</b>");
537
- } else if (j["code"] && j["code"] === 3) {
560
+ } else if (j["code"] === 3) {
538
561
  let doing_content = j["doing_content"] ? ("(" + j["doing_content"] + ")") : "";
539
562
  $("#task_tips").html("<b class='text-danger'>有任务" + doing_content + "在执行中!</b>");
540
563
  } else {
@@ -875,11 +898,11 @@ $(function () {
875
898
  $("#machine_action_add").attr("disabled", true);
876
899
  Util.post(location.pathname, {active_div: "machine_action_add", "machine_id": machine_id, "content": action_content, action_type: action_type}, function (j) {
877
900
  $("#machine_action_add").attr("disabled", false);
878
- if (j["code"] && j["code"] === 1) {
901
+ if (j["code"] === 1) {
879
902
  $("#machine_action_tips").html("<b class='text-success'>任务`" + action_content + "`添加成功!</b>");
880
- } else if (j["code"] && j["code"] === 2) {
903
+ } else if (j["code"] === 2) {
881
904
  $("#machine_action_tips").html("<b class='text-danger'>Machine 不存在!</b>");
882
- } else if (j["code"] && j["code"] === 3) {
905
+ } else if (j["code"] === 3) {
883
906
  $("#machine_action_tips").html("<b class='text-danger'>任务内容异常!</b>");
884
907
  } else {
885
908
  $("#machine_action_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
@@ -954,9 +977,9 @@ $(function () {
954
977
  $("#machine_cookie_add").attr("disabled", true);
955
978
  Util.post(location.pathname, {active_div: "machine_cookie_add", "machine_id": machine_id, "cookie": machine_cookie}, function (j) {
956
979
  $("#machine_cookie_add").attr("disabled", false);
957
- if (j["code"] && j["code"] === 1) {
980
+ if (j["code"] === 1) {
958
981
  $("#machine_cookie_tips").html("<b class='text-success'>Cookie添加成功!</b>");
959
- } else if (j["code"] && j["code"] === 2) {
982
+ } else if (j["code"] === 2) {
960
983
  $("#machine_cookie_tips").html("<b class='text-danger'>Machine 不存在!</b>");
961
984
  } else {
962
985
  $("#machine_cookie_tips").html("<b class='text-danger'>Cookie异常!</b>");
@@ -1033,11 +1056,11 @@ $(function () {
1033
1056
  let chinese = $("#word_chinese").val();
1034
1057
  if (chinese) {
1035
1058
  Util.post(location.pathname, {"active_div": "word_modify", "word": word, "chinese": chinese}, function (j) {
1036
- if (j["code"] && j["code"] === 1) {
1059
+ if (j["code"] === 1) {
1037
1060
  $("#word_chinese").val(j["chinese"]);
1038
1061
  $(tr_obj).children('td').eq(2).html(j["chinese"]);
1039
1062
  $("#word_tips").html("<b class='text-success'>修改成功!</b>");
1040
- } else if (j["code"] && j["code"] === 2) {
1063
+ } else if (j["code"] === 2) {
1041
1064
  $("#word_tips").html("<b class='text-danger'>中文有误!</b>");
1042
1065
  } else {
1043
1066
  $("#word_tips").html("<b class='text-danger'>修改失败!</b>");
package/util.js CHANGED
@@ -77,18 +77,14 @@ const Util = {
77
77
  return false;
78
78
  });
79
79
 
80
- $("#random_walk").click(function () {
81
- let url_arr = [];
82
- $('.side-menu li a').each(function () {
83
- let url = $(this).attr("href");
84
- if (url) {
85
- url_arr.push(url);
86
- }
87
- });
88
- if (url_arr.length > 0) {
89
- window.open(Util.array_rand(url_arr), "_blank");
80
+ document.getElementById("random_walk").addEventListener("click", () => {
81
+ let nodeObject = document.querySelectorAll(".side-menu li a");
82
+ let url_array = Array.from(nodeObject).map(a => a.getAttribute("href")).filter(Boolean);
83
+ if (url_array.length > 0) {
84
+ window.open(Util.array_rand(url_array), "_blank");
90
85
  }
91
86
  });
87
+
92
88
  $("#save_page_content").click(function() {
93
89
  let element;
94
90
  if (document.getElementsByClassName("save_page_div").length > 0) {
@@ -115,12 +111,12 @@ const Util = {
115
111
  $("#search-tips").css("display", "none");
116
112
  }
117
113
  });
118
-
119
- $(document).click(function (event) {
120
- let e_obj = Util.eventTarget(event);
121
- let e_id = $(e_obj).attr("id");
122
- if (e_id !== "stock") {
123
- $("#search-tips").css("display", "none");
114
+ document.addEventListener("click", function(event) {
115
+ if (event.target.id !== "stock") {
116
+ let st_object = document.getElementById("search-tips");
117
+ if (st_object) {
118
+ st_object.style.display = "none";
119
+ }
124
120
  }
125
121
  });
126
122
 
@@ -1716,9 +1712,11 @@ const Util = {
1716
1712
  let word = $(tr_obj).children('td').eq(1).text();
1717
1713
  let chinese = $(tr_obj).children('td').eq(2).text();
1718
1714
  if (confirm("是否确定要删除“ " + word + "「" + chinese + "」 ” ?")) {
1715
+ Util.show_loading();
1719
1716
  Util.post(location.pathname, {"active_div": "word_del", "word": word}, function () {
1720
1717
  $(tr_obj).remove();
1721
- Util.show_tips("删除 “ " + word + " ” 成功", 3456, "alert-success");
1718
+ Util.hide_tips();
1719
+ Util.show_tips("删除 “ " + word + " ” 成功", 4567, "alert-success");
1722
1720
  });
1723
1721
  }
1724
1722
  });
@@ -3165,8 +3163,8 @@ const Util = {
3165
3163
  get_page_title: function () {
3166
3164
  let current_url = location.pathname;
3167
3165
  if (current_url) {
3168
- let arrayObject = document.querySelectorAll('.side-menu li a');
3169
- let match = Array.from(arrayObject).find(a => a.getAttribute("href") === current_url);
3166
+ let nodeObject = document.querySelectorAll('.side-menu li a');
3167
+ let match = Array.from(nodeObject).find(a => a.getAttribute("href") === current_url);
3170
3168
  return match ? match.textContent : "";
3171
3169
  }
3172
3170
  return "";