sbd-npm 1.2.72 → 1.2.74

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 +7 -17
  3. package/util.js +53 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.72",
3
+ "version": "1.2.74",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -238,18 +238,8 @@ let Stock = {
238
238
  $(this).attr("target", "_blank");
239
239
  $(this).attr("rel", "noopener noreferrer nofollow");
240
240
  });
241
- // 日均线抵扣价
242
- if (item["price"] && item["ma_deduction"] && item["ma_deduction"].length > 0) {
243
- let ma_deduction_html = [];
244
- item["ma_deduction"].forEach(function (ma) {
245
- if (ma["deduction_price"] > 0) {
246
- let deduction_cls = Util.text_color(item["price"], ma["deduction_price"]);
247
- let ma_cls = Util.text_color(item["price"], ma["ma"]);
248
- ma_deduction_html.push(ma["day"] + "日均线:<b class='" + ma_cls + "'>" + ma["ma"] + "</b>(<b class='" + deduction_cls + "'>" + ma["deduction_price"] + "</b>)");
249
- }
250
- });
251
- $("#ma_deduction").html(ma_deduction_html.join("、 "));
252
- }
241
+ // 日均线/抵扣价数据
242
+ Util.render_ma_deduction(item, "ma_deduction");
253
243
  if (item["boll_up"] && item["boll_up"] > 0 && item["boll_down"] && item["boll_down"] > 0) {
254
244
  $("#boll").html("<a title='当前上轨线 / 当前下轨线' target='_blank' rel='noopener noreferrer nofollow' href='" + Util.get_url("trend_boll") + "'><b class='text-danger'>" + Util.to_float(item["boll_up"], 2) + "</b> / <b class='text-success'>" + Util.to_float(item["boll_down"], 2) + "</b></a>");
255
245
  }
@@ -400,11 +390,11 @@ let Stock = {
400
390
  Util.render_table_html("big_deal_table_body", _html);
401
391
  _html = [];
402
392
  _html.push("<tr>");
403
- _html.push("<td><b class='", Util.text_color(total_net_inflow), "'>", Util.to_unit(total_net_inflow), "</b></td>");
404
- _html.push("<td><b class='", Util.text_color(day20_net_inflow), "'>", Util.to_unit(day20_net_inflow), "</b></td>");
405
- _html.push("<td><b class='", Util.text_color(day10_net_inflow), "'>", Util.to_unit(day10_net_inflow), "</b></td>");
406
- _html.push("<td><b class='", Util.text_color(day5_net_inflow), "'>", Util.to_unit(day5_net_inflow), "</b></td>");
407
- _html.push("<td><b class='", Util.text_color(day3_net_inflow), "'>", Util.to_unit(day3_net_inflow), "</b></td>");
393
+ _html.push("<td><b class='", Util.text_color(total_net_inflow), "'>", Util.to_unit(total_net_inflow, 4), "</b></td>");
394
+ _html.push("<td><b class='", Util.text_color(day20_net_inflow), "'>", Util.to_unit(day20_net_inflow, 4), "</b></td>");
395
+ _html.push("<td><b class='", Util.text_color(day10_net_inflow), "'>", Util.to_unit(day10_net_inflow, 4), "</b></td>");
396
+ _html.push("<td><b class='", Util.text_color(day5_net_inflow), "'>", Util.to_unit(day5_net_inflow, 4), "</b></td>");
397
+ _html.push("<td><b class='", Util.text_color(day3_net_inflow), "'>", Util.to_unit(day3_net_inflow, 4), "</b></td>");
408
398
  _html.push("</tr>");
409
399
  Util.render_table_html("big_deal_summary_table_body", _html);
410
400
  }
