sbd-npm 1.2.7 → 1.2.10

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/stock_basics.js +1 -20
  3. package/util.js +32 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.7",
3
+ "version": "1.2.10",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -27,7 +27,6 @@ let Stock = {
27
27
  hist_type: "",
28
28
  hist_start_date: "",
29
29
  hist_end_date: "",
30
- profile: "",
31
30
  data: {},
32
31
  profit_data: [], // 盈利数据
33
32
 
@@ -171,25 +170,7 @@ let Stock = {
171
170
  cf_obj.html(Util.strip_html(Util.to_unit(cf_obj.attr("title"))));
172
171
  //获取股票详情数据
173
172
  Util.post("/stock/" + Stock["code"], {action: "code_detail"}, function (item) {
174
- if (item["intro"]) {
175
- // 简介
176
- Util.init_modal_skeleton("profile_modal");
177
- $("#profile_modal_title").html("简介");
178
- Stock.profile = item["intro"];
179
- let profile = Util.sub_str(Stock.profile, 250);
180
- profile += "&nbsp;&nbsp;&nbsp;<a class='unfold text-info' data-toggle='modal' data-target='.profile_modal' href='#'>展开</a>";
181
- $("#profile").html(profile);
182
- $('#profile_modal').on('shown.bs.modal', function () {
183
- let p_arr = Stock.profile.split("。");
184
- let _html = [];
185
- p_arr.forEach(function (p) {
186
- if (p.length > 0) {
187
- _html.push("<p>", p.replace(/,/g, ","), "。</p>");
188
- }
189
- });
190
- Util.render_table_html("profile_modal_body", _html);
191
- });
192
- }
173
+ Util.init_profile_component("profile", item["intro"]);
193
174
  if (item["latest_date"] && !Stock.hist_end_date) {
194
175
  Stock.hist_end_date = Util.seconds_to_format(item["latest_date"], "%Y-%m-%d");
195
176
  Stock.hist_start_date = Util.seconds_to_format(item["latest_date"] - 60 * Util.one_day_second, "%Y-%m-%d");
package/util.js CHANGED
@@ -1208,18 +1208,19 @@ const Util = {
1208
1208
  },
1209
1209
 
1210
1210
  /**
1211
- * 沪深港股通成交股统计
1212
- * @param obj
1211
+ * 初始简介组件
1212
+ * @param element_id
1213
1213
  * @param profile
1214
1214
  */
1215
- init_profile_component: function(obj, profile) {
1215
+ init_profile_component: function(element_id, profile) {
1216
1216
  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
- obj.html(sub_profile);
1222
- $('#profile_modal').on('shown.bs.modal', function () {
1217
+ let modal_id = element_id + "_modal";
1218
+ Util.init_modal_skeleton(modal_id);
1219
+ $("#" + modal_id + "_title").html("简介");
1220
+ let show_profile = Util.sub_str(profile, 250);
1221
+ show_profile += "&nbsp;&nbsp;&nbsp;<a class='unfold text-info' data-toggle='modal' data-target='." + modal_id + "' href='#'>展开</a>";
1222
+ $("#" + element_id).html(show_profile);
1223
+ $('#' + modal_id).on('shown.bs.modal', function () {
1223
1224
  let p_arr = profile.split("。");
1224
1225
  let _html = [];
1225
1226
  p_arr.forEach(function (p) {
@@ -1227,7 +1228,7 @@ const Util = {
1227
1228
  _html.push("<p>", p.replace(/,/g, ","), "。</p>");
1228
1229
  }
1229
1230
  });
1230
- Util.render_table_html("profile_modal_body", _html);
1231
+ Util.render_table_html(modal_id + "_body", _html);
1231
1232
  });
1232
1233
  }
1233
1234
  },
@@ -1711,13 +1712,15 @@ const Util = {
1711
1712
  }
1712
1713
  $(this).click(function () {
1713
1714
  if (!Util.is_loading()) {
1714
- $(this).parent().parent().find("i").each(function () {
1715
+ let this_parent = $(this).parent();
1716
+ this_parent.parent().find("i").each(function () {
1715
1717
  if ($(this).hasClass("fa")) {
1716
1718
  $(this).removeClass("fa-sort-asc");
1717
1719
  $(this).removeClass("fa-sort-desc");
1718
1720
  if (!$(this).hasClass("fa-sort")) {
1719
1721
  $(this).addClass("fa-sort");
1720
1722
  }
1723
+ $(this).parent().removeClass("info");
1721
1724
  }
1722
1725
  });
1723
1726
  let sort_type = $(this).attr("data-val").toString();
@@ -1728,12 +1731,13 @@ const Util = {
1728
1731
  Obj[sort_order] = Obj[sort_order] === 0 ? 1 : 0;
1729
1732
  }
1730
1733
  let sort_cls = Obj[sort_order] === 0 ? "fa-sort-desc" : "fa-sort-asc";
1731
- $(this).parent().find("i").each(function () {
1734
+ this_parent.find("i").each(function () {
1732
1735
  if ($(this).hasClass("fa")) {
1733
1736
  $(this).removeClass("fa-sort");
1734
1737
  $(this).addClass(sort_cls);
1735
1738
  }
1736
1739
  });
1740
+ this_parent.addClass("info");
1737
1741
  callback_func(1);
1738
1742
  }
1739
1743
  return false;
@@ -1818,6 +1822,7 @@ const Util = {
1818
1822
  if (!$(this).hasClass("fa-sort")) {
1819
1823
  $(this).addClass("fa-sort");
1820
1824
  }
1825
+ $(this).parent().removeClass("info");
1821
1826
  }
1822
1827
  });
1823
1828
  $(this).find("i").each(function () {
@@ -1826,6 +1831,7 @@ const Util = {
1826
1831
  $(this).addClass(sort_cls);
1827
1832
  }
1828
1833
  });
1834
+ $(this).addClass("info");
1829
1835
  });
1830
1836
  });
1831
1837
  },
@@ -2213,12 +2219,20 @@ const Util = {
2213
2219
  parse_index_data: function (index_data) {
2214
2220
  let _html = [];
2215
2221
  if (index_data) {
2222
+ let is_small = Util.is_small_screen();
2216
2223
  index_data.forEach(function (item) {
2217
2224
  let short_name = item["name"];
2225
+ if (is_small) {
2226
+ short_name = short_name.replace("指数", "").replace("成指", "").replace("板指", "");
2227
+ }
2218
2228
  if (item["href"]) {
2219
2229
  short_name = "<a style='text-decoration: none;' href='" + item["href"] + "' target='_blank' rel='noopener noreferrer nofollow'>" + short_name + "</a>";
2220
2230
  }
2221
- _html.push("<span title='", item["name"], "'>", short_name, ":");
2231
+ let title = item["name"];
2232
+ if (item["code"]) {
2233
+ title = item["name"] + "(" + item["code"] + ")";
2234
+ }
2235
+ _html.push("<span title='", title, "'>", short_name, ":");
2222
2236
  _html.push(Util.pack_index_data(item["value"], item["change_rate"]));
2223
2237
  _html.push("</span> ");
2224
2238
  });
@@ -2275,9 +2289,12 @@ const Util = {
2275
2289
  if (item["snowball_follower"] && item["snowball_follower"] > 0) {
2276
2290
  let snowball_follower_rank = Util.to_unit(item["snowball_follower"]) + "(" + item["snowball_follower_rank"] + ")";
2277
2291
  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);
2292
+ let url = Util.get_url("rank_holder") + "?sort_type=snowball_follower&market_type=" + market_type;
2293
+ if (item["code"]) {
2294
+ url += "&code=" + item["code"];
2295
+ }
2279
2296
  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>');
2297
+ $("#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
2298
  $("[data-toggle='tooltip']").tooltip();
2282
2299
  }
2283
2300
  },