sbd-npm 1.4.70 → 1.4.71

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.70",
3
+ "version": "1.4.71",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/status.js CHANGED
@@ -108,14 +108,8 @@ $(function () {
108
108
  if (j["ip_date"]) {
109
109
  let id_obj = $("#ip_date");
110
110
  id_obj.val(Util.seconds_to_format(j["ip_date"], "%Y-%m-%d"));
111
- id_obj.daterangepicker({
112
- locale: {format: 'YYYY-MM-DD'},
113
- singleDatePicker: true,
114
- singleClasses: "picker_2"
115
- }, function () {
116
- setTimeout(Status.fetch_data, 123);
117
- });
118
111
  id_obj.parent().attr("title", Util.seconds_to_format(j["ip_date"]));
112
+ Util.bind_date_picker_callback("ip_date", Status.fetch_data);
119
113
  }
120
114
  Util.hide_tips();
121
115
  });
package/stock_basics.js CHANGED
@@ -54,7 +54,7 @@ let Stock = {
54
54
  break;
55
55
  case "margin":
56
56
  if (!Stock.rzye_chart) {
57
- Util.init_range_date("margin_start_end_date", Stock, "fetch_margin");
57
+ Util.init_date_range_picker("margin_start_end_date", Stock, "fetch_margin");
58
58
  }
59
59
  $("#query_margin").click(function () {
60
60
  Stock.fetch_margin();
@@ -66,7 +66,7 @@ let Stock = {
66
66
  break;
67
67
  case "hkex_holding":
68
68
  if (!Stock.hkex_holding_chart) {
69
- Util.init_range_date("hkex_start_end_date", Stock, "fetch_hkex_holding");
69
+ Util.init_date_range_picker("hkex_start_end_date", Stock, "fetch_hkex_holding");
70
70
  }
71
71
  $("#query_hkex_holding").click(function () {
72
72
  Stock.fetch_hkex_holding();
@@ -99,9 +99,9 @@ let Stock = {
99
99
  break;
100
100
  case "hist_trade": // 个股历史交易记录
101
101
  if (Stock.hist_start_date && Stock.hist_end_date) {
102
- Util.init_range_date("hist_start_end_date", Stock, "fetch_hist_data", Stock.hist_start_date, Stock.hist_end_date);
102
+ Util.init_date_range_picker("hist_start_end_date", Stock, "fetch_hist_data", Stock.hist_start_date, Stock.hist_end_date);
103
103
  } else {
104
- Util.init_range_date("hist_start_end_date", Stock, "fetch_hist_data", 60);
104
+ Util.init_date_range_picker("hist_start_end_date", Stock, "fetch_hist_data", 60);
105
105
  }
106
106
  if (Stock.hist_type) {
107
107
  $("#hist_type").val(Stock.hist_type);
package/summary_daily.js CHANGED
@@ -496,20 +496,13 @@ $(function () {
496
496
  date_html.push('</li></ul>');
497
497
  $('.top_nav .nav_menu nav div.toggle').after(date_html.join(""));
498
498
  $("#trade_date").val(Util.seconds_to_format(trade_date, "%Y-%m-%d"));
499
- Util.init_date_range_picker("trade_date", DailySummary.fetch_data);
499
+ Util.bind_date_picker_callback("trade_date", DailySummary.fetch_data);
500
500
  }
501
501
 
502
502
  };
503
503
 
504
- $("#trade_date").daterangepicker({
505
- locale: {format: 'YYYY-MM-DD'},
506
- singleDatePicker: true,
507
- singleClasses: "picker_2"
508
- }, function () {
509
- if (!Util.is_load) {
510
- setTimeout(DailySummary.fetch_data, 123);
511
- }
512
- });
504
+ Util.bind_date_picker_callback("trade_date", DailySummary.fetch_data);
505
+
513
506
  // 成交概况数据
514
507
  let Modal = {
515
508
 
@@ -686,7 +679,7 @@ $(function () {
686
679
  mam_obj.on('shown.bs.modal', function (e) {
687
680
  Util.set_table_loading("index_hist_modal_body_body");
688
681
  if ($("#index_hist_modal_start_date").length <= 0) {
689
- Util.init_range_date("index_hist_modal_start_end_date", DailySummary, "render_index_hist_modal");
682
+ Util.init_date_range_picker("index_hist_modal_start_end_date", DailySummary, "render_index_hist_modal");
690
683
  }
691
684
  $("#index_hist_modal_query").click(function () {
692
685
  DailySummary.render_index_hist_modal();
package/util.js CHANGED
@@ -52,6 +52,17 @@ const Util = {
52
52
  minSpotColor: "#34495E"
53
53
  },
54
54
 
55
+ // 日期范围选择器配置
56
+ DateRangePickerOptions: {
57
+ locale: {
58
+ format: 'YYYY-MM-DD',
59
+ daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
60
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
61
+ },
62
+ singleDatePicker: true,
63
+ singleClasses: "picker_2"
64
+ },
65
+
55
66
  sbd_init: function () {
56
67
  this.show_loading();
57
68
 
@@ -1817,7 +1828,7 @@ const Util = {
1817
1828
  let currency = $(e.relatedTarget).attr("data-code");
1818
1829
  Util.set_table_loading(component_id + "_body_body");
1819
1830
  if ($("#currency_modal_start_date").length <= 0) {
1820
- Util.init_range_date("currency_modal_start_end_date", Util, "render_currency_modal", 60);
1831
+ Util.init_date_range_picker("currency_modal_start_end_date", Util, "render_currency_modal", 60);
1821
1832
  }
1822
1833
  let title_obj = $("#currency_modal_title");
1823
1834
  title_obj.html(currency);
@@ -1909,7 +1920,7 @@ const Util = {
1909
1920
  Util.set_table_loading(component_id + "_body_body");
1910
1921
  let coin = $(e.relatedTarget).attr("data-coin");
1911
1922
  if ($("#" + component_id + "_start_date").length <= 0) {
1912
- Util.init_range_date(component_id + "_start_end_date", Util, "render_btc_modal", 60);
1923
+ Util.init_date_range_picker(component_id + "_start_end_date", Util, "render_btc_modal", 60);
1913
1924
  }
1914
1925
  let title_obj = $("#" + component_id + "_title");
1915
1926
  title_obj.html(coin);
@@ -3590,7 +3601,15 @@ const Util = {
3590
3601
  }
3591
3602
  },
3592
3603
 
3593
- init_range_date: function (element_id, Obj, callback_func, start_date = 0, end_date = 0) {
3604
+ /**
3605
+ * 初始日期范围选择器
3606
+ * @param element_id
3607
+ * @param Obj
3608
+ * @param callback_func
3609
+ * @param start_date
3610
+ * @param end_date
3611
+ */
3612
+ init_date_range_picker: function (element_id, Obj, callback_func, start_date = 0, end_date = 0) {
3594
3613
  let separator = element_id.indexOf("_start_end") > -1 ? "_start_end" : "_";
3595
3614
  let element_arr = element_id.split(separator);
3596
3615
  let prefix = element_arr[0];
@@ -3629,6 +3648,12 @@ const Util = {
3629
3648
  Util.init_time_select_range(Obj, select_id, start_id, end_id, callback_func);
3630
3649
  },
3631
3650
 
3651
+ /**
3652
+ * 初始日期范围选择器的时间参数
3653
+ * @param start_id
3654
+ * @param end_id
3655
+ * @param nth_day
3656
+ */
3632
3657
  init_range_picker_date: function (start_id, end_id = "", nth_day = 0) {
3633
3658
  let date = new Date();
3634
3659
  let year = date.getFullYear();
@@ -3646,31 +3671,24 @@ const Util = {
3646
3671
  }
3647
3672
  start_obj.val(start_date);
3648
3673
  }
3649
- start_obj.daterangepicker({
3650
- locale: {format: 'YYYY-MM-DD'},
3651
- singleDatePicker: true,
3652
- singleClasses: "picker_2"
3653
- });
3674
+ start_obj.daterangepicker(Util.DateRangePickerOptions);
3654
3675
  if (end_id.length > 0) {
3655
3676
  let end_obj = $('#' + end_id);
3656
3677
  if (!Util.regexp_date_yyyy_mm_dd(end_obj.val())) {
3657
3678
  let day = date.getDate();
3658
3679
  end_obj.val(year + "-" + month + "-" + day);
3659
3680
  }
3660
- end_obj.daterangepicker({
3661
- locale: {format: 'YYYY-MM-DD'},
3662
- singleDatePicker: true,
3663
- singleClasses: "picker_2"
3664
- });
3681
+ end_obj.daterangepicker(Util.DateRangePickerOptions);
3665
3682
  }
3666
3683
  },
3667
3684
 
3668
- init_date_range_picker: function (element_id, callback_func) {
3669
- $("#" + element_id).daterangepicker({
3670
- locale: {format: 'YYYY-MM-DD'},
3671
- singleDatePicker: true,
3672
- singleClasses: "picker_2"
3673
- }, function () {
3685
+ /**
3686
+ * 初始日期范围选择器,并绑定一个回调函数
3687
+ * @param element_id
3688
+ * @param callback_func
3689
+ */
3690
+ bind_date_picker_callback: function (element_id, callback_func) {
3691
+ $("#" + element_id).daterangepicker(Util.DateRangePickerOptions, function () {
3674
3692
  setTimeout(callback_func, 123);
3675
3693
  });
3676
3694
  },