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

Merge commit 'e39693b0798699c921fbc8a2fb3b266dd8c51c68' of http://192.168.8.168/mint/

Bhikkhu-Kosalla 5 лет назад
Родитель
Сommit
2865c99f70

+ 13 - 0
app/article/article.js

@@ -175,3 +175,16 @@ function set_channal(channalid) {
 	}
 	location.assign(url);
 }
+function setMode(mode = "read") {
+	let url = "../article/index.php?id=" + _articel_id;
+	if (_channal != "") {
+		url += "&channal=" + _channal;
+	}
+	if (_display != "") {
+		url += "&display=" + _display;
+	}
+	if (mode != "") {
+		url += "&mode=" + mode;
+	}
+	location.assign(url);
+}

+ 18 - 33
app/article/index.php

@@ -39,6 +39,14 @@ require_once "../pcdl/html_head.php";
 	if(isset($_GET["author"])){
 		echo "_author='".$_GET["author"]."';";
 	}
+	if(isset($_GET["mode"]) && $_GET["mode"]=="edit"){
+		$_mode = "edit";
+		echo "_mode='edit';";
+	}
+	else{
+		$_mode = "read";
+		echo "_mode='read';";
+	}
 	?>
 	</script>
 
@@ -69,38 +77,6 @@ require_once "../pcdl/html_head.php";
 			echo "<a href='../article/frame.php?id=".$_GET["id"];
 			echo "'>{$_local->gui->add}{$_local->gui->subfield}</a></button>";	
 			
-			
-			if(isset($_GET["display"]) && $_GET["display"]=="para"){
-				echo "<button class='icon_btn active' title='{$_local->gui->show} {$_local->gui->each_paragraph}'>";
-				echo $_local->gui->each_paragraph;
-				echo "</button>";
-			}
-			else{
-				
-				echo "<button class='icon_btn'>";
-				echo "<a href='../article/?id=".$_GET["id"];
-				if(isset($_GET["channal"])){
-					echo "&channal=".$_GET["channal"];
-				}
-				echo "&display=para'  title='{$_local->gui->show} {$_local->gui->each_paragraph}'>";		
-				echo $_local->gui->each_paragraph;
-				echo "</a>";
-				echo "</button>";
-			}
-	
-			if(isset($_GET["display"]) && $_GET["display"]=="sent"){
-				echo "<button class='icon_btn active'  title='{$_local->gui->show} {$_local->gui->each_sentence}'>";
-				echo $_local->gui->each_sentence;
-				echo "</button>";
-			}
-			else{
-				echo "<button class='icon_btn'><a href='../article/?id=".$_GET["id"];
-				if(isset($_GET["channal"])){
-					echo "&channal=".$_GET["channal"];
-				}
-				echo "&display=sent";
-				echo "'  title='{$_local->gui->show} {$_local->gui->each_sentence}'>{$_local->gui->each_sentence}</a></button>";
-			}
 		}
 
 		?>
@@ -118,7 +94,16 @@ require_once "../pcdl/html_head.php";
 </div>
 <div id="contents_view">
 	<div id="contents_div">
-		<div id="contents">
+		<div id="contents" 
+		<?php
+				if($_mode=="read"){
+					echo 'class="para_mode horizontal"';
+				}
+				else{
+					echo 'class="sent_mode vertical"';
+				}
+				?>
+		>
 		<?php echo $_local->gui->loading; ?>...
 		</div>
 		<div id="contents_foot">

+ 24 - 76
app/reader/index.php

@@ -49,6 +49,14 @@ require_once "../pcdl/html_head.php";
 	if(isset($_GET["author"])){
 		echo "_author='".$_GET["author"]."';";
 	}
+	if(isset($_GET["mode"]) && $_GET["mode"]=="edit"){
+		$_mode = "edit";
+		echo "_mode='edit';";
+	}
+	else{
+		$_mode = "read";
+		echo "_mode='read';";
+	}
 	?>
 	</script>
 
@@ -64,80 +72,11 @@ require_once "../pcdl/html_head.php";
 
 	<div>
 		<span>
