添加收藏文本功能,更改划词搜索UI

This commit is contained in:
fofolee 2020-04-05 14:15:40 +08:00
parent 5fd5144b4b
commit 18e3ff0fed

View File

@ -394,14 +394,15 @@ $(document).keydown(e => {
}) })
} }
} }
break;
// 划词翻译 // 划词翻译
case 84: case 84:
if ($('#mainlist').is(':hidden') && $("#manual").is(":visible")) { if ($('#mainlist').is(':hidden') && $("#manual").is(":visible")) {
let text = window.getSelection().toString(); let text = window.getSelection().toString();
if (text) { if (text) {
if (/[\u4e00-\u9fa5]/.test(text)){ // if (/[\u4e00-\u9fa5]/.test(text)){
utools.showNotification('中文你还看不懂嘛!', clickFeatureCode = null, silent = true) // utools.showNotification('中文你还看不懂嘛!', clickFeatureCode = null, silent = true)
} else { // } else {
let enText = encodeURIComponent(text) let enText = encodeURIComponent(text)
$("#infopannel").html('在线翻译中...').fadeIn(300); $("#infopannel").html('在线翻译中...').fadeIn(300);
$.get("http://fanyi.youdao.com/translate?&doctype=json&type=EN2ZH_CN&i=" + enText, data => { $.get("http://fanyi.youdao.com/translate?&doctype=json&type=EN2ZH_CN&i=" + enText, data => {
@ -417,8 +418,9 @@ $(document).keydown(e => {
} }
$("#infopannel").html(cnText) $("#infopannel").html(cnText)
}) })
} // }
} }
} }
break;
} }
}); });