sbd-npm 1.1.1 → 1.1.5

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 +23 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.1.1",
3
+ "version": "1.1.5",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -209,15 +209,14 @@ let Util = {
209
209
  * @returns {string}
210
210
  */
211
211
  map_url: function (location, location_name = "") {
212
- if (location === "--") {
213
- return location;
214
- } else if (location) {
215
- location_name = location_name === "" ? location : location_name;
216
- if (location_name.length > 8) {
217
- return "<a title='" + location + "' target='_blank' class='link_cls map_link' rel='noopener noreferrer nofollow' href='https://map.baidu.com/m?fr=ps01000&word=" + location + "'>" + location_name.substr(0, 8) + "</a>";
218
- } else {
219
- 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>";
212
+ if (location) {
213
+ if (location === "--") {
214
+ return location;
215
+ }
216
+ if (location_name === "") {
217
+ location_name = location.length > 8 ? location.substr(0, 8) : location;
220
218
  }
219
+ 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>";
221
220
  }
222
221
  return "--";
223
222
  },
@@ -284,6 +283,21 @@ let Util = {
284
283
  }
285
284
  $(this).html(price);
286
285
  });
286
+ $(".year_price_" + code).each(function () {
287
+ if (item["year_price"]) {
288
+ $(this).html(Util.year_price_rate(item["price"], item["year_price"]));
289
+ } else {
290
+ let year_price = $(this).attr("data-val");
291
+ if (year_price) {
292
+ $(this).html(Util.year_price_rate(item["price"], Util.to_float(year_price)));
293
+ }
294
+ }
295
+ });
296
+ if (item["high_52week"]) {
297
+ $(".high_52week_" + code).each(function () {
298
+ $(this).html(Util.year_price_rate(item["price"], item["high_52week"]));
299
+ });
300
+ }
287
301
  }
288
302
  if (item["high"]) {
289
303
  let high_price = Util.digit_compare_trend(item["high"], item["previous_price"]);
@@ -903,7 +917,7 @@ let Util = {
903
917
  array_rand: function(arr, default_val = "") {
904
918
  if (arr.length > 0) {
905
919
  let rand_index = Math.floor((Math.random() * arr.length));
906
- return url_arr[rand_index];
920
+ return arr[rand_index];
907
921
  }
908
922
  return default_val;
909
923
  },