-		<input type="checkbox" onchange="setVisibility('palitext',this)" checked><?php echo $_local->gui->script; ?>
-		<?php
-		//echo "<button class='icon_btn'  title='{$_local->gui->add}{$_local->gui->subfield}'>";
-		//echo "<a href='../article/frame.php?id=".$_GET["id"];
-		//echo "'>{$_local->gui->add}{$_local->gui->subfield}</a></button>";
-		
-		if(isset($_GET["display"]) && $_GET["display"]=="para"){
-			echo "<button class='icon_btn active' title='{$_local->gui->show} {$_local->gui->each_paragraph}'>";
-			echo $_local->gui->each_paragraph;
-			echo "</button>";
-		}
-		else{
-			echo "<button class='icon_btn'>";
-			echo "<a href='../reader/?view=".$_GET["view"];
-			if(isset($_GET["book"])){
-				echo "&book=".$_GET["book"];
-			}
-			if(isset($_GET["para"])){
-				echo "&para=".$_GET["para"];
-			}
-			if(isset($_GET["begin"])){
-				echo "&begin=".$_GET["begin"];
-			}
-			if(isset($_GET["end"])){
-				echo "&end=".$_GET["end"];
-			}
-			if(isset($_GET["channal"])){
-				echo "&channal=".$_GET["channal"];
-			}
-			if(isset($_GET["lang"])){
-				echo "&lang=".$_GET["lang"];
-			}
-			echo "&display=para'  title='{$_local->gui->show} {$_local->gui->each_paragraph}'>";		
-			echo $_local->gui->each_paragraph;
-			echo "</a>";
-			echo "</button>";
-		}
-
-		if(isset($_GET["display"]) && $_GET["display"]=="sent"){
-			echo "<button class='icon_btn active'  title='{$_local->gui->show} {$_local->gui->each_sentence}'>";
-			echo $_local->gui->each_sentence;
-			echo "</button>";
-		}
-		else{
-			echo "<button class='icon_btn'>";
-			echo "<a href='../reader/?view=".$_GET["view"];
-			if(isset($_GET["book"])){
-				echo "&book=".$_GET["book"];
-			}
-			if(isset($_GET["para"])){
-				echo "&para=".$_GET["para"];
-			}
-			if(isset($_GET["begin"])){
-				echo "&begin=".$_GET["begin"];
-			}
-			if(isset($_GET["end"])){
-				echo "&end=".$_GET["end"];
-			}
-			if(isset($_GET["channal"])){
-				echo "&channal=".$_GET["channal"];
-			}
-			if(isset($_GET["lang"])){
-				echo "&lang=".$_GET["lang"];
-			}
-			echo "&display=sent";
-			echo "'  title='{$_local->gui->show} {$_local->gui->each_sentence}'>{$_local->gui->each_sentence}</a></button>";
-		}
-		?>
-			
-		<span>
-		<?php include "../reader/right_tool_bar.php";?>
-		</span>
-
-
+			<input type="checkbox" onchange="setVisibility('palitext_div',this)" checked><?php echo $_local->gui->script; ?>
+	
+			<span>
+			<?php include "../reader/right_tool_bar.php";?>
+			</span>
 		</span>
 	</div>
 </div>
@@ -168,8 +107,17 @@ require_once "../pcdl/html_head.php";
 			</div>
 		</div>
 		<div id="contents_view">
-			<div id="contents_div" style="padding: 0 1em 0 30px;width:70vw;">
-				<div id="contents"><?php echo $_local->gui->loading; ?>...</div>
+			<div id="contents_div" >
+				<div id="contents" 
+				<?php
+				if($_mode=="read"){
+					echo 'class="para_mode horizontal"';
+				}
+				else{
+					echo 'class="sent_mode vertical"';
+				}
+				?>
+				><?php echo $_local->gui->loading; ?>...</div>
 				<div id="contents_toc"></div>
 				<div id="contents_foot">
 					<div id="contents_nav" style="display:flex;justify-content: space-between;">

+ 14 - 0
app/reader/mobile.css

@@ -13,3 +13,17 @@
 	margin-bottom: auto;
 	padding-left: 0.5em;
 }
