sbd-npm 1.5.32 → 1.5.34

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.5.32",
3
+ "version": "1.5.34",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
@@ -0,0 +1,554 @@
1
+ /**
2
+ * Copyright (C) 2015-present dhq <dhq314@gmail.com>
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ $(function () {
17
+
18
+ let SnowballTool = {
19
+
20
+ cn_stock_data: [],
21
+ hk_stock_data: [],
22
+ us_stock_data: [],
23
+ status_data: [],
24
+ user_dict: {},
25
+
26
+ fetch: function () {
27
+ if (Util.is_load) {
28
+ return false;
29
+ }
30
+ let key_word = $("#key_word").val().trim();
31
+ if (key_word) {
32
+ Util.show_loading();
33
+ $("#key-tips").css("display", "none");
34
+ for (const [user_id, user_name] of Object.entries(SnowballTool.user_dict)) {
35
+ if (key_word === user_name) {
36
+ key_word = user_id;
37
+ }
38
+ }
39
+ Util.post(location.pathname, {key_word: key_word}, function (j) {
40
+ $("#search_tips").remove();
41
+ $("#particles-js").remove();
42
+ if (j.user) {
43
+ $("#snowball-data").removeClass("hide");
44
+
45
+ $("#user_id").html(Util.pack_html_link("https://xueqiu.com/u/" + j.user.id, j.user.id));
46
+ let user_api_url = "https://xueqiu.com/user/show.json?id=" + j.user.id + "&_=" + Util.now();
47
+ j.user.screen_name = j.user.screen_name ? j.user.screen_name : "--";
48
+ let name_html = Util.pack_html_link(user_api_url, j.user.screen_name);
49
+ if (j.user.name_list) {
50
+ name_html += '&nbsp;<i class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-container="body" data-original-title="' + j.user.name_list.join("、") + '"></i>';
51
+ $("#user_name").html(name_html);
52
+ $("[data-toggle='tooltip']").tooltip();
53
+ } else {
54
+ $("#user_name").html(name_html);
55
+ }
56
+ let province = j.user.province;
57
+ if (j.user.city && j.user.city.length > 0 && province !== j.user.city) {
58
+ if (province === "海外") {
59
+ province = j.user.city;
60
+ } else {
61
+ province += j.user.city;
62
+ }
63
+ }
64
+ $("#province").html(province ? Util.map_url(province) : "--");
65
+ $("#ip_location").html(j.user.ip_location ? Util.map_url(j.user.ip_location) : "--");
66
+ $("#gender").html(j.user.gender === "f" ? "女" : "男");
67
+ if (j.user.friends_count) {
68
+ $("#friends_count").html(Util.pack_html_link("https://xueqiu.com/u/" + j.user.id + "#/follow", j.user.friends_count));
69
+ } else {
70
+ $("#friends_count").html(j.user.friends_count);
71
+ }
72
+ if (j.user.followers_count) {
73
+ $("#followers_count").html(Util.pack_html_link("https://xueqiu.com/u/" + j.user.id + "#/fans", j.user.followers_count));
74
+ } else {
75
+ $("#followers_count").html(j.user.followers_count);
76
+ }
77
+ if (j.user.status_count) {
78
+ $("#status_count").html(Util.pack_html_link("https://xueqiu.com/v4/statuses/user_timeline.json?&user_id=" + j.user.id + "&type=0&count=20", j.user.status_count));
79
+ } else {
80
+ $("#status_count").html(0);
81
+ }
82
+ let description = j.user.description ? j.user.description : "";
83
+ let verified_array = [];
84
+ if (j.user.verified_infos && j.user.verified_infos.length > 0) {
85
+ j.user.verified_infos.forEach(function (item) {
86
+ verified_array.push(item.verified_desc);
87
+ });
88
+ }
89
+ if (j.user.verified_description && j.user.verified_description.length > 0 && !verified_array.includes(j.user.verified_description)) {
90
+ verified_array.push(j.user.verified_description);
91
+ }
92
+ if (verified_array.length > 0) {
93
+ description += "<br>";
94
+ verified_array.forEach(function (verified) {
95
+ description += "<span class='label label-info'>" + verified + "</span> ";
96
+ });
97
+ }
98
+ $("#description").html(description);
99
+ if (j.user.created_at && j.user.created_at > 0) {
100
+ if (j.user.created_at.toString().length > 10) {
101
+ j.user.created_at = j.user.created_at / 1000;
102
+ }
103
+ $("#created_time").html(Util.seconds_to_format(j.user.created_at));
104
+ } else {
105
+ $("#created_time").html("--");
106
+ }
107
+ if (j.user.weibo_id > 0) {
108
+ $("#weibo_id").html(Util.pack_html_link("https://m.weibo.cn/profile/" + j.user.weibo_id, j.user.weibo_id));
109
+ } else {
110
+ $("#weibo_id").html("--");
111
+ }
112
+ if (j.user.profile_image_url) {
113
+ let img_array = j.user.profile_image_url.split(",");
114
+ if (img_array.length > 0) {
115
+ let avatar_url = img_array[0];
116
+ if (!avatar_url.startsWith('http')) {
117
+ avatar_url = "https:" + (j.user.photo_domain ? j.user.photo_domain : "") + img_array[0];
118
+ }
119
+ let avatar_object = $("#avatar");
120
+ avatar_object.html('<img alt="' + j.user.screen_name + '" id="avatar_img" src="' + avatar_url + '!180x180.png">');
121
+ avatar_object.attr("target", "_blank");
122
+ avatar_object.attr("href", avatar_url);
123
+ $('#avatar_img').load(function () {
124
+ SnowballTool.resize_avatar_img();
125
+ });
126
+ $("#menu_toggle").click(function () {
127
+ SnowballTool.resize_avatar_img();
128
+ });
129
+ }
130
+ }
131
+ if (j.stocks) {
132
+ $("#total_stock_num").html(j.stocks.length > 0 ? Util.pack_html_link("https://xueqiu.com/u/" + j.user.id + "#/stock", j.stocks.length) : "--");
133
+ SnowballTool.init_stock_data(j.stocks);
134
+ }
135
+ SnowballTool.render_snowball_html();
136
+ SnowballTool.status_data = [];
137
+ $("#tweet a").first().html("推文");
138
+ Util.post(location.pathname, {action: "tweet", uid: j.user.id}, function (j) {
139
+ SnowballTool.status_data = j.data ? j.data : [];
140
+ $("#tweet a").first().html("推文 <span class='badge alert-info'>" + SnowballTool.status_data.length + "</span>");
141
+ });
142
+ Util.hide_tips();
143
+ } else {
144
+ $("#snowball-data").addClass("hide");
145
+ Util.hide_tips();
146
+ Util.show_tips("不存在该用户!!!", 5000, "alert-danger");
147
+ }
148
+ });
149
+ }
150
+ },
151
+
152
+ init_stock_data: function (stock_data) {
153
+ SnowballTool.cn_stock_data = [];
154
+ SnowballTool.hk_stock_data = [];
155
+ SnowballTool.us_stock_data = [];
156
+ stock_data.forEach(function (item) {
157
+ if (Util.is_hk(item.code)) {
158
+ SnowballTool.hk_stock_data.push(item);
159
+ } else if (Util.is_us(item.code)) {
160
+ SnowballTool.us_stock_data.push(item);
161
+ } else {
162
+ SnowballTool.cn_stock_data.push(item);
163
+ }
164
+ });
165
+ $("#cn a").first().html("A股 <span class='badge alert-info'>" + SnowballTool.cn_stock_data.length + "</span>");
166
+ $("#hk a").first().html("港股 <span class='badge alert-info'>" + SnowballTool.hk_stock_data.length + "</span>");
167
+ $("#us a").first().html("美股 <span class='badge alert-info'>" + SnowballTool.us_stock_data.length + "</span>");
168
+ localStorage["snowball_tool_nav"] = SnowballTool.cn_stock_data.length > 0 ? "cn" : (SnowballTool.hk_stock_data.length > 0 ? "hk" : (SnowballTool.us_stock_data.length > 0 ? "us" : "tweet"));
169
+ Util.tab_switch("snowball_tool_nav", SnowballTool.render_snowball_html);
170
+ },
171
+
172
+ resize_avatar_img: function () {
173
+ let avatar_object = $("#avatar");
174
+ if (Util.is_mobile()) {
175
+ let client_width = document.body.clientWidth;
176
+ avatar_object.css("width", client_width + "px");
177
+ } else {
178
+ let avatar_height = avatar_object.width();
179
+ avatar_object.css("height", (avatar_height + 10) + "px");
180
+ let img_object = $("#avatar_img");
181
+ let dist = avatar_height - img_object.height();
182
+ if (dist > 5) {
183
+ img_object.css("margin-top", (dist / 2) + "px");
184
+ }
185
+ }
186
+ },
187
+
188
+ render_snowball_html: function () {
189
+ let tab_type = SnowballTool.get_tab_type();
190
+ if (tab_type === "tweet") {
191
+ if (SnowballTool.status_data.length > 0) {
192
+ SnowballTool.render_tweet_html();
193
+ } else {
194
+ SnowballTool.fetch_tweet_data();
195
+ }
196
+ } else {
197
+ SnowballTool.init_table_skeleton(tab_type);
198
+ let data_type_key = tab_type + "_stock_data";
199
+ if (SnowballTool[data_type_key]) {
200
+ Util.render_type_option($("#industry"), SnowballTool[data_type_key], "industry", SnowballTool.render_stock_html);
201
+ Util.render_type_option($("#area"), SnowballTool[data_type_key], "area", SnowballTool.render_stock_html);
202
+ }
203
+ SnowballTool.render_stock_html();
204
+ }
205
+ },
206
+
207
+ fetch_tweet_data: function () {
208
+ let uid = $("#user_id").text();
209
+ if (uid) {
210
+ Util.show_loading();
211
+ $("#snowball_tool_div").html('<div class="x_panel text-center">Loading...</div>');
212
+ Util.post(location.pathname, {action: "tweet", uid: uid}, function (j) {
213
+ SnowballTool.status_data = j.data ? j.data : [];
214
+ SnowballTool.render_tweet_html();
215
+ Util.hide_tips();
216
+ });
217
+ } else {
218
+ $("#snowball_tool_div").html('<div class="x_panel text-center">暂无数据</div>');
219
+ }
220
+ },
221
+
222
+ render_tweet_html: function () {
223
+ if (SnowballTool.status_data && SnowballTool.status_data.length > 0) {
224
+ let html = [];
225
+ html.push('<div class="x_panel"><ul class="list-unstyled timeline widget">');
226
+ SnowballTool.status_data.forEach(function (item) {
227
+ html.push('<li><div class="block"><div class="block_content">');
228
+ if (item.title) {
229
+ item.title = Util.strip_html(item.title).replace(/\\/g, "");
230
+ item.title = Util.truncate(item.title, 50);
231
+ } else {
232
+ item.title = item.url;
233
+ }
234
+ item.content = item.content.replace(/\\/g, "");
235
+ item.content = item.content.replace(/thumb\.jpg/g, "custom.jpg");
236
+ if (item.pic) {
237
+ let pic_array = item.pic.split(",");
238
+ pic_array.forEach(function (pic) {
239
+ if (pic.includes("thumb.jpg")) {
240
+ pic = pic.replace("thumb.jpg", "custom.jpg");
241
+ } else if (!pic.includes("custom.jpg")) {
242
+ pic += "!custom.jpg";
243
+ }
244
+ if (!item.content.includes(pic)) {
245
+ item.content += "<br><img src='" + pic + "'>";
246
+ }
247
+ });
248
+ }
249
+ html.push('<h2 class="title">' + Util.pack_html_link(item.url, item.title) + '</h2>');
250
+ html.push('<div class="byline"><span>', Util.seconds_to_format(item.create_time), '</span></div>');
251
+ html.push('<p class="excerpt">', item.content, '</p>');
252
+ html.push('</div></div></li>');
253
+ });
254
+ html.push('</ul></div>');
255
+ $("#snowball_tool_div").html(html.join(""));
256
+ $("#tweet a").first().html("推文 <span class='badge alert-info'>" + SnowballTool.status_data.length + "</span>");
257
+ } else {
258
+ $("#snowball_tool_div").html('<div class="x_panel text-center">暂无数据</div>');
259
+ }
260
+ },
261
+
262
+ render_stock_html: function () {
263
+ let html = [];
264
+ let tab_type = SnowballTool.get_tab_type();
265
+ let data_type_key = tab_type + "_stock_data";
266
+ if (SnowballTool[data_type_key]) {
267
+ let stock_num = 0, stock_profit = 0, hk_mutual_code_list = [];
268
+ let area = $("#area").val();
269
+ let industry = $("#industry").val();
270
+ SnowballTool[data_type_key].forEach(function (item) {
271
+ if (Util.is_industry_area(item, industry, area)) {
272
+ item.code = item.code.replace(item.exchange, "");
273
+ if (item.is_hk_mutual && item.is_hk_mutual === 1) {
274
+ hk_mutual_code_list.push(item.code);
275
+ }
276
+ html.push("<tr", (item.is_recommend && item.is_recommend === 1 ? " class='info'" : ""), ">");
277
+ html = Util.stock_basics_html(html, item);
278
+ html.push("<td>", Util.year_price_rate(item.stock_price, item.year_price), "</td>");
279
+ html.push("<td>", Util.year_price_rate(item.stock_price, item.d5_price), "</td>");
280
+ if (tab_type === "cn") {
281
+ html.push("<td class='holder_", item.code, "'>--</td>");
282
+ html.push("<td class='fund_", item.code, "'>--</td>");
283
+ }
284
+ html.push("<td>", Util.seconds_to_format(item.created), "</td>");
285
+ item.start_price = Util.to_float(item.start_price, 2);
286
+ html.push("<td id='sp_", item.code, "'>", Util.digit_compare_trend1(item.stock_price, item.start_price), "</td>");
287
+ let high_price = item.stock_price > item.high_price ? item.stock_price : item.high_price;
288
+ html.push("<td id='hp_", item.code, "' data-price='", high_price, "'>", Util.digit_compare_trend1(high_price, item.start_price), "</td>");
289
+ html.push("</tr>");
290
+ stock_profit += ((item.stock_price - item.start_price) / item.start_price);
291
+ stock_num++;
292
+ }
293
+ });
294
+ Util.render_table_html("snowball_tool_div_body", html);
295
+ let code_list = Util.get_code_list("snowball_tool_div_body");
296
+ if (code_list.length > 0) {
297
+ Util.post("/action", {action: "price", code_list: code_list.join("-")}, function (j) {
298
+ for (let [code, item] of Object.entries(j)) {
299
+ Util.render_price(item);
300
+ let sp_object = $("#sp_" + code);
301
+ let start_price = Util.to_float(parseFloat(Util.strip_bracket_string(sp_object.text())), 2); // 删除括号内的字符
302
+ sp_object.html(Util.digit_compare_trend1(item.price, start_price));
303
+ let hp_object = $("#hp_" + code);
304
+ let high_price = parseFloat(hp_object.attr("data-price"));
305
+ if (item.price > high_price) {
306
+ hp_object.html(Util.digit_compare_trend1(item.price, start_price));
307
+ }
308
+ }
309
+ });
310
+ if (tab_type === "hk") {
311
+ if (hk_mutual_code_list.length > 0) {
312
+ $("#snowball_tool_div_body .code_item").each(function () {
313
+ let hk_code = $(this).text().replace(/[^0-9]/ig, "");
314
+ if (hk_mutual_code_list.includes(hk_code)) {
315
+ $(this).parent().parent().children('td').eq(1).addClass("danger");
316
+ }
317
+ });
318
+ }
319
+ $("#snowball_tool_div_body .industry_link").each(function () {
320
+ $(this).attr("href", Util.get_url("hk_list") + "?industry=" + $(this).text());
321
+ });
322
+ } else if (tab_type === "us") {
323
+ $("#snowball_tool_div_body .industry_link").each(function () {
324
+ $(this).attr("href", Util.get_url("us_list") + "?industry=" + $(this).text());
325
+ });
326
+ $("#snowball_tool_div_body .map_link").each(function () {
327
+ $(this).attr("href", Util.get_url("us_list") + "?market=" + $(this).text());
328
+ });
329
+ } else {
330
+ Util.init_stock_stuff("snowball_tool_div_body", [], 0, 0);
331
+ }
332
+ }
333
+ $("#stock_num").html(stock_num);
334
+ if (stock_num > 0) {
335
+ stock_profit = Util.to_float((stock_profit / stock_num) * 100, 2);
336
+ $("#stock_profit").html(",平均收益: " + Util.parse_ratio(stock_profit) + "&nbsp;&nbsp;&nbsp;");
337
+ }
338
+ } else {
339
+ Util.render_table_html("snowball_tool_div_body", html);
340
+ }
341
+ },
342
+
343
+ init_data: function (is_render) {
344
+ Util.post(location.pathname, {action: "init_tool"}, function (j) {
345
+ if (j["user"] && typeof j["user"] === 'object') {
346
+ SnowballTool.user_dict = j["user"];
347
+ if (is_render === 1) {
348
+ let html = [];
349
+ for (const [user_id, user_name] of Object.entries(SnowballTool.user_dict)) {
350
+ html.push('<a class="btn btn-default" data-val="', user_id, '" style="margin-bottom: 10px;" href="#">', user_name, '</a>');
351
+ }
352
+ $("#search_tips").html(html.join("")).find("a").each(function () {
353
+ $(this).click(function () {
354
+ $("#key_word").val($(this).attr("data-val"));
355
+ SnowballTool.fetch();
356
+ });
357
+ });
358
+ }
359
+ }
360
+ if (is_render === 1) {
361
+ Util.hide_tips();
362
+ }
363
+ });
364
+ },
365
+
366
+ render_recent_stock_modal: function() {
367
+ Util.show_loading();
368
+ Util.post(location.pathname, {"action": "recent_stock"}, function (j) {
369
+ let html = [];
370
+ j.data.forEach(function (item, index) {
371
+ html.push("<tr>");
372
+ html.push("<td>", (index + 1), "</td>");
373
+ html.push("<td><a class='user_td' data-val='", item.uid, "' href='#'>", item.user_name, "</a></td>");
374
+ html.push("<td class='code_item'>", Util.snowball_url(Util.is_alphabet(item.code) ? item.code.toUpperCase() : item.code), "</td>");
375
+ html.push("<td>", Util.stock_url(item.code, item.name ? item.name : item.code.toUpperCase()), "</td>");
376
+ html.push("<td>", Util.map_url((item.province_city && item.province_city !== "None") ? item.province_city : item.area), "</td>");
377
+ html.push("<td>", item.industry ? item.industry.slice(0, 6) : "--", "</td>");
378
+ html.push("<td class='price_", item.code.toLowerCase(), "'>", item.stock_price, "</td>");
379
+ html.push("<td>", Util.year_price_rate(item.stock_price, item.year_price), "</td>");
380
+ html.push("<td>", Util.year_price_rate(item.stock_price, item.d5_price), "</td>");
381
+ html.push("<td>", Util.seconds_to_format(item.create_time), "</td>");
382
+ html.push("</tr>");
383
+ });
384
+ Util.render_table_html("recent_stock_modal_body_body", html);
385
+ $("#recent_stock_modal_body_body .user_td").each(function() {
386
+ $(this).click(function() {
387
+ $("#key_word").val($(this).attr("data-val"));
388
+ $('#recent_stock_modal').modal('hide');
389
+ setTimeout(SnowballTool.fetch, 789);
390
+ });
391
+ });
392
+ Util.refresh_price("recent_stock_modal_body_body");
393
+ Util.hide_tips();
394
+ });
395
+ },
396
+
397
+ get_tab_type: function() {
398
+ let tab_type = "cn";
399
+ $("#snowball_tool_nav").find("li").each(function () {
400
+ if ($(this).hasClass("active")) {
401
+ tab_type = $(this).attr("id");
402
+ }
403
+ });
404
+ return tab_type;
405
+ },
406
+
407
+ init_table_skeleton: function (tab_type) {
408
+ let head_columns = [
409
+ {"name": "代码"},
410
+ {"name": "名称"},
411
+ {"name": "PE", "title": "市盈率(Price Earnings Ratio)", "table_sort": 1},
412
+ {"name": "总市值", "table_sort": 1},
413
+ {"name": "行业", "select_id": "industry"},
414
+ {"name": "地区", "select_id": "area"},
415
+ {"name": "当前价", "table_sort": 1},
416
+ {"name": "年初至今", "table_sort": 1},
417
+ {"name": "近5日", "table_sort": 1},
418
+ ];
419
+ if (tab_type === "cn") {
420
+ head_columns.push({"name": "股东数", "table_sort": 1});
421
+ head_columns.push({"name": "基金数", "table_sort": 1});
422
+ }
423
+ head_columns.push({"name": "创建时间", "class": "info", "table_sort": 1});
424
+ head_columns.push({"name": "创建收益", "table_sort": 1});
425
+ head_columns.push({"name": "创建最高收益", "table_sort": 1});
426
+ Util.init_table_skeleton({
427
+ "element_id": "snowball_tool_div",
428
+ "caption": '<caption class="text-right">共 <span id="stock_num" class="label label-info">0</span> 只自选股<span id="stock_profit"></span></caption>',
429
+ "head_columns": head_columns
430
+ });
431
+ }
432
+ };
433
+
434
+ $("#query-stock").click(function () {
435
+ SnowballTool.fetch();
436
+ });
437
+
438
+ $("#key_word").focus(function () {
439
+ let html = [];
440
+ html.push('<div class="list-group">');
441
+ for (const user_name of Object.values(SnowballTool.user_dict)) {
442
+ html.push('<a href="#" class="list-group-item">', user_name, '</a>');
443
+ }
444
+ html.push('</div>');
445
+ $("#key-tips").html(html.join("")).slideDown(300);
446
+ $(".list-group-item").each(function () {
447
+ $(this).click(function () {
448
+ $("#key_word").val($(this).text());
449
+ $("#key-tips").slideUp(200);
450
+ SnowballTool.fetch();
451
+ });
452
+ });
453
+ });
454
+ $(document).click(function (event) {
455
+ if (!$(event.target).closest("#key_word, #key-tips").length) {
456
+ $("#key-tips").slideUp(200);
457
+ }
458
+ });
459
+
460
+ let request_arguments = Util.request_arguments();
461
+ if (request_arguments.uid) {
462
+ $("#key_word").val(parseInt(request_arguments.uid));
463
+ SnowballTool.fetch();
464
+ SnowballTool.init_data(0);
465
+ } else {
466
+ SnowballTool.init_data(1);
467
+ }
468
+
469
+ Util.init_modal_skeleton("recent_stock_modal");
470
+ $("#recent_stock_modal_title").html("特别关注的用户最近一周内新添的个股");
471
+ Util.init_table_skeleton({
472
+ "element_id": "recent_stock_modal_body",
473
+ "head_columns": [
474
+ {"name": "序号", "table_sort": 1},
475
+ {"name": "用户"},
476
+ {"name": "代码"},
477
+ {"name": "名字"},
478
+ {"name": "地区"},
479
+ {"name": "行业"},
480
+ {"name": "当前价", "table_sort": 1},
481
+ {"name": "年初至今", "table_sort": 1},
482
+ {"name": "近5日", "table_sort": 1},
483
+ {"name": "时间", "table_sort": 1, "class": "info"},
484
+ ]
485
+ });
486
+ let rsm_object = $('#recent_stock_modal');
487
+ rsm_object.on('shown.bs.modal', function (e) {
488
+ SnowballTool.render_recent_stock_modal();
489
+ });
490
+ rsm_object.on('hidden.bs.modal', function () {
491
+ Util.set_table_loading("recent_stock_modal_body_body");
492
+ Util.hide_tips();
493
+ });
494
+
495
+ });
496
+
497
+ if (!Util.is_small_screen()) {
498
+ particlesJS('particles-js', { // https://github.com/VincentGarreau/particles.js
499
+ "particles": {
500
+ "number": {"value": 80, "density": {"enable": true, "value_area": 800}},
501
+ "color": {"value": "#8f8f8f"},
502
+ "shape": {
503
+ "type": "circle",
504
+ "stroke": {"width": 0, "color": "#000000"},
505
+ "polygon": {"nb_sides": 5},
506
+ "image": {"src": "img/github.svg", "width": 100, "height": 100}
507
+ },
508
+ "opacity": {
509
+ "value": 0.5,
510
+ "random": false,
511
+ "anim": {"enable": false, "speed": 1, "opacity_min": 0.1, "sync": false}
512
+ },
513
+ "size": {
514
+ "value": 5,
515
+ "random": true,
516
+ "anim": {"enable": false, "speed": 40, "size_min": 0.1, "sync": false}
517
+ },
518
+ "line_linked": {"enable": true, "distance": 150, "color": "#8f8f8f", "opacity": 0.4, "width": 1},
519
+ "move": {
520
+ "enable": true,
521
+ "speed": 6,
522
+ "direction": "none",
523
+ "random": false,
524
+ "straight": false,
525
+ "out_mode": "out",
526
+ "attract": {"enable": false, "rotateX": 600, "rotateY": 1200}
527
+ }
528
+ },
529
+ "interactivity": {
530
+ "detect_on": "canvas",
531
+ "events": {
532
+ "onhover": {"enable": true, "mode": "repulse"},
533
+ "onclick": {"enable": true, "mode": "push"},
534
+ "resize": true
535
+ },
536
+ "modes": {
537
+ "grab": {"distance": 400, "line_linked": {"opacity": 1}},
538
+ "bubble": {"distance": 400, "size": 40, "duration": 2, "opacity": 8, "speed": 3},
539
+ "repulse": {"distance": 200},
540
+ "push": {"particles_nb": 4},
541
+ "remove": {"particles_nb": 2}
542
+ }
543
+ },
544
+ "retina_detect": true,
545
+ "config_demo": {
546
+ "hide_card": false,
547
+ "background_color": "#FFF",
548
+ "background_image": "",
549
+ "background_position": "50% 50%",
550
+ "background_repeat": "no-repeat",
551
+ "background_size": "cover"
552
+ }
553
+ });
554
+ }
package/snowball_tweet.js CHANGED
@@ -15,7 +15,7 @@
15
15
  */
