Просмотр исходного кода

Merge pull request #381 from visuddhinanda/master

🐛 单句采纳 采纳了全部
visuddhinanda 4 лет назад
Родитель
Сommit
6b267c8f57

+ 3 - 2
app/article/index.php

@@ -37,7 +37,8 @@ require_once "../pcdl/html_head.php";
 	if(isset($_GET["author"])){
 		echo "_author='".$_GET["author"]."';";
 	}
-	if(isset($_GET["mode"]) && $_GET["mode"]=="edit"){
+	if(isset($_GET["mode"]) && $_GET["mode"]=="edit" && isset($_COOKIE["userid"])){
+		#登录状态下 编辑模式
 		$_mode = "edit";
 		echo "_mode='edit';";
 	}
@@ -52,7 +53,7 @@ require_once "../pcdl/html_head.php";
 		}
 		else{
 			$_display = $_GET["display"];
-			echo "_display='".$_GET["display"]."';";			
+			echo "_display='".$_GET["display"]."';";	
 		}
 	}
 	else{

+ 8 - 0
app/commit/commit.css

@@ -60,3 +60,11 @@ ins {
 .commit_win_inner {
 	padding: 1em;
 }
+.commit_win_inner #step1 {
+	display: flex;
+	flex-direction: column;
+}
+.commit_win_inner .channel {
+	font-size: 110%;
+	padding: 5px, 5px, 5px, 20px;
+}

+ 9 - 33
app/commit/commit.js

@@ -21,10 +21,11 @@ function commit_render_channel_select() {
 	let html = "";
 	html += "<div class='commit_win_inner' >";
 	html += commit_render_head(1);
-	html += "<div style='display:flex;'>";
+	html += "<div id='step1' >";
 
 	if (typeof _commit_data.src != "undefined") {
-		html += "<div>译文来源:";
+		html += "<div >译文来源</div>";
+		html += "<div class='channel'>";
 		let isFound = false;
 		for (const iterator of _my_channal) {
 			if (_commit_data.src == iterator.id) {
@@ -50,8 +51,8 @@ function commit_render_channel_select() {
 		html += "<div>请选择译文来源";
 		html += "</div>";
 	}
-	html += "<div>目标译文:</div>";
-	html += "<div>";
+	html += "<div>目标译文:</div>";
+	html += "<div class='channel'>";
 	html += "<select id='dest_channel' onchange='dest_change(this)'>";
 	if (typeof _commit_data.dest == "undefined") {
 		let lastDest = localStorage.getItem("commit_dest_" + _commit_data.dest);
@@ -250,18 +251,14 @@ function commit_render_comp(mode) {
 							html += "<ins>" + iterator.translation[0].text + "</ins>";
 						} else {
 							if (iterator.translation[0].update_time > iterator.translation[1].update_time) {
-								html += commit_render_diff(iterator.translation[1].text, iterator.translation[0].text);
-								//html += "<del>" + iterator.translation[1].text + "</del><br>";
-								//html += "<ins>" + iterator.translation[0].text + "</ins>";
+								html += str_diff(iterator.translation[1].text, iterator.translation[0].text);
 							} else {
 								html += "[新]" + iterator.translation[1].text;
 							}
 						}
 						break;
 					case 1:
-						html += commit_render_diff(iterator.translation[1].text, iterator.translation[0].text);
-						//html += "<del>" + iterator.translation[1].text + "</del><br>";
-						//html += "<ins>" + iterator.translation[0].text + "</ins>";
+						html += str_diff(iterator.translation[1].text, iterator.translation[0].text);
 						break;
 					case 2:
 						html += iterator.translation[1].text;
@@ -281,25 +278,6 @@ function commit_render_comp(mode) {
 	return html;
 }
 
-function commit_render_diff(str1, str2) {
-	let output = "";
-
-	const diff = Diff.diffChars(str1, str2);
-
-	diff.forEach((part) => {
-		// green for additions, red for deletions
-		// grey for common parts
-		if (part.added) {
-			output += "<ins>" + part.value + "</ins>";
-		} else if (part.removed) {
-			output += "<del>" + part.value + "</del>";
-		} else {
-			output += part.value;
-		}
-	});
-	return output;
-}
-
 function commit_sent_select(obj) {
 	let sent_id = $(obj).attr("sent_id");
 	for (let iterator of sentData) {
@@ -342,12 +320,10 @@ function commit_pull() {
 	let pullData = new Array();
 	for (const iterator of sentData) {
 		if (iterator.checked) {
-			for (const iterator of _arrData) {
-				pullData.push(iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end);
-			}
-			_commit_data.sent = pullData;
+			pullData.push(iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end);
 		}
 	}
+	_commit_data.sent = pullData;
 	if (pullData.length == 0) {
 		alert("没有数据被选择");
 		return;

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

@@ -226,5 +226,23 @@ function getDataTime(time) {
 	}
 	return output;
 }
+function str_diff(str1, str2) {
+	let output = "";
+
+	const diff = Diff.diffChars(str1, str2);
+
+	diff.forEach((part) => {
+		// green for additions, red for deletions
+		// grey for common parts
+		if (part.added) {
+			output += "<ins>" + part.value + "</ins>";
+		} else if (part.removed) {
+			output += "<del>" + part.value + "</del>";
+		} else {
+			output += part.value;
+		}
+	});
+	return output;
+}
 //所有页面都需要在加载的的时候设置浏览器时区
 setTimeZone();

+ 0 - 1
app/sync/table_term_editor.php

@@ -1,5 +1,4 @@
 <?php
-//header('Content-type: application/json; charset=utf8');
 
 require_once "../path.php";
 require_once "../sync/function.php";

+ 43 - 0
app/sync/table_wbw_block.php

@@ -0,0 +1,43 @@
+<?php
+
+require_once "../path.php";
+require_once "../sync/function.php";
+
+$input = (object) [
+    "database" =>  _FILE_DB_USER_WBW_,
+    "table" =>  "wbw",
+    "uuid" =>  "id",
+    "sync_id" =>  ["block_id","wid"],
+    "modify_time" =>  "modify_time",
+    "receive_time" =>  "receive_time",
+	"where"=>" and ( (channal IS NOT NULL ) or channal <> '' )",
+    "insert" => [
+        'id',
+		'block_id',
+		'book',
+		'paragraph',
+		'wid',
+		'word',
+		'data',
+		'status',
+		'owner',
+		'receive_time',
+		'modify_time'
+    ],
+    "update" =>  [
+        'id',
+		'book',
+		'paragraph',
+		'word',
+		'data',
+		'status',
+		'owner',
+		'receive_time',
+		'modify_time'
+    ]    
+];
+
+$result = do_sync($input);
+echo json_encode($result, JSON_UNESCAPED_UNICODE);
+
+?>

+ 72 - 63
app/term/note.js

@@ -373,6 +373,15 @@ function render_channal_list(channalinfo) {
 	}
 	output += "<div class='list_with_head " + selected + "'>";
 
+	output += '<div class="tool_bar">';
+	output += '<div class="right">';
+	output += '<div class="pop_menu">';
+	output += render_icon_button("copy", "commit_init({src:'" + channalinfo.id + "'})", gLocal.gui.copy_to);
+	output += render_icon_button("ic_mode_edit", "", gLocal.gui.modify);
+	output += "</div>";
+	output += "</div>";
+	output += "</div>";
+
 	output +=
 		'<div class="channel_select"><input type="checkbox" ' + checked + " channal_id='" + channalinfo.id + "'></div>";
 	output += "<div class='head'>";
@@ -750,10 +759,24 @@ function sent_commit(src, id) {
 	commit_init({
 		src: src,
 		sent: [id],
-		express: true,
+		express: false,
 	});
 }
-function render_one_sent_tran_a(iterator) {
+
+function render_icon_button(icon_id, event, tiptitle) {
+	let html = "";
+	html += "<button class='icon_btn tooltip' onclick=\"" + event + '">';
+	html += '<svg class="icon" >';
+	html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#' + icon_id + '"></use>';
+	html += "</svg>";
+	html += "<span class='tooltiptext tooltip-top'>";
+	html += tiptitle;
+	html += "</span>";
+	html += "</button>";
+	return html;
+}
+
+function render_one_sent_tran_a(iterator, diff = false) {
 	let mChannel = get_channel_by_id(iterator.channal);
 
 	let tranText;
@@ -775,8 +798,29 @@ function render_one_sent_tran_a(iterator) {
 				"</span>";
 		}
 	} else {
-		//note_init处理句子链接
-		tranText = note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
+		if (diff) {
+			let orgText = "";
+			for (const oneSent of _arrData) {
+				if (
+					oneSent.book == iterator.book &&
+					oneSent.para == iterator.para &&
+					oneSent.begin == iterator.begin &&
+					oneSent.end == iterator.end
+				) {
+					for (const tran of oneSent.translation) {
+						if (tran.channal == iterator.channal) {
+							orgText = tran.text;
+							break;
+						}
+					}
+					break;
+				}
+			}
+			tranText = str_diff(orgText, iterator.text);
+		} else {
+			//note_init处理句子链接
+			tranText = note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
+		}
 	}
 	let html = "";
 	html += "<div class='sent_tran ";
@@ -795,66 +839,30 @@ function render_one_sent_tran_a(iterator) {
 		if (typeof iterator.is_pr_editor != "undefined" && iterator.is_pr_editor == true) {
 			//提交人
 			//修改按钮
-			html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
-			html += '<svg class="icon" >';
-			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
-			html += "</svg>";
-			html += "<span class='tooltiptext tooltip-top'>";
-			html += gLocal.gui.modify;
-			html += "</span>";
-			html += "</button>";
-
+			html += render_icon_button("ic_mode_edit", "sent_tran_edit(this)", gLocal.gui.modify);
 			//删除按钮
-			html += "<button class='icon_btn tooltip' onclick='sent_pr_del(this)'>";
-			html += '<svg class="icon" >';
-			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_delete"></use>';
-			html += "</svg>";
-			html += "<span class='tooltiptext tooltip-top'>";
-			html += gLocal.gui.delete;
-			html += "</span>";
-			html += "</button>";
+			html += render_icon_button("ic_delete", "sent_pr_del(this)", gLocal.gui.delete);
 		} else {
 			//非提交人
 			if (parseInt(iterator.mypower) >= 20) {
 				//有权限 采纳按钮
-				html += "<button class='icon_btn tooltip' onclick=\"sent_pr_merge('" + iterator.id + "')\">";
-				html += '<svg class="icon" >';
-				html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#accept_copy"></use>';
-				html += "</svg>";
-				html += "<span class='tooltiptext tooltip-top'>";
-				html += gLocal.gui.accept_copy;
-				html += "</span>";
-				html += "</button>";
+				html += render_icon_button(
+					"accept_copy",
+					"sent_pr_merge('" + iterator.id + "')",
+					gLocal.gui.accept_copy
+				);
 			}
 			//点赞按钮
-			html += "<button class='icon_btn tooltip' onclick='sent_pr_like(this)'>";
-			html += '<svg class="icon" >';
-			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#like"></use>';
-			html += "</svg>";
-			html += "<span class='tooltiptext tooltip-top'>";
-			html += gLocal.gui.like;
-			html += "</span>";
-			html += "</button>";
+			html += render_icon_button("like", "sent_pr_like(this)", gLocal.gui.like);
 		}
 	} else {
 		//非pr列表里的句子
 		//编辑按钮
-		html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
-		html += '<svg class="icon" >';
 		if (parseInt(iterator.mypower) < 20) {
-			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#my_idea"></use>';
+			html += render_icon_button("my_idea", "sent_tran_edit(this)", gLocal.gui.suggest);
 		} else {
-			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
+			html += render_icon_button("ic_mode_edit", "sent_tran_edit(this)", gLocal.gui.edit);
 		}
-		html += "</svg>";
-		html += "<span class='tooltiptext tooltip-top'>";
-		if (parseInt(iterator.mypower) < 20) {
-			html += gLocal.gui.suggest;
-		} else {
-			html += gLocal.gui.edit;
-		}
-		html += "</span>";
-		html += "</button>";
 
 		//推送按钮
 		let commitIcon = "";
@@ -874,24 +882,18 @@ function render_one_sent_tran_a(iterator) {
 				commitTipText = gLocal.gui.copy_to;
 			}
 		}
-		html += "<button class='icon_btn tooltip' ";
-		html += " onclick=\"sent_commit('" + iterator.channal + "','" + sid + "')\">";
-		html += '<svg class="icon" >';
-		html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#' + commitIcon + '"></use>';
-		html += "</svg>";
-		html += "<span class='tooltiptext tooltip-top'>";
-		html += commitTipText;
-		html += "</span>";
-		html += "</button>";
+		html += render_icon_button(commitIcon, "sent_commit('" + iterator.channal + "','" + sid + "')", commitTipText);
 		//推送按钮结束
 
 		//更多按钮
 		html += '<div class="case_dropdown">';
+
 		html += "<button class='icon_btn'>";
 		html += '<svg class="icon" >';
 		html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_more"></use>';
 		html += "</svg>";
 		html += "</button>";
+
 		html += '<div class="case_dropdown-content menu_space_between" style="right:0;">';
 		//时间线
 		html += "<a onclick=\"history_show('" + iterator.id + "')\">";
@@ -929,6 +931,7 @@ function render_one_sent_tran_a(iterator) {
 
 	html += "</div>";
 	//句子菜单结束
+
 	html += "</div>";
 	html += "</div>";
 	//tool_bar 结束
@@ -960,13 +963,19 @@ function render_one_sent_tran_a(iterator) {
 	html += '<div class="body">';
 	html += '<div class="head_bar">';
 	html += '<div class="info">';
-	html += '<span class="name" title="' + iterator.editor_name.nickname + gLocal.gui.recent_update + '">';
+	html += '<span class="name channel_name" title="' + iterator.editor_name.nickname + gLocal.gui.recent_update + '">';
 	if (typeof iterator.channalinfo == "undefined") {
 		html += "unkown";
 	} else {
 		html += iterator.channalinfo.name;
 	}
-
+	html += "</span>";
+	html += '<span class="name editor_name" title="' + iterator.channalinfo.name + gLocal.gui.recent_update + '">';
+	if (typeof iterator.channalinfo == "undefined") {
+		html += "unkown";
+	} else {
+		html += iterator.editor_name.nickname;
+	}
 	html += "</span>";
 	html += '<span class="date">' + getPassDataTime(iterator.update_time) + "</span>";
 	html += "</div>";
@@ -1942,9 +1951,9 @@ function note_get_pr(channel, id) {
 		function (data) {
 			let result = JSON.parse(data);
 			if (result.length > 0) {
-				let html = "<div class='compact'>";
+				let html = "<div class='compact pr'>";
 				for (const iterator of result) {
-					html += render_one_sent_tran_a(iterator);
+					html += render_one_sent_tran_a(iterator, true);
 				}
 				html += "</div>";
 				$(".sent_tran[channel='" + channel + "'][sid='" + id + "']")

+ 23 - 1
app/term/term.css

@@ -642,6 +642,15 @@ pw {
 	white-space: nowrap;
 	margin-right: 0.5em;
 }
+.head_bar > .info > .editor_name {
+	display: none;
+}
+.pr .head_bar > .info > .editor_name {
+	display: inline-block;
+}
+.pr .head_bar > .info > .channel_name {
+	display: none;
+}
 .head_bar > .info > .date {
 	font-size: 0.8em;
 	color: gray;
@@ -670,7 +679,12 @@ pw {
 .sent_tran_inner:hover .tool_bar > .right {
 	display: block;
 }
-
+.list_with_head:hover .tool_bar > .right {
+	display: block;
+}
+.list_with_head {
+	position: relative;
+}
 .body > .edit {
 	display: none;
 }
@@ -927,3 +941,11 @@ span.tran_sent {
 .palitext n {
 	color: dodgerblue;
 }
+/*字符串比对*/
+del {
+	color: red;
+}
+ins {
+	background-color: greenyellow;
+	text-decoration: unset;
+}

+ 5 - 5
app/widget/iframe_modal_win.css

@@ -6,11 +6,11 @@
 	width: 100%;
 	height: 100%;
 	display: none;
-	z-index: 99;
+	z-index: 1001;
 }
 .iframe_container {
 	display: none;
-	z-index: 100;
+	z-index: 1002;
 	background-color: var(--bg-color);
 	border-radius: 20px;
 	width: 75%;
@@ -29,11 +29,11 @@
 }
 .model_win_container {
 	display: none;
-	z-index: 100;
+	z-index: 1002;
 	background-color: var(--bg-color);
 	border-radius: 20px;
-	width: 75%;
-	height: 80%;
+	width: 95%;
+	height: 90%;
 	margin: auto;
 	position: fixed;
 	top: 0;