+.language-para {
+	display: none;
+}
+#contents_div {
+	flex: 7;
+	padding: 5px;
+	width: 100%;
+}
+#contents .para_div {
+	flex-direction: column;
+}
+#contents .note_shell > note > .note_body {
+	flex-direction: column;
+}

+ 26 - 0
app/reader/reader.js

@@ -255,3 +255,29 @@ function set_channal(channalid) {
 function edit_wbw(book, para) {
 	wbw_channal_list_open(book, [para]);
 }
+
+function setMode(mode = "read") {
+	let url = "../reader/?view=" + _reader_view;
+	if (_reader_book != -1) {
+		url += "&book=" + _reader_book;
+	}
+	if (_reader_para != -1) {
+		url += "&para=" + _reader_para;
+	}
+	if (_reader_begin != -1) {
+		url += "&begin=" + _reader_begin;
+	}
+	if (_reader_end != -1) {
+		url += "&end=" + _reader_end;
+	}
+	if (_channal != "") {
+		url += "&channal=" + _channal;
+	}
+	if (_display != "") {
+		url += "&display=" + _display;
+	}
+	if (mode != "") {
+		url += "&mode=" + mode;
+	}
+	location.assign(url);
+}

+ 35 - 0
app/reader/right_tool_bar.php

@@ -56,6 +56,41 @@
 	display: none;
 }
 	</style>
+			<select name="direction" onchange='setDirection(this)' >
+			<option value="row">横向</option>
+			<option value="column">纵向</option>
+		</select>
+<?php
+		if($_mode == "read"){
+			echo "<select onchange='setDisplay(this)'>";
+			echo "<option value='para'>逐段</option>";
+			echo "<option value='sent'>逐句</option>";
+			echo "</select>";
+		}
+		if($_mode == "read"){
+			echo "<button class='icon_btn active' title='{$_local->gui->show} {$_local->gui->each_paragraph}'>";
+			echo $_local->gui->read;
+			echo "</button>";
+
+			echo "<button class='icon_btn'>";
+			echo "<a onclick=\"setMode('edit')\"";
+
+			echo " title='{$_local->gui->show} {$_local->gui->edit}'>{$_local->gui->edit}</a></button>";
+		}
+		else{
+			echo "<button class='icon_btn'>";
+			echo "<a onclick=\"setMode('read')\"";
+			echo " title='{$_local->gui->show} {$_local->gui->read}'>";		
+			echo $_local->gui->read;
+			echo "</a>";
+			echo "</button>";
+
+			echo "<button class='icon_btn active'  title='{$_local->gui->show} {$_local->gui->edit}'>";
+			echo $_local->gui->edit;
+			echo "</button>";
+		}
+?>
+
 				<button id="btn_show_dict" class='icon_btn' onclick="show_dict(this)">
 				<?php echo $_local->gui->dict; ?>
 				</button>

+ 2 - 0
app/reader/style.css

@@ -66,6 +66,8 @@
 }
 #contents_div {
 	flex: 7;
+	padding: 0 1em 0 30px;
+	width: 70vw;
 }
 #contents {
 }

+ 4 - 1
app/studio/css/style.css

