sbd-npm 1.2.29 → 1.2.32
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/.npmignore +1 -0
- package/package.json +1 -1
- package/util.js +87 -64
package/.npmignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
sbd-npm.md
|
package/package.json
CHANGED
package/util.js
CHANGED
@@ -876,6 +876,8 @@ const Util = {
|
|
876
876
|
head_cols.push({"name": "成交均价", "table_sort": 1});
|
877
877
|
head_cols.push({"name": "股东数", "table_sort": 1});
|
878
878
|
head_cols.push({"name": "备注", "id": "stock_category_remark_title"});
|
879
|
+
} else {
|
880
|
+
head_cols.unshift({"name": ""});
|
879
881
|
}
|
880
882
|
let table_options = {
|
881
883
|
"element_id": table_id,
|
@@ -904,17 +906,19 @@ const Util = {
|
|
904
906
|
|
905
907
|
render_stock_category_html: function () {
|
906
908
|
if (Util["stock_category_table_id"]) {
|
907
|
-
let _html = [];
|
908
|
-
let
|
909
|
+
let _html = [], total_num = 0;
|
910
|
+
let is_us = $("#stock_category_remark_title").length === 0 ? 1 : 0;
|
909
911
|
if (Util["stock_category_data"]) {
|
910
912
|
let industry = $("#stock_category_industry").val();
|
911
913
|
let area = $("#stock_category_area").val();
|
912
|
-
let is_us = $("#stock_category_remark_title").length === 0 ? 1 : 0;
|
913
914
|
Util["stock_category_data"].forEach(function (item) {
|
914
915
|
if (Util.is_industry_area(item, industry, area)) {
|
915
916
|
total_num++;
|
916
917
|
_html.push("<tr>");
|
917
918
|
item["code"] = item["code"].toLowerCase();
|
919
|
+
if (is_us === 1) {
|
920
|
+
_html.push('<td>', Util.us_logo_html(item["code"]), '</td>');
|
921
|
+
}
|
918
922
|
_html = Util.stock_basics_html(_html, item);
|
919
923
|
_html.push("<td id='high_", item["code"], "'>0</td>");
|
920
924
|
_html.push("<td id='low_", item["code"], "'>0</td>");
|
@@ -932,6 +936,11 @@ const Util = {
|
|
932
936
|
});
|
933
937
|
}
|
934
938
|
Util.render_table_html(Util["stock_category_table_id"] + "_body", _html);
|
939
|
+
if (is_us === 1) {
|
940
|
+
$("img").on("error", function () {
|
941
|
+
$(this).attr("src", "https://storage.googleapis.com/iex/api/logos/LI.png");
|
942
|
+
});
|
943
|
+
}
|
935
944
|
$("#" + Util["stock_category_table_id"] + "_body_tips").html('共 <span class="label label-info">' + total_num + '</span> 家');
|
936
945
|
}
|
937
946
|
},
|
@@ -1847,70 +1856,84 @@ const Util = {
|
|
1847
1856
|
}
|
1848
1857
|
}
|
1849
1858
|
$(this).click(function () {
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
}
|
1882
|
-
};
|
1883
|
-
row_arr.sort(function (row1, row2) {
|
1884
|
-
let td1_val = get_td_value(row1);
|
1885
|
-
let td2_val = get_td_value(row2);
|
1886
|
-
return $.isNumeric(td1_val) && $.isNumeric(td2_val) ? td1_val - td2_val : td1_val.localeCompare(td2_val);
|
1887
|
-
});
|
1888
|
-
let sort_cls = "fa-sort-asc";
|
1889
|
-
this.asc = !this.asc;
|
1890
|
-
if (!this.asc) {
|
1891
|
-
row_arr = row_arr.reverse();
|
1892
|
-
sort_cls = "fa-sort-desc";
|
1859
|
+
Util.sort_table_row($(this));
|
1860
|
+
});
|
1861
|
+
});
|
1862
|
+
},
|
1863
|
+
|
1864
|
+
/**
|
1865
|
+
* 对表格每一行排序
|
1866
|
+
* @param td_obj 表格里的单元格对象
|
1867
|
+
*/
|
1868
|
+
sort_table_row: function (td_obj) {
|
1869
|
+
let table = td_obj.parents('table').eq(0);
|
1870
|
+
let row_arr = table.find('tr:gt(0)').toArray();
|
1871
|
+
let td_index = td_obj.index();
|
1872
|
+
row_arr.sort(function (row1, row2) {
|
1873
|
+
let td1_val = Util.get_table_td_value(row1, td_index);
|
1874
|
+
let td2_val = Util.get_table_td_value(row2, td_index);
|
1875
|
+
return $.isNumeric(td1_val) && $.isNumeric(td2_val) ? td1_val - td2_val : td1_val.localeCompare(td2_val);
|
1876
|
+
});
|
1877
|
+
let sort_cls = "fa-sort-asc";
|
1878
|
+
this.asc = !this.asc;
|
1879
|
+
if (!this.asc) {
|
1880
|
+
row_arr = row_arr.reverse();
|
1881
|
+
sort_cls = "fa-sort-desc";
|
1882
|
+
}
|
1883
|
+
table.children('tbody').empty().html(row_arr);
|
1884
|
+
table.find("i").each(function () {
|
1885
|
+
if ($(this).hasClass("fa")) {
|
1886
|
+
$(this).removeClass("fa-sort-asc");
|
1887
|
+
$(this).removeClass("fa-sort-desc");
|
1888
|
+
if (!$(this).hasClass("fa-sort")) {
|
1889
|
+
$(this).addClass("fa-sort");
|
1893
1890
|
}
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1891
|
+
$(this).parent().removeClass("info");
|
1892
|
+
}
|
1893
|
+
});
|
1894
|
+
td_obj.find("i").each(function () {
|
1895
|
+
if ($(this).hasClass("fa")) {
|
1896
|
+
$(this).removeClass("fa-sort");
|
1897
|
+
$(this).addClass(sort_cls);
|
1898
|
+
}
|
1899
|
+
});
|
1900
|
+
td_obj.addClass("info");
|
1901
|
+
},
|
1902
|
+
|
1903
|
+
/**
|
1904
|
+
* 获取表格的单元格值
|
1905
|
+
* @param row
|
1906
|
+
* @param td_index
|
1907
|
+
*/
|
1908
|
+
get_table_td_value: function (row, td_index) {
|
1909
|
+
let td_obj = $(row).children('td').eq(td_index);
|
1910
|
+
if (td_obj.attr("data-val")) {
|
1911
|
+
return td_obj.attr("data-val");
|
1912
|
+
} else {
|
1913
|
+
let td_val = td_obj.text();
|
1914
|
+
// 2017-12-7 这种时间格式
|
1915
|
+
if (Util.regexp_date_yyyy_mm_dd(td_val)) {
|
1916
|
+
return Util.format_to_second(td_val);
|
1917
|
+
} else {
|
1918
|
+
// 174.36(+0.79%) 括号里的数字
|
1919
|
+
let bracket_re = /\(([-+]?\d*\.?\d+|[-+]?\d+|\d+)\%?\)/;
|
1920
|
+
let match_arr = bracket_re.exec(td_val);
|
1921
|
+
if ($.isArray(match_arr)) {
|
1922
|
+
if (match_arr.length >= 2) {
|
1923
|
+
return match_arr[1];
|
1903
1924
|
}
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1925
|
+
return 0;
|
1926
|
+
} else {
|
1927
|
+
// 匹配数字
|
1928
|
+
let digit_re = /([-+]?\d*\.?\d+|[-+]?\d+|\d+)/;
|
1929
|
+
match_arr = digit_re.exec(td_val);
|
1930
|
+
if ($.isArray(match_arr) && match_arr[0]) {
|
1931
|
+
return match_arr[0];
|
1909
1932
|
}
|
1910
|
-
|
1911
|
-
|
1912
|
-
}
|
1913
|
-
}
|
1933
|
+
return Util.filter_chinese(td_val).replace("%", "");
|
1934
|
+
}
|
1935
|
+
}
|
1936
|
+
}
|
1914
1937
|
},
|
1915
1938
|
|
1916
1939
|
/**
|