sbd-npm 1.3.12 → 1.3.13
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/package.json +1 -1
- package/util.js +47 -9
package/package.json
CHANGED
package/util.js
CHANGED
@@ -82,6 +82,7 @@ const Util = {
|
|
82
82
|
window.open(Util.array_rand(url_arr), "_blank");
|
83
83
|
}
|
84
84
|
});
|
85
|
+
$("#save_page_content").click(Util.save_page_content_image);
|
85
86
|
|
86
87
|
$('#stock').keyup(function () {
|
87
88
|
let st_obj = $("#search-tips");
|
@@ -181,6 +182,48 @@ const Util = {
|
|
181
182
|
return url;
|
182
183
|
},
|
183
184
|
|
185
|
+
/**
|
186
|
+
* 当前页面内容保存为图片
|
187
|
+
*/
|
188
|
+
save_page_content_image: function() {
|
189
|
+
if (!Util.is_load) {
|
190
|
+
Util.is_load = true;
|
191
|
+
Util.show_loading();
|
192
|
+
// 获取要截取的HTML元素
|
193
|
+
let element = document.getElementById('page_content');
|
194
|
+
// 创建canvas元素
|
195
|
+
let canvas = document.createElement("canvas");
|
196
|
+
canvas.width = element.offsetWidth;
|
197
|
+
canvas.height = element.offsetHeight;
|
198
|
+
// 将html元素渲染到canvas上
|
199
|
+
html2canvas(element).then((canvas) => {
|
200
|
+
// 获取Canvas上下文对象
|
201
|
+
//let ctx = canvas.getContext('2d');
|
202
|
+
// 添加水印
|
203
|
+
//ctx.font = '30px Arial';
|
204
|
+
//ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
|
205
|
+
//let text = 'Stock Big Data';
|
206
|
+
//let textSize = ctx.measureText(text);
|
207
|
+
//let centerX = (canvas.width - textSize.width) / 2;
|
208
|
+
//let centerY = canvas.height / 2;
|
209
|
+
//ctx.fillText(text, centerX, centerY);
|
210
|
+
|
211
|
+
// 创建一个新的图像对象
|
212
|
+
let img = new Image();
|
213
|
+
// 设置图像的源为canvas中的内容
|
214
|
+
img.src = canvas.toDataURL("image/png");
|
215
|
+
// 创建一个下载链接并模拟点击
|
216
|
+
let link = document.createElement("a");
|
217
|
+
link.download = "sbd_page_content_" + Util.now() + ".png";
|
218
|
+
link.href = img.src;
|
219
|
+
link.click();
|
220
|
+
|
221
|
+
Util.is_load = false;
|
222
|
+
Util.hide_tips();
|
223
|
+
});
|
224
|
+
}
|
225
|
+
},
|
226
|
+
|
184
227
|
/**
|
185
228
|
* https://api.jquery.com/jquery.ajax/
|
186
229
|
* $.ajax 方法参数:
|
@@ -1106,8 +1149,7 @@ const Util = {
|
|
1106
1149
|
Util.init_modal_skeleton(component_id, modal_content_html);
|
1107
1150
|
let component_obj = $('#' + component_id);
|
1108
1151
|
component_obj.on('shown.bs.modal', function (e) {
|
1109
|
-
let
|
1110
|
-
let fund_code = $(obj).attr("data-val");
|
1152
|
+
let fund_code = $(e.relatedTarget).attr("data-val");
|
1111
1153
|
Util.fetch_public_fund_detail(fund_code, component_id);
|
1112
1154
|
});
|
1113
1155
|
component_obj.on('hidden.bs.modal', function () {
|
@@ -1344,8 +1386,7 @@ const Util = {
|
|
1344
1386
|
});
|
1345
1387
|
let component_obj = $('#' + component_id);
|
1346
1388
|
component_obj.on('shown.bs.modal', function (e) { // 此事件在模态框已经显示出来触发
|
1347
|
-
let
|
1348
|
-
let currency = $(obj).attr("data-code");
|
1389
|
+
let currency = $(e.relatedTarget).attr("data-code");
|
1349
1390
|
Util.set_table_loading(component_id + "_body_body");
|
1350
1391
|
if ($("#currency_modal_start_date").length <= 0) {
|
1351
1392
|
Util.init_range_date("currency_modal_start_end_date", Util, "render_currency_modal", 60);
|
@@ -1437,8 +1478,7 @@ const Util = {
|
|
1437
1478
|
});
|
1438
1479
|
let component_obj = $('#' + component_id);
|
1439
1480
|
component_obj.on('shown.bs.modal', function (e) { // 此事件在模态框已经显示出来触发
|
1440
|
-
let
|
1441
|
-
let coin = $(obj).attr("data-coin");
|
1481
|
+
let coin = $(e.relatedTarget).attr("data-coin");
|
1442
1482
|
Util.set_table_loading(component_id + "_body_body");
|
1443
1483
|
if ($("#" + component_id + "_start_date").length <= 0) {
|
1444
1484
|
Util.init_range_date(component_id + "_start_end_date", Util, "render_btc_modal", 60);
|
@@ -2666,9 +2706,7 @@ const Util = {
|
|
2666
2706
|
* @returns {string}
|
2667
2707
|
*/
|
2668
2708
|
digit_compare_trend: function (digit, previous_digit) {
|
2669
|
-
let cls = "";
|
2670
|
-
let trend_ratio = "(0)";
|
2671
|
-
let ratio_val = 0;
|
2709
|
+
let cls = "", trend_ratio = "(0)", ratio_val = 0;
|
2672
2710
|
if (digit > 0 && previous_digit > 0) {
|
2673
2711
|
if (digit > previous_digit) {
|
2674
2712
|
cls = "text-danger";
|