sbd-npm 1.4.43 → 1.4.45
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/status.js +44 -14
- package/util.js +25 -6
package/package.json
CHANGED
package/status.js
CHANGED
@@ -739,22 +739,45 @@ $(function () {
|
|
739
739
|
html.push('</form>');
|
740
740
|
html.push('<div id="word_process_div"></div>');
|
741
741
|
$("#word_div").html(html.join(""));
|
742
|
+
let head_cols = [
|
743
|
+
{"name": "序号", "table_sort": 1},
|
744
|
+
{"name": "单词", "table_sort": 1},
|
745
|
+
{"name": "中文"},
|
746
|
+
{"name": "时间", "table_sort": 1},
|
747
|
+
];
|
748
|
+
if ('speechSynthesis' in window) {
|
749
|
+
head_cols.push({"name": "朗读", "id": "word_recite", "link": "#"});
|
750
|
+
}
|
751
|
+
head_cols.push({"name": "操作"});
|
742
752
|
Util.init_table_skeleton({
|
743
753
|
"element_id": "word_process_div",
|
744
754
|
"caption": '<caption class="' + (is_mobile ? "text-left" : "text-right") + '" id="word_num"></caption>',
|
745
|
-
"head_cols":
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
755
|
+
"head_cols": head_cols
|
756
|
+
});
|
757
|
+
$("#word_recite").click(function() {
|
758
|
+
let voices = window.speechSynthesis.getVoices();
|
759
|
+
if (voices.length > 0) {
|
760
|
+
Status.show_speech_voices(voices);
|
761
|
+
} else {
|
762
|
+
window.speechSynthesis.onvoiceschanged = () => {
|
763
|
+
let voices = window.speechSynthesis.getVoices();
|
764
|
+
Status.show_speech_voices(voices);
|
765
|
+
};
|
766
|
+
}
|
752
767
|
});
|
753
768
|
Status.init_word_modal();
|
754
769
|
}
|
755
770
|
Util.fetch_word_data(is_init, "", "");
|
756
771
|
},
|
757
772
|
|
773
|
+
show_speech_voices: function(voices) {
|
774
|
+
let data = [];
|
775
|
+
voices.forEach(voice => {
|
776
|
+
data.push(`Name: ${voice.name}, Lang: ${voice.lang}, Default: ${voice.default}`);
|
777
|
+
});
|
778
|
+
alert(data.join("\n"));
|
779
|
+
},
|
780
|
+
|
758
781
|
init_machine_action_modal: function () {
|
759
782
|
Util.init_modal_skeleton("machine_action_modal");
|
760
783
|
$("#machine_action_modal_title").html("添加任务");
|
@@ -1052,19 +1075,26 @@ $(function () {
|
|
1052
1075
|
}
|
1053
1076
|
if (match_ip_data) {
|
1054
1077
|
Util.show_loading();
|
1078
|
+
ip = match_ip_data[0];
|
1055
1079
|
$("#ip").prop('disabled', true);
|
1056
1080
|
$("#ip_query").attr("disabled", true);
|
1057
|
-
ip = match_ip_data[0];
|
1058
|
-
$("#ip").val(ip);
|
1059
1081
|
Util.post("/action", {action: "ip_query", ip: ip}, function (j) {
|
1060
1082
|
$("#ip").prop('disabled', false);
|
1061
1083
|
$("#ip_query").attr("disabled", false);
|
1062
1084
|
if (j["ip"]) {
|
1085
|
+
if (j["domain"]) {
|
1086
|
+
let domain = $("#ip").val().trim();
|
1087
|
+
j["domain"] = domain ? domain : j["domain"];
|
1088
|
+
}
|
1063
1089
|
$("#ip").val(j["ip"]);
|
1064
1090
|
let ip_address = Status.convert_ip_address(j);
|
1065
1091
|
if (ip_address.length > 0) {
|
1066
1092
|
let map_url = Status.map_url(ip_address, "<i class='glyphicon glyphicon-map-marker'></i>");
|
1067
|
-
|
1093
|
+
let ip_result = Util.pack_html_link(Status.ip_url(j["ip"]), "<b class='text-success'>" + ip_address + "</b>") + " " + map_url;
|
1094
|
+
if (j["domain"]) {
|
1095
|
+
ip_result += "<br><br>" + Util.pack_html_link(j["domain"], "<b>" + j["domain"] + "</b>");
|
1096
|
+
}
|
1097
|
+
$("#ip_result").html(ip_result);
|
1068
1098
|
} else {
|
1069
1099
|
$("#ip_result").html(Util.pack_html_link(Status.ip_url(ip), "<b class='text-danger'>找不到结果!</b>"));
|
1070
1100
|
}
|
@@ -1084,7 +1114,7 @@ $(function () {
|
|
1084
1114
|
Status.phone_query();
|
1085
1115
|
});
|
1086
1116
|
$("#md5_encrypt").click(function () {
|
1087
|
-
let md5 = $("#md5").val();
|
1117
|
+
let md5 = $("#md5").val().trim();
|
1088
1118
|
if (md5) {
|
1089
1119
|
Util.show_loading();
|
1090
1120
|
$("#md5").prop('disabled', true);
|
@@ -1100,7 +1130,7 @@ $(function () {
|
|
1100
1130
|
}
|
1101
1131
|
});
|
1102
1132
|
$("#base64_action").click(function () {
|
1103
|
-
let base64 = $("#base64").val();
|
1133
|
+
let base64 = $("#base64").val().trim();
|
1104
1134
|
if (base64) {
|
1105
1135
|
if ($(this).text() === "编 码") {
|
1106
1136
|
$("#base64_result").html("<b class='text-success'>" + Util.base64_encode(base64) + "</b>");
|
@@ -1115,7 +1145,7 @@ $(function () {
|
|
1115
1145
|
$("#base64_action").text($(this).text());
|
1116
1146
|
});
|
1117
1147
|
$("#unicode_convert").click(function () {
|
1118
|
-
let unicode_str = $("#unicode").val();
|
1148
|
+
let unicode_str = $("#unicode").val().trim();
|
1119
1149
|
if (unicode_str) {
|
1120
1150
|
try {
|
1121
1151
|
let obj = JSON.parse('{"data": "' + unicode_str + '"}');
|
@@ -1128,7 +1158,7 @@ $(function () {
|
|
1128
1158
|
}
|
1129
1159
|
});
|
1130
1160
|
$("#segment_parse").click(function () {
|
1131
|
-
let segment_str = $("#segment").val();
|
1161
|
+
let segment_str = $("#segment").val().trim();
|
1132
1162
|
if (segment_str) {
|
1133
1163
|
try {
|
1134
1164
|
let segmenter = new Intl.Segmenter("zh-CN", {granularity: "word"});
|
package/util.js
CHANGED
@@ -1658,6 +1658,7 @@ const Util = {
|
|
1658
1658
|
Util.post(location.pathname, {active_div: "word", is_init: is_init, specify_day: specify_day, search_key: search_key}, function (j) {
|
1659
1659
|
let html = [], index = 0;
|
1660
1660
|
let is_mobile = Util.is_mobile();
|
1661
|
+
let is_speech_synthesis = $("#word_recite").length > 0 ? 1 : 0;
|
1661
1662
|
j["data"].forEach(function (item) {
|
1662
1663
|
index++;
|
1663
1664
|
html.push("<tr>");
|
@@ -1669,6 +1670,9 @@ const Util = {
|
|
1669
1670
|
html.push("<td>", item["chinese"], "</td>");
|
1670
1671
|
}
|
1671
1672
|
html.push("<td>", Util.seconds_to_format(item["date"]), "</td>");
|
1673
|
+
if (is_speech_synthesis === 1) {
|
1674
|
+
html.push("<td class='word_utterance' style='cursor: pointer;'><i class='glyphicon glyphicon-volume-up'></i></td>");
|
1675
|
+
}
|
1672
1676
|
html.push("<td><a href='#' data-toggle='modal' data-target='.word_modal'>修改</a> <a class='word_del' href='#'>删除</a></td>");
|
1673
1677
|
html.push("</tr>");
|
1674
1678
|
});
|
@@ -1687,7 +1691,23 @@ const Util = {
|
|
1687
1691
|
Util.fetch_word_data(0, appoint_day, "");
|
1688
1692
|
});
|
1689
1693
|
}
|
1690
|
-
|
1694
|
+
if (is_speech_synthesis === 1) {
|
1695
|
+
$("#word_process_div_body .word_utterance").each(function () {
|
1696
|
+
$(this).click(function () {
|
1697
|
+
let word = $(this).parent().children('td').eq(1).text();
|
1698
|
+
if (/^[A-Za-z]+$/.test(word)) {
|
1699
|
+
window.speechSynthesis.cancel(); // 清除队列
|
1700
|
+
let utterance = new SpeechSynthesisUtterance(word);
|
1701
|
+
utterance.lang = 'en-US'; // 设置语言为英语(美式英语)
|
1702
|
+
utterance.rate = 1; // 语速(0.1 到 10)
|
1703
|
+
utterance.volume = 1; // 音量(0 到 1)
|
1704
|
+
utterance.pitch = 1; // 音调(0 到 2)
|
1705
|
+
window.speechSynthesis.speak(utterance);
|
1706
|
+
}
|
1707
|
+
});
|
1708
|
+
});
|
1709
|
+
}
|
1710
|
+
$("#word_process_div_body .word_del").each(function () {
|
1691
1711
|
$(this).click(function () {
|
1692
1712
|
let tr_obj = $(this).parent().parent();
|
1693
1713
|
let word = $(tr_obj).children('td').eq(1).text();
|
@@ -2947,11 +2967,7 @@ const Util = {
|
|
2947
2967
|
if (!obj.hasClass("glyphicon-info-sign")) {
|
2948
2968
|
obj.addClass("glyphicon-info-sign");
|
2949
2969
|
}
|
2950
|
-
obj.attr("data-original-title", tip);
|
2951
|
-
obj.attr("data-toggle", "tooltip");
|
2952
|
-
obj.attr("data-placement", "bottom");
|
2953
|
-
obj.attr("data-container", "body");
|
2954
|
-
obj.tooltip();
|
2970
|
+
obj.attr("data-original-title", tip).attr("data-toggle", "tooltip").attr("data-placement", "bottom").attr("data-container", "body").tooltip();
|
2955
2971
|
},
|
2956
2972
|
|
2957
2973
|
/**
|
@@ -3286,6 +3302,9 @@ const Util = {
|
|
3286
3302
|
*/
|
3287
3303
|
pack_html_link: function (url, title) {
|
3288
3304
|
if (url) {
|
3305
|
+
if (url === "#") {
|
3306
|
+
return "<a class='link_cls' href='#'>" + title + "</a>";
|
3307
|
+
}
|
3289
3308
|
if (!url.startsWith("http") && !url.startsWith("/")) {
|
3290
3309
|
url = "http://" + url;
|
3291
3310
|
}
|