sbd-npm 1.1.9 → 1.1.13

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 (2) hide show
  1. package/package.json +1 -1
  2. package/util.js +66 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.1.9",
3
+ "version": "1.1.13",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -618,7 +618,14 @@ let Util = {
618
618
  let tz_obj = $("#" + options["table_zone_id"]);
619
619
  tz_obj.html(_html.join(""));
620
620
  if (Util.is_mobile() && !tz_obj.hasClass("table-responsive")) {
621
- tz_obj.addClass("table-responsive");
621
+ let tz_obj_parent = tz_obj.parent();
622
+ if (!tz_obj_parent.hasClass("table-responsive")) {
623
+ if (tz_obj_parent.hasClass("row")) {
624
+ tz_obj_parent.addClass("table-responsive");
625
+ } else {
626
+ tz_obj.addClass("table-responsive");
627
+ }
628
+ }
622
629
  }
623
630
  if (is_table_sort === 1) {
624
631
  Util.table_sort();
@@ -1321,6 +1328,47 @@ let Util = {
1321
1328
  obj.tooltip();
1322
1329
  },
1323
1330
 
1331
+ init_stock_stuff: function (element_id, index_list, is_us = 0) {
1332
+ let code_list = Util.get_code_list($("#" + element_id));
1333
+ if (code_list.length > 0) {
1334
+ Util.show_tips("Loading...");
1335
+ //获取股票详情数据
1336
+ $.post("/action", {action: "code_detail", code_list: code_list.join("-")}, function (j) {
1337
+ $.each(j, function (code, item) {
1338
+ Util.render_price(item);
1339
+ if ($("#remark_" + code).length) {
1340
+ let remark = "";
1341
+ if (parseInt(item["down_day"]) > 0) {
1342
+ let down_ratio = "";
1343
+ if (item["down_ratio"] > 0) {
1344
+ down_ratio = "(" + item["down_ratio"] + "%)";
1345
+ }
1346
+ remark += "<b>" + item["down_day"] + "天连跌" + down_ratio + "</b><br />";
1347
+ }
1348
+ if (parseInt(item["ma_trend"]) > 0) {
1349
+ remark += "<b>低于 " + item["ma_trend"] + " 日均线</b><br />";
1350
+ }
1351
+ if (parseInt(item["is_down_macd"]) > 0) {
1352
+ remark += "<b>MACD 下行</b><br />";
1353
+ }
1354
+ if (item["is_msci"] === 1) {
1355
+ remark += "<b>MSCI 成份股</b><br />";
1356
+ }
1357
+ if (item["is_hkscc"] === 1) {
1358
+ remark += "<b>港交所成份股</b><br />";
1359
+ }
1360
+ if (item["is_hs300s"] === 1) {
1361
+ remark += "<b>沪深300成份股</b><br />";
1362
+ }
1363
+ $("#remark_" + code).html(remark);
1364
+ }
1365
+ });
1366
+ Util.refresh_index_price(element_id, index_list.join("-"), is_us);
1367
+ Util.hide_tips();
1368
+ }, "json");
1369
+ }
1370
+ },
1371
+
1324
1372
  countdown_func: function (interval, tips_id, callback_func) {
1325
1373
  if (interval > 0) {
1326
1374
  $("#" + tips_id).html("交易中, " + interval + " 秒后刷新");
@@ -1348,13 +1396,24 @@ let Util = {
1348
1396
  refresh_index_price: function (element_id, index_list, is_us = 0, us_market_status = -1) {
1349
1397
  let code_list = Util.get_code_list($("#" + element_id));
1350
1398
  if (code_list.length > 0) {
1351
- let data = {action: "index_price", index_list: index_list, code_list: code_list.join("-")};
1352
- $.post("/action", data, function (j) {
1399
+ $.post("/action", {action: "index_price", index_list: index_list, code_list: code_list.join("-")}, function (j) {
1353
1400
  // 当前行情指数
1354
- let index_data_html = Util.parse_index_data(j["index_data"]);
1355
- $("#index_data").html(index_data_html);
1356
- $.each(j["price_data"], function (code, item) {
1357
- Util.render_price(item);
1401
+ if (j["index_data"] && $("#index_data").length) {
1402
+ let index_data_html = Util.parse_index_data(j["index_data"]);
1403
+ $("#index_data").html(index_data_html);
1404
+ }
1405
+ code_list.forEach(function (code) {
1406
+ if (j["price_data"].hasOwnProperty(code)) {
1407
+ Util.render_price(j["price_data"][code]);
1408
+ } else {
1409
+ $(".price_" + code).each(function () {
1410
+ let price = $(this).text();
1411
+ if (price.indexOf("(") === -1 && price.indexOf(")") === -1) {
1412
+ price = parseFloat(price);
1413
+ $(this).html(Util.digit_compare_trend(price, price));
1414
+ }
1415
+ });
1416
+ }
1358
1417
  });
1359
1418
  if (is_us === 1) {
1360
1419
  if (us_market_status === 1) {