sbd-npm 1.4.20 → 1.4.22

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 +103 -14
  3. package/util.js +11 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.20",
3
+ "version": "1.4.22",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/status.js CHANGED
@@ -190,7 +190,7 @@ $(function () {
190
190
  Status.handle_process();
191
191
  });
192
192
  if (!document.getElementById("client_action_add")) {
193
- Status.init_worker_modal();
193
+ Status.init_client_action_modal();
194
194
  }
195
195
  }
196
196
  let is_py_process = $("#is_py_process").prop("checked") ? "1" : "0";
@@ -527,32 +527,38 @@ $(function () {
527
527
  if (!document.getElementById("workers")) {
528
528
  is_init = 1;
529
529
  let hw_html = [];
530
- hw_html.push('<form class="form-inline">');
530
+ if (Util.is_mobile()) {
531
+ hw_html.push('<form class="form-inline" style="margin-bottom: 5px;">');
532
+ } else {
533
+ hw_html.push('<form class="form-inline">');
534
+ }
531
535
  hw_html.push('<div class="form-group">');
532
536
  hw_html.push('<select id="workers" class="form-control">');
533
537
  hw_html.push('<option value="">Loading...</option>');
534
538
  hw_html.push('</select>');
535
539
  hw_html.push('</div>');
536
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>');
537
542
  hw_html.push('</form>');
538
543
  hw_html.push('<div id="worker_process_div"></div>');
539
544
  $("#worker_div").html(hw_html.join(""));
540
545
  if (!document.getElementById("client_action_add")) {
541
- Status.init_worker_modal();
546
+ Status.init_client_action_modal();
547
+ Status.init_client_cookie_modal();
542
548
  }
543
549
  }
544
- Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, key: $("#workers").val()}, function (j) {
550
+ Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, machine_id: $("#workers").val()}, function (j) {
545
551
  if (j["workers"]) {
546
552
  let select_html = [];
547
553
  select_html.push("<option value=''>共 ", j["workers"].length, " 个Worker</option>");
548
554
  j["workers"].forEach(function (w) {
549
- select_html.push("<option value='", w["key"], "'>", w["ip"], "(", w["num"], ")</option>");
555
+ select_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
550
556
  });
551
557
  $("#workers").html(select_html.join(""));
552
558
  if (j["workers"].length > 0) {
553
559
  $("#workers").change(function() {
554
- let worker_key = $(this).val();
555
- if (worker_key) {
560
+ let machine_id = $(this).val();
561
+ if (machine_id) {
556
562
  Util.show_loading();
557
563
  Util.set_table_loading("worker_process_div_body");
558
564
  Status.handle_worker();
@@ -605,7 +611,7 @@ $(function () {
605
611
  });
606
612
  },
607
613
 
608
- init_worker_modal: function () {
614
+ init_client_action_modal: function () {
609
615
  Util.init_modal_skeleton("client_action_modal");
610
616
  $("#client_action_modal_title").html("添加任务");
611
617
  let html = [];
@@ -649,7 +655,7 @@ $(function () {
649
655
  if (j["workers"]) {
650
656
  let worker_html = [];
651
657
  j["workers"].forEach(function (w) {
652
- worker_html.push("<option value='", w["key"], "'>", w["ip"], "(", w["num"], ")</option>");
658
+ worker_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
653
659
  });
654
660
  let caw_obj = $("#client_action_worker");
655
661
  caw_obj.html(worker_html.join(""));
@@ -669,23 +675,22 @@ $(function () {
669
675
  });
670
676
  });
671
677
  cam_obj.on('hidden.bs.modal', function () {
672
- $("#client_action_content").val("");
673
678
  $("#client_action_tips").html("");
674
679
  Util.hide_tips();
675
680
  });
676
681
  $("#client_action_add").click(function() {
677
- let action_type = 1, worker_key = "1";
682
+ let action_type = 1, machine_id = "1";
678
683
  if ($("#action_worker_div").css("display") === "block") {
679
684
  action_type = 2;
680
- worker_key = $("#client_action_worker").val();
685
+ machine_id = $("#client_action_worker").val();
681
686
  }
682
- if (worker_key) {
687
+ if (machine_id) {
683
688
  let action_content = $("#client_action_content").val();
684
689
  if (action_content) {
685
690
  Util.show_loading();
686
691
  $("#client_action_tips").html("");
687
692
  $("#client_action_add").attr("disabled", true);
688
- Util.post(location.pathname, {active_div: "client_action_add", "key": worker_key, "content": action_content, action_type: action_type}, function (j) {
693
+ Util.post(location.pathname, {active_div: "client_action_add", "machine_id": machine_id, "content": action_content, action_type: action_type}, function (j) {
689
694
  $("#client_action_add").attr("disabled", false);
690
695
  if (j["code"] && j["code"] === 1) {
691
696
  $("#client_action_tips").html("<b class='text-success'>任务`" + action_content + "`添加成功!</b>");
@@ -708,6 +713,90 @@ $(function () {
708
713
  });
709
714
  },
710
715
 
716
+ init_client_cookie_modal: function () {
717
+ Util.init_modal_skeleton("client_cookie_modal");
718
+ $("#client_cookie_modal_title").html("雪球Cookie");
719
+ let html = [];
720
+ html.push('<form data-parsley-validate class="form-horizontal form-label-left">');
721
+ html.push('<div class="form-group" id="action_worker_div">');
722
+ html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">Worker </label>');
723
+ html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
724
+ html.push('<select id="client_cookie_worker" class="form-control col-md-7 col-xs-12">');
725
+ html.push('<option value="">Loading...</option>');
726
+ html.push('</select>');
727
+ html.push('</div>');
728
+ html.push('</div>');
729
+ html.push('<div class="form-group">');
730
+ html.push('<label class="control-label col-md-3 col-sm-3 col-xs-12" for="search_ip">Cookie </label>');
731
+ html.push('<div class="col-md-6 col-sm-6 col-xs-12">');
732
+ html.push('<textarea class="form-control" rows="10" id="client_cookie_content"></textarea>');
733
+ html.push('</div>');
734
+ html.push('</div>');
735
+ html.push('<div class="form-group">');
736
+ html.push('<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">');
737
+ html.push('<button id="client_cookie_add" type="button" class="btn btn-success">添 加</button>');
738
+ html.push('<span id="client_cookie_tips"></span>');
739
+ html.push('</div>');
740
+ html.push('</div>');
741
+ html.push('</form>');
742
+ let ccmb_obj = $("#client_cookie_modal_body");
743
+ ccmb_obj.html(html.join(""));
744
+ ccmb_obj.parent().parent().removeClass("modal-xlg");
745
+ let ccm_obj = $('#client_cookie_modal');
746
+ ccm_obj.on('show.bs.modal', function (e) {
747
+ Util.show_loading();
748
+ Util.post(location.pathname, {active_div: "client_action", action_type: 2}, function (j) {
749
+ if (j["workers"]) {
750
+ let worker_html = [];
751
+ j["workers"].forEach(function (w) {
752
+ worker_html.push("<option value='", w["machine_id"], "'>", w["ip"], "(", w["num"], ")</option>");
753
+ });
754
+ let caw_obj = $("#client_cookie_worker");
755
+ caw_obj.html(worker_html.join(""));
756
+ let worker = $("#workers").val();
757
+ if (worker) {
758
+ caw_obj.find("option[value='" + worker + "']").attr("selected", true);
759
+ }
760
+ }
761
+ Util.hide_tips();
762
+ });
763
+ });
764
+ ccm_obj.on('hidden.bs.modal', function () {
765
+ $("#client_cookie_content").val("");
766
+ $("#client_cookie_tips").html("");
767
+ Util.hide_tips();
768
+ });
769
+ $("#client_cookie_add").click(function() {
770
+ let machine_id = $("#client_cookie_worker").val();
771
+ if (machine_id) {
772
+ let client_cookie = $("#client_cookie_content").val();
773
+ if (client_cookie) {
774
+ Util.show_loading();
775
+ $("#client_cookie_tips").html("");
776
+ $("#client_cookie_add").attr("disabled", true);
777
+ Util.post(location.pathname, {active_div: "client_cookie_add", "machine_id": machine_id, "cookie": client_cookie}, function (j) {
778
+ $("#client_cookie_add").attr("disabled", false);
779
+ if (j["code"] && j["code"] === 1) {
780
+ $("#client_cookie_tips").html("<b class='text-success'>Cookie添加成功!</b>");
781
+ } else if (j["code"] && j["code"] === 2) {
782
+ $("#client_cookie_tips").html("<b class='text-danger'>Worker 不存在!</b>");
783
+ } else if (j["code"] && j["code"] === 3) {
784
+ $("#client_cookie_tips").html("<b class='text-danger'>Cookie异常!</b>");
785
+ } else {
786
+ $("#client_cookie_tips").html("<b class='text-danger'>Cookie不能为空!</b>");
787
+ }
788
+ Util.hide_tips();
789
+ });
790
+ } else {
791
+ $("#client_cookie_tips").html("<b class='text-danger'>Cookie不能为空!</b>");
792
+ }
793
+ } else {
794
+ $("#client_cookie_tips").html("<b class='text-danger'>Worker 异常!</b>");
795
+ }
796
+ return false;
797
+ });
798
+ },
799
+
711
800
  handle_tool: function () {
712
801
  let t_obj = $("#timestamp");
713
802
  let t_val = t_obj.val();
package/util.js CHANGED
@@ -650,11 +650,7 @@ const Util = {
650
650
  * @returns {string}
651
651
  */
652
652
  code_to_symbol: function (code) {
653
- let market = "";
654
- if (!Util.is_us(code)) {
655
- market = Util.code_to_market(code);
656
- }
657
- return market + code;
653
+ return Util.is_us(code) ? code : (Util.code_to_market(code) + code);
658
654
  },
659
655
 
660
656
  /**
@@ -753,6 +749,15 @@ const Util = {
753
749
  * @returns {boolean}
754
750
  */
755
751
  is_hk: function (code) {
752
+ if (/^[Hh][a-zA-Z0-9]+$/.test(code)) {
753
+ code = code.toLowerCase();
754
+ if (code.slice(0, 2) === "hk") {
755
+ code = code.slice(2);
756
+ }
757
+ if (["hsi", "hsci", "hstech", "hshkbio", "hscei"].includes(code)) {
758
+ return true;
759
+ }
760
+ }
756
761
  return /^\d{5}$/.test(code);
757
762
  },
758
763
 
@@ -1883,7 +1888,7 @@ const Util = {
1883
1888
  _html.push("</tr>");
1884
1889
  });
1885
1890
  Util.render_table_html("btc_modal_body_body", _html);
1886
- let btc_title = j["cn_name"] + "(" + Util.pack_html_link('https://www.binance.com/zh-CN/trade/' + j["short_name"] + '_USDT?theme=dark', j["short_name"]) + ", " + Util.pack_html_link("https://www.feixiaohaozh.info/currencies/" + j["coin"], j["coin"]) + ")";
1891
+ let btc_title = j["cn_name"] + "(" + Util.pack_html_link('https://www.binance.com/zh-CN/trade/' + j["short_name"] + '_USDT?theme=dark', j["short_name"]) + ", " + Util.pack_html_link("https://www.feixiaohao.com/currencies/" + j["coin"], j["coin"]) + ")";
1887
1892
  btc_title += "&nbsp;&nbsp;<small>历史最低:<span class='label label-success'>" + j["hist_low"] + "</span> 历史最高:<span class='label label-danger'>" + j["hist_high"] +
1888
1893
  "</span> 年初至今:" + Util.digit_compare_trend1(j["price"], j["year_price"]) +
1889
1894
  " 52周最高:" + Util.digit_compare_trend1(j["price"], j["week52high"]) +