@@ -3072,6 +3072,7 @@ th {
 .tooltip:hover .tooltip-top {
 	top: -180%;
 }
+
 .tooltip .tooltip-top::after {
 	content: " ";
 	position: absolute;
@@ -3087,7 +3088,9 @@ th {
 	left: 50%;
 	margin-left: -60px;
 }
-
+.tooltip:hover .tooltip-bottom {
+	top: 120%;
+}
 .tooltip-bottom::after {
 	content: "";
 	position: absolute;

+ 16 - 6
app/sync/function.php

@@ -19,12 +19,22 @@ function do_sync($param)
     switch ($op) {
         case "sync":
             {
-                $time = $_POST["time"];
-                $query = "select {$param->uuid} as guid, {$param->modify_time} from {$param->table}  where {$param->receive_time} > '{$time}' limit 0,10000";
-                $stmt = $PDO->query($query);
-                $Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
-                $iFetch = count($Fetch);
-                echo (json_encode($Fetch, JSON_UNESCAPED_UNICODE));
+				if(isset($_POST["time"])){
+					$time = $_POST["time"];
+					$query = "SELECT {$param->uuid} as guid, {$param->modify_time} as modify_time from {$param->table}  where {$param->modify_time} > '{$time}' order by {$param->modify_time} ASC  limit 0,1000";
+					$stmt = $PDO->query($query);
+					$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
+					$iFetch = count($Fetch);
+					echo (json_encode($Fetch, JSON_UNESCAPED_UNICODE));					
+				}
+				else if(isset($_POST["id"])){
+					$query = "SELECT {$param->uuid} as guid, {$param->modify_time} from {$param->table}  where {$param->uuid} in ({$_POST["id"]})  limit 0,1000";
+					$stmt = $PDO->query($query);
+					$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
+					$iFetch = count($Fetch);
+					echo (json_encode($Fetch, JSON_UNESCAPED_UNICODE));						
+				}
+
                 break;
             }
         case "get":

+ 5 - 4
app/sync/index.php

@@ -4,7 +4,7 @@ require_once "../path.php";
 
 ?>
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!DOCTYPE html >
 <html>
 	<head>
 		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
@@ -23,14 +23,15 @@ require_once "../path.php";
 			<div id="wiki_search" style="width:100%;">
 				<div>
 					<h3>Server Address</h3>
-					<input id="sync_server_address" type="input" placeholder="server address" value="https://www.wikipali.org/demo" style="width:30em;" />
+					<input id="sync_server_address" type="input" placeholder="server address" value="https://www.wikipali.org" style="width:30em;" />
 					<h3>Local Address</h3>
 					<input id="sync_local_address" type="input" placeholder="local address" value="" style="width:30em;" />
 					
-					<button onclick="sync_start()">Start</button>
+					<button onclick="sync_pull()">pull</button>
+					<button onclick="sync_push()">push</button>
 				</div>
-
 			</div>
+			<div>上次更新时间:</div>
 			<div id="sync_result">
 
 			</div>

+ 42 - 30
app/sync/sync.js

@@ -1,34 +1,46 @@
-//var sync_db_list= new Array("term","usent");
-var sync_db_list= new Array("doc/sync_index.php","term/sync.php","usent/sync.php");
+var sync_db_list = new Array("term/sync_index.php");
+//var sync_db_list = ["doc/sync_index.php", "term/sync_index.php", "usent/sync.php"];
 var sync_curr_do_db = 0;
-function sync_index_init(){
-	
-}
-
+function sync_index_init() {}
 
-function sync_start(){
+function sync_pull() {
 	sync_curr_do_db = 0;
-	$("#sync_result").html("working"); // 
-	sync_do_db();
-
+	$("#sync_result").html("working"); //
+	sync_do_db($("#sync_server_address").val(), $("#sync_local_address").val(), 1);
+}
+function sync_push() {
+	sync_curr_do_db = 0;
+	$("#sync_result").html("working"); //
+	sync_do_db($("#sync_local_address").val(), $("#sync_server_address").val(), 1);
+}
+function sync_do_db(src, dest, time = 1) {
+	$.get(
+		"sync.php",
+		{
+			server: $("#sync_server_address").val(),
+			localhost: $("#sync_local_address").val(),
+			path: sync_db_list[sync_curr_do_db],
+			time: time,
+		},
+		function (data) {
+			let result;
+			try {
+				result = JSON.parse(data);
+			} catch (error) {
+				console.error(error + " data:" + data);
+				return;
+			}
+			$("#sync_result").html($("#sync_result").html() + "<br>" + result.message + "<br>" + result.row); //
+			if (result.row == 1000) {
+				sync_do_db(src, dest, result.time);
+			} else {
+				sync_curr_do_db++;
+				if (sync_curr_do_db < sync_db_list.length) {
+					sync_do_db(src, dest, 1);
+				} else {
+					$("#sync_result").html($("#sync_result").html() + "<br>All Done"); //
+				}
+			}
+		}
+	);
 }
-
-function sync_do_db(){
-	
-	$.get("sync.php", 
-	{
-	"server": $("#sync_server_address").val(),
-	"localhost": $("#sync_local_address").val(),
-	"path": sync_db_list[sync_curr_do_db]
-	},
-   function(data){
-     $("#sync_result").html($("#sync_result").html()+"<br>"+data); // 
-	 sync_curr_do_db++;
-	 if(sync_curr_do_db<sync_db_list.length){
-		 sync_do_db();
-	 }
-	 else{
-		 $("#sync_result").html($("#sync_result").html()+"<br>All Done"); // 
-	 }
-   });	
-}

+ 33 - 15
app/sync/sync.php

@@ -3,15 +3,32 @@ require '../vendor/autoloader.php';
 $server = $_GET["server"];
 $localhost = $_GET["localhost"];
 $path=$_GET["path"];
+$time=$_GET["time"];
 
-$client = new \GuzzleHttp\Client();
-$response = $client->request('POST', $server.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'sync','time'=>'1']]);
-$serverJson=$response->getBody();
-$serverData = json_decode($serverJson);
+$message="";
 
+$response=["message"=>"","time"=>0,"row"=>0];
 
-$response = $client->request('POST', $localhost.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'sync','time'=>'1']]);
+$client = new \GuzzleHttp\Client();
 
+$response = $client->request('POST', $server.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'sync','time'=>$time]]);
+$serverJson=$response->getBody();
+$serverData = json_decode($serverJson);
+$response["row"]=count($serverData);
+if($response["row"]>0){
+	$response["time"]=$serverData[$response["row"]-1]->modify_time;
+}
+else{
+    echo json_encode($response, JSON_UNESCAPED_UNICODE);
+	exit;
+}
+$aIdList=array();
+foreach($serverData as $sd){
+	$aIdList[]=$sd->guid;
+}
+$sIdlist = implode(",",$aIdList);
+// 拉 id 列表
+$response = $client->request('POST', $localhost.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'sync','id'=>$sIdlist]]);
 $strLocalData = $response->getBody();
 $localData = json_decode($strLocalData);
 
