瀏覽代碼

Merge branch 'master' of https://github.com/iapt-platform/mint

bhikkhu-kosalla-china 4 年之前
父節點
當前提交
57ff13ef7c
共有 5 個文件被更改,包括 109 次插入34 次删除
  1. 5 13
      app/studio/editor.php
  2. 22 0
      app/studio/plugin/system_layout/module_function.js
  3. 14 6
      app/term/term.js
  4. 25 15
      app/term/term_edit_dlg.js
  5. 43 0
      app/term/term_post.php

+ 5 - 13
app/studio/editor.php

@@ -87,20 +87,12 @@ else{$currDevice="computer";}
 
 	<script  src="../channal/channal.js"></script>
 	<script>
-		get_channel_list_callback = function(){
+		get_channel_list_callback=renderChannelList();
+		window.addEventListener('load',(event)=>{
+			renderChannelList();
+
+		});
 
-			let html ="";
-			html += "<input type='checkbox' id='layout_channel_display_all' checked channel_id='-1' onclick=\"channelDisplayAll(this)\" />全选</li>"
-			html +="<ul id='layout_channel_display'>";
-			html += "<li><input type='checkbox' checked channel_id='0' onclick=\"channelDisplay(this)\" />其他</li>"
-			if (_my_channal != null) {
-				for (const iterator of _my_channal) {
-					html += "<li><input type='checkbox' checked channel_id='"+iterator.id+"' onclick=\"channelDisplay(this)\" />"+iterator.name+"</li>"
-				}
-				html +="</ul>";
-				$("#layout_channel").html(html);
-			}		
-		}
 	</script>
 
 	

+ 22 - 0
app/studio/plugin/system_layout/module_function.js

@@ -287,4 +287,26 @@ function channelDisplayAll(obj) {
 		$("#layout_channel_display").children("li").children("input").prop("checked",false);
 		$(".trans_text_block").hide();
 	}
+}
+
+function renderChannelList(){
+	let html ="";
+	html += "<div>";
+	html +="<button onclick='renderChannelList()'>";
+	html += "<svg class='icon' style='fill: var(--box-bg-color1)'>";
+	html += "<use xlink:href='../../node_modules/bootstrap-icons/bootstrap-icons.svg#arrow-clockwise'>";
+	html += "</svg>" ;
+	html += gLocal.gui.refresh;
+	html +="</button>";
+	html +="</div>";
+	html += "<input type='checkbox' id='layout_channel_display_all' checked channel_id='-1' onclick=\"channelDisplayAll(this)\" />全选</li>"
+	html +="<ul id='layout_channel_display'>";
+	html += "<li><input type='checkbox' checked channel_id='0' onclick=\"channelDisplay(this)\" />其他</li>"
+	if (_my_channal != null) {
+		for (const iterator of _my_channal) {
+			html += "<li><input type='checkbox' checked channel_id='"+iterator.id+"' onclick=\"channelDisplay(this)\" />"+iterator.name+"</li>"
+		}
+		html +="</ul>";
+		$("#layout_channel").html(html);
+	}
 }

+ 14 - 6
app/term/term.js

