sbd-npm 1.1.69 → 1.1.70

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 +24 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.1.69",
3
+ "version": "1.1.70",
4
4
  "description": "Stock Big Data",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -333,22 +333,30 @@ const Util = {
333
333
  render_price: function (item) {
334
334
  let code = item["code"];
335
335
  if (item["price"]) {
336
- let price = Util.digit_compare_trend(item["price"], item["previous_price"]);
337
- $(".price_" + code).each(function () {
338
- if ($(this).attr("data-color")) {
339
- let pre_price = parseFloat(Util.strip_bracket_string($(this).text()));
340
- if (item["price"] > pre_price && pre_price > 0) {
341
- $(this).css("background-color", "#FF7B7B");
342
- $(this).animate({backgroundColor: $(this).attr("data-color")}, 2000);
343
- } else if (item["price"] > 0 && item["price"] < pre_price) {
344
- $(this).css("background-color", "#ADFFAD");
345
- $(this).animate({backgroundColor: $(this).attr("data-color")}, 2000);
336
+ if ($("#price_change_" + code).length) {
337
+ let price_cls = Util.text_color(item["price"], item["previous_price"]);
338
+ $(".price_" + code).each(function () {
339
+ $(this).html("<b class='" + price_cls + "'>" + item["price"] + "</b>");
340
+ });
341
+ $("#price_change_" + code).html(Util.year_price_rate(item["price"], item["previous_price"]));
342
+ } else {
343
+ let price = Util.digit_compare_trend(item["price"], item["previous_price"]);
344
+ $(".price_" + code).each(function () {
345
+ if ($(this).attr("data-color")) {
346
+ let pre_price = parseFloat(Util.strip_bracket_string($(this).text()));
347
+ if (item["price"] > pre_price && pre_price > 0) {
348
+ $(this).css("background-color", "#FF7B7B");
349
+ $(this).animate({backgroundColor: $(this).attr("data-color")}, 2000);
350
+ } else if (item["price"] > 0 && item["price"] < pre_price) {
351
+ $(this).css("background-color", "#ADFFAD");
352
+ $(this).animate({backgroundColor: $(this).attr("data-color")}, 2000);
353
+ }
354
+ } else {
355
+ $(this).attr("data-color", $(this).css("background-color"));
346
356
  }
347
- } else {
348
- $(this).attr("data-color", $(this).css("background-color"));
349
- }
350
- $(this).html(price);
351
- });
357
+ $(this).html(price);
358
+ });
359
+ }
352
360
  $(".year_price_" + code).each(function () {
353
361
  if (item["year_price"]) {
354
362
  $(this).html(Util.year_price_rate(item["price"], item["year_price"]));
@@ -902,7 +910,7 @@ const Util = {
902
910
  let net = "--";
903
911
  if (j["net"] > 0) {
904
912
  net = j["net"];
905
- let net_cls = Util.text_color(j["change_percent"])
913
+ let net_cls = Util.text_color(j["change_percent"]);
906
914
  if (net_cls !== "") {
907
915
  net = "<b class='" + net_cls + "'>" + net + "(" + Util.to_float(j["change_percent"], 2) + "%)</b>";
908
916
  }