sbd-npm 1.4.33 → 1.4.35

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/status.js +2 -51
  3. package/util.js +67 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.4.33",
3
+ "version": "1.4.35",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/status.js CHANGED
@@ -2,7 +2,7 @@ $(function () {
2
2
 
3
3
  let Status = {
4
4
 
5
- tab_token: "status_nav",
5
+ tab_token: "status_navigation",
6
6
  task_status: 0,
7
7
  task_timer_id: 0,
8
8
  data: {},
@@ -667,56 +667,7 @@ $(function () {
667
667
  });
668
668
  Status.init_word_modal();
669
669
  }
670
- Status.fetch_word_data(is_init, "");
671
- },
672
-
673
- fetch_word_data: function(is_init, day) {
674
- Util.show_loading();
675
- Util.post(location.pathname, {active_div: localStorage[Status.tab_token], is_init: is_init, day: day}, function (j) {
676
- let html = [], index = 0;
677
- let is_mobile = Util.is_mobile();
678
- j["data"].forEach(function (item) {
679
- index++;
680
- html.push("<tr>");
681
- html.push("<td>", index, "</td>");
682
- html.push("<td>", Util.pack_html_link("https://cn.bing.com/dict/search?q=" + item["word"], item["word"]), "</td>");
683
- if (is_mobile) {
684
- html.push("<td class='text-left'>", item["chinese"], "</td>");
685
- } else {
686
- html.push("<td>", item["chinese"], "</td>");
687
- }
688
- html.push("<td>", Util.seconds_to_format(item["date"]), "</td>");
689
- html.push("<td><a href='#' data-toggle='modal' data-target='.word_modal'>修改</a> &nbsp; <a class='word_del' href='#'>删除</a></td>");
690
- html.push("</tr>");
691
- });
692
- Util.render_table_html("word_process_div_body", html);
693
- $("#word_num").html("共 <span class='label label-info'>" + index + "</span> 条");
694
- if (j["day_num"]) {
695
- let day_num_html = [];
696
- day_num_html.push('<option value="">全部</option>');
697
- j["day_num"].forEach(function (item) {
698
- day_num_html.push('<option value="', item["day"], '">', item["day"], '(', item["num"], ')</option>');
699
- });
700
- let wdn_obj = $("#word_day_num");
701
- wdn_obj.html(day_num_html.join(""));
702
- wdn_obj.change(function() {
703
- let day = $("#word_day_num").val();
704
- Status.fetch_word_data(0, day);
705
- });
706
- }
707
- $(".word_del").each(function () {
708
- $(this).click(function () {
709
- let tr_obj = $(this).parent().parent();
710
- let word = $(tr_obj).children('td').eq(1).text();
711
- if (confirm("是否确定要删除“ " + word + " ” ?")) {
712
- Util.post(location.pathname, {"active_div": "word_del", "word": word}, function () {
713
- $(tr_obj).remove();
714
- });
715
- }
716
- });
717
- });
718
- Util.hide_tips();
719
- });
670
+ Util.fetch_word_data(is_init, "", "");
720
671
  },
721
672
 
722
673
  init_client_action_modal: function () {
package/util.js CHANGED
@@ -62,7 +62,11 @@ const Util = {
62
62
  $("#search-stock").click(function () {
63
63
  let code = $("#stock").val();
64
64
  if (code) {
65
- window.open("/stock/" + code, "_blank");
65
+ if (window.location.pathname === "/status" && $("#word").hasClass('active') && (Util.is_alpha(code) || Util.is_chinese(code))) {
66
+ Util.fetch_word_data(0, "", code);
67
+ } else {
68
+ window.open("/stock/" + code, "_blank");
69
+ }
66
70
  } else {
67
71
  Util.post("/action", {action: "rand_stock", stock_type: "cn"}, function (j) {
68
72
  if (j["code"]) {
@@ -99,6 +103,9 @@ const Util = {
99
103
  let key_word = $(this).val();
100
104
  if (key_word) {
101
105
  if (Util.is_has_chinese(key_word) || (Util.is_alpha(key_word) && key_word.length >= 2) || ($.isNumeric(key_word) && key_word.length >= 3)) {
106
+ if (window.location.pathname === "/status" && $("#word").hasClass('active')) {
107
+ return false;
108
+ }
102
109
  Util.hide_tips();
103
110
  clearTimeout(Util.stock_timer_id);
104
111
  $("#search-tips").css("display", "none");
@@ -1646,6 +1653,55 @@ const Util = {
1646
1653
  });
1647
1654
  },
1648
1655
 
1656
+ fetch_word_data: function(is_init, specify_day, search_key) {
1657
+ Util.show_loading();
1658
+ Util.post(location.pathname, {active_div: "word", is_init: is_init, specify_day: specify_day, search_key: search_key}, function (j) {
1659
+ let html = [], index = 0;
1660
+ let is_mobile = Util.is_mobile();
1661
+ j["data"].forEach(function (item) {
1662
+ index++;
1663
+ html.push("<tr>");
1664
+ html.push("<td>", index, "</td>");
1665
+ html.push("<td>", Util.pack_html_link("https://cn.bing.com/dict/search?q=" + item["word"], item["word"]), "</td>");
1666
+ if (is_mobile) {
1667
+ html.push("<td class='text-left'>", item["chinese"], "</td>");
1668
+ } else {
1669
+ html.push("<td>", item["chinese"], "</td>");
1670
+ }
1671
+ html.push("<td>", Util.seconds_to_format(item["date"]), "</td>");
1672
+ html.push("<td><a href='#' data-toggle='modal' data-target='.word_modal'>修改</a> &nbsp; <a class='word_del' href='#'>删除</a></td>");
1673
+ html.push("</tr>");
1674
+ });
1675
+ Util.render_table_html("word_process_div_body", html);
1676
+ $("#word_num").html("共 <span class='label label-info'>" + index + "</span> 条");
1677
+ if (j["day_num"]) {
1678
+ let day_num_html = [];
1679
+ day_num_html.push('<option value="">全部</option>');
1680
+ j["day_num"].forEach(function (item) {
1681
+ day_num_html.push('<option value="', item["day"], '">', item["day"], '(', item["num"], ')</option>');
1682
+ });
1683
+ let wdn_obj = $("#word_day_num");
1684
+ wdn_obj.html(day_num_html.join(""));
1685
+ wdn_obj.change(function() {
1686
+ let appoint_day = $("#word_day_num").val();
1687
+ Util.fetch_word_data(0, appoint_day, "");
1688
+ });
1689
+ }
1690
+ $(".word_del").each(function () {
1691
+ $(this).click(function () {
1692
+ let tr_obj = $(this).parent().parent();
1693
+ let word = $(tr_obj).children('td').eq(1).text();
1694
+ if (confirm("是否确定要删除“ " + word + " ” ?")) {
1695
+ Util.post(location.pathname, {"active_div": "word_del", "word": word}, function () {
1696
+ $(tr_obj).remove();
1697
+ });
1698
+ }
1699
+ });
1700
+ });
1701
+ Util.hide_tips();
1702
+ });
1703
+ },
1704
+
1649
1705
  init_category_top_modal: function(category_top_type) {
1650
1706
  Util.init_modal_skeleton("category_top_modal", '');
1651
1707
  $("#category_top_modal_title").html("<select id='category_top_type'><option value='1'>行业ETF</option><option value='2'>同花顺行业</option><option value='3'>申万行业</option></select> 每日涨幅第一的时间统计分析(时间为过去一年内)");
@@ -2491,7 +2547,7 @@ const Util = {
2491
2547
  * @returns {boolean}
2492
2548
  */
2493
2549
  is_alpha: function (str) {
2494
- return /^[A-Za-z]*$/.test(str);
2550
+ return /^[A-Za-z]+$/.test(str);
2495
2551
  },
2496
2552
 
2497
2553
  /**
@@ -2503,6 +2559,15 @@ const Util = {
2503
2559
  return /^\d+$/.test(str);
2504
2560
  },
2505
2561
 
2562
+ /**
2563
+ * 是否都是中文
2564
+ * @param str
2565
+ * @returns {boolean}
2566
+ */
2567
+ is_chinese: function (str) {
2568
+ return /^[\u4e00-\u9fa5]+$/.test(str);
2569
+ },
2570
+
2506
2571
  /**
2507
2572
  * 判断一个字符串是否有中文
2508
2573
  * @param str