@@ -21,7 +38,7 @@ $insert_to_server=array();
 $update_to_server=array();
 $insert_to_local=array();
 $update_to_local=array();
-echo "<h3>{$path}</h3>";
+$message .= "<h3>{$path}</h3>";
 foreach($localData as $local){
 	$localindex[$local->guid][0]=$local->modify_time;
 	$localindex[$local->guid][1]=false;
@@ -56,7 +73,7 @@ foreach($localindex as  $x=>$x_value){
 
 $syncCount = count($insert_to_server)+count($update_to_server)+count($insert_to_local)+count($update_to_local);
 if($syncCount==0){
-	echo "与服务器数据完全一致,无需更新。<br>";
+	$message .=  "与服务器数据完全一致,无需更新。<br>";
 }
 else{
 //start sync
@@ -64,13 +81,13 @@ else{
 		/*
 
 		*/
-		echo "需要插入服务器".count($insert_to_server)."条记录<br>";
+		$message .=  "需要插入服务器".count($insert_to_server)."条记录<br>";
 		
 		$idInLocal = json_encode($insert_to_server, JSON_UNESCAPED_UNICODE);
 		$response = $client->request('POST', $localhost.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'get','id'=>"{$idInLocal}"]]);
 		$localData=$response->getBody();
 		$response = $client->request('POST', $server.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'insert','data'=>"{$localData}"]]);
-		echo $response->getBody()."<br>";
+		$message .=  $response->getBody()."<br>";
 		
 	}
 
@@ -78,41 +95,42 @@ else{
 		/*
 
 		*/
-		echo "需要更新到服务器".count($update_to_server)."条记录<br>";
+		$message .=  "需要更新到服务器".count($update_to_server)."条记录<br>";
 		
 		$idInLocal = json_encode($update_to_server, JSON_UNESCAPED_UNICODE);
 		$response = $client->request('POST', $localhost.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'get','id'=>"{$idInLocal}"]]);
 		$localData=$response->getBody();
 		$response = $client->request('POST', $server.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'update','data'=>"{$localData}"]]);
