Browse Source

Merge pull request #527 from visuddhinanda/master

@visuddhinanda
加入中文测试函数
a8c4fb4
@visuddhinanda
拆分意思自动合并到整体意思检测中文,单词间不加空格,没有中文,加空格。
655a11d
@visuddhinanda
删除带字典名的菜单
837ba55
@visuddhinanda
意思下拉菜单增加查字典按钮
ed62225
@visuddhinanda
🎨 单词编辑框拆分下拉菜单不换行
f23b1e3
@visuddhinanda
取消拆分意思空白时的下箭头
b2f91c3
@visuddhinanda
🐛 中文检测错误
visuddhinanda 4 years ago
parent
commit
c3d8835d56
3 changed files with 57 additions and 36 deletions
  1. 31 0
      app/public/js/comm.js
  2. 8 0
      app/studio/editor.php
  3. 18 36
      app/studio/js/editor.js

+ 31 - 0
app/public/js/comm.js

@@ -244,5 +244,36 @@ function str_diff(str1, str2) {
 	});
 	return output;
 }
+
+function testCJK(string){
+	/*
+	\u4e00-\u9fa5 (中文)
+	U+4E00至U+9FFF[1]
+	U+3400至U+4DBF[2](扩展A)
+	U+20000至U+2A6DF[3](扩展B)
+	U+2A700至U+2B73F[4](扩展C)
+	U+2B740至U+2B81F[5](扩展D)
+	U+2B820至U+2CEAF[6](扩展E)
+	U+F900至U+FAFF[7](兼容)
+	U+2F800至U+2FA1F[8](兼容补充)
+	U+2F00至U+2FDF[9](康熙部首)
+	U+2E80至U+2EFF[10](部首补充)
+	U+31C0至U+31EF[11](笔画)
+
+	\x3130-\x318F (韩文
+	\xAC00-\xD7A3 (韩文)
+	Unicode范围	U+AC00-U+D7A3,
+	U+1100-U+11FF,
+	U+3131-U+318E,
+	U+FFA1-U+FFDC
+
+	\u0800-\u4e00 (日文)ひらがな平仮名
+	U+4E00–U+9FBF 汉字; U+3040–U+309F 平假名; U+30A0–U+30FF 片假名
+	*/
+	reg = /[\u4e00-\u9fa5]+/;//cn
+	return reg.test(string);
+
+}
+
 //所有页面都需要在加载的的时候设置浏览器时区
 setTimeZone();

+ 8 - 0
app/studio/editor.php

@@ -259,6 +259,14 @@ else{$currDevice="computer";}
 		min-width: 1em;
 		min-height: 1.3em;
 	}
+
+	#word_mdf_parts_dropdown  a {
+		width: 100%;
+		display: inline-block;
+		overflow: hidden;
+		white-space: nowrap;
+		text-overflow: ellipsis;
+	}
 	</style>
 	<link type="text/css" rel="stylesheet" href="css/print.css" media="print" />
 	<style id="display_set">

+ 18 - 36
app/studio/js/editor.js

@@ -3541,7 +3541,13 @@ function refreshPartMeaningSelect() {
 }
 //编辑窗口拆分意思复制到整体意思
 function copy_part_mean_to_mean() {
-	$("#input_meaning").val(removeFormulaB(g_arrPartMean.join(""), "[", "]"));
+	let meaning = g_arrPartMean.join("");
+	if(testCJK(meaning)){
+		$("#input_meaning").val(removeFormulaB(g_arrPartMean.join(""), "[", "]"));
+	}else{
+		$("#input_meaning").val(removeFormulaB(g_arrPartMean.join(" "), "[", "]"));
+	}
+	
 }
 //编辑窗口拆分意思下拉菜单
 function getMeaningMenuList(index, word) {
@@ -3557,7 +3563,7 @@ function getMeaningMenuList(index, word) {
 	if (part_mean_display_array.length - 1 >= index) {
 		currMeaningList.push(part_mean_display_array[index]);
 	} else {
-		currMeaningList.push("↓↓");
+		currMeaningList.push(" ");
 	}
 	for (const iterator of currMeaningList0) {
 		if (iterator != "") {
@@ -3577,51 +3583,27 @@ function getMeaningMenuList(index, word) {
 		currMean = g_arrPartMean[index];
 	}
 	if (currMean == "") {
-		currMean = "↓↓";
+		currMean = " ";
 	}
 	output += currMean + "</p>";
 
 	output += '<div class="case_dropdown-content" id=\'part_mean_menu_' + index + "'>";
 	//直列菜单
-	for (i in currMeaningList) {
-		output +=
-			"<a onclick='meaningPartChange(" +
-			index +
-			',"' +
-			currMeaningList[i] +
-			"\")'>" +
-			currMeaningList[i] +
-			"</a>";
-	}
-
-	//带字典名的菜单
-	/*
-	if(mDict[word]){
-		for(var j=0;j<mDict[word].length;j++){
-			//
-			output += "<div class='om_menu'>";
-			var dictName = mDict[word][j].dict_name;
-			if(dictName==""){
-				dictName="未知";
-			}
-			output += "<span>"+dictName+"</span>";
-			var currOM=mDict[word][j].mean.split("$");
-			for(var iMean in currOM){
-				if(currOM[iMean].length>0 && currOM[iMean]!="?"){
-					output +="<a  onclick='meaningPartChange("+index+",\""+currOM[iMean]+"\")'>"+currOM[iMean]+"</a>";
-				}
-			}
-			output +="</div>";			
+	output += "<a onclick='meaningPartLookup(\"" +word +"\")'>🔍" +gLocal.gui.dict +"</a>";	
+	for (const itMean of currMeaningList) {
+		if(itMean!="?"){
+			output += "<a onclick='meaningPartChange(" +index +	',"' +itMean +	"\")'>" +itMean +"</a>";					
 		}
+
 	}
-	else{
-		output += "未知";
-	}
-	*/
+
 	output += "</div>";
 	output += "</div>";
 	return output;
 }
+function meaningPartLookup(word){
+	window.open("../dict/index.php?builtin=true&theme=dark&key="+word,target="dict");
+}
 function getWordMeaningList(word) {
 	var currOM = "";
 	var arrOM = new Array();