Przeglądaj źródła

Merge pull request #375 from visuddhinanda/master

同步支持选择
visuddhinanda 4 lat temu
rodzic
commit
e88687be3b

+ 2 - 1
app/article/index.php

@@ -93,7 +93,8 @@ require_once "../pcdl/html_head.php";
 	else{
 		$contentClass .= ' sent_mode ';
 	}
-
+	$contentClass .= " $_mode ";
+	
 	?>
 	</script>
 

+ 2 - 0
app/pcdl/html_head.php

@@ -83,6 +83,8 @@ if (isset($_GET["language"])) {
 	<script src="../term/note.js"></script>
 	<script src="../term/term_popup.js"></script>
 	<link type="text/css" rel="stylesheet" href="../term/term.css" />
+	<link type="text/css" rel="stylesheet" href="../term/term_mobile.css" media="screen and (max-width:800px)">
+
 	<?php
 	if (isset($_GET["display"]) && $_GET["display"] == "para") {
 		echo '<link type="text/css" rel="stylesheet" href="../term/term_para.css"/>';

+ 1 - 1
app/sync/login.php

@@ -36,7 +36,7 @@ if(isset($_POST["userid"]) && isset($_POST["password"]) ){
 				setcookie ( "sync_userid" ,  $_POST["userid"] , 0 ,  "/" , "" ,  false , true );
 				setcookie ( "sync_server" ,  $_POST["server"] , 0 ,  "/" , "" ,  false , true );				
 				$redis->hset("sync://key",$_POST["userid"],$arrServerMsg["key"]);
-				$output["message"]="本机登录成功<br>服务器验证成功<br>";
+				$output["message"]="本机登录成功<br>服务器验证成功<br>".$arrServerMsg["message"];
 				$output["message"].="<a href='index.php'>开始同步</a>";
 			}
 			else{

+ 22 - 7
app/sync/sync.js

@@ -1,6 +1,7 @@
 var sync_db_list = [
 	{ script: "sync/table_article.php", count: -1, finished: 0, enable: false },
-	{ script: "sync/table_term.php", count: -1, finished: 0, enable: false },
+	{ script: "sync/table_term_channel.php", count: -1, finished: 0, enable: false },
+	{ script: "sync/table_term_editor.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_article_collect.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_channel.php", count: -1, finished: 0, enable: false },
 	{ script: "sync/table_sentence.php", count: -1, finished: 0, enable: true },
@@ -118,21 +119,35 @@ function sync_do_db(src, dest, time = 1) {
 		);
 	}
 }
+
+function db_selected(obj) {
+	let index = $(obj).attr("index");
+	sync_db_list[index].enable = obj.checked;
+}
+
 function render_progress() {
 	let html = "";
-	for (const iterator of sync_db_list) {
-		let spanWidth = parseInt((500 * iterator.finished) / iterator.count);
+	for (let index = 0; index < sync_db_list.length; index++) {
+		const element = sync_db_list[index];
+		let spanWidth = parseInt((500 * element.finished) / element.count);
+		html += "<div style='width:500px;background-color:white;color:black;'>";
+		html += "<input type='checkbox' index='" + index + "' ";
+		if (element.enable) {
+			html += "checked";
+		}
+		html += " onclick='db_selected(this)' />";
 		html +=
-			"<div style='width:500px;background-color:white;color:black;'><span style='background-color:green;display:inline-block;width:" +
+			"<span style='background-color:green;display:inline-block;width:" +
 			spanWidth +
 			"px;'>" +
-			iterator.script +
+			element.script +
 			"|" +
-			iterator.finished +
+			element.finished +
 			"/" +
-			iterator.count +
+			element.count +
 			"<span></div>";
 	}
+
 	$("#sync_result").html(html);
 }
 function login() {

+ 2 - 2
app/sync/table_sentence.php

@@ -13,7 +13,7 @@ $input = (object) [
     "sync_id" =>  ["book","paragraph","begin","end","channal"],
     "modify_time" =>  "modify_time",
     "receive_time" =>  "receive_time",
-	"where"=>"and (not (channal is null))",
+	"where"=>"and ( channal IS NOT NULL )",
     "insert" => [
         'id',
 		'block_id',
@@ -108,7 +108,7 @@ switch ($op) {
 			$result = $Sent->update($arrData);
 			if($result==false){
 				$output["error"]=1;
-				$output["message"]="修改失败";				
+				$output["message"]="修改失败";
 			}
 			else{
 				$output["error"]=0;

+ 49 - 0
app/sync/table_term_channel.php

@@ -0,0 +1,49 @@
+<?php
+//header('Content-type: application/json; charset=utf8');
+
+require_once "../path.php";
+require_once "../sync/function.php";
+
+$input = (object) [
+    "database" =>  _FILE_DB_TERM_,
+    "table" =>  "term",
+    "uuid" =>  "guid",
+    "sync_id" =>  ["pali","tag","channal"],
+    "modify_time" =>  "modify_time",
+    "receive_time" =>  "receive_time",
+	"where"=>" and ( (channal IS NOT NULL) or channal <> '') ",
+    "insert" => [
+        'guid',
+		'word',
+		'word_en',
+		'meaning',
+		'other_meaning',
+		'note',
+		'tag',
+		'create_time',
+		'owner',
+		'hit',
+		'language',
+		'receive_time',
+		'modify_time'
+    ],
+    "update" =>  [
+        "word",
+        "word_en",
+        "meaning",
+        "other_meaning",
+        "note",
+        "tag",
+        "owner",
+        "hit",
+        "language",
+        "create_time",
+		"modify_time",
+        "receive_time" 
+    ]    
+];
+
+$result = do_sync($input);
+echo json_encode($result, JSON_UNESCAPED_UNICODE);
+
+?>

+ 2 - 2
app/sync/table_term.php → app/sync/table_term_editor.php

@@ -8,10 +8,10 @@ $input = (object) [
     "database" =>  _FILE_DB_TERM_,
     "table" =>  "term",
     "uuid" =>  "guid",
-    "sync_id" =>  ["pali","tag","channal","owner"],
+    "sync_id" =>  ["pali","tag","owner"],
     "modify_time" =>  "modify_time",
     "receive_time" =>  "receive_time",
-	"where"=>"",
+	"where"=>" and ( (channal IS NULL) or channal = '' )",
     "insert" => [
         'guid',
 		'word',

+ 49 - 0
app/sync/table_user_wbw_block.php

@@ -0,0 +1,49 @@
+<?php
+//header('Content-type: application/json; charset=utf8');
+
+require_once "../path.php";
+require_once "../sync/function.php";
+
+$input = (object) [
+    "database" =>  _FILE_DB_TERM_,
+    "table" =>  "term",
+    "uuid" =>  "guid",
+    "sync_id" =>  ["pali","tag","channal"],
+    "modify_time" =>  "modify_time",
+    "receive_time" =>  "receive_time",
+	"where"=>" and ( (channal IS NOT NULL) or channal <> '') ",
+    "insert" => [
+        'guid',
+		'word',
+		'word_en',
+		'meaning',
+		'other_meaning',
+		'note',
+		'tag',
+		'create_time',
+		'owner',
+		'hit',
+		'language',
+		'receive_time',
+		'modify_time'
+    ],
+    "update" =>  [
+        "word",
+        "word_en",
+        "meaning",
+        "other_meaning",
+        "note",
+        "tag",
+        "owner",
+        "hit",
+        "language",
+        "create_time",
+		"modify_time",
+        "receive_time" 
+    ]    
+];
+
+$result = do_sync($input);
+echo json_encode($result, JSON_UNESCAPED_UNICODE);
+
+?>

+ 7 - 0
app/term/error.svg

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="14px" height="14px" viewBox="0 0 14 14"  xml:space="preserve">
+	<path d="M7,0C3.134,0,0,3.134,0,7s3.134,7,7,7s7-3.134,7-7S10.866,0,7,0z M7,2c0.552,0,1,0.447,1,1S7.552,4,7,4S6,3.553,6,3
+	S6.448,2,7,2z M9,11H5v-1h1V6H5V5h3v5h1V11z" />
+</svg>

+ 1 - 0
app/term/loading-onequarter.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1620719939833" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2297" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M512 512m-426.666667 0a426.666667 426.666667 0 1 0 853.333334 0 426.666667 426.666667 0 1 0-853.333334 0Z" fill="#959BA7" fill-opacity=".3" p-id="2298"></path><path d="M938.666667 512c0-235.648-191.018667-426.666667-426.666667-426.666667v426.666667h426.666667z" fill="#008CD1" p-id="2299"></path><path d="M512 512m-320 0a320 320 0 1 0 640 0 320 320 0 1 0-640 0Z" fill="#FFFFFF" p-id="2300"></path></svg>

+ 3 - 0
app/term/loading.svg

@@ -0,0 +1,3 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg t="1620719900640"  viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2162" xmlns:xlink="http://www.w3.org/1999/xlink" width="14px" height="14px"><defs><style type="text/css"></style></defs><path d="M512 128c211.2 0 384 172.8 384 384s-172.8 384-384 384-384-172.8-384-384 172.8-384 384-384m0-64C262.4 64 64 262.4 64 512s198.4 448 448 448 448-198.4 448-448-198.4-448-448-448z" fill="#333333" p-id="2163"></path><path d="M544 512m-32 0a32 32 0 1 0 64 0 32 32 0 1 0-64 0Z" fill="#333333" p-id="2164"></path><path d="M800 512m-32 0a32 32 0 1 0 64 0 32 32 0 1 0-64 0Z" fill="#333333" p-id="2165"></path><path d="M544 480h256v64h-256z" fill="#333333" p-id="2166"></path></svg>

+ 32 - 6
app/term/note.js

@@ -36,6 +36,10 @@ var gBuildinDictIsOpen = false;
 
 */
 function note_create() {
+	$.post("../ucenter/get_setting.php", {}, function (data, status) {
+		setting = JSON.parse(data);
+	});
+
 	wbw_channal_list_init();
 	note_sent_edit_dlg_init();
 	term_edit_dlg_init();
@@ -929,6 +933,18 @@ function render_one_sent_tran_a(iterator) {
 	html += "</div>";
 	//tool_bar 结束
 	html += '<div class="left_bar" >';
+	html += "<span class='icon_sent_status icon_sent_loading'>";
+	html +=
+		"<svg class='icon icon_spin' style='fill: var(--detail-color); '>" +
+		"<use xlink='http://www.w3.org/1999/xlink' href='../studio/svg/icon.svg#loading'></use>" +
+		"</svg>";
+	html += "</span>";
+	html += "<span class='icon_sent_status icon_sent_error' title='再次发送' onclick='tran_sent_save(this)'>";
+	html +=
+		"<svg class='icon' style='fill: red; '>" +
+		"<use xlink='http://www.w3.org/1999/xlink' href='../term/error.svg'></use>" +
+		"</svg>";
+	html += "</span>";
 	html += '	<div class="face">';
 	if (iterator.id != "") {
 		html += '<span class="head_img">' + iterator.editor_name.nickname.slice(0, 1) + "</span>";
@@ -977,7 +993,7 @@ function render_one_sent_tran_a(iterator) {
 	html += "<a onclick='tran_sent_edit_cancel(this)'>" + gLocal.gui.cancel + "</a>";
 	html += "</span>";
 	html += "<span style='display: inline-flex;'>";
-	html += '<span class="keybutton" >Ctrl</span>';
+	html += '<span class="keybutton" >Ctrl/⌘</span>';
 	html += "➕";
 	html += '<span class="keybutton" >Enter</span> = ';
 	if (parseInt(iterator.mypower) < 20) {
@@ -1393,6 +1409,8 @@ function set_more_button_display() {
 								$(".other_tran_div[sent='" + sentId + "']")
 									.children(".other_tran")
 									.html(html);
+								//初始化文本编辑框消息处理
+								tran_sent_textarea_event_init();
 							}
 						);
 					} else {
@@ -1496,7 +1514,7 @@ function note_pr_save(obj) {
 	);
 
 	if (sent_tran_div) {
-		$(sent_tran_div).find(".preview").addClass("loading");
+		$(sent_tran_div).addClass("loading");
 	}
 }
 
@@ -1552,12 +1570,20 @@ function note_sent_save_a(obj) {
 			//alert("second success");
 		})
 		.error(function (xhr, error, data) {
+			let sid = book + "-" + para + "-" + begin + "-" + end;
+
+			let sent_tran_div = $(".sent_tran[channel='" + channal + "'][sid='" + sid + "']");
+			if (sent_tran_div) {
+				sent_tran_div.removeClass("loading");
+				sent_tran_div.addClass("error");
+			}
+
 			switch (error) {
 				case "timeout":
-					alert("服务器长时间没有回应。");
+					alert("服务器长时间没有回应。请稍后重试。");
 					break;
 				case "error":
-					alert("与服务器通讯失败,您可能没有连接到网络。");
+					alert("与服务器通讯失败,您可能没有连接到网络。请稍后重试。");
 					break;
 				case "notmodified":
 					break;
@@ -1578,7 +1604,7 @@ function note_sent_save_a(obj) {
 		});
 
 	if (sent_tran_div) {
-		$(sent_tran_div).find(".preview").addClass("loading");
+		$(sent_tran_div).addClass("loading");
 	}
 }
 function update_sent_tran(sentData) {}
@@ -1625,7 +1651,7 @@ function sent_save_callback(data) {
 						}
 					}
 				}
-				sent_tran_div.find(".preview").removeClass("loading");
+				sent_tran_div.removeClass("loading");
 			}
 		} else if (result.commit_type == 3) {
 			ntf_show("已经提交修改建议");

+ 57 - 1
app/term/term.css

@@ -606,7 +606,7 @@ pw {
 }
 .sent_tran .left_bar > .face {
 	display: block;
-	margin: auto 0.5em auto auto;
+	margin: 0 0.5em auto auto;
 }
 .compact .left_bar > .face {
 	display: none;
@@ -868,3 +868,59 @@ span.keybutton {
 span.tran_sent {
 	display: block;
 }
+
+.icon_sent_status {
+	display: none;
+	width: 22px;
+	height: 22px;
+	background-repeat: no-repeat;
+	background-size: contain;
+	margin: 0 6px;
+}
+.icon_sent_status .icon {
+	width: 22px;
+	height: 22px;
+}
+.icon_sent_loading {
+	background: url(loading.gif);
+	background-size: contain;
+}
+.loading .icon_sent_loading {
+	display: block;
+}
+.loading .face {
+	display: none;
+}
+.error .left_bar > .face {
+	display: none;
+}
+.icon_sent_error {
+	display: none;
+	fill: red;
+	cursor: pointer;
+	background: url(error.svg);
+	background-size: contain;
+}
+.error .icon_sent_error {
+	display: block;
+}
+.icon_spin {
+	-webkit-animation: spin 1.5s linear infinite;
+	animation: spin 1.5s linear infinite;
+}
+
+.read .bg_color_1 {
+	background-color: unset;
+}
+.read .bg_color_2 {
+	background: unset;
+}
+.read .bg_color_3 {
+	background: unset;
+}
+.read .bg_color_4 {
+	background: unset;
+}
+.read .bg_color_5 {
+	background: unset;
+}

+ 23 - 7
app/term/term.js

@@ -7,7 +7,7 @@ var arrWordIdTermId = new Array();
 
 //术语渲染模板
 var strTermTanslationTmp = "[%mean%](%pali% %mean2% %mymean%)";
-var strTermTanslationTmp2 = "[%mean%](%pali%)";
+var strTermTanslationTmp2 = "[%mean%]";
 
 var termCounter = new Array();
 var noteCounter = 0; //正文内注释计数器
@@ -409,6 +409,15 @@ function term_array_updata() {
 function term_updata_translation() {
 	termCounter = new Array();
 	noteCounter = 1;
+	//计算有效模版数量
+	let iValidTmp = 0;
+	if (typeof setting !== "undefined") {
+		for (const iterator of setting["term.template"]) {
+			if (iterator != "") {
+				iValidTmp++;
+			}
+		}
+	}
 	$("term").each(function () {
 		let status = $(this).attr("status");
 		let termText = $(this).text();
@@ -466,10 +475,18 @@ function term_updata_translation() {
 				if (renderTo == "wbw") {
 					noteText = "%note%";
 				} else {
-					if (termCounter[guid] == 1) {
-						noteText = strTermTanslationTmp;
+					if (typeof setting !== "undefined") {
+						let currTermCounter = termCounter[guid];
+						if (currTermCounter > iValidTmp) {
+							currTermCounter = iValidTmp;
+						}
+						noteText = setting["term.template"][currTermCounter - 1];
 					} else {
-						noteText = strTermTanslationTmp2;
+						if (termCounter[guid] == 1) {
+							noteText = strTermTanslationTmp;
+						} else {
+							noteText = strTermTanslationTmp2;
+						}
 					}
 				}
 
@@ -492,10 +509,9 @@ function term_updata_translation() {
 				noteText = noteText.replace("]", "</span>");
 				noteText = noteText.replace("%mean%", "<span class='term_mean'>" + mean + "</span>");
 				noteText = noteText.replace("%pali%", "<span class='term_pali'>" + pali + "</span>");
-				if(mean2!=""){
+				if (mean2 != "") {
 					noteText = noteText.replace("%mean2%", ", <span class='term_mean2'>" + mean2 + "</span>");
-				}
-				else{
+				} else {
 					noteText = noteText.replace("%mean2%", "");
 				}
 				noteText = noteText.replace("%note%", "<span class='term_note'>" + "" + "</span>");

+ 9 - 0
app/term/term_mobile.css

@@ -0,0 +1,9 @@
+/*段落模式 横向*/
+.horizontal .para_div {
+	flex-direction: column;
+}
+/*句子模式 横向*/
+
+.horizontal .note_shell > note > .note_body {
+	flex-direction: column;
+}

+ 7 - 0
app/term/waiting.svg

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="14px" height="14px" viewBox="0 0 14 14"  xml:space="preserve">
+	<path d="M7,0C3.134,0,0,3.134,0,7s3.134,7,7,7s7-3.134,7-7S10.866,0,7,0z M7,2c0.552,0,1,0.447,1,1S7.552,4,7,4S6,3.553,6,3
+	S6.448,2,7,2z M9,11H5v-1h1V6H5V5h3v5h1V11z" />
+</svg>

+ 2 - 1
app/ucenter/default.json

@@ -21,5 +21,6 @@
 	"dict.blacklist": ["@all", "bhmf"],
 	"lib.first_script": "Roman",
 	"lib.second_script": "none",
-	"lib.pali_script": ["none", "Roman", "မြန်မာ"]
+	"lib.pali_script": ["none", "Roman", "မြန်မာ"],
+	"term.template": ["[%mean%](%pali% %mean2% %mymean%)", "[%mean%]", "", ""]
 }

+ 39 - 3
app/ucenter/setting.js

@@ -1,4 +1,11 @@
 var setting;
+$(document).load(function () {
+	$.post("../ucenter/get_setting.php", {}, function (data, status) {
+		try {
+			setting = JSON.parse(data);
+		} catch (e) {}
+	});
+});
 function setting_head_render(file) {
 	let html = '<svg class="head_icon" style="height: 3em;width: 3em;">';
 	html += '<use xlink:href="../head/images/"' + file + "></use>";
@@ -20,11 +27,40 @@ function setting_onload() {
 			//Library 设置
 
 			html = "";
-			html += "<h3>"+gLocal.gui.script+gLocal.gui.display+"</h3>";
-			html += "<div>"+gLocal.gui.main_code +"&nbsp;"+ setting_render_paliscript("lib.first_script") + "</div>";
-			html += "<div>"+gLocal.gui.sub_pcode +"&nbsp;"+ setting_render_paliscript("lib.second_script") + "</div>";
+			html += "<h3>" + gLocal.gui.script + gLocal.gui.display + "</h3>";
+			html +=
+				"<div>" + gLocal.gui.main_code + "&nbsp;" + setting_render_paliscript("lib.first_script") + "</div>";
+			html +=
+				"<div>" + gLocal.gui.sub_pcode + "&nbsp;" + setting_render_paliscript("lib.second_script") + "</div>";
+			html += "<h3>术语模版" + "</h3>";
+			html +=
+				"<div>第一次出现<input type='input' class='term_template' index='0' value='" +
+				setting["term.template"][0] +
+				"' placeholder='不能为空'/>" +
+				"</div>";
+			html +=
+				"<div>第二次出现<input type='input'  class='term_template' index='1' value='" +
+				setting["term.template"][1] +
+				"' placeholder='同上'/>" +
+				"</div>";
+			html +=
+				"<div>第三次出现<input type='input'  class='term_template' index='2' value='" +
+				setting["term.template"][2] +
+				"' placeholder='同上'/>" +
+				"</div>";
+			html +=
+				"<div>第四次出现<input type='input'  class='term_template' index='3' value='" +
+				setting["term.template"][3] +
+				"' placeholder='同上' />" +
+				"</div>";
+			html += "<div>以后出现同第四次</div>";
+			html += "<div><button onclick='setting_save()'>保存</button></div>";
 
 			$("#setting_library").html(html);
+			$(".term_template").change(function () {
+				$index = $(this).attr("index");
+				setting["term.template"][$index] = $(this).val();
+			});
 			//Library 设置结束
 
 			//Studio 设置

+ 4 - 0
app/usent/historay.js

@@ -1,3 +1,7 @@
+/**
+ * 显示句子历史记录窗口
+ */
+
 function historay_init() {
 	$("body").append('<div id="sent_history_dlg" title="History"><div id="sent_history_content"></div></div>');
 	$("#sent_history_dlg").dialog({

+ 2 - 2
app/usent/usent_ref.js

@@ -124,7 +124,7 @@ class USentResult {
 								"_" +
 								oneSent.channal
 						).html(
-							"<svg class='icon icon_spin' style='fill: var(--detail-color); '><use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#loading'>"
+							"<svg class='icon icon_spin' style='fill: var(--detail-color); '><use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#loading'></use></svg>"
 						);
 					}
 					$.post(
@@ -151,7 +151,7 @@ class USentResult {
 											iterator.channal
 									).html(
 										now_time.toLocaleTimeString() +
-											"<svg class='icon' style='fill: var(--detail-color);'><use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_done'>"
+											"<svg class='icon' style='fill: var(--detail-color);'><use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_done'></use></svg>"
 									);
 								}
 							}