-		echo $response->getBody()."<br>";
+		$message .=  $response->getBody()."<br>";
 		
 	}
 
 	if(count($insert_to_local)>0){
 
-		echo "需要新增到本地".count($insert_to_local)."条记录<br>";
+		$message .=  "需要新增到本地".count($insert_to_local)."条记录<br>";
 		
 		$idInServer = json_encode($insert_to_local, JSON_UNESCAPED_UNICODE);
 		$response = $client->request('POST', $server.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'get','id'=>"{$idInServer}"]]);
 		$serverData=$response->getBody();
 		$response = $client->request('POST', $localhost.'/app/'.$path, ['verify' => false,'form_params'=>['op'=>'insert','data'=>"{$serverData}"]]);
-		echo $response->getBody()."<br>";
+		$message .=  $response->getBody()."<br>";
 		
 		
 	}
 
 	if(count($update_to_local)>0){
 
-		echo "需要更新到本地".count($update_to_local)."条记录<br>";
+		$message .=  "需要更新到本地".count($update_to_local)."条记录<br>";
 		
 		$idInServer = json_encode($update_to_local, JSON_UNESCAPED_UNICODE);
 		$response = $client->request('POST', $server.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'get','id'=>"{$idInServer}"]]);
 		$serverData=$response->getBody();
 		$response = $client->request('POST', $localhost.'/app/'.$path,['verify' => false,'form_params'=>['op'=>'update','data'=>"{$serverData}"]]);
-		echo $response->getBody()."<br>";
+		$message .=  $response->getBody()."<br>";
 		
 	}
 	
 }
+$response["message"]=$message;
 
 ?>

+ 20 - 0
app/term/channal_list.php

@@ -7,6 +7,9 @@ require_once '../channal/function.php';
 require_once '../ucenter/function.php';
 require_once '../share/function.php';
 
+$log = "";
+$timeStart = microtime(true);
+
 $_data = array();
 $output = array();
 if (isset($_POST["data"])) {
@@ -42,6 +45,9 @@ if (isset($_COOKIE["userid"])) {
 		$channal_list[] = $value["id"];
 		$channel_power[$value["id"]]=30;
     }
+	$time = microtime(true);
+	$log .= $time-$timeStart ." - 找自己的结束". PHP_EOL;
+	$timeStart = $time;
 
 	# 找协作的
 	$coop_channal =  share_res_list_get($_COOKIE["userid"],2);
@@ -54,6 +60,9 @@ if (isset($_COOKIE["userid"])) {
 			}
 		}
 	}
