sbd-npm 1.2.12 → 1.2.15

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 +28 -31
  3. package/util.js +7 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.2.12",
3
+ "version": "1.2.15",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/stock_basics.js CHANGED
@@ -613,11 +613,11 @@ let Stock = {
613
613
  "element_id": "profit_table",
614
614
  "head_cols": [
615
615
  {"name": "年份季度"},
616
- {"name": "净资产收益率(ROE)", "tooltip": "Return On Equity"},
616
+ {"name": "ROE", "tooltip": "净资产收益率(Return On Equity)"},
617
617
  {"name": "净利率(%)"},
618
618
  {"name": "毛利率"},
619
619
  {"name": "净利润"},
620
- {"name": "每股收益(EPS)", "tooltip": "Earnings Per Share"},
620
+ {"name": "EPS", "tooltip": "每股收益(Earnings Per Share)"},
621
621
  {"name": "营业收入"},
622
622
  {"name": "每股主营业务收入"},
623
623
  ]
@@ -1226,11 +1226,8 @@ let Stock = {
1226
1226
  },
1227
1227
 
1228
1228
  fetch_hkex_holding: function () {
1229
+ let is_summary = Stock.hkex_holding_chart ? 0 : 1;
1229
1230
  Stock["hkex_holding_chart"] = Util.show_chart_loading(Stock["hkex_holding_chart"], "hkex_holding_line_canvas");
1230
- let is_summary = 0;
1231
- if (!Stock.hkex_holding_chart) {
1232
- is_summary = 1;
1233
- }
1234
1231
  let payload = {
1235
1232
  action: "hkex_holding",
1236
1233
  is_summary: is_summary,
@@ -1248,33 +1245,33 @@ let Stock = {
1248
1245
  volume_data.push(item["volume"]);
1249
1246
  price_data.push(item["price"]);
1250
1247
  });
1251
- if (!Stock.hkex_holding_chart && j["latest"].length > 0) {
1252
- let circulation_stock = $("#circulation_stock").attr("data-val");
1253
- let latest_html = "";
1254
- if (j["latest"].length === 1) {
1255
- let holding_num = Util.to_hundred_million(j["latest"][0]["volume"]);
1256
- let holding_rate = Math.round((holding_num / circulation_stock) * 10000) / 100;
1257
- latest_html = "最新(" + Util.seconds_to_format(j["latest"][0]["date"], "%Y-%m-%d") + "): " + holding_num + "亿股, 占 <b>" + holding_rate + "%</b> 流通股, ";
1258
- } else if (j["latest"].length === 2) {
1259
- let d1 = j["latest"][0];
1260
- let d2 = j["latest"][1];
1261
- let difference = d1["volume"] - d2["volume"];
1262
- let dist_tips = "";
1263
- if (difference > 0) {
1264
- dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["volume"])) + "股' style='color: #a94442;'>+" + Util.strip_html(Util.to_unit(difference)) + "股</b>)";
1265
- } else if (difference < 0) {
1266
- dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["volume"])) + "股' style='color: #3c763d;'>" + Util.strip_html(Util.to_unit(difference)) + "股</b>)";
1248
+ if (is_summary === 1) {
1249
+ let hhs_obj = $("#hkex_holding_summary");
1250
+ let hkex_holding_summary = "[" + Util.pack_html_link(j["url"], hhs_obj.text()) + "]";
1251
+ if (j["latest"].length > 0) {
1252
+ let circulation_stock = $("#circulation_stock").attr("data-val");
1253
+ let latest_html = "";
1254
+ if (j["latest"].length === 1) {
1255
+ let holding_num = Util.to_hundred_million(j["latest"][0]["volume"]);
1256
+ let holding_rate = Math.round((holding_num / circulation_stock) * 10000) / 100;
1257
+ latest_html = "最新(" + Util.seconds_to_format(j["latest"][0]["date"], "%Y-%m-%d") + "): " + holding_num + "亿股, 占 <b>" + holding_rate + "%</b> 流通股, ";
1258
+ } else if (j["latest"].length === 2) {
1259
+ let d1 = j["latest"][0];
1260
+ let d2 = j["latest"][1];
1261
+ let difference = d1["volume"] - d2["volume"];
1262
+ let dist_tips = "";
1263
+ if (difference > 0) {
1264
+ dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["volume"])) + "股' style='color: #a94442;'>+" + Util.strip_html(Util.to_unit(difference)) + "股</b>)";
1265
+ } else if (difference < 0) {
1266
+ dist_tips = "(<b title='" + Util.strip_html(Util.to_unit(d2["volume"])) + "股' style='color: #3c763d;'>" + Util.strip_html(Util.to_unit(difference)) + "股</b>)";
1267
+ }
1268
+ let holding_num = Util.to_hundred_million(d1["volume"]);
1269
+ let holding_rate = Math.round((holding_num / circulation_stock) * 10000) / 100;
1270
+ latest_html = "最新(" + Util.seconds_to_format(d1["date"], "%Y-%m-%d") + "): " + holding_num + "亿股" + dist_tips + ", 占 <b>" + holding_rate + "%</b> 流通股, ";
1267
1271
  }
1268
- let holding_num = Util.to_hundred_million(d1["volume"]);
1269
- let holding_rate = Math.round((holding_num / circulation_stock) * 10000) / 100;
1270
- latest_html = "最新(" + Util.seconds_to_format(d1["date"], "%Y-%m-%d") + "): " + holding_num + "亿股" + dist_tips + ", 占 <b>" + holding_rate + "%</b> 流通股, ";
1272
+ hkex_holding_summary += (latest_html + ' 最高: ' + Util.to_unit(j["high"]["volume"]) + '股(' + Util.seconds_to_format(j["high"]["date"], "%Y-%m-%d") +
1273
+ ') 最低: ' + Util.to_unit(j["low"]["volume"]) + '股(' + Util.seconds_to_format(j["low"]["date"], "%Y-%m-%d") + ')');
1271
1274
  }
1272
- let hhs_obj = $("#hkex_holding_summary");
1273
- let hkex_holding_summary = hhs_obj.text();
1274
- hkex_holding_summary = '[<a target="_blank" rel="noopener noreferrer nofollow" class="link_cls" href="' + j["url"] + '">' +
1275
- hkex_holding_summary + "</a>]" + latest_html + ' 最高: ' + Util.to_unit(j["high"]["volume"]) +
1276
- '股(' + Util.seconds_to_format(j["high"]["date"], "%Y-%m-%d") +
1277
- ') 最低: ' + Util.to_unit(j["low"]["volume"]) + '股(' + Util.seconds_to_format(j["low"]["date"], "%Y-%m-%d") + ')';
1278
1275
  hhs_obj.html(hkex_holding_summary);
1279
1276
  }
1280
1277
  Stock["hkex_holding_chart"] = Util.multi_axis_line(Stock["hkex_holding_chart"], "hkex_holding_line_canvas", date_data, '持股数', volume_data, '股价', price_data);
package/util.js CHANGED
@@ -577,6 +577,13 @@ const Util = {
577
577
  return /(iPhone|iPad|iPod|iOS|Android|Mobile)/i.test(navigator.userAgent);
578
578
  },
579
579
 
580
+ /**
581
+ * 是否苹果系的设备
582
+ */
583
+ is_macintosh: function () {
584
+ return /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent);
585
+ },
586
+
580
587
  /**
581
588
  * 分页函数
582
589
  * @param data_id