sbd-npm 1.4.44 → 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 +20 -1
- package/util.js +5 -2
package/package.json
CHANGED
package/status.js
CHANGED
@@ -746,7 +746,7 @@ $(function () {
|
|
746
746
|
{"name": "时间", "table_sort": 1},
|
747
747
|
];
|
748
748
|
if ('speechSynthesis' in window) {
|
749
|
-
head_cols.push({"name": "朗读"});
|
749
|
+
head_cols.push({"name": "朗读", "id": "word_recite", "link": "#"});
|
750
750
|
}
|
751
751
|
head_cols.push({"name": "操作"});
|
752
752
|
Util.init_table_skeleton({
|
@@ -754,11 +754,30 @@ $(function () {
|
|
754
754
|
"caption": '<caption class="' + (is_mobile ? "text-left" : "text-right") + '" id="word_num"></caption>',
|
755
755
|
"head_cols": head_cols
|
756
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
|
+
}
|
767
|
+
});
|
757
768
|
Status.init_word_modal();
|
758
769
|
}
|
759
770
|
Util.fetch_word_data(is_init, "", "");
|
760
771
|
},
|
761
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
|
+
|
762
781
|
init_machine_action_modal: function () {
|
763
782
|
Util.init_modal_skeleton("machine_action_modal");
|
764
783
|
$("#machine_action_modal_title").html("添加任务");
|
package/util.js
CHANGED
@@ -1658,7 +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 =
|
1661
|
+
let is_speech_synthesis = $("#word_recite").length > 0 ? 1 : 0;
|
1662
1662
|
j["data"].forEach(function (item) {
|
1663
1663
|
index++;
|
1664
1664
|
html.push("<tr>");
|
@@ -1695,7 +1695,7 @@ const Util = {
|
|
1695
1695
|
$("#word_process_div_body .word_utterance").each(function () {
|
1696
1696
|
$(this).click(function () {
|
1697
1697
|
let word = $(this).parent().children('td').eq(1).text();
|
1698
|
-
if (word) {
|
1698
|
+
if (/^[A-Za-z]+$/.test(word)) {
|
1699
1699
|
window.speechSynthesis.cancel(); // 清除队列
|
1700
1700
|
let utterance = new SpeechSynthesisUtterance(word);
|
1701
1701
|
utterance.lang = 'en-US'; // 设置语言为英语(美式英语)
|
@@ -3302,6 +3302,9 @@ const Util = {
|
|
3302
3302
|
*/
|
3303
3303
|
pack_html_link: function (url, title) {
|
3304
3304
|
if (url) {
|
3305
|
+
if (url === "#") {
|
3306
|
+
return "<a class='link_cls' href='#'>" + title + "</a>";
|
3307
|
+
}
|
3305
3308
|
if (!url.startsWith("http") && !url.startsWith("/")) {
|
3306
3309
|
url = "http://" + url;
|
3307
3310
|
}
|