16
16
  $(function () {
17
17
 
18
- let Tweet = {
18
+ let SnowballTweet = {
19
19
 
20
20
  pageYOffset: 0,
21
21
  user_data: {},
@@ -32,7 +32,7 @@ $(function () {
32
32
  if (j.user_data) {
33
33
  let uid = request_arguments.uid ? parseInt(request_arguments.uid) : 0;
34
34
  j.user_data.forEach(function (item) {
35
- Tweet.user_data[item.uid] = item.name;
35
+ SnowballTweet.user_data[item.uid] = item.name;
36
36
  let select_mark = "";
37
37
  if (item.uid === uid) {
38
38
  is_select = 1;
@@ -51,16 +51,16 @@ $(function () {
51
51
  $("#tid").val (request_arguments.tid);
52
52
  }
53
53
  if (is_select === 1) {
54
- Tweet.fetch_tweet_data();
54
+ SnowballTweet.fetch_tweet_data();
55
55
  }
56
56
  if (j.key_words) {
57
- Tweet.tweet_key_words = j.key_words;
58
- let key_words = Tweet.tweet_key_words.map(item => "“" + item + "”").join("、");
57
+ SnowballTweet.tweet_key_words = j.key_words;
58
+ let key_words = SnowballTweet.tweet_key_words.map(item => "“" + item + "”").join("、");
59
59
  $("#content").attr("data-original-title", "推文内容搜索,例如:" + key_words);
60
60
  }
61
61
  if (j.special_observe_uid_list) {
62
- Tweet.special_observe_uid_list = j.special_observe_uid_list;
63
- Tweet.raw_special_observe_uid_list = j.special_observe_uid_list;
62
+ SnowballTweet.special_observe_uid_list = j.special_observe_uid_list;
63
+ SnowballTweet.raw_special_observe_uid_list = j.special_observe_uid_list;
64
64
  }
65
65
  $("#today_so_num").html(j.today_so_num && j.today_so_num > 0 ? ("(" + j.today_so_num + ")") : "");
66
66
  $("#update_time").html(j.update_time && j.update_time > 0 ? ("&nbsp;(更新于:" + Util.seconds_to_format(j.update_time) + ")") : "");
@@ -70,8 +70,8 @@ $(function () {
70
70
  $("#today_new_tweet").after('<a href="#" id="key_word_tweet" class="btn btn-danger form-control">关键词(<span>' + j.key_word_num + '</span>)</a>');
71
71
  $("#key_word_tweet").click(function() {
72
72
  if (!Util.is_load) {
73
- Tweet.is_key_word_tweet = 1;
74
- Tweet.fetch_tweet_data();
73
+ SnowballTweet.is_key_word_tweet = 1;
74
+ SnowballTweet.fetch_tweet_data();
75
75
  }
76
76
  });
77
77
  }
@@ -108,10 +108,19 @@ $(function () {
108
108
  html.push('</div>');
109
109
  $("#today_tweet_statistics_modal_body").html(html.join("")).find("a").each(function() {
110
110
  $(this).click(function() {
111
- Tweet.set_today_date();
112
- $("#uid").val($(this).attr("data-val"));
111
+ SnowballTweet.set_today_date();
112
+ $("#tweet_list").html("");
113
+ let uid = $(this).attr("data-val");
114
+ if (uid) {
115
+ let user_name = $(this).text();
116
+ let uid_object = $("#uid");
117
+ if (uid_object.find("option[value='" + uid + "']").length === 0) {
118
+ uid_object.append($("<option>", { value: uid, text: user_name }));
119
+ }
120
+ uid_object.val(uid);
121
+ }
113
122
  $('#today_tweet_statistics_modal').modal('hide');
114
- setTimeout(Tweet.fetch_tweet_data, 789);
123
+ setTimeout(SnowballTweet.fetch_tweet_data, 789);
115
124
  });
116
125
  });;
117
126
  Util.hide_tips();
@@ -129,25 +138,25 @@ $(function () {
129
138
  }
130
139
  }
131
140
  } else {
132
- Tweet.init_tweet_status();
141
+ SnowballTweet.init_tweet_status();
133
142
  }
134
143
  });
135
144
  },
136
145
 
137
146
  fetch_tweet_data: function() {
138
147
  Util.show_loading();
139
- let payload = Tweet.get_payload();
140
- payload["is_key_word_tweet"] = Tweet.is_key_word_tweet;
148
+ let payload = SnowballTweet.get_payload();
149
+ payload["is_key_word_tweet"] = SnowballTweet.is_key_word_tweet;
141
150
  Util.post(location.pathname, payload, function (j) {
142
- Tweet.render_tweet_html(j.data, 0);
143
- Tweet.is_key_word_tweet = 0;
151
+ SnowballTweet.render_tweet_html(j.data, 0);
152
+ SnowballTweet.is_key_word_tweet = 0;
144
153
  });
145
154
  },
146
155
 
147
156
  get_payload: function() {
148
157
  let special_observe_uid = "";
149
- if (Tweet.special_observe_uid_list && $("#is_special_observe").prop("checked")) {
150
- special_observe_uid = Tweet.special_observe_uid_list.join(",");
158
+ if (SnowballTweet.special_observe_uid_list && $("#is_special_observe").prop("checked")) {
159
+ special_observe_uid = SnowballTweet.special_observe_uid_list.join(",");
151
160
  }
152
161
  return {
153
162
  action: "tweet_search",
@@ -165,7 +174,7 @@ $(function () {
165
174
  render_tweet_html: function(data, render_type) {
166
175
  if (data && data.length > 0) {
167
176
  let html = [], regexp_pattern = null, is_simple = 0;
168
- let key_word_array = Tweet.tweet_key_words.slice();
177
+ let key_word_array = SnowballTweet.tweet_key_words.slice();
169
178
  let key_word = $("#content").val().trim();
170
179
  if (key_word) {
171
180
  key_word_array.push(key_word);
@@ -234,17 +243,17 @@ $(function () {
234
243
  }
235
244
  }
236
245
  let user_name = "";
237
- if (item.mark && Tweet.user_data[item.mark]) {
238
- user_name = Util.pack_html_link("https://xueqiu.com/S/" + item.mark, Tweet.user_data[item.mark]) + " - ";
246
+ if (item.mark && SnowballTweet.user_data[item.mark]) {
247
+ user_name = Util.pack_html_link("https://xueqiu.com/S/" + item.mark, SnowballTweet.user_data[item.mark]) + " - ";
239
248
  if (item.user_name) {
240
249
  user_name += Util.pack_html_link(user_url, item.user_name);
241
- } else if (Tweet.user_data[item.uid]) {
242
- user_name += Util.pack_html_link(user_url, Tweet.user_data[item.uid]);
250
+ } else if (SnowballTweet.user_data[item.uid]) {
251
+ user_name += Util.pack_html_link(user_url, SnowballTweet.user_data[item.uid]);
243
252
  } else {
244
253
  user_name += Util.pack_html_link(user_url, item.uid);
245
254
  }
246
- } else if (Tweet.user_data[item.uid]) {
247
- user_name = Util.pack_html_link(user_url, Tweet.user_data[item.uid]);
255
+ } else if (SnowballTweet.user_data[item.uid]) {
256
+ user_name = Util.pack_html_link(user_url, SnowballTweet.user_data[item.uid]);
248
257
  } else {
249
258
  user_name = Util.pack_html_link(user_url, item.uid);
250
259
  }
@@ -274,7 +283,7 @@ $(function () {
274
283
 
275
284
  render_special_observe_html() {
276
285
  let html = [];
277
- let so_uid_list = Tweet.special_observe_uid_list ? Tweet.special_observe_uid_list : [];
286
+ let so_uid_list = SnowballTweet.special_observe_uid_list ? SnowballTweet.special_observe_uid_list : [];
278
287
  html.push('<div class="form-inline text-center">');
279
288
  html.push('<div class="form-group text-left">');
280
289
  $('#uid option').each(function() {
@@ -301,10 +310,10 @@ $(function () {
301
310
  });
302
311
  });
303
312
  $("#reset_so_uid").click(function() {
304
- if (Tweet.raw_special_observe_uid_list) {
313
+ if (SnowballTweet.raw_special_observe_uid_list) {
305
314
  document.querySelectorAll('#special_observe_modal_body input[type="checkbox"]').forEach(cb => {
306
315
  let uid = parseInt(cb.value);
307
- cb.checked = Tweet.raw_special_observe_uid_list.includes(uid) ? true : false;
316
+ cb.checked = SnowballTweet.raw_special_observe_uid_list.includes(uid) ? true : false;
308
317
  });
309
318
  }
310
319
  });
@@ -317,7 +326,7 @@ $(function () {
317
326
  so_uid_list.push(uid);
318
327
  }
319
328
  });
320
- Tweet.special_observe_uid_list = so_uid_list;
329
+ SnowballTweet.special_observe_uid_list = so_uid_list;
321
330
  $("#so_uid_tips").html("<b class='text-success'>保存成功!</b>");
322
331
  });
323
332
  },
@@ -333,7 +342,7 @@ $(function () {
333
342
 
334
343
  };
335
344
 
336
- Util.init_date_range_picker("tweet_start_end_date", Tweet, "fetch_tweet_data");
345
+ Util.init_date_range_picker("tweet_start_end_date", SnowballTweet, "fetch_tweet_data");
337
346
  $("#tweet_start_date").val("");
338
347
  $("#tweet_end_date").val("");
339
348
  $("#today_new_tweet").click(function() {
@@ -342,19 +351,19 @@ $(function () {
342
351
  if (today_num > 0) {
343
352
  let uid = parseInt($("#uid").val());
344
353
  if (uid === 0) {
345
- Tweet.set_today_date();
354
+ SnowballTweet.set_today_date();
346
355
  }
347
- Tweet.fetch_tweet_data();
356
+ SnowballTweet.fetch_tweet_data();
348
357
  } else {
349
358
  Util.show_tips("今日暂无新帖", 4567, "alert-danger");
350
359
  }
351
360
  }
352
361
  });
353
362
  $("#tweet_type").change(function() {
354
- Tweet.pageYOffset = 0;
363
+ SnowballTweet.pageYOffset = 0;
355
364
  $("#uid").html('<option value="0">Loading...</option>');
356
365
  $("#tweet_list").html("");
357
- Tweet.init_tweet_status();
366
+ SnowballTweet.init_tweet_status();
358
367
  });
359
368
 
360
369
  Util.init_modal_skeleton("special_observe_modal");
@@ -362,26 +371,26 @@ $(function () {
362
371
  $("#special_observe_modal_body").parent().parent().removeClass("modal-xlg");
363
372
  let som_object = $('#special_observe_modal');
364
373
  som_object.on('show.bs.modal', function (e) {
365
- Tweet.render_special_observe_html();
374
+ SnowballTweet.render_special_observe_html();
366
375
  });
367
376
  som_object.on('hidden.bs.modal', function () {
368
377
  $("#special_observe_modal_body").html("");
369
378
  Util.hide_tips();
370
379
  });
371
380
 
372
- Tweet.init_tweet_status();
381
+ SnowballTweet.init_tweet_status();
373
382
  $("#query_data").click(function() {
374
- Tweet.fetch_tweet_data();
383
+ SnowballTweet.fetch_tweet_data();
375
384
  });
376
385
  $("#is_simple").click(function() {
377
386
  if ($('#tweet_list li').length > 0) {
378
- Tweet.fetch_tweet_data();
387
+ SnowballTweet.fetch_tweet_data();
379
388
  }
380
389
  });
381
390
 
382
391
  // 触发下拉到底部时的事件
383
392
  window.onscroll = function(ev) {
384
- if (!Util.is_load && window.pageYOffset > Tweet.pageYOffset) {
393
+ if (!Util.is_load && window.pageYOffset > SnowballTweet.pageYOffset) {
385
394
  if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
386
395
  if (!document.getElementById("tweet_loading")) {
387
396
  let create_time = 0;
@@ -393,14 +402,14 @@ $(function () {
393
402
  }
394
403
  });
395
404
  if (create_time > 0) {
396
- Tweet.pageYOffset = window.pageYOffset;
405
+ SnowballTweet.pageYOffset = window.pageYOffset;
397
406
  $('#tweet_list').append('<li id="tweet_loading"><div class="block"><div class="block_content text-center" style="font-size: 25px; line-height: 2em;">Loading...</div></div></li>');
398
407
  Util.show_loading();
399
- let payload = Tweet.get_payload();
408
+ let payload = SnowballTweet.get_payload();
400
409
  payload["append_time"] = create_time;
401
410
  Util.post(location.pathname, payload, function (j) {
402
411
  $("#tweet_loading").remove();
403
- Tweet.render_tweet_html(j.data, 1);
412
+ SnowballTweet.render_tweet_html(j.data, 1);
404
413
  });
405
414
  }
406
415
  }