sbd-npm 1.1.94 → 1.1.97

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.
package/util.js CHANGED
@@ -262,7 +262,7 @@ const Util = {
262
262
  return location;
263
263
  }
264
264
  if (location_name === "") {
265
- location_name = location.length > 10 ? location.substr(0, 10) : location;
265
+ location_name = location.length > 20 ? location.substr(0, 20) : location;
266
266
  }
267
267
  return "<a target='_blank' class='link_cls map_link' rel='noopener noreferrer nofollow' href='https://map.baidu.com/m?fr=ps01000&word=" + location + "'>" + location_name + "</a>";
268
268
  }
@@ -281,7 +281,7 @@ const Util = {
281
281
  return location;
282
282
  }
283
283
  if (location_name === "") {
284
- location_name = location.length > 10 ? location.substr(0, 10) : location;
284
+ location_name = location.length > 20 ? location.substr(0, 20) : location;
285
285
  }
286
286
  return "<a target='_blank' class='link_cls map_link' rel='noopener noreferrer nofollow' href='https://www.google.com/maps?&hl=zh-Hans&q=" + location + "'>" + location_name + "</a>";
287
287
  }
@@ -1917,6 +1917,7 @@ const Util = {
1917
1917
  let valid_code_list = [];
1918
1918
  let total_change_percent = 0;
1919
1919
  let total_year_change_percent = 0;
1920
+ let total_d5_change_percent = 0;
1920
1921
  $.each(j, function (code, item) {
1921
1922
  if (item["price"] && item["previous_price"] && item["price"] > 0 && item["previous_price"] > 0) {
1922
1923
  valid_code_list.push(item["code"]);
@@ -1924,6 +1925,9 @@ const Util = {
1924
1925
  if (item["year_price"] && item["year_price"] > 0) {
1925
1926
  total_year_change_percent += ((item["price"] - item["year_price"]) / item["year_price"]);
1926
1927
  }
1928
+ if (item["d5_price"] && item["d5_price"] > 0) {
1929
+ total_d5_change_percent += ((item["price"] - item["d5_price"]) / item["d5_price"]);
1930
+ }
1927
1931
  }
1928
1932
  Util.render_price(item);
1929
1933
  if (item["holder_num"] && item["holder_num"] > 0) {
@@ -1968,29 +1972,8 @@ const Util = {
1968
1972
  if ($("#" + element_id + "_tips").length) {
1969
1973
  let average_change_percent = Math.round((total_change_percent / total_num) * 10000) / 100;
1970
1974
  let average_year_change_percent = Math.round((total_year_change_percent / total_num) * 10000) / 100;
1971
- let week_tips_id = element_id + "week_tips";
1972
- $("#" + element_id + "_tips").html('共 <span class="label label-info">' + total_num + '</span> 家 平均涨跌: ' + Util.parse_ratio(average_change_percent) + "<span id='" + week_tips_id + "'></span> 年初至今: " + Util.parse_ratio(average_year_change_percent));
1973
- let code_price_dict = {};
1974
- valid_code_list.forEach(function (code) {
1975
- code_price_dict[code] = j[code]["price"];
1976
- });
1977
- Util.post("/action", {action: "code_d5_price", code_list: code_list.join("-")}, function (j) {
1978
- let total_num = 0;
1979
- let total_week_change_percent = 0;
1980
- $.each(j, function (code, d5_price) {
1981
- if (d5_price > 0 && code_price_dict[code]) {
1982
- total_num += 1;
1983
- total_week_change_percent += ((code_price_dict[code] - d5_price) / d5_price);
1984
- $(".d5_price_" + code).each(function () {
1985
- $(this).html(Util.year_price_rate(code_price_dict[code], d5_price));
1986
- });
1987
- }
1988
- });
1989
- if (total_num > 0) {
1990
- let average_week_change_percent = Math.round((total_week_change_percent / total_num) * 10000) / 100;
1991
- $("#" + week_tips_id).html(" 最近5日: " + Util.parse_ratio(average_week_change_percent));
1992
- }
1993
- });
1975
+ let average_d5_change_percent = Math.round((total_d5_change_percent / total_num) * 10000) / 100;
1976
+ $("#" + element_id + "_tips").html('共 <span class="label label-info">' + total_num + '</span> 家 平均涨跌: ' + Util.parse_ratio(average_change_percent) + " 最近5日: " + Util.parse_ratio(average_d5_change_percent) + " 年初至今: " + Util.parse_ratio(average_year_change_percent));
1994
1977
  }
1995
1978
  }
1996
1979
  Util.hide_tips();