@@ -420,7 +420,12 @@ function term_updata_translation() {
 	}
 	$("term").each(function () {
 		let status = $(this).attr("status");
-		let termText = $(this).text();
+
+		let termText;
+		termText = $(this).attr("pali");
+		if(typeof termText=="undefined"){
+			termText = $(this).text();
+		}
 
 		if (termText.slice(0, 1) == "#") {
 			if (status == 0) {
@@ -432,7 +437,8 @@ function term_updata_translation() {
 			$(this).html("<a onclick=\"alert('" + noteText + "')\">[" + noteCounter + "]</a>");
 			noteCounter++;
 		} else {
-			if (status == 0 || status == 2) {
+			//if (status == 0 || status == 2) 
+			{
 				let myterm = term_lookup_my(
 					termText,
 					$(this).attr("channal"),
@@ -457,6 +463,8 @@ function term_updata_translation() {
 			let mean = $(this).attr("mean");
 			let mean2 = $(this).attr("mean2");
 			let renderTo = $(this).attr("pos");
+			let channel = $(this).attr("channal");
+			let lang = $(this).attr("lang");
 			let noteText = "";
 
 			if (termCounter[guid]) {
@@ -504,7 +512,7 @@ function term_updata_translation() {
 						guid +
 						"','" +
 						pali +
-						"')\">"
+						"','"+channel+"','"+lang+"')\">"
 				);
 				noteText = noteText.replace("]", "</span>");
 				noteText = noteText.replace("%mean%", "<span class='term_mean'>" + mean + "</span>");
@@ -535,7 +543,7 @@ function term_updata_translation() {
 					str_term_fun_word_link +
 					"('','" +
 					termText +
-					"')\">" +
+					"','"+channel+"','"+lang+"')\">" +
 					termText +
 					"</span>";
 			}
@@ -545,10 +553,10 @@ function term_updata_translation() {
 	term_popup_init();
 }
 
-function term_show_win(guid, keyWord = "") {
+function term_show_win(guid, keyWord = "",channel="",lang="") {
 	if (guid == "") {
 		if (typeof term_body == "undefined") {
-			term_edit_dlg_open("", keyWord);
+			term_edit_dlg_open("", keyWord,channel,lang);
 		} else {
 			$(term_body).html(
 				"“" +

+ 25 - 15
app/term/term_edit_dlg.js

@@ -22,7 +22,7 @@ function term_edit_dlg_init(title = gLocal.gui.dict_terms) {
 		],
 	});
 }
-function term_edit_dlg_open(id = "", word = "") {
+function term_edit_dlg_open(id = "", word = "",channel="",lang="") {
 	if (id == "") {
 		let newWord = new Object();
 		newWord.guid = "";
@@ -31,8 +31,8 @@ function term_edit_dlg_open(id = "", word = "") {
 		newWord.other_meaning = "";
 		newWord.tag = "";
 		newWord.note = "";
-		newWord.language = "zh";
-		newWord.channal = "";
+		newWord.language = lang;
+		newWord.channel = channel;
 		let html = term_edit_dlg_render(newWord);
 		$("#term_edit_dlg_content").html(html);
 		$("#term_edit_dlg").dialog("open");
@@ -117,22 +117,21 @@ function term_edit_dlg_render(word = "") {
 
 	output += "<fieldset>";
 	output += "<legend>" + gLocal.gui.channel + "</legend>";
-	output +=
-		"<input type='input' id='term_edit_form_channal' name='channal' value='" +
-		word.channal +
-		"' placeholder=" +
-		gLocal.gui.optional +
-		">";
+	output += "<select id='term_edit_form_channal' name='channal'>";
+	output += "<option value=''>通用于所有版本</option>";
+	for (const iterator of _my_channal) {
+		if(iterator.id==word.channel){
+		output += "<option value='"+iterator.id+"'>仅用于"+iterator.name+"</option>";
+		}
+	}
+	output += "</select>";
 	output += "</fieldset>";
 
 	output += "<fieldset>";
 	output += "<legend>" + gLocal.gui.encyclopedia + "</legend>";
-	output +=
-		"<textarea id='term_edit_form_note' name='note' placeholder=" +
-		gLocal.gui.optional +
-		">" +
-		word.note +
-		"</textarea>";
+	output += "<textarea id='term_edit_form_note' name='note' placeholder=" + gLocal.gui.optional +	">";
+	output += word.note ;
+	output += "</textarea>";
 	output += "</fieldset>";
 	output += "</form>";
 
@@ -149,6 +148,17 @@ function term_edit_dlg_save() {
 
 			if (result.status == 0) {
 				alert(result.message + gLocal.gui.saved + gLocal.gui.successful);
+				for (let index = 0; index < arrMyTerm.length; index++) {
+					const element = arrMyTerm[index];
+					if(element.guid==result.data.guid){
+						arrMyTerm.splice(index,1);
+						break;
+					}
+				}
+				arrMyTerm.push(result.data);
+				
+				term_updata_translation();
+
 			} else {
 				alert("error:" + result.message);
 			}

+ 43 - 0
app/term/term_post.php

@@ -58,6 +58,17 @@ if ($_POST["id"] != "") {
     } else {
         $respond['status'] = 0;
         $respond['message'] = $_POST["word"];
+        $respond['data'] = ["guid"=>$_POST["id"],
+							"word"=>$_POST["word"],
+							"word_en"=>$_POST["word"],
+							"meaning"=>$_POST["mean"],
+							"other_meaning"=>$_POST["mean2"],
+							"tag"=>$_POST["tag"],
+							"channal"=>$_POST["channal"],
+							"language"=>$_POST["language"],
+							"note"=>$_POST["note"],
+							"owner"=>$_COOKIE["userid"]
+						];
     }
 } else {
 	#新建
@@ -79,6 +90,26 @@ if ($_POST["id"] != "") {
 		echo json_encode($respond, JSON_UNESCAPED_UNICODE);
 		exit;
 	}
+	#先查询是否有重复数据
+	if($_POST["channal"]==""){
+		$query = "SELECT id from term where word= ? and  language=? and tag=? and owner = ? ";
+		$stmt = $PDO->prepare($query);
+		$stmt->execute(array($_POST["word"],$_POST["language"],$_POST["tag"],$_COOKIE["userid"]));
+	}else{
+		$query = "SELECT id from term where word= ? and channal=?  and tag=? and owner = ? ";
+		$stmt = $PDO->prepare($query);
+		$stmt->execute(array($_POST["word"],$_POST["channal"],$_POST["tag"],$_COOKIE["userid"]));
+	}
+	
+	if ($stmt) {
+		$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
+		if($Fetch){
+			$respond['status'] = 1;
+			$respond['message'] = "已经有同样的记录";
+			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+			exit;
+		}
+	}
     $parm[] = UUID::v4();
     $parm[] = $_POST["word"];
     $parm[] = pali2english($_POST["word"]);
@@ -103,6 +134,18 @@ if ($_POST["id"] != "") {
     } else {
         $respond['status'] = 0;
         $respond['message'] = $_POST["word"];
+        $respond['data'] = ["guid"=>$parm[0],
+							"word"=>$parm[1],
+							"word_en"=>$parm[2],
+							"meaning"=>$parm[3],
+							"other_meaning"=>$parm[4],
+							"tag"=>$parm[5],
+							"channal"=>$parm[6],
+							"language"=>$parm[7],
+							"note"=>$parm[8],
+							"owner"=>$parm[9]
+						];
+
     }
 }