sbd-npm 1.2.6 → 1.2.9

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.6",
3
+ "version": "1.2.9",
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
@@ -1207,6 +1207,32 @@ const Util = {
1207
1207
  });
1208
1208
  },
1209
1209
 
1210
+ /**
1211
+ * 初始简介组件
1212
+ * @param element_id
1213
+ * @param profile
1214
+ */
1215
+ init_profile_component: function(element_id, profile) {
1216
+ if (profile && profile.length > 0) {
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 () {
1224
+ let p_arr = profile.split("。");
1225
+ let _html = [];
1226
+ p_arr.forEach(function (p) {
1227
+ if (p.length > 0) {
1228
+ _html.push("<p>", p.replace(/,/g, ","), "。</p>");
1229
+ }
1230
+ });
1231
+ Util.render_table_html(modal_id + "_body", _html);
1232
+ });
1233
+ }
1234
+ },
1235
+
1210
1236
  /**
1211
1237
  * 当前时间戳
1212
1238
  * @returns {number}
@@ -2188,12 +2214,20 @@ const Util = {
2188
2214
  parse_index_data: function (index_data) {
2189
2215
  let _html = [];
2190
2216
  if (index_data) {
2217
+ let is_small = Util.is_small_screen();
2191
2218
  index_data.forEach(function (item) {
2192
2219
  let short_name = item["name"];
2220
+ if (is_small) {
2221
+ short_name = short_name.replace("指数", "").replace("成指", "").replace("板指", "");
2222
+ }
2193
2223
  if (item["href"]) {
2194
2224
  short_name = "<a style='text-decoration: none;' href='" + item["href"] + "' target='_blank' rel='noopener noreferrer nofollow'>" + short_name + "</a>";
2195
2225
  }
2196
- _html.push("<span title='", item["name"], "'>", short_name, ":");
2226
+ let title = item["name"];
2227
+ if (item["code"]) {
2228
+ title = item["name"] + "(" + item["code"] + ")";
2229
+ }
2230
+ _html.push("<span title='", title, "'>", short_name, ":");
2197
2231
  _html.push(Util.pack_index_data(item["value"], item["change_rate"]));
2198
2232
  _html.push("</span> ");
2199
2233
  });