sbd-npm 1.4.26 → 1.4.27

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 +4 -3
  2. package/status.js +115 -70
  3. package/util.js +2 -4
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.26",
3
+ "version": "1.4.27",
4
4
  "description": "Stock Big Data",
5
+ "author": "DHQ <dhq314@gmail.com>",
6
+ "license": "ISC",
5
7
  "main": "index.js",
6
8
  "scripts": {
7
9
  "test": "echo \"Error: no test specified\" && exit 1"
8
10
  },
9
- "author": "dhq",
10
- "license": "ISC"
11
+ "keywords": ["large", "scale", "data"]
11
12
  }
package/status.js CHANGED
@@ -38,8 +38,11 @@ $(function () {
38
38
  case "task":
39
39
  Status.handle_task();
40
40
  break;
41
- case "worker":
42
- Status.handle_worker();
41
+ case "machine":
42
+ Status.handle_machine();
43
+ break;
44
+ case "word":
45
+ Status.handle_word();
43
46
  break;
44
47
  case "tool":
45
48
  Status.handle_tool();
@@ -526,27 +529,27 @@ $(function () {
526
529
  });
527
530
  },
528
531
 
529
- handle_worker: function () {
532
+ handle_machine: function () {
530
533
  let is_init = 0;
531
- if (!document.getElementById("workers")) {
534
+ if (!document.getElementById("machines")) {
532
535
  is_init = 1;
533
- let hw_html = [];
536
+ let machine_html = [];
534
537
  if (Util.is_mobile()) {
535
- hw_html.push('<form class="form-inline" style="margin-bottom: 5px;">');
538
+ machine_html.push('<form class="form-inline" style="margin-bottom: 5px;">');
536
539
  } else {
537
- hw_html.push('<form class="form-inline">');
540
+ machine_html.push('<form class="form-inline">');
538
541
  }
539
- hw_html.push('<div class="form-group">');
540
- hw_html.push('<select id="workers" class="form-control">');
541
- hw_html.push('<option value="">Loading...</option>');
542
- hw_html.push('</select>');
543
- hw_html.push('</div>');
544
- hw_html.push('&nbsp;&nbsp;<a href="#" data-toggle="modal" data-target=".client_action_modal" data-type="2" class="btn btn-warning">添加任务</a>');
545
- hw_html.push('<a href="#" data-toggle="modal" data-target=".client_cookie_modal" class="btn btn-warning">雪球Cookie</a>');
546
- hw_html.push('<a href="#" id="machine_refresh" class="btn btn-warning">刷新Machine</a>');
547
- hw_html.push('</form>');
548
- hw_html.push('<div id="worker_process_div"></div>');
549
- $("#worker_div").html(hw_html.join(""));
542
+ machine_html.push('<div class="form-group">');
543
+ machine_html.push('<select id="machines" class="form-control">');
544
+ machine_html.push('<option value="">Loading...</option>');
545
+ machine_html.push('</select>');
546
+ machine_html.push('</div>');
547
+ machine_html.push('&nbsp;&nbsp;<a href="#" data-toggle="modal" data-target=".client_action_modal" data-type="2" class="btn btn-warning">添加任务</a>');
548
+ machine_html.push('<a href="#" data-toggle="modal" data-target=".client_cookie_modal" class="btn btn-warning">雪球Cookie</a>');
549
+ machine_html.push('<a href="#" id="machine_refresh" class="btn btn-warning">刷新Machine</a>');
550
+ machine_html.push('</form>');
551
+ machine_html.push('<div id="machine_process_div"></div>');
552
+ $("#machine_div").html(machine_html.join(""));
550
553
  if (!document.getElementById("client_action_add")) {
551
554
  Status.init_client_action_modal();
552
555
  Status.init_client_cookie_modal();
@@ -555,44 +558,44 @@ $(function () {
555
558
  $("#machine_refresh").attr("disabled", true).html("正在处理中...");
556
559
  Util.post(location.pathname, {active_div: "machine_refresh"}, function (j) {
557
560
  setTimeout(function () {
558
- $('#workers').html('<option value="">暂无Machine</option>');
561
+ $('#machines').html('<option value="">暂无Machine</option>');
559
562
  $("#machine_refresh").html("刷新Machine").attr("disabled", false);
560
563
  Util.hide_tips();
561
564
  Util.show_tips("刷新成功", 3456, "alert-success");
562
- }, 3456);
565
+ }, 2345);
563
566
  });
564
567
  return false;
565
568
  });
566
569
  }
567
570
  }
568
- Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, machine_id: $("#workers").val()}, function (j) {
569
- if (j["workers"]) {
571
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, machine_id: $("#machines").val()}, function (j) {
572
+ if (j["machines"]) {
570
573
  let select_html = [];
571
- select_html.push("<option value=''>共 ", j["workers"].length, " 个Worker</option>");
572
- j["workers"].forEach(function (w) {
574
+ select_html.push("<option value=''>共 ", j["machines"].length, " 个Machine</option>");
575
+ j["machines"].forEach(function (w) {
573
576
  select_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
574
577
  });
575
- $("#workers").html(select_html.join(""));
576
- if (j["workers"].length > 0) {
577
- $("#workers").change(function() {
578
+ $("#machines").html(select_html.join(""));
579
+ if (j["machines"].length > 0) {
580
+ $("#machines").change(function() {
578
581
  let machine_id = $(this).val();
579
582
  if (machine_id) {
580
583
  Util.show_loading();
581
- Util.set_table_loading("worker_process_div_body");
582
- Status.handle_worker();
584
+ Util.set_table_loading("machine_process_div_body");
585
+ Status.handle_machine();
583
586
  }
584
587
  });
585
588
  }
586
589
  } else if (j["process"]) {
587
- if (!document.getElementById("worker_process_div_body")) {
590
+ if (!document.getElementById("machine_process_div_body")) {
588
591
  let prefix_caption = "";
589
592
  if (Util.is_mobile()) {
590
- prefix_caption = "<caption id='worker_process_tip'>&nbsp;&nbsp;&nbsp;";
593
+ prefix_caption = "<caption id='machine_process_tip'>&nbsp;&nbsp;&nbsp;";
591
594
  } else {
592
- prefix_caption = '<caption id="worker_process_tip" class="text-right">';
595
+ prefix_caption = '<caption id="machine_process_tip" class="text-right">';
593
596
  }
594
597
  Util.init_table_skeleton({
595
- "element_id": "worker_process_div",
598
+ "element_id": "machine_process_div",
596
599
  "caption": prefix_caption + '</caption>',
597
600
  "head_cols": [
598
601
  {"name": "进程ID", "table_sort": 1},
@@ -621,12 +624,54 @@ $(function () {
621
624
  html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
622
625
  html.push("</tr>");
623
626
  });
624
- Util.render_table_html("worker_process_div_body", html);
625
- $("#worker_process_tip").html('共 <span class="label label-info">' + process_num + '</span> 进程,最后更新时间:' + Util.seconds_to_format(j["date"]) + ',Revision:' + j["revision"] + ',MachineId:' + j["machine_id"]);
626
- $("#workers option[value='" + $("#workers").val() + "']").text(j["ip"] + "(" + process_num + ")");
627
+ Util.render_table_html("machine_process_div_body", html);
628
+ $("#machine_process_tip").html('共 <span class="label label-info">' + process_num + '</span> 进程,最后更新时间:' + Util.seconds_to_format(j["date"]) + ',Revision:' + j["revision"] + ',MachineId:' + j["machine_id"]);
629
+ $("#machines option[value='" + $("#machines").val() + "']").text(j["ip"] + "(" + process_num + ")");
627
630
  } else if (is_init === 1) {
628
- $('#workers').html('<option value="">暂无Machine</option>');
631
+ $('#machines').html('<option value="">暂无Machine</option>');
632
+ }
633
+ Util.hide_tips();
634
+ });
635
+ },
636
+
637
+ handle_word: function() {
638
+ if (!document.getElementById("word_process_div")) {
639
+ let word_html = [];
640
+ if (Util.is_mobile()) {
641
+ word_html.push('<form class="form-inline" style="margin-bottom: 5px;">');
642
+ } else {
643
+ word_html.push('<form class="form-inline">');
629
644
  }
645
+ word_html.push('<a href="#" id="word_previous" class="btn btn-warning">前一天WORD</a>');
646
+ word_html.push('</form>');
647
+ word_html.push('<div id="word_process_div"></div>');
648
+ $("#word_div").html(word_html.join(""));
649
+ Util.init_table_skeleton({
650
+ "element_id": "word_process_div",
651
+ "caption": '<caption class="text-right" id="word_num"></caption>',
652
+ "head_cols": [
653
+ {"name": "序号", "table_sort": 1},
654
+ {"name": "单词", "table_sort": 1},
655
+ {"name": "中文"},
656
+ {"name": "时间", "table_sort": 1},
657
+ {"name": "操作"},
658
+ ]
659
+ });
660
+ }
661
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token]}, function (j) {
662
+ let html = [], index = 0;
663
+ j["data"].forEach(function (item) {
664
+ index++;
665
+ html.push("<tr>");
666
+ html.push("<td>", index, "</td>");
667
+ html.push("<td>", Util.pack_html_link("https://cn.bing.com/dict/search?q=" + item["word"], item["word"]), "</td>");
668
+ html.push("<td>", item["chinese"], "</td>");
669
+ html.push("<td>", Util.seconds_to_format(item["date"]), "</td>");
670
+ html.push("<td><a href='#'>修改</a> &nbsp; <a href='#'>删除</a></td>");
671
+ html.push("</tr>");
672
+ });
673
+ Util.render_table_html("word_process_div_body", html);
674
+ $("#word_num").html("共 <span class='label label-info'>" + index + "</span> 条");
630
675
  Util.hide_tips();
631
676
  });
632
677
  },
@@ -636,10 +681,10 @@ $(function () {
636
681
  $("#client_action_modal_title").html("添加任务");
637
682
  let html = [];
638
683
  html.push('<form data-parsley-validate class="form-horizontal form-label-left">');
639
- html.push('<div class="form-group" id="action_worker_div">');
640
- html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">Worker </label>');
684
+ html.push('<div class="form-group" id="action_machine_div">');
685
+ html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">Machine </label>');
641
686
  html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
642
- html.push('<select id="client_action_worker" class="form-control col-md-7 col-xs-12">');
687
+ html.push('<select id="client_action_machine" class="form-control col-md-7 col-xs-12">');
643
688
  html.push('<option value="">Loading...</option>');
644
689
  html.push('</select>');
645
690
  html.push('</div>');
@@ -667,21 +712,21 @@ $(function () {
667
712
  Util.show_loading();
668
713
  let action_type = parseInt($(e.relatedTarget).attr("data-type"));
669
714
  if (action_type === 1) {
670
- $("#action_worker_div").css("display", "none");
715
+ $("#action_machine_div").css("display", "none");
671
716
  } else {
672
- $("#action_worker_div").css("display", "block");
717
+ $("#action_machine_div").css("display", "block");
673
718
  }
674
719
  Util.post(location.pathname, {active_div: "client_action", action_type: action_type}, function (j) {
675
- if (j["workers"]) {
676
- let worker_html = [];
677
- j["workers"].forEach(function (w) {
678
- worker_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
720
+ if (j["machines"]) {
721
+ let machine_html = [];
722
+ j["machines"].forEach(function (w) {
723
+ machine_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
679
724
  });
680
- let caw_obj = $("#client_action_worker");
681
- caw_obj.html(worker_html.join(""));
682
- let worker = $("#workers").val();
683
- if (worker) {
684
- caw_obj.find("option[value='" + worker + "']").attr("selected", true);
725
+ let caw_obj = $("#client_action_machine");
726
+ caw_obj.html(machine_html.join(""));
727
+ let machine = $("#machines").val();
728
+ if (machine) {
729
+ caw_obj.find("option[value='" + machine + "']").attr("selected", true);
685
730
  }
686
731
  }
687
732
  if (j["actions"]) {
@@ -700,9 +745,9 @@ $(function () {
700
745
  });
701
746
  $("#client_action_add").click(function() {
702
747
  let action_type = 1, machine_id = "1";
703
- if ($("#action_worker_div").css("display") === "block") {
748
+ if ($("#action_machine_div").css("display") === "block") {
704
749
  action_type = 2;
705
- machine_id = $("#client_action_worker").val();
750
+ machine_id = $("#client_action_machine").val();
706
751
  }
707
752
  if (machine_id) {
708
753
  let action_content = $("#client_action_content").val();
@@ -715,7 +760,7 @@ $(function () {
715
760
  if (j["code"] && j["code"] === 1) {
716
761
  $("#client_action_tips").html("<b class='text-success'>任务`" + action_content + "`添加成功!</b>");
717
762
  } else if (j["code"] && j["code"] === 2) {
718
- $("#client_action_tips").html("<b class='text-danger'>Worker 不存在!</b>");
763
+ $("#client_action_tips").html("<b class='text-danger'>Machine 不存在!</b>");
719
764
  } else if (j["code"] && j["code"] === 3) {
720
765
  $("#client_action_tips").html("<b class='text-danger'>任务内容异常!</b>");
721
766
  } else {
@@ -727,7 +772,7 @@ $(function () {
727
772
  $("#client_action_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
728
773
  }
729
774
  } else {
730
- $("#client_action_tips").html("<b class='text-danger'>Worker 异常!</b>");
775
+ $("#client_action_tips").html("<b class='text-danger'>Machine 异常!</b>");
731
776
  }
732
777
  return false;
733
778
  });
@@ -738,10 +783,10 @@ $(function () {
738
783
  $("#client_cookie_modal_title").html("雪球Cookie");
739
784
  let html = [];
740
785
  html.push('<form data-parsley-validate class="form-horizontal form-label-left">');
741
- html.push('<div class="form-group" id="action_worker_div">');
742
- html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">Worker </label>');
786
+ html.push('<div class="form-group" id="action_machine_div">');
787
+ html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">Machine </label>');
743
788
  html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
744
- html.push('<select id="client_cookie_worker" class="form-control col-md-7 col-xs-12">');
789
+ html.push('<select id="client_cookie_machine" class="form-control col-md-7 col-xs-12">');
745
790
  html.push('<option value="">Loading...</option>');
746
791
  html.push('</select>');
747
792
  html.push('</div>');
@@ -766,16 +811,16 @@ $(function () {
766
811
  ccm_obj.on('show.bs.modal', function (e) {
767
812
  Util.show_loading();
768
813
  Util.post(location.pathname, {active_div: "client_action", action_type: 2}, function (j) {
769
- if (j["workers"]) {
770
- let worker_html = [];
771
- j["workers"].forEach(function (w) {
772
- worker_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
814
+ if (j["machines"]) {
815
+ let machine_html = [];
816
+ j["machines"].forEach(function (w) {
817
+ machine_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
773
818
  });
774
- let caw_obj = $("#client_cookie_worker");
775
- caw_obj.html(worker_html.join(""));
776
- let worker = $("#workers").val();
777
- if (worker) {
778
- caw_obj.find("option[value='" + worker + "']").attr("selected", true);
819
+ let caw_obj = $("#client_cookie_machine");
820
+ caw_obj.html(machine_html.join(""));
821
+ let machine = $("#machines").val();
822
+ if (machine) {
823
+ caw_obj.find("option[value='" + machine + "']").attr("selected", true);
779
824
  }
780
825
  }
781
826
  Util.hide_tips();
@@ -787,7 +832,7 @@ $(function () {
787
832
  Util.hide_tips();
788
833
  });
789
834
  $("#client_cookie_add").click(function() {
790
- let machine_id = $("#client_cookie_worker").val();
835
+ let machine_id = $("#client_cookie_machine").val();
791
836
  if (machine_id) {
792
837
  let client_cookie = $("#client_cookie_content").val();
793
838
  if (client_cookie) {
@@ -799,7 +844,7 @@ $(function () {
799
844
  if (j["code"] && j["code"] === 1) {
800
845
  $("#client_cookie_tips").html("<b class='text-success'>Cookie添加成功!</b>");
801
846
  } else if (j["code"] && j["code"] === 2) {
802
- $("#client_cookie_tips").html("<b class='text-danger'>Worker 不存在!</b>");
847
+ $("#client_cookie_tips").html("<b class='text-danger'>Machine 不存在!</b>");
803
848
  } else if (j["code"] && j["code"] === 3) {
804
849
  $("#client_cookie_tips").html("<b class='text-danger'>Cookie异常!</b>");
805
850
  } else {
@@ -811,7 +856,7 @@ $(function () {
811
856
  $("#client_cookie_tips").html("<b class='text-danger'>Cookie不能为空!</b>");
812
857
  }
813
858
  } else {
814
- $("#client_cookie_tips").html("<b class='text-danger'>Worker 异常!</b>");
859
+ $("#client_cookie_tips").html("<b class='text-danger'>Machine 异常!</b>");
815
860
  }
816
861
  return false;
817
862
  });
package/util.js CHANGED
@@ -95,7 +95,7 @@ const Util = {
95
95
  Util.save_page_content_image(element);
96
96
  });
97
97
 
98
- $('#stock').keyup(function () {
98
+ $("#stock").on("focus keyup", function () {
99
99
  let key_word = $(this).val();
100
100
  if (key_word) {
101
101
  if (Util.is_has_chinese(key_word) || (Util.is_alpha(key_word) && key_word.length >= 2) || ($.isNumeric(key_word) && key_word.length >= 3)) {
@@ -173,9 +173,7 @@ const Util = {
173
173
  html.push('<a href="#" class="list-group-item disabled">无数据</a>');
174
174
  }
175
175
  html.push('</div>');
176
- let st_obj = $("#search-tips");
177
- st_obj.html(html.join(""));
178
- st_obj.css("display", "block");
176
+ $("#search-tips").html(html.join("")).css("display", "block");
179
177
  Util.hide_tips();
180
178
  } else {
181
179
  Util.hide_tips();