sbd-npm 1.1.10 → 1.1.14

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 +62 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.1.10",
3
+ "version": "1.1.14",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -616,9 +616,23 @@ let Util = {
616
616
  _html.push('</tr></tbody>');
617
617
  _html.push('</table>');
618
618
  let tz_obj = $("#" + options["table_zone_id"]);
619
- tz_obj.html(_html.join(""));
619
+ if (tz_obj.hasClass("panel")) {
620
+ tz_obj.find("table").each(function () {
621
+ $(this).remove();
622
+ });
623
+ tz_obj.append(_html.join(""));
624
+ } else {
625
+ tz_obj.html(_html.join(""));
626
+ }
620
627
  if (Util.is_mobile() && !tz_obj.hasClass("table-responsive")) {
621
- tz_obj.addClass("table-responsive");
628
+ let tz_obj_parent = tz_obj.parent();
629
+ if (!tz_obj_parent.hasClass("table-responsive")) {
630
+ if (tz_obj_parent.hasClass("row")) {
631
+ tz_obj_parent.addClass("table-responsive");
632
+ } else {
633
+ tz_obj.addClass("table-responsive");
634
+ }
635
+ }
622
636
  }
623
637
  if (is_table_sort === 1) {
624
638
  Util.table_sort();
@@ -1321,6 +1335,47 @@ let Util = {
1321
1335
  obj.tooltip();
1322
1336
  },
1323
1337
 
1338
+ init_stock_stuff: function (element_id, index_list, is_us = 0) {
1339
+ let code_list = Util.get_code_list($("#" + element_id));
1340
+ if (code_list.length > 0) {
1341
+ Util.show_tips("Loading...");
1342
+ //获取股票详情数据
1343
+ $.post("/action", {action: "code_detail", code_list: code_list.join("-")}, function (j) {
1344
+ $.each(j, function (code, item) {
1345
+ Util.render_price(item);
1346
+ if ($("#remark_" + code).length) {
1347
+ let remark = "";
1348
+ if (parseInt(item["down_day"]) > 0) {
1349
+ let down_ratio = "";
1350
+ if (item["down_ratio"] > 0) {
1351
+ down_ratio = "(" + item["down_ratio"] + "%)";
1352
+ }
1353
+ remark += "<b>" + item["down_day"] + "天连跌" + down_ratio + "</b><br />";
1354
+ }
1355
+ if (parseInt(item["ma_trend"]) > 0) {
1356
+ remark += "<b>低于 " + item["ma_trend"] + " 日均线</b><br />";
1357
+ }
1358
+ if (parseInt(item["is_down_macd"]) > 0) {
1359
+ remark += "<b>MACD 下行</b><br />";
1360
+ }
1361
+ if (item["is_msci"] === 1) {
1362
+ remark += "<b>MSCI 成份股</b><br />";
1363
+ }
1364
+ if (item["is_hkscc"] === 1) {
1365
+ remark += "<b>港交所成份股</b><br />";
1366
+ }
1367
+ if (item["is_hs300s"] === 1) {
1368
+ remark += "<b>沪深300成份股</b><br />";
1369
+ }
1370
+ $("#remark_" + code).html(remark);
1371
+ }
1372
+ });
1373
+ Util.refresh_index_price(element_id, index_list.join("-"), is_us);
1374
+ Util.hide_tips();
1375
+ }, "json");
1376
+ }
1377
+ },
1378
+
1324
1379
  countdown_func: function (interval, tips_id, callback_func) {
1325
1380
  if (interval > 0) {
1326
1381
  $("#" + tips_id).html("交易中, " + interval + " 秒后刷新");
@@ -1348,11 +1403,12 @@ let Util = {
1348
1403
  refresh_index_price: function (element_id, index_list, is_us = 0, us_market_status = -1) {
1349
1404
  let code_list = Util.get_code_list($("#" + element_id));
1350
1405
  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) {
1406
+ $.post("/action", {action: "index_price", index_list: index_list, code_list: code_list.join("-")}, function (j) {
1353
1407
  // 当前行情指数
1354
- let index_data_html = Util.parse_index_data(j["index_data"]);
1355
- $("#index_data").html(index_data_html);
1408
+ if (j["index_data"] && $("#index_data").length) {
1409
+ let index_data_html = Util.parse_index_data(j["index_data"]);
1410
+ $("#index_data").html(index_data_html);
1411
+ }
1356
1412
  code_list.forEach(function (code) {
1357
1413
  if (j["price_data"].hasOwnProperty(code)) {
1358
1414
  Util.render_price(j["price_data"][code]);