package/util.js CHANGED
@@ -144,15 +144,17 @@ const Util = {
144
144
  let _html = [];
145
145
  _html.push('<div class="menu_section">');
146
146
  _html.push('<ul class="nav side-menu">');
147
- MenuList.forEach(function (menu) {
148
- _html.push('<li><a><i class="fa fa-', menu["icon"], '"></i> ', menu["name"], ' <span class="fa fa-chevron-down"></span></a>');
149
- _html.push('<ul class="nav child_menu">');
150
- menu["menu"].forEach(function (m) {
151
- _html.push('<li><a href="', m["url"], '">', m["name"], '</a></li>');
147
+ if (typeof MenuList != "undefined") {
148
+ MenuList.forEach(function (menu) {
149
+ _html.push('<li><a><i class="fa fa-', menu["icon"], '"></i> ', menu["name"], ' <span class="fa fa-chevron-down"></span></a>');
150
+ _html.push('<ul class="nav child_menu">');
151
+ menu["menu"].forEach(function (m) {
152
+ _html.push('<li><a href="', m["url"], '">', m["name"], '</a></li>');
153
+ });
154
+ _html.push('</ul>');
155
+ _html.push('</li>');
152
156
  });
153
- _html.push('</ul>');
154
- _html.push('</li>');
155
- });
157
+ }
156
158
  _html.push('</div>');
157
159
  _html.push('</div>');
158
160
  $("#sidebar-menu").html(_html.join(""));
@@ -165,13 +167,15 @@ const Util = {
165
167
  */
166
168
  get_url: function (key) {
167
169
  let url = location.pathname;
168
- MenuList.forEach(function (menu) {
169
- menu["menu"].forEach(function (m) {
170
- if (m["key"] === key) {
171
- url = m["url"];
172
- }
170
+ if (typeof MenuList != "undefined") {
171
+ MenuList.forEach(function (menu) {
172
+ menu["menu"].forEach(function (m) {
173
+ if (m["key"] === key) {
174
+ url = m["url"];
175
+ }
176
+ });
173
177
  });
174
- });
178
+ }
175
179
  return url;
176
180
  },
177
181
 
@@ -1321,9 +1325,11 @@ const Util = {
1321
1325
  html.push('<label for="', element_id, '"></label>');
1322
1326
  html.push('<select id="', element_id, '" class="form-control">');
1323
1327
  html.push('<option value="">指数板块</option>');
1324
- ClassifyList.forEach(function (classify) {
1325
- html.push('<option value="', classify, '">', classify, '</option>');
1326
- });
1328
+ if (typeof ClassifyList != "undefined") {
1329
+ ClassifyList.forEach(function (classify) {
1330
+ html.push('<option value="', classify, '">', classify, '</option>');
1331
+ });
1332
+ }
1327
1333
  html.push('</select>');
1328
1334
  $("#" + component_id).html(html.join(""));
1329
1335
  },
@@ -1360,11 +1366,13 @@ const Util = {
1360
1366
  if (is_select !== 1) {
1361
1367
  html.push('<option value="">指数</option>');
1362
1368
  }
1363
- IndexList.forEach(function (item) {
1364
- if (index_type === 0 || (index_type === 1 && item["is_industry"] === 1) || (index_type === 2 && item["is_key"] === 1)) {
1365
- html.push('<option ', ((item["code"] === "SH000906" && is_select === 1) ? "selected" : ""), ' value="', item["code"], '">', item["name"], '</option>');
1366
- }
1367
- });
1369
+ if (typeof IndexList != "undefined") {
1370
+ IndexList.forEach(function (item) {
1371
+ if (index_type === 0 || (index_type === 1 && item["is_industry"] === 1) || (index_type === 2 && item["is_key"] === 1)) {
1372
+ html.push('<option ', ((item["code"] === "SH000906" && is_select === 1) ? "selected" : ""), ' value="', item["code"], '">', item["name"], '</option>');
1373
+ }
1374
+ });
1375
+ }
1368
1376
  html.push('</select>');
1369
1377
  $("#" + component_id).html(html.join(""));
1370
1378
  },
@@ -2536,6 +2544,29 @@ const Util = {
2536
2544
  }
2537
2545
  },
2538
2546
 
2547
+ /**
2548
+ * 组装日均线/抵扣价数据
2549
+ * @param item
2550
+ * @param element_id
2551
+ */
2552
+ render_ma_deduction: function (item, element_id) {
2553
+ if (item["price"] && item["ma_deduction"] && item["ma_deduction"].length > 0) {
2554
+ let ma_deduction_html = [];
2555
+ item["ma_deduction"].forEach(function (ma) {
2556
+ if (ma["deduction_price"] > 0) {
2557
+ let day_ma_str = ma["day"] + "日均线";
2558
+ if (ma["day"] === 20 || ma["day"] === 60 || ma["day"] === 120) {
2559
+ day_ma_str = "<span class='label label-info'>" + day_ma_str + "</span>";
2560
+ }
2561
+ let deduction_cls = Util.text_color(item["price"], ma["deduction_price"]);
2562
+ let ma_cls = Util.text_color(item["price"], ma["ma"]);
2563
+ ma_deduction_html.push(day_ma_str + ":<b class='" + ma_cls + "'>" + ma["ma"] + "</b>(<b class='" + deduction_cls + "'>" + ma["deduction_price"] + "</b>)");
2564
+ }
2565
+ });
2566
+ $("#" + element_id).html(ma_deduction_html.join("&nbsp;&nbsp;"));
2567
+ }
2568
+ },
2569
+
2539
2570
  /**
2540
2571
  * 设置 option 的第 nth 项为默认项
2541
2572
  * @param obj