sbd-npm 1.4.38 → 1.4.39

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 +55 -45
  3. package/util.js +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.38",
3
+ "version": "1.4.39",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/status.js CHANGED
@@ -471,11 +471,21 @@ $(function () {
471
471
  },
472
472
 
473
473
  handle_task: function () {
474
+ let is_init = 0;
474
475
  if (!document.getElementById("task_content")) {
476
+ is_init = 1;
475
477
  let ht_html = [];
476
478
  ht_html.push('<div class="page-header" style="margin-top: 15px; text-align: center;">');
477
479
  ht_html.push('<div class="form-inline">');
478
480
  ht_html.push('<div class="form-group">');
481
+ ht_html.push('<select id="task_machines" class="form-control">');
482
+ ht_html.push('<option value="">Loading...</option>');
483
+ ht_html.push('</select>');
484
+ ht_html.push('</div>');
485
+ if (!Util.is_mobile()) {
486
+ ht_html.push('&nbsp;');
487
+ }
488
+ ht_html.push('<div class="form-group">');
479
489
  ht_html.push('<input data-toggle="tooltip" data-placement="top" title="要执行的任务内容" placeholder="要执行的任务内容" value="" type="text" class="form-control" id="task_content" autocomplete="off" />');
480
490
  ht_html.push('</div>&nbsp;');
481
491
  ht_html.push('<button class="btn btn-default" id="task_add">添加任务</button>');
@@ -509,7 +519,7 @@ $(function () {
509
519
  $("#task_result").val(task_result);
510
520
  if ($("#is_refresh_task").prop("checked")) {
511
521
  Status.task_timer_id = setTimeout(function () {
512
- Status.fetch_task_data();
522
+ Status.fetch_task_data(0);
513
523
  }, 5678);
514
524
  }
515
525
  } else {
@@ -535,16 +545,23 @@ $(function () {
535
545
  if (Status.task_status > 0) {
536
546
  clearTimeout(Status.task_timer_id);
537
547
  if ($("#is_refresh_task").prop("checked")) {
538
- Status.fetch_task_data();
548
+ Status.fetch_task_data(0);
539
549
  }
540
550
  }
541
551
  });
542
552
  }
543
- Status.fetch_task_data();
553
+ Status.fetch_task_data(is_init);
544
554
  },
545
555
 
546
- fetch_task_data: function() {
547
- Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
556
+ fetch_task_data: function(is_init = 0) {
557
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init}, function (j) {
558
+ if (j["machines"]) {
559
+ Status.pack_machine_component("task_machines", j["machines"]);
560
+ } else {
561
+ if (is_init === 1) {
562
+ $('#task_machines').html('<option value="">暂无Machine</option>');
563
+ }
564
+ }
548
565
  if (j["code"] && j["code"] > 1 && j["content"]) {
549
566
  let ta_obj = $("#task_add");
550
567
  let tc_obj = $("#task_content");
@@ -563,7 +580,7 @@ $(function () {
563
580
  tc_obj.prop('disabled', true);
564
581
  if ($("#is_refresh_task").prop("checked")) {
565
582
  Status.task_timer_id = setTimeout(function () {
566
- Status.fetch_task_data();
583
+ Status.fetch_task_data(0);
567
584
  }, 3456);
568
585
  }
569
586
  }
@@ -632,12 +649,7 @@ $(function () {
632
649
  }
633
650
  Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, machine_id: $("#machines").val()}, function (j) {
634
651
  if (j["machines"]) {
635
- let select_html = [];
636
- select_html.push("<option value=''>共 ", j["machines"].length, " 个Machine</option>");
637
- j["machines"].forEach(function (w) {
638
- select_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
639
- });
640
- $("#machines").html(select_html.join(""));
652
+ Status.pack_machine_component("machines", j["machines"]);
641
653
  if (j["machines"].length > 0) {
642
654
  $("#machines").change(function() {
643
655
  let machine_id = $(this).val();
@@ -670,7 +682,7 @@ $(function () {
670
682
  let html = [], process_num = 0;
671
683
  j["process"].forEach(function (item) {
672
684
  process_num++;
673
- if (item["cmdline"].includes("zotonic")) {
685
+ if (item["cmdline"].includes("zotonic") || item["cmdline"].includes("xmrig")) {
674
686
  html.push("<tr class='info'>");
675
687
  } else {
676
688
  html.push("<tr>");
@@ -678,7 +690,7 @@ $(function () {
678
690
  html.push("<td>", item["pid"], "</td>");
679
691
  html.push("<td>", item["status"], "</td>");
680
692
  let cmdline = Util.substring(item["cmdline"], 100);
681
- if (item["cmdline"].includes("zotonic")) {
693
+ if (item["cmdline"].includes("zotonic") || item["cmdline"].includes("xmrig")) {
682
694
  html.push("<td>", Util.pack_html_link("/xmr", cmdline), "</td>");
683
695
  } else {
684
696
  html.push("<td title='", item["cmdline"], "'>", cmdline, "</td>");
@@ -700,22 +712,23 @@ $(function () {
700
712
  let is_init = 0;
701
713
  if (!document.getElementById("word_process_div")) {
702
714
  is_init = 1;
703
- let word_html = [];
704
- if (Util.is_mobile()) {
705
- word_html.push('<form class="form-inline" style="margin-bottom: 5px;">');
715
+ let html = [];
716
+ let is_mobile = Util.is_mobile();
717
+ if (is_mobile) {
718
+ html.push('<form class="form-inline" style="margin-bottom: 5px;">');
706
719
  } else {
707
- word_html.push('<form class="form-inline">');
720
+ html.push('<form class="form-inline">');
708
721
  }
709
- word_html.push('<div class="form-group">');
710
- word_html.push('<select id="word_day_num" class="form-control"><option value="">Loading...</option></select>');
711
- word_html.push('</div>');
712
- word_html.push('&nbsp;<a href="#" data-toggle="modal" data-target=".word_modal" id="word_random" class="btn btn-warning">RANDOM</a>');
713
- word_html.push('</form>');
714
- word_html.push('<div id="word_process_div"></div>');
715
- $("#word_div").html(word_html.join(""));
722
+ html.push('<div class="form-group">');
723
+ html.push('<select id="word_day_num" class="form-control"><option value="">Loading...</option></select>');
724
+ html.push('</div>');
725
+ html.push('&nbsp;<a href="#" data-toggle="modal" data-target=".word_modal" id="word_random" class="btn btn-warning">RANDOM</a>');
726
+ html.push('</form>');
727
+ html.push('<div id="word_process_div"></div>');
728
+ $("#word_div").html(html.join(""));
716
729
  Util.init_table_skeleton({
717
730
  "element_id": "word_process_div",
718
- "caption": '<caption class="text-right" id="word_num"></caption>',
731
+ "caption": '<caption class="' + (is_mobile ? "text-left" : "text-right") + '" id="word_num"></caption>',
719
732
  "head_cols": [
720
733
  {"name": "序号", "table_sort": 1},
721
734
  {"name": "单词", "table_sort": 1},
@@ -771,15 +784,10 @@ $(function () {
771
784
  }
772
785
  Util.post(location.pathname, {active_div: "client_action", action_type: action_type}, function (j) {
773
786
  if (j["machines"]) {
774
- let machine_html = [];
775
- j["machines"].forEach(function (w) {
776
- machine_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
777
- });
778
- let caw_obj = $("#client_action_machine");
779
- caw_obj.html(machine_html.join(""));
787
+ Status.pack_machine_component("client_action_machine", j["machines"]);
780
788
  let machine = $("#machines").val();
781
789
  if (machine) {
782
- caw_obj.find("option[value='" + machine + "']").attr("selected", true);
790
+ $("#client_action_machine").find("option[value='" + machine + "']").attr("selected", true);
783
791
  }
784
792
  }
785
793
  if (j["actions"]) {
@@ -865,15 +873,10 @@ $(function () {
865
873
  Util.show_loading();
866
874
  Util.post(location.pathname, {active_div: "client_action", action_type: 2}, function (j) {
867
875
  if (j["machines"]) {
868
- let machine_html = [];
869
- j["machines"].forEach(function (w) {
870
- machine_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
871
- });
872
- let caw_obj = $("#client_cookie_machine");
873
- caw_obj.html(machine_html.join(""));
876
+ Status.pack_machine_component("client_cookie_machine", j["machines"]);
874
877
  let machine = $("#machines").val();
875
878
  if (machine) {
876
- caw_obj.find("option[value='" + machine + "']").attr("selected", true);
879
+ $("#client_cookie_machine").find("option[value='" + machine + "']").attr("selected", true);
877
880
  }
878
881
  }
879
882
  Util.hide_tips();
@@ -898,10 +901,8 @@ $(function () {
898
901
  $("#client_cookie_tips").html("<b class='text-success'>Cookie添加成功!</b>");
899
902
  } else if (j["code"] && j["code"] === 2) {
900
903
  $("#client_cookie_tips").html("<b class='text-danger'>Machine 不存在!</b>");
901
- } else if (j["code"] && j["code"] === 3) {
902
- $("#client_cookie_tips").html("<b class='text-danger'>Cookie异常!</b>");
903
904
  } else {
904
- $("#client_cookie_tips").html("<b class='text-danger'>Cookie不能为空!</b>");
905
+ $("#client_cookie_tips").html("<b class='text-danger'>Cookie异常!</b>");
905
906
  }
906
907
  Util.hide_tips();
907
908
  });
@@ -915,6 +916,15 @@ $(function () {
915
916
  });
916
917
  },
917
918
 
919
+ pack_machine_component: function(element_id, machines) {
920
+ let html = [];
921
+ html.push("<option value=''>共 ", machines.length, " 个Machine</option>");
922
+ machines.forEach(function (m) {
923
+ html.push("<option value='", m["machine_id"], "'>", m["ip"], "(", m["num"], ")</option>");
924
+ });
925
+ $("#" + element_id).html(html.join(""));
926
+ },
927
+
918
928
  init_word_modal: function () {
919
929
  Util.init_modal_skeleton("word_modal");
920
930
  let html = [];
@@ -991,7 +1001,7 @@ $(function () {
991
1001
 
992
1002
  handle_tool: function () {
993
1003
  let t_obj = $("#timestamp");
994
- let t_val = t_obj.val();
1004
+ let t_val = t_obj.val().trim();
995
1005
  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)) {
996
1006
  $("#date_format").val(Util.format_to_second(t_val));
997
1007
  } else if (/^[1-9]\d{3}$/.test(t_val)) { // 年份的字符串
@@ -1003,7 +1013,7 @@ $(function () {
1003
1013
  }
1004
1014
  $("#timestamp_convert").click(function () {
1005
1015
  let t_obj = $("#timestamp");
1006
- let t_val = t_obj.val();
1016
+ let t_val = t_obj.val().trim();
1007
1017
  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)) {
1008
1018
  $("#date_format").val(Util.format_to_second(t_val));
1009
1019
  } else if (/^[1-9]\d{3}$/.test(t_val)) { // 年份的字符串
package/util.js CHANGED
@@ -1673,7 +1673,7 @@ const Util = {
1673
1673
  html.push("</tr>");
1674
1674
  });
1675
1675
  Util.render_table_html("word_process_div_body", html);
1676
- $("#word_num").html(" <span class='label label-info'>" + index + "</span> 条");
1676
+ $("#word_num").html("&nbsp;&nbsp;共 <span class='label label-info'>" + index + "</span> 条");
1677
1677
  if (j["day_num"]) {
1678
1678
  let day_num_html = [];
1679
1679
  day_num_html.push('<option value="">全部</option>');
@@ -1694,6 +1694,7 @@ const Util = {
1694
1694
  if (confirm("是否确定要删除“ " + word + " ” ?")) {
1695
1695
  Util.post(location.pathname, {"active_div": "word_del", "word": word}, function () {
1696
1696
  $(tr_obj).remove();
1697
+ Util.show_tips("删除 “ " + word + " ” 成功", 3456, "alert-success");
1697
1698
  });
1698
1699
  }
1699
1700
  });