sbd-npm 1.4.70 → 1.4.72

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.72",
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,18 @@ 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
+ firstDay: 1 // 一周从星期一开始
62
+ },
63
+ singleDatePicker: true,
64
+ singleClasses: "picker_2"
65
+ },
66
+
55
67
  sbd_init: function () {
56
68
  this.show_loading();
57
69
 
@@ -1817,7 +1829,7 @@ const Util = {
1817
1829
  let currency = $(e.relatedTarget).attr("data-code");
1818
1830
  Util.set_table_loading(component_id + "_body_body");
1819
1831
  if ($("#currency_modal_start_date").length <= 0) {
1820
- Util.init_range_date("currency_modal_start_end_date", Util, "render_currency_modal", 60);
1832
+ Util.init_date_range_picker("currency_modal_start_end_date", Util, "render_currency_modal", 60);
1821
1833
  }
1822
1834
  let title_obj = $("#currency_modal_title");
1823
1835
  title_obj.html(currency);
@@ -1909,7 +1921,7 @@ const Util = {
1909
1921
  Util.set_table_loading(component_id + "_body_body");
1910
1922
  let coin = $(e.relatedTarget).attr("data-coin");
1911
1923
  if ($("#" + component_id + "_start_date").length <= 0) {
1912
- Util.init_range_date(component_id + "_start_end_date", Util, "render_btc_modal", 60);
1924
+ Util.init_date_range_picker(component_id + "_start_end_date", Util, "render_btc_modal", 60);
1913
1925
  }
1914
1926
  let title_obj = $("#" + component_id + "_title");
1915
1927
  title_obj.html(coin);
@@ -3590,7 +3602,15 @@ const Util = {
3590
3602
  }
3591
3603
  },
3592
3604
 
3593
- init_range_date: function (element_id, Obj, callback_func, start_date = 0, end_date = 0) {
3605
+ /**
3606
+ * 初始日期范围选择器
3607
+ * @param element_id
3608
+ * @param Obj
3609
+ * @param callback_func
3610
+ * @param start_date
3611
+ * @param end_date
3612
+ */
3613
+ init_date_range_picker: function (element_id, Obj, callback_func, start_date = 0, end_date = 0) {
3594
3614
  let separator = element_id.indexOf("_start_end") > -1 ? "_start_end" : "_";
3595
3615
  let element_arr = element_id.split(separator);
3596
3616
  let prefix = element_arr[0];
@@ -3629,6 +3649,12 @@ const Util = {
3629
3649
  Util.init_time_select_range(Obj, select_id, start_id, end_id, callback_func);
3630
3650
  },
3631
3651
 
3652
+ /**
3653
+ * 初始日期范围选择器的时间参数
3654
+ * @param start_id
3655
+ * @param end_id
3656
+ * @param nth_day
3657
+ */
3632
3658
  init_range_picker_date: function (start_id, end_id = "", nth_day = 0) {
3633
3659
  let date = new Date();
3634
3660
  let year = date.getFullYear();
@@ -3646,31 +3672,24 @@ const Util = {
3646
3672
  }
3647
3673
  start_obj.val(start_date);
3648
3674
  }
3649
- start_obj.daterangepicker({
3650
- locale: {format: 'YYYY-MM-DD'},
3651
- singleDatePicker: true,
3652
- singleClasses: "picker_2"
3653
- });
3675
+ start_obj.daterangepicker(Util.DateRangePickerOptions);
3654
3676
  if (end_id.length > 0) {
3655
3677
  let end_obj = $('#' + end_id);
3656
3678
  if (!Util.regexp_date_yyyy_mm_dd(end_obj.val())) {
3657
3679
  let day = date.getDate();
3658
3680
  end_obj.val(year + "-" + month + "-" + day);
3659
3681
  }
3660
- end_obj.daterangepicker({
3661
- locale: {format: 'YYYY-MM-DD'},
3662
- singleDatePicker: true,
3663
- singleClasses: "picker_2"
3664
- });
3682
+ end_obj.daterangepicker(Util.DateRangePickerOptions);
3665
3683
  }
3666
3684
  },
3667
3685
 
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 () {
3686
+ /**
3687
+ * 初始日期范围选择器,并绑定一个回调函数
3688
+ * @param element_id
3689
+ * @param callback_func
3690
+ */
3691
+ bind_date_picker_callback: function (element_id, callback_func) {
3692
+ $("#" + element_id).daterangepicker(Util.DateRangePickerOptions, function () {
3674
3693
  setTimeout(callback_func, 123);
3675
3694
  });
3676
3695
  },