sbd-npm 1.4.25 → 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 +125 -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.25",
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();
@@ -439,7 +442,11 @@ $(function () {
439
442
  if (!document.getElementById("task_result")) {
440
443
  $("#task_result_zone").html('<textarea rows="20" id="task_result" class="form-control"></textarea>');
441
444
  }
442
- $("#task_result").val("任务 `" + task_content + "` 处理中...");
445
+ let task_result = "任务 `" + j["content"] + "` 处理中...";
446
+ if (j["chinese"]) {
447
+ task_result += " [" + j["chinese"] + "]";
448
+ }
449
+ $("#task_result").val(task_result);
443
450
  if ($("#is_refresh_task").prop("checked")) {
444
451
  Status.task_timer_id = setTimeout(function () {
445
452
  Status.fetch_task_data();
@@ -522,27 +529,27 @@ $(function () {
522
529
  });
523
530
  },
524
531
 
525
- handle_worker: function () {
532
+ handle_machine: function () {
526
533
  let is_init = 0;
527
- if (!document.getElementById("workers")) {
534
+ if (!document.getElementById("machines")) {
528
535
  is_init = 1;
529
- let hw_html = [];
536
+ let machine_html = [];
530
537
  if (Util.is_mobile()) {
531
- hw_html.push('<form class="form-inline" style="margin-bottom: 5px;">');
538
+ machine_html.push('<form class="form-inline" style="margin-bottom: 5px;">');
532
539
  } else {
533
- hw_html.push('<form class="form-inline">');
540
+ machine_html.push('<form class="form-inline">');
534
541
  }
535
- hw_html.push('<div class="form-group">');
536
- hw_html.push('<select id="workers" class="form-control">');
537
- hw_html.push('<option value="">Loading...</option>');
538
- hw_html.push('</select>');
539
- hw_html.push('</div>');
540
- hw_html.push('&nbsp;&nbsp;<a href="#" data-toggle="modal" data-target=".client_action_modal" data-type="2" class="btn btn-warning">添加任务</a>');
541
- hw_html.push('<a href="#" data-toggle="modal" data-target=".client_cookie_modal" class="btn btn-warning">雪球Cookie</a>');
542
- hw_html.push('<a href="#" id="machine_refresh" class="btn btn-warning">刷新Machine</a>');
543
- hw_html.push('</form>');
544
- hw_html.push('<div id="worker_process_div"></div>');
545
- $("#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(""));
546
553
  if (!document.getElementById("client_action_add")) {
547
554
  Status.init_client_action_modal();
548
555
  Status.init_client_cookie_modal();
@@ -550,41 +557,45 @@ $(function () {
550
557
  Util.show_loading();
551
558
  $("#machine_refresh").attr("disabled", true).html("正在处理中...");
552
559
  Util.post(location.pathname, {active_div: "machine_refresh"}, function (j) {
553
- $("#machine_refresh").html("刷新Machine").attr("disabled", false);
554
- Util.hide_tips();
560
+ setTimeout(function () {
561
+ $('#machines').html('<option value="">暂无Machine</option>');
562
+ $("#machine_refresh").html("刷新Machine").attr("disabled", false);
563
+ Util.hide_tips();
564
+ Util.show_tips("刷新成功", 3456, "alert-success");
565
+ }, 2345);
555
566
  });
556
567
  return false;
557
568
  });
558
569
  }
559
570
  }
560
- Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, machine_id: $("#workers").val()}, function (j) {
561
- 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"]) {
562
573
  let select_html = [];
563
- select_html.push("<option value=''>共 ", j["workers"].length, " 个Worker</option>");
564
- j["workers"].forEach(function (w) {
574
+ select_html.push("<option value=''>共 ", j["machines"].length, " 个Machine</option>");
575
+ j["machines"].forEach(function (w) {
565
576
  select_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
566
577
  });
567
- $("#workers").html(select_html.join(""));
568
- if (j["workers"].length > 0) {
569
- $("#workers").change(function() {
578
+ $("#machines").html(select_html.join(""));
579
+ if (j["machines"].length > 0) {
580
+ $("#machines").change(function() {
570
581
  let machine_id = $(this).val();
571
582
  if (machine_id) {
572
583
  Util.show_loading();
573
- Util.set_table_loading("worker_process_div_body");
574
- Status.handle_worker();
584
+ Util.set_table_loading("machine_process_div_body");
585
+ Status.handle_machine();
575
586
  }
576
587
  });
577
588
  }
578
589
  } else if (j["process"]) {
579
- if (!document.getElementById("worker_process_div_body")) {
590
+ if (!document.getElementById("machine_process_div_body")) {
580
591
  let prefix_caption = "";
581
592
  if (Util.is_mobile()) {
582
- prefix_caption = "<caption id='worker_process_tip'>&nbsp;&nbsp;&nbsp;";
593
+ prefix_caption = "<caption id='machine_process_tip'>&nbsp;&nbsp;&nbsp;";
583
594
  } else {
584
- prefix_caption = '<caption id="worker_process_tip" class="text-right">';
595
+ prefix_caption = '<caption id="machine_process_tip" class="text-right">';
585
596
  }
586
597
  Util.init_table_skeleton({
587
- "element_id": "worker_process_div",
598
+ "element_id": "machine_process_div",
588
599
  "caption": prefix_caption + '</caption>',
589
600
  "head_cols": [
590
601
  {"name": "进程ID", "table_sort": 1},
@@ -613,23 +624,67 @@ $(function () {
613
624
  html.push("<td>", Util.seconds_to_format(item["create_time"]), "</td>");
614
625
  html.push("</tr>");
615
626
  });
616
- Util.render_table_html("worker_process_div_body", html);
617
- $("#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"]);
618
- $("#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 + ")");
630
+ } else if (is_init === 1) {
631
+ $('#machines').html('<option value="">暂无Machine</option>');
619
632
  }
620
633
  Util.hide_tips();
621
634
  });
622
635
  },
623
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">');
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> 条");
675
+ Util.hide_tips();
676
+ });
677
+ },
678
+
624
679
  init_client_action_modal: function () {
625
680
  Util.init_modal_skeleton("client_action_modal");
626
681
  $("#client_action_modal_title").html("添加任务");
627
682
  let html = [];
628
683
  html.push('<form data-parsley-validate class="form-horizontal form-label-left">');
629
- html.push('<div class="form-group" id="action_worker_div">');
630
- 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>');
631
686
  html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
632
- 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">');
633
688
  html.push('<option value="">Loading...</option>');
634
689
  html.push('</select>');
635
690
  html.push('</div>');
@@ -657,21 +712,21 @@ $(function () {
657
712
  Util.show_loading();
658
713
  let action_type = parseInt($(e.relatedTarget).attr("data-type"));
659
714
  if (action_type === 1) {
660
- $("#action_worker_div").css("display", "none");
715
+ $("#action_machine_div").css("display", "none");
661
716
  } else {
662
- $("#action_worker_div").css("display", "block");
717
+ $("#action_machine_div").css("display", "block");
663
718
  }
664
719
  Util.post(location.pathname, {active_div: "client_action", action_type: action_type}, function (j) {
665
- if (j["workers"]) {
666
- let worker_html = [];
667
- j["workers"].forEach(function (w) {
668
- 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>");
669
724
  });
670
- let caw_obj = $("#client_action_worker");
671
- caw_obj.html(worker_html.join(""));
672
- let worker = $("#workers").val();
673
- if (worker) {
674
- 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);
675
730
  }
676
731
  }
677
732
  if (j["actions"]) {
@@ -690,9 +745,9 @@ $(function () {
690
745
  });
691
746
  $("#client_action_add").click(function() {
692
747
  let action_type = 1, machine_id = "1";
693
- if ($("#action_worker_div").css("display") === "block") {
748
+ if ($("#action_machine_div").css("display") === "block") {
694
749
  action_type = 2;
695
- machine_id = $("#client_action_worker").val();
750
+ machine_id = $("#client_action_machine").val();
696
751
  }
697
752
  if (machine_id) {
698
753
  let action_content = $("#client_action_content").val();
@@ -705,7 +760,7 @@ $(function () {
705
760
  if (j["code"] && j["code"] === 1) {
706
761
  $("#client_action_tips").html("<b class='text-success'>任务`" + action_content + "`添加成功!</b>");
707
762
  } else if (j["code"] && j["code"] === 2) {
708
- $("#client_action_tips").html("<b class='text-danger'>Worker 不存在!</b>");
763
+ $("#client_action_tips").html("<b class='text-danger'>Machine 不存在!</b>");
709
764
  } else if (j["code"] && j["code"] === 3) {
710
765
  $("#client_action_tips").html("<b class='text-danger'>任务内容异常!</b>");
711
766
  } else {
@@ -717,7 +772,7 @@ $(function () {
717
772
  $("#client_action_tips").html("<b class='text-danger'>任务内容不能为空!</b>");
718
773
  }
719
774
  } else {
720
- $("#client_action_tips").html("<b class='text-danger'>Worker 异常!</b>");
775
+ $("#client_action_tips").html("<b class='text-danger'>Machine 异常!</b>");
721
776
  }
722
777
  return false;
723
778
  });
@@ -728,10 +783,10 @@ $(function () {
728
783
  $("#client_cookie_modal_title").html("雪球Cookie");
729
784
  let html = [];
730
785
  html.push('<form data-parsley-validate class="form-horizontal form-label-left">');
731
- html.push('<div class="form-group" id="action_worker_div">');
732
- 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>');
733
788
  html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
734
- 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">');
735
790
  html.push('<option value="">Loading...</option>');
736
791
  html.push('</select>');
737
792
  html.push('</div>');
@@ -756,16 +811,16 @@ $(function () {
756
811
  ccm_obj.on('show.bs.modal', function (e) {
757
812
  Util.show_loading();
758
813
  Util.post(location.pathname, {active_div: "client_action", action_type: 2}, function (j) {
759
- if (j["workers"]) {
760
- let worker_html = [];
761
- j["workers"].forEach(function (w) {
762
- 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>");
763
818
  });
764
- let caw_obj = $("#client_cookie_worker");
765
- caw_obj.html(worker_html.join(""));
766
- let worker = $("#workers").val();
767
- if (worker) {
768
- 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);
769
824
  }
770
825
  }
771
826
  Util.hide_tips();
@@ -777,7 +832,7 @@ $(function () {
777
832
  Util.hide_tips();
778
833
  });
779
834
  $("#client_cookie_add").click(function() {
780
- let machine_id = $("#client_cookie_worker").val();
835
+ let machine_id = $("#client_cookie_machine").val();
781
836
  if (machine_id) {
782
837
  let client_cookie = $("#client_cookie_content").val();
783
838
  if (client_cookie) {
@@ -789,7 +844,7 @@ $(function () {
789
844
  if (j["code"] && j["code"] === 1) {
790
845
  $("#client_cookie_tips").html("<b class='text-success'>Cookie添加成功!</b>");
791
846
  } else if (j["code"] && j["code"] === 2) {
792
- $("#client_cookie_tips").html("<b class='text-danger'>Worker 不存在!</b>");
847
+ $("#client_cookie_tips").html("<b class='text-danger'>Machine 不存在!</b>");
793
848
  } else if (j["code"] && j["code"] === 3) {
794
849
  $("#client_cookie_tips").html("<b class='text-danger'>Cookie异常!</b>");
795
850
  } else {
@@ -801,7 +856,7 @@ $(function () {
801
856
  $("#client_cookie_tips").html("<b class='text-danger'>Cookie不能为空!</b>");
802
857
  }
803
858
  } else {
804
- $("#client_cookie_tips").html("<b class='text-danger'>Worker 异常!</b>");
859
+ $("#client_cookie_tips").html("<b class='text-danger'>Machine 异常!</b>");
805
860
  }
806
861
  return false;
807
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();