+	$time = microtime(true);
+	$log .= $time-$timeStart ." - 找协作的结束". PHP_EOL;
+	$timeStart = $time;
 }
 if (count($channal_list) > 0) {
 	#  创建一个填充了和params相同数量占位符的字符串 
@@ -64,6 +73,9 @@ if (count($channal_list) > 0) {
 }
 
 # 查询有阅读权限的channel 结束
+$time = microtime(true);
+$log .= $time-$timeStart ." - 查询有阅读权限的channel 结束". PHP_EOL;
+$timeStart = $time;
 
 $final = array();
 $article_len = 0;
@@ -119,6 +131,10 @@ foreach ($_data as $key => $value) {
 
 }
 
+$time = microtime(true);
+$log .= $time-$timeStart ." - 查询句子长度 结束 ". PHP_EOL;
+$timeStart = $time;
+
 foreach ($channal as $key => $value) {
     # 计算句子的完成分布
     $arr_sent_final = array();
@@ -151,4 +167,8 @@ foreach ($channal as $key => $value) {
     $output[] = $channalInfo;
 }
 
+$time = microtime(true);
+$log .= $time-$timeStart ." - 计算句子的完成分布 结束 ". PHP_EOL;
+$timeStart = $time;
+
 echo json_encode($output, JSON_UNESCAPED_UNICODE);

+ 85 - 27
app/term/note.js

@@ -1,4 +1,5 @@
 var _display = "";
+var _mode = "read";
 var _word = "";
 var _channal = "";
 var _lang = "";
@@ -155,7 +156,7 @@ function note_refresh_new() {
 						for (const iterator of sentData) {
 							let id = iterator.id;
 							let strHtml = "<a name='" + id + "'></a>";
-							if (_display && _display == "para") {
+							if (_mode && _mode == "read") {
 								//阅读模式
 								strHtml += render_read_mode_sent(iterator);
 								$("#" + id).html(strHtml);
@@ -210,47 +211,66 @@ function render_read_mode_sent(iterator) {
 		"' >" +
 		iterator.palitext +
 		"</pali>";
-	let divPali = $("#" + id)
-		.parent()
-		.parent()
-		.children(".palitext");
-	if (divPali.length == 0) {
+
+	if (
+		$("#" + id)
+			.parent()
+			.parent()
+			.children(".para_div").length == 0
+	) {
+		let tranDivHtml = "";
 		if (_channal != "") {
 			let arrChannal = _channal.split(",");
 			for (let index = arrChannal.length - 1; index >= 0; index--) {
 				const iChannal = arrChannal[index];
-				$("#" + id)
-					.parent()
-					.parent()
-					.prepend("<div class='tran_div'  channal='" + iChannal + "'></div>");
+				tranDivHtml += "<div class='tran_div_channel'  channal='" + iChannal + "'></div>";
 			}
+		} else {
+			tranDivHtml = "<div class='tran_div_channel'  channal='0'></div>";
 		}
-
 		$("#" + id)
 			.parent()
 			.parent()
-			.prepend("<div class='palitext'></div>");
+			.prepend(
+				"<div class='para_div'><div class='palitext_div'><div class='palitext palitext1'></div><div class='palitext palitext2'></div></div><div class='para_tran_div'>" +
+					tranDivHtml +
+					"</div></div>"
+			);
 	}
+
 	$("#" + id)
 		.parent()
 		.parent()
-		.children(".palitext")
+		.children(".para_div")
+		.find(".palitext")
 		.first()
 		.append(strPalitext);
-	let htmlTran = "";
+
+	let htmlSent = "";
+	htmlSent += "<div class='note_body'>";
+	htmlSent += "<div class='palitext_div'>";
+	htmlSent += "<div class='palitext palitext1'>" + strPalitext + "</div>";
+	htmlSent += "<div class='palitext palitext2'></div>";
+	htmlSent += "</div>";
+	htmlSent += "<div class='sent_tran_div'>";
 	for (const oneTran of iterator.translation) {
-		let html = "<span class='tran' lang='" + oneTran.lang + "' channal='" + oneTran.channal + "'>";
+		let html = "<span class='tran_sent' lang='" + oneTran.lang + "' channal='" + oneTran.channal + "'>";
 		html += marked(term_std_str_to_tran(oneTran.text, oneTran.channal, oneTran.editor, oneTran.lang));
 		html += "</span>";
-		if (_channal == "") {
-			htmlTran += html;
-		} else {
-			$("#" + id)
-				.siblings(".tran_div[channal='" + oneTran.channal + "']")
-				.append(html);
+		htmlSent += html;
+		let channelId = "0";
+		if (_channal != "") {
+			channelId = oneTran.channal;
 		}
+		$("#" + id)
+			.parent()
+			.parent()
+			.find(".tran_div_channel[channal='" + channelId + "']")
+			.append(html);
 	}
-	return htmlTran;
+	htmlSent += "</div>";
+	htmlSent += "</div>";
+	return htmlSent;
 }
 //生成channel列表
 function note_channal_list() {
@@ -383,12 +403,13 @@ function render_channal_list(channalinfo) {
 	output += channalinfo["username"];
 	output += "</div>";
 
+	//绘制句子进度
 	if (channalinfo["final"]) {
 		//进度
 		output += "<div>";
 		let article_len = channalinfo["article_len"];
 		let svg_width = article_len;
-		let svg_height = parseInt(article_len / 10);
+		let svg_height = parseInt(article_len / 15);
 		output += '<svg viewBox="0 0 ' + svg_width + " " + svg_height + '" width="100%" >';
 
 		let curr_x = 0;
@@ -530,18 +551,35 @@ function note_json_html(in_json) {
 	output += "</div>";
 	output += " </div>";
 
-	output += "<div class='pali_div'>";
-	output += "<div class='palitext palitext_roma'>" + in_json.palitext + "</div>";
+	let strPalitext =
+		"<pali book='" +
+		in_json.book +
+		"' para='" +
+		in_json.para +
+		"' begin='" +
+		in_json.begin +
+		"' end='" +
+		in_json.end +
+		"' >" +
+		in_json.palitext +
+		"</pali>";
+
+	output += "<div class='note_body'>";
+	output += "<div class='palitext_div'>";
+	output += "<div class='palitext palitext_roma'>" + strPalitext + "</div>";
 	output += "<div class='palitext palitext1'></div>";
 	output += "<div class='palitext palitext2'></div>";
 	output += "</div>";
 
-	output += "<div class='translation_div'>";
+	//译文开始
+	output += "<div class='sent_tran_div'>";
 	for (const iterator of in_json.translation) {
 		output += render_one_sent_tran_a(iterator);
 	}
-	//所选全部译文结束
 	output += "</div>";
+	//译文结束
+	output += "</div>"; /**note_body end */
+
 	//工具栏开始
 	output += "<div class='other_tran_div' sent='";
 	output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "' >";
@@ -1783,3 +1821,23 @@ function get_channel_by_id(id) {
 	}
 	return false;
 }
+//设置显示方向
+function setDirection(obj) {
+	if (obj.value == "row") {
+		$("#contents").removeClass("vertical");
+		$("#contents").addClass("horizontal");
+	} else {
+		$("#contents").removeClass("horizontal");
+		$("#contents").addClass("vertical");
+	}
+}
+//设置逐段或逐句模式
+function setDisplay(obj) {
+	if (obj.value == "para") {
+		$("#contents").removeClass("sent_mode");
+		$("#contents").addClass("para_mode");
+	} else {
+		$("#contents").removeClass("para_mode");
+		$("#contents").addClass("sent_mode");
+	}
+}

+ 46 - 0
app/term/sync_index.php

@@ -0,0 +1,46 @@
+<?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",
+    "modify_time" =>  "modify_time",
+    "receive_time" =>  "receive_time",
+    "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" 
+    ]    
+];
+
+do_sync($input);
+
+?>

+ 61 - 1
app/term/term.css

@@ -641,7 +641,7 @@ pw {
 	display: none;
 }
 .foot_bar .info {
-	color: var(--main-color);
+	color: var(--btn-border-line-color);
 }
 .tool_bar > .right {
 	position: absolute;
@@ -757,3 +757,63 @@ li.active {
 	justify-content: center;
 	font-weight: bold;
 }
+w {
+	cursor: pointer;
+}
+w:hover {
+	text-decoration: underline;
+}
+
+/*纵向*/
+.vertical .para_div {
+	flex-direction: column;
+}
+.vertical .note_shell > note > .note_body {
+	flex-direction: column;
+}
+
+.para_div {
+	display: flex;
+}
+.note_shell > note > .note_body {
+	display: flex;
+}
+/*段落模式 横向*/
+.horizontal .para_div {
+	flex-direction: row;
+}
+.horizontal .palitext_div {
+	flex: 5;
+}
+.horizontal .para_tran_div {
+	flex: 5;
+}
+/*句子模式 横向*/
+
+.horizontal .note_shell > note > .note_body {
+	flex-direction: row;
+}
+.horizontal .palitext_div {
+	flex: 5;
+}
+.horizontal .sent_tran_div {
+	flex: 5;
+}
+
+/*段落模式*/
+.para_mode .para_div {
+	display: flex;
+}
+.para_mode .note_shell {
+	display: none;
+}
+/*句子模式*/
+.sent_mode .para_div {
+	display: none;
+}
+.sent_mode .note_shell {
+	display: block;
+}
+.tran_sent p {
+	display: inline;
+}

+ 1 - 1
app/ucenter/setting_function.php

@@ -4,7 +4,7 @@ function get_setting()
 {
 
     if (!isset($_COOKIE["userid"])) {
-        $setting = array();
+        $setting = json_decode(file_get_contents("../ucenter/default.json"), true);
     } else {
         $setting = json_decode(file_get_contents("../ucenter/default.json"), true);
         //打开数据库