sbd-npm 1.5.39 → 1.5.41

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/constant.js CHANGED
@@ -215,8 +215,8 @@ const MenuList = [
215
215
  {'key': 'us_buffett', 'name': '巴菲特持仓', 'url': '/0xe51dc830e90a6ca5bbae5d867ebd69d57aa85208'},
216
216
  {'key': 'us_biotechnology', 'name': '生物科技', 'url': '/0x88bee1b829887f7c2fbfeea7a3c60c330d477f62'},
217
217
  {'key': 'us_dollar_index', 'name': '美元指数', 'url': '/0x99533982f67f489dce7c0738c2e2a94239e35cde'},
218
- {'key': 'us_bond_yield', 'name': '美十年国债收益率', 'url': '/0xdf01c6a366340dce84867ca34e7dd6fc6ed5e631'},
219
- {'key': 'us_usd_cnh', 'name': '美元离岸人民币汇率', 'url': '/0x6010e54df39e6e00b255d6271d9972fb8c9faf11'},
218
+ {'key': 'us_bond_yield', 'name': '美十年国债收益', 'url': '/0xdf01c6a366340dce84867ca34e7dd6fc6ed5e631'},
219
+ {'key': 'us_usd_cnh', 'name': '美元人民币汇率', 'url': '/0x6010e54df39e6e00b255d6271d9972fb8c9faf11'},
220
220
  {'key': 'us_vix', 'name': 'VIX恐慌指数', 'url': '/0xc767b343d8a06290ca1593da8e20c14584ccd45b'},
221
221
  {'key': 'us_pe', 'name': '标普500历史PE', 'url': '/0x65702c301edb87adb7a5e99a02d4bd5500bd7c8e'},
222
222
  {'key': 'us_short_rank', 'name': '做空排行', 'url': '/0x2421be33e4e06950b6ff117fdf2e3b6822806f7a'}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbd-npm",
3
- "version": "1.5.39",
3
+ "version": "1.5.41",
4
4
  "description": "Stock Big Data",
5
5
  "author": "DHQ <dhq314@gmail.com>",
6
6
  "license": "ISC",
package/snowball_tweet.js CHANGED
@@ -99,7 +99,8 @@ $(function () {
99
99
  html.push('<div class="form-group text-left">');
100
100
  j.data.forEach(function (item) {
101
101
  total_num += item.num;
102
- html.push('<a class="btn btn-default" data-val="', item.uid, '" style="margin-bottom: 10px;" href="#">', item.name, '(', item.num, ')</a>');
102
+ let item_num = (item.stock_num && item.stock_num > 0) ? item.stock_num : item.num;
103
+ html.push('<a class="btn btn-default" data-val="', item.uid, '" style="margin-bottom: 10px;" href="#">', item.name, '(', item_num, ')</a>');
103
104
  });
104
105
  html.push('</div>');
105
106
  html.push('<div class="form-group" style="margin: 10px 0;">');
@@ -333,8 +334,7 @@ $(function () {
333
334
 
334
335
  set_today_date: function() {
335
336
  let now = Util.now();
336
- let date = new Date();
337
- let hour = date.getHours();
337
+ let hour = new Date().getHours();
338
338
  let start_date = hour < 6 ? (now - Util.ONE_DAY_SECOND) : now;
339
339
  $('#tweet_start_date').data('daterangepicker').setStartDate(Util.seconds_to_format(start_date, "%Y-%m-%d"));
340
340
  $('#tweet_end_date').data('daterangepicker').setStartDate(Util.seconds_to_format(now, "%Y-%m-%d"));
package/status.js CHANGED
@@ -849,13 +849,40 @@ $(function () {
849
849
  {"name": "物理内存", "table_sort": 1, "title": "Resident Set Size(常驻内存,进程实际占用的物理内存)"},
850
850
  {"name": "启动命令"},
851
851
  {"name": "创建时间", "class": "info", "table_sort": 1},
852
- {"name": "操作"}
852
+ {"name": "操作", "id": "machine_action_log", "link": "#", "title": "操作日志记录"}
853
853
  ]
854
854
  });
855
+ $("#machine_action_log").click(function() {
856
+ let machine_id = $("#machines").val();
857
+ if (machine_id) {
858
+ let instruction = "screen_1_machine_action_log";
859
+ Util.post(location.pathname, {action: "machine_instruction_add", "machine_id": machine_id, "instruction": instruction, "action_type": 2}, function (j) {
860
+ Util.hide_tips();
861
+ if (j.code === 1) {
862
+ Status.reset_screen_status("machine_process_div_body");
863
+ $("#machine_action_log").html("<a href='#'><span title='日志记录获取中...' class='label label-info'>操作</span></a>");
864
+ Util.show_tips("[获取操作日志记录] 已加到会话队列中", 4567, "alert-success");
865
+ } else if (j.code === 2) {
866
+ Util.show_tips("Machine 不存在!", 4567, "alert-danger");
867
+ } else {
868
+ Util.show_tips("[获取操作日志记录] 异常!", 4567, "alert-danger");
869
+ }
870
+ });
871
+ }
872
+ });
855
873
  }
856
874
  let html = [], process_num = 0;
857
875
  let screen_pid = j.screen_pid ? j.screen_pid : 0;
858
876
  let screen_pid_date = j.screen_pid_date ? j.screen_pid_date : 0;
877
+ if (screen_pid === 1) {
878
+ if (screen_pid_date > 0) {
879
+ $("#machine_action_log").html("<a href='#'><span title='日志记录已成功获取(" + Util.seconds_to_format(screen_pid_date) + ")' class='label label-success'>操作</span></a>");
880
+ } else {
881
+ $("#machine_action_log").html("<a href='#'><span title='日志记录获取中...' class='label label-info'>操作</span></a>");
882
+ }
883
+ } else {
884
+ $("#machine_action_log").html("<a href='#'>操作</a>");
885
+ }
859
886
  j.process.forEach(function (item) {
860
887
  process_num++;
861
888
  let is_xmr = 0, is_screen = 0;
@@ -984,19 +1011,8 @@ $(function () {
984
1011
  Util.post(location.pathname, {action: "machine_instruction_add", "machine_id": machine_id, "instruction": instruction, "action_type": action_type}, function (j) {
985
1012
  Util.hide_tips();
986
1013
  if (j.code === 1) {
987
- $("#" + element_id + " a").each(function() {
988
- let span_object = $(this).find('span.label.label-info');
989
- if (span_object.length) {
990
- var span_text = span_object.text();
991
- span_object.remove();
992
- $(this).append(span_text);
993
- } else {
994
- let is_fetch_screen = $(this).attr("data-screen");
995
- if (is_fetch_screen && is_fetch_screen == "1") {
996
- $(this).text('会话').removeAttr('data-screen');
997
- }
998
- }
999
- });
1014
+ $("#machine_action_log").html("<a href='#'>操作</a>");
1015
+ Status.reset_screen_status(element_id);
1000
1016
  this_object.html("<span title='会话数据获取中...' class='label label-info'>会话</span>");
1001
1017
  Util.show_tips("进程 [" + pid + "(" + action + ")] 已加到会话队列中", 4567, "alert-success");
1002
1018
  } else if (j.code === 2) {
@@ -1013,6 +1029,22 @@ $(function () {
1013
1029
  });
1014
1030
  },
1015
1031
 
1032
+ reset_screen_status: function(element_id) {
1033
+ $("#" + element_id + " a").each(function() {
1034
+ let span_object = $(this).find('span.label.label-info');
1035
+ if (span_object.length) {
1036
+ let span_text = span_object.text();
1037
+ span_object.remove();
1038
+ $(this).append(span_text);
1039
+ } else {
1040
+ let is_fetch_screen = $(this).attr("data-screen");
1041
+ if (is_fetch_screen && is_fetch_screen == "1") {
1042
+ $(this).text('会话').removeAttr('data-screen');
1043
+ }
1044
+ }
1045
+ });
1046
+ },
1047
+
1016
1048
  pack_screen_html: function(is_screen, pid, screen_pid, screen_pid_date, cmdline) {
1017
1049
  if (is_screen === 1) {
1018
1050
  let screen_html = "";
@@ -1307,7 +1339,7 @@ $(function () {
1307
1339
  machines.forEach(function (m) {
1308
1340
  html.push("<option value='", m["machine_id"], "'>", m["ip"], "(", m["num"], ")</option>");
1309
1341
  });
1310
- $("#" + element_id).html(html.join(""));
1342
+ document.getElementById(element_id).innerHTML = html.join("");
1311
1343
  },
1312
1344
 
1313
1345
  init_word_modal: function () {
@@ -1333,9 +1365,7 @@ $(function () {
1333
1365
  html.push('</div>');
1334
1366
  html.push('</div>');
1335
1367
  html.push('</form>');
1336
- let wmb_object = $("#word_modal_body");
1337
- wmb_object.html(html.join(""));
1338
- wmb_object.parent().parent().removeClass("modal-xlg");
1368
+ $("#word_modal_body").html(html.join("")).parent().parent().removeClass("modal-xlg");
1339
1369
  let wm_object = $('#word_modal');
1340
1370
  wm_object.on('show.bs.modal', function (e) {
1341
1371
  if ($(e.relatedTarget).attr("id") === "word_random") {
@@ -1352,18 +1382,18 @@ $(function () {
1352
1382
  });
1353
1383
  } else {
1354
1384
  let tr_object = $(e.relatedTarget).parent().parent();
1355
- let word = $(tr_object).children('td').eq(1).text();
1385
+ let word = tr_object.children('td').eq(1).text();
1356
1386
  $("#word_modal_title").html(Util.pack_html_link("https://cn.bing.com/dict/search?q=" + word, "单词修改"));
1357
1387
  $('#word_modify').css('display', 'inline');
1358
1388
  $("#word_value").val(word).attr('readonly', true);
1359
- $("#word_chinese").val($(tr_object).children('td').eq(2).text()).attr('readonly', false);
1389
+ $("#word_chinese").val(tr_object.children('td').eq(2).text()).attr('readonly', false);
1360
1390
  $("#word_modify").off("click").click(function () {
1361
1391
  let chinese = $("#word_chinese").val();
1362
1392
  if (chinese) {
1363
1393
  Util.post(location.pathname, {"action": "word_modify", "word": word, "chinese": chinese}, function (j) {
1364
1394
  if (j.code === 1) {
1365
1395
  $("#word_chinese").val(j.chinese);
1366
- $(tr_object).children('td').eq(2).html(j.chinese);
1396
+ tr_object.children('td').eq(2).html(j.chinese);
1367
1397
  $("#word_tips").html("<b class='text-success'>修改成功!</b>");
1368
1398
  } else if (j.code === 2) {
1369
1399
  $("#word_tips").html("<b class='text-danger'>中文有误!</b>");
package/summary_daily.js CHANGED
@@ -598,8 +598,8 @@ $(function () {
598
598
 
599
599
  render_stock_rate_html: function() {
600
600
  let html = [], index = 0;
601
- let industry = $("#p_change_industry").val();
602
601
  let area = $("#p_change_area").val();
602
+ let industry = $("#p_change_industry").val();
603
603
  Modal["p_change_data"].forEach(function (item) {
604
604
  if (Util.is_industry_area(item, industry, area)) {
605
605
  index++;
package/util.js CHANGED
@@ -1052,9 +1052,9 @@ const Util = {
1052
1052
  if (html.length > 0) {
1053
1053
  document.getElementById(element_id).innerHTML = html.join("");
1054
1054
  } else {
1055
- let element_object = $("#" + element_id);
1056
- let td_num = element_object.parent().find('thead td').length;
1057
- element_object.html('<tr><td colspan="' + td_num + '">暂无数据</td></tr>');
1055
+ let element_object = document.getElementById(element_id);
1056
+ let td_num = element_object.closest('table').querySelectorAll('thead td').length;
1057
+ element_object.innerHTML = '<tr><td colspan="' + td_num + '">暂无数据</td></tr>';
1058
1058
  }
1059
1059
  },
1060
1060
 
@@ -1070,7 +1070,7 @@ const Util = {
1070
1070
  html.push('<option value="', i["id"], '">', i["industry"], '(', i["num"], ')</option>');
1071
1071
  });
1072
1072
  }
1073
- $("#" + element_id).html(html.join(""));
1073
+ document.getElementById(element_id).innerHTML = html.join("");
1074
1074
  },
1075
1075
 
1076
1076
  /**
@@ -1085,7 +1085,7 @@ const Util = {
1085
1085
  html.push('<option value="', a["area"], '">', a["area"], '(', a["num"], ')</option>');
1086
1086
  });
1087
1087
  }
1088
- $("#" + element_id).html(html.join(""));
1088
+ document.getElementById(element_id).innerHTML = html.join("");
1089
1089
  },
1090
1090
 
1091
1091
  /**
@@ -1094,10 +1094,12 @@ const Util = {
1094
1094
  * @param load_text
1095
1095
  */
1096
1096
  set_table_loading: function (element_id, load_text = "") {
1097
- let element_object = $("#" + element_id);
1098
- let td_num = element_object.parent().find('thead td').length;
1099
- load_text = load_text.length > 0 ? load_text : "Loading...";
1100
- element_object.html('<tr><td colspan="' + td_num + '">' + load_text + '</td></tr>');
1097
+ let element_object = document.getElementById(element_id);
1098
+ if (element_object) {
1099
+ let td_num = element_object.closest('table').querySelectorAll('thead td').length;
1100
+ load_text = load_text.length > 0 ? load_text : "Loading...";
1101
+ element_object.innerHTML = '<tr><td colspan="' + td_num + '">' + load_text + '</td></tr>';
1102
+ }
1101
1103
  },
1102
1104
 
1103
1105
  /**
@@ -1754,13 +1756,13 @@ const Util = {
1754
1756
  $("#word_process_div_body .word_del").each(function () {
1755
1757
  $(this).click(function () {
1756
1758
  let tr_object = $(this).parent().parent();
1757
- let word = $(tr_object).children('td').eq(1).text();
1758
- let word_chinese = $(tr_object).children('td').eq(2).text();
1759
+ let word = tr_object.children('td').eq(1).text();
1760
+ let word_chinese = tr_object.children('td').eq(2).text();
1759
1761
  word_chinese = "“ " + word + "「" + word_chinese + "」”";
1760
1762
  if (confirm("是否确定要删除 " + word_chinese + " ?")) {
1761
1763
  Util.show_loading();
1762
- Util.post(location.pathname, {"active_div": "word_del", "word": word}, function () {
1763
- $(tr_object).remove();
1764
+ Util.post(location.pathname, {"action": "word_del", "word": word}, function () {
1765
+ tr_object.remove();
1764
1766
  Util.hide_tips();
1765
1767
  Util.show_tips("删除 " + word_chinese + " 成功", 4567, "alert-success");
1766
1768
  });
@@ -2272,8 +2274,7 @@ const Util = {
2272
2274
  * @returns {*|number}
2273
2275
  */
2274
2276
  get_weekday: function () {
2275
- let date = new Date();
2276
- let weekday = date.getDay();
2277
+ let weekday = new Date().getDay();
2277
2278
  weekday = weekday > 0 ? weekday : 7; // 星期天是0
2278
2279
  return weekday;
2279
2280
  },
@@ -2893,9 +2894,10 @@ const Util = {
2893
2894
  },
2894
2895
 
2895
2896
  uuid: function () {
2896
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
2897
- var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
2898
- return v.toString(16);
2897
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
2898
+ let randomHexDigit = Math.random() * 16 | 0;
2899
+ let digit = char == 'x' ? randomHexDigit : (randomHexDigit & 0x3 | 0x8);
2900
+ return digit.toString(16);
2899
2901
  });
2900
2902
  },
2901
2903
 
@@ -3572,43 +3574,6 @@ const Util = {
3572
3574
  Util.render_table_html("index_table_body", html);
3573
3575
  },
3574
3576
 
3575
- /**
3576
- * 设置 option 的第 nth 项为默认项
3577
- * @param obj
3578
- * @param nth
3579
- */
3580
- set_option_selected: function (obj, nth) {
3581
- let option_val = "";
3582
- obj.find("option").each(function () {
3583
- if (option_val === "" || nth >= 0) {
3584
- option_val = $(this).attr("value");
3585
- }
3586
- nth -= 1;
3587
- });
3588
- obj.val(option_val);
3589
- },
3590
-
3591
- /**
3592
- * 设置当年的第一个项为默认项
3593
- * @param obj
3594
- */
3595
- set_year_option_selected: function (obj) {
3596
- let date = new Date();
3597
- let year = date.getFullYear();
3598
- let option_val = "";
3599
- obj.find("option").each(function () {
3600
- let o_val = $(this).attr("value");
3601
- if (year === parseInt(o_val.split('-')[0])) {
3602
- option_val = o_val
3603
- }
3604
- });
3605
- if (option_val !== "") {
3606
- obj.val(option_val);
3607
- } else {
3608
- Util.set_option_selected(obj, 100);
3609
- }
3610
- },
3611
-
3612
3577
  /**
3613
3578
  * 初始日期范围选择器
3614
3579
  * @param element_id
@@ -3651,7 +3616,7 @@ const Util = {
3651
3616
  html.push('<span class="fa fa-calendar-o form-control-feedback left" aria-hidden="true"></span>');
3652
3617
  html.push('</div>');
3653
3618
  html.push('</div>');
3654
- $("#" + element_id).html(html.join(""));
3619
+ document.getElementById(element_id).innerHTML = html.join("");
3655
3620
  Util.init_range_picker_date(start_id, end_id, nth_day);
3656
3621
  Util.init_time_select_range(Obj, select_id, start_id, end_id, callback_func);
3657
3622
  },