sbd-npm 1.2.8 → 1.2.11

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/.npmignore ADDED
@@ -0,0 +1 @@
1
+ sbd-npm.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.8",
3
+ "version": "1.2.11",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/sbd.css CHANGED
@@ -61,4 +61,68 @@ table a:hover, a.btn {
61
61
  .modal-xlg {
62
62
  width: 90%;
63
63
  }
64
- }
64
+ }
65
+
66
+ #loading_div {
67
+ position:absolute;
68
+ top:0;
69
+ left:0;
70
+ right:0;
71
+ bottom:0;
72
+ height: 100px;
73
+ text-align: center;
74
+ margin-top: 200px;
75
+ }
76
+ #loading_div .circle {
77
+ margin: 20px;
78
+ height: 50px;
79
+ width: 50px;
80
+ border-radius: 50%;
81
+ display: inline-block;
82
+ background-color: #4695B8;
83
+ transform: scale(0);
84
+ animation: bulge 2s infinite ease-in-out;
85
+ }
86
+ #loading_div .circle::after {
87
+ position: absolute;
88
+ display: inline-block;
89
+ content: '';
90
+ height: 100%;
91
+ width: 100%;
92
+ border-radius: 50%;
93
+ background-color: inherit;
94
+ top: 0;
95
+ left: 0;
96
+ z-index: -1;
97
+ transform: scale(1);
98
+ animation: blow 2s infinite ease-in-out;
99
+ }
100
+ #loading_div .circle:nth-child(1) {
101
+ animation-delay: 0s;
102
+ }
103
+ #loading_div .circle:nth-child(2) {
104
+ animation-delay: .25s;
105
+ }
106
+ #loading_div .circle:nth-child(3) {
107
+ animation-delay: .50s;
108
+ }
109
+ @keyframes bulge {
110
+ 50% {
111
+ transform: scale(1);
112
+ }
113
+ }
114
+ @keyframes blow {
115
+ 25% {
116
+ opacity: 0.5;
117
+ }
118
+ 50% {
119
+ opacity: 0.5;
120
+ }
121
+ 90% {
122
+ opacity: 0;
123
+ }
124
+ 100% {
125
+ transform: scale(2);
126
+ opacity: 0;
127
+ }
128
+ }
package/stock_basics.js CHANGED
@@ -35,7 +35,7 @@ let Stock = {
35
35
  if (Stock.data.hasOwnProperty(active_div)) {
36
36
  return false;
37
37
  }
38
- Util.show_tips("Loading...");
38
+ Util.show_loading();
39
39
  switch (active_div) {
40
40
  case "base":
41
41
  Stock.fetch_base();
@@ -274,7 +274,7 @@ let Stock = {
274
274
  },
275
275
 
276
276
  fetch_hist_data: function () {
277
- Util.show_tips("Loading...");
277
+ Util.show_loading();
278
278
  let hist_type = $("#hist_type").val();
279
279
  let payload = {
280
280
  sort_type: Stock.sort_type,
@@ -344,7 +344,7 @@ let Stock = {
344
344
 
345
345
  fetch_big_deal: function () {
346
346
  if ($("#big_deal_table_body").length <= 0) {
347
- Util.show_tips("Loading...");
347
+ Util.show_loading();
348
348
  Util.init_table_skeleton({
349
349
  "element_id": "big_deal_summary_table",
350
350
  "head_cols": [
@@ -429,7 +429,7 @@ let Stock = {
429
429
  },
430
430
 
431
431
  fetch_rps_data: function () {
432
- Util.show_tips("Loading...");
432
+ Util.show_loading();
433
433
  Util.post("/stock/" + Stock.code, {action: "rps"}, function (j) {
434
434
  let _html = [];
435
435
  j["data"].forEach(function (item) {
@@ -460,7 +460,7 @@ let Stock = {
460
460
  },
461
461
 
462
462
  fetch_holder_top: function () {
463
- Util.show_tips("Loading...");
463
+ Util.show_loading();
464
464
  Util.init_table_skeleton({
465
465
  "element_id": "circulation_holder_table",
466
466
  "head_cols": [
@@ -571,7 +571,7 @@ let Stock = {
571
571
  },
572
572
 
573
573
  fetch_finance: function () {
574
- Util.show_tips("Loading...");
574
+ Util.show_loading();
575
575
  Util.init_table_skeleton({
576
576
  "element_id": "cash_flow_table",
577
577
  "head_cols": [
@@ -812,7 +812,7 @@ let Stock = {
812
812
  },
813
813
 
814
814
  fetch_notice: function () {
815
- Util.show_tips("Loading...");
815
+ Util.show_loading();
816
816
  Util.init_table_skeleton({
817
817
  "element_id": "notice_table",
818
818
  "head_cols": [
@@ -859,7 +859,7 @@ let Stock = {
859
859
 
860
860
  // 机构研究报告数据
861
861
  fetch_report_organization: function () {
862
- Util.show_tips("Loading...");
862
+ Util.show_loading();
863
863
  Util.init_table_skeleton({
864
864
  "element_id": "report_organization_table",
865
865
  "head_cols": [
@@ -890,7 +890,7 @@ let Stock = {
890
890
 
891
891
  // 公募持股
892
892
  fetch_public_fund: function () {
893
- Util.show_tips("Loading...");
893
+ Util.show_loading();
894
894
  Util.init_table_skeleton({
895
895
  "element_id": "public_fund_table",
896
896
  "head_cols": [
@@ -1120,7 +1120,7 @@ let Stock = {
1120
1120
  },
1121
1121
 
1122
1122
  fetch_bias_data: function () {
1123
- Util.show_tips("Loading...");
1123
+ Util.show_loading();
1124
1124
  Util.post("/stock/" + Stock["code"], {action: "bias"}, function (j) {
1125
1125
  let date_data = [];
1126
1126
  let bias20_data = [];
package/summary_daily.js CHANGED
@@ -74,7 +74,7 @@ $(document).ready(function () {
74
74
  return false;
75
75
  }
76
76
  DailySummary.is_load = true;
77
- Util.show_tips("Loading...");
77
+ Util.show_loading();
78
78
  Util.post(location.pathname, {date: $("#trade_date").val(), action: "market_overview"}, function (j) {
79
79
  DailySummary.pack_market_overview(j["market_overview"]);
80
80
  DailySummary.fetch_statistics_daily();
@@ -400,7 +400,7 @@ $(document).ready(function () {
400
400
  * 沪深港股通每日十大成交活跃股数据
401
401
  */
402
402
  fetch_hsgt_ten: function (hsgt_type) {
403
- Util.show_tips("Loading...");
403
+ Util.show_loading();
404
404
  let date = $("#trade_date").val();
405
405
  Util.post(location.pathname, {date: date, action: "hsgt_stock", "hsgt_type": hsgt_type}, function (j) {
406
406
  DailySummary.pack_hsgt_ten(j["data"], "hgt", j["url"]);
@@ -488,7 +488,7 @@ $(document).ready(function () {
488
488
  if (Modal.mo_end_time === 0) {
489
489
  Modal.init_market_overview_time(obj);
490
490
  } else {
491
- Util.show_tips("Loading...");
491
+ Util.show_loading();
492
492
  let data_type = $(obj).attr("id");
493
493
  let payload = {
494
494
  date: $("#trade_date").val(),
@@ -531,7 +531,7 @@ $(document).ready(function () {
531
531
  },
532
532
 
533
533
  render_stock_rate_modal: function (obj) {
534
- Util.show_tips("Loading...");
534
+ Util.show_loading();
535
535
  let cp = $(obj).attr("data-cp");
536
536
  let payload = {date: $("#trade_date").val(), action: "p_change", p_change_type: $("#p_change_type").val()};
537
537
  if (cp) {
@@ -579,7 +579,7 @@ $(document).ready(function () {
579
579
  },
580
580
 
581
581
  render_news_modal: function () {
582
- Util.show_tips("Loading...");
582
+ Util.show_loading();
583
583
  Util.post(location.pathname, {action: "pbc_news"}, function (j) {
584
584
  let _html = [];
585
585
  let index = 0;
@@ -671,7 +671,7 @@ $(document).ready(function () {
671
671
  });
672
672
 
673
673
  $("#news_type").change(function () {
674
- Util.show_tips("Loading...");
674
+ Util.show_loading();
675
675
  let news_type = parseInt($("#news_type").val());
676
676
  let payload = {action: "news", limit_num: DailySummary.limit_num(), news_type: news_type};
677
677
  Util.post(location.pathname, payload, function (j) {
package/util.js CHANGED
@@ -22,6 +22,7 @@
22
22
  const Util = {
23
23
 
24
24
  tips_token: "util-tips-div",
25
+ load_token: "loading_div",
25
26
  interval_timer: null,
26
27
  stock_timer_id: 0,
27
28
  // 1年的天数
@@ -46,7 +47,7 @@ const Util = {
46
47
  },
47
48
 
48
49
  sbd_init: function () {
49
- Util.show_tips("Loading...");
50
+ Util.show_loading();
50
51
 
51
52
  Util.init_menu();
52
53
 
@@ -88,7 +89,7 @@ const Util = {
88
89
  clearTimeout(Util.stock_timer_id);
89
90
  st_obj.css("display", "none");
90
91
  Util.stock_timer_id = setTimeout(function () {
91
- Util.show_tips("Loading...");
92
+ Util.show_loading();
92
93
  Util.post("/action", {action: "search", key_word: key_word}, function (j) {
93
94
  let key_word = $("#stock").val();
94
95
  if (key_word) {
@@ -837,7 +838,7 @@ const Util = {
837
838
  * @param alert_tips
838
839
  */
839
840
  init_stock_category_data: function (stock_category, table_id, alert_tips = "") {
840
- Util.show_tips("Loading...");
841
+ Util.show_loading();
841
842
  let head_cols = [
842
843
  {"name": "代码"},
843
844
  {"name": "名称"},
@@ -1008,7 +1009,7 @@ const Util = {
1008
1009
  * @param component_id
1009
1010
  */
1010
1011
  fetch_public_fund_stock: function (fund_code, date, component_id) {
1011
- Util.show_tips("Loading...");
1012
+ Util.show_loading();
1012
1013
  let component_tr = component_id + "_tr";
1013
1014
  $("." + component_tr).each(function () {
1014
1015
  $(this).remove();
@@ -1110,7 +1111,7 @@ const Util = {
1110
1111
  if (!currency) {
1111
1112
  return false;
1112
1113
  }
1113
- Util.show_tips("Loading...");
1114
+ Util.show_loading();
1114
1115
  let payload = {
1115
1116
  currency: currency,
1116
1117
  start_date: $("#currency_modal_start_date").val(),
@@ -1208,18 +1209,19 @@ const Util = {
1208
1209
  },
1209
1210
 
1210
1211
  /**
1211
- * 沪深港股通成交股统计
1212
+ * 初始简介组件
1212
1213
  * @param element_id
1213
1214
  * @param profile
1214
1215
  */
1215
1216
  init_profile_component: function(element_id, profile) {
1216
1217
  if (profile && profile.length > 0) {
1217
- Util.init_modal_skeleton("profile_modal");
1218
- $("#profile_modal_title").html("简介");
1219
- let sub_profile = Util.sub_str(profile, 250);
1220
- sub_profile += "&nbsp;&nbsp;&nbsp;<a class='unfold text-info' data-toggle='modal' data-target='.profile_modal' href='#'>展开</a>";
1221
- $("#" + element_id).html(sub_profile);
1222
- $('#profile_modal').on('shown.bs.modal', function () {
1218
+ let modal_id = element_id + "_modal";
1219
+ Util.init_modal_skeleton(modal_id);
1220
+ $("#" + modal_id + "_title").html("简介");
1221
+ let show_profile = Util.sub_str(profile, 250);
1222
+ show_profile += "&nbsp;&nbsp;&nbsp;<a class='unfold text-info' data-toggle='modal' data-target='." + modal_id + "' href='#'>展开</a>";
1223
+ $("#" + element_id).html(show_profile);
1224
+ $('#' + modal_id).on('shown.bs.modal', function () {
1223
1225
  let p_arr = profile.split("。");
1224
1226
  let _html = [];
1225
1227
  p_arr.forEach(function (p) {
@@ -1227,7 +1229,7 @@ const Util = {
1227
1229
  _html.push("<p>", p.replace(/,/g, ","), "。</p>");
1228
1230
  }
1229
1231
  });
1230
- Util.render_table_html("profile_modal_body", _html);
1232
+ Util.render_table_html(modal_id + "_body", _html);
1231
1233
  });
1232
1234
  }
1233
1235
  },
@@ -1711,13 +1713,15 @@ const Util = {
1711
1713
  }
1712
1714
  $(this).click(function () {
1713
1715
  if (!Util.is_loading()) {
1714
- $(this).parent().parent().find("i").each(function () {
1716
+ let this_parent = $(this).parent();
1717
+ this_parent.parent().find("i").each(function () {
1715
1718
  if ($(this).hasClass("fa")) {
1716
1719
  $(this).removeClass("fa-sort-asc");
1717
1720
  $(this).removeClass("fa-sort-desc");
1718
1721
  if (!$(this).hasClass("fa-sort")) {
1719
1722
  $(this).addClass("fa-sort");
1720
1723
  }
1724
+ $(this).parent().removeClass("info");
1721
1725
  }
1722
1726
  });
1723
1727
  let sort_type = $(this).attr("data-val").toString();
@@ -1728,12 +1732,13 @@ const Util = {
1728
1732
  Obj[sort_order] = Obj[sort_order] === 0 ? 1 : 0;
1729
1733
  }
1730
1734
  let sort_cls = Obj[sort_order] === 0 ? "fa-sort-desc" : "fa-sort-asc";
1731
- $(this).parent().find("i").each(function () {
1735
+ this_parent.find("i").each(function () {
1732
1736
  if ($(this).hasClass("fa")) {
1733
1737
  $(this).removeClass("fa-sort");
1734
1738
  $(this).addClass(sort_cls);
1735
1739
  }
1736
1740
  });
1741
+ this_parent.addClass("info");
1737
1742
  callback_func(1);
1738
1743
  }
1739
1744
  return false;
@@ -1818,6 +1823,7 @@ const Util = {
1818
1823
  if (!$(this).hasClass("fa-sort")) {
1819
1824
  $(this).addClass("fa-sort");
1820
1825
  }
1826
+ $(this).parent().removeClass("info");
1821
1827
  }
1822
1828
  });
1823
1829
  $(this).find("i").each(function () {
@@ -1826,6 +1832,7 @@ const Util = {
1826
1832
  $(this).addClass(sort_cls);
1827
1833
  }
1828
1834
  });
1835
+ $(this).addClass("info");
1829
1836
  });
1830
1837
  });
1831
1838
  },
@@ -1926,9 +1933,23 @@ const Util = {
1926
1933
  },
1927
1934
 
1928
1935
  hide_tips: function () {
1929
- let obj = $('#' + Util.tips_token);
1930
- if (obj.length) {
1931
- obj.remove();
1936
+ let tips_obj = $('#' + Util.tips_token);
1937
+ if (tips_obj.length) {
1938
+ tips_obj.remove();
1939
+ }
1940
+ let load_obj = $('#' + Util.load_token);
1941
+ if (load_obj.length) {
1942
+ load_obj.remove();
1943
+ }
1944
+ },
1945
+
1946
+ show_loading: function () {
1947
+ let load_obj = document.getElementById(Util.load_token);
1948
+ if (!load_obj) {
1949
+ let load_obj = document.createElement('div');
1950
+ load_obj.id = Util.load_token;
1951
+ load_obj.innerHTML = '<div class="circle"></div><div class="circle"></div><div class="circle"></div>';
1952
+ document.getElementsByTagName('body')[0].appendChild(load_obj);
1932
1953
  }
1933
1954
  },
1934
1955
 
@@ -1937,7 +1958,7 @@ const Util = {
1937
1958
  * @returns {boolean}
1938
1959
  */
1939
1960
  is_loading: function () {
1940
- return $("#" + Util.tips_token).length > 0;
1961
+ return $("#" + Util.load_token).length > 0;
1941
1962
  },
1942
1963
 
1943
1964
  tooltip: function (element_id, tip) {
@@ -1965,7 +1986,7 @@ const Util = {
1965
1986
  init_stock_stuff: function (element_id, index_list, is_us = 0, is_refresh = 1) {
1966
1987
  let code_list = Util.get_code_list(element_id);
1967
1988
  if (code_list.length > 0) {
1968
- Util.show_tips("Loading...");
1989
+ Util.show_loading();
1969
1990
  //获取股票详情数据
1970
1991
  Util.post("/action", {action: "code_detail", code_list: code_list.join("-")}, function (j) {
1971
1992
  let valid_code_list = [];
@@ -2213,12 +2234,20 @@ const Util = {
2213
2234
  parse_index_data: function (index_data) {
2214
2235
  let _html = [];
2215
2236
  if (index_data) {
2237
+ let is_small = Util.is_small_screen();
2216
2238
  index_data.forEach(function (item) {
2217
2239
  let short_name = item["name"];
2240
+ if (is_small) {
2241
+ short_name = short_name.replace("指数", "").replace("成指", "").replace("板指", "");
2242
+ }
2218
2243
  if (item["href"]) {
2219
2244
  short_name = "<a style='text-decoration: none;' href='" + item["href"] + "' target='_blank' rel='noopener noreferrer nofollow'>" + short_name + "</a>";
2220
2245
  }
2221
- _html.push("<span title='", item["name"], "'>", short_name, ":");
2246
+ let title = item["name"];
2247
+ if (item["code"]) {
2248
+ title = item["name"] + "(" + item["code"] + ")";
2249
+ }
2250
+ _html.push("<span title='", title, "'>", short_name, ":");
2222
2251
  _html.push(Util.pack_index_data(item["value"], item["change_rate"]));
2223
2252
  _html.push("</span> ");
2224
2253
  });
@@ -2275,9 +2304,12 @@ const Util = {
2275
2304
  if (item["snowball_follower"] && item["snowball_follower"] > 0) {
2276
2305
  let snowball_follower_rank = Util.to_unit(item["snowball_follower"]) + "(" + item["snowball_follower_rank"] + ")";
2277
2306
  let market_type = Util.is_hk(item["code"]) ? "hk" : "cn";
2278
- snowball_follower_rank = Util.pack_html_link(Util.get_url("rank_holder") + "?sort_type=snowball_follower&market_type=" + market_type, snowball_follower_rank);
2307
+ let url = Util.get_url("rank_holder") + "?sort_type=snowball_follower&market_type=" + market_type;
2308
+ if (item["code"]) {
2309
+ url += "&code=" + item["code"];
2310
+ }
2279
2311
  let tooltip = item["snowball_follower"] + " 人关注,关注排名第 " + item["snowball_follower_rank"] + " 位";
2280
- $("#snowball_follower").html(snowball_follower_rank + ' <i class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="top" data-original-title="' + tooltip + '"></i>');
2312
+ $("#snowball_follower").html(Util.pack_html_link(url, snowball_follower_rank) + ' <i class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="top" data-original-title="' + tooltip + '"></i>');
2281
2313
  $("[data-toggle='tooltip']").tooltip();
2282
2314
  }
2283
2315
  },
@@ -2822,7 +2854,7 @@ const Util = {
2822
2854
  * @returns {*|jQuery|void}
2823
2855
  */
2824
2856
  show_chart_loading: function (chart_instance, element_id) {
2825
- Util.show_tips("Loading...");
2857
+ Util.show_loading();
2826
2858
  if (!chart_instance) {
2827
2859
  chart_instance = Util.init_chart_instance(element_id);
2828
2860
  }
@@ -3405,4 +3437,3 @@ Object.size = function (obj) {
3405
3437
  console.log(Notification.permission);
3406
3438
  break;
3407
3439
  }*/
3408
-