2
0
visuddhinanda 5 жил өмнө
parent
commit
a2575d7699

+ 28 - 5
app/article/index.php

@@ -7,7 +7,9 @@ require_once "../pcdl/html_head.php";
 	<script src="../term/term.js"></script>
 	<script src="../term/note.js"></script>
 	<script src="./article.js"></script>
+	<script src="../public/js/jquery-ui-1.12.1/jquery-ui.js"></script>
 	<link type="text/css" rel="stylesheet" href="../term/term.css"/>
+	<link type="text/css" rel="stylesheet" href="../public/js/jquery-ui-1.12.1/jquery-ui.css"/>
 	<script>
 	<?php
 	$_id = "";
@@ -32,9 +34,7 @@ require_once "../pcdl/html_head.php";
 	?>
 	</script>
 	<style>
-	body{
-		font-size:12pt;
-	}
+
 
 	#search_result{
 		position: absolute;
@@ -122,8 +122,9 @@ require_once "../pcdl/html_head.php";
 		display: flex;
     justify-content: space-between;
     height: 5em;
-    background-color: var(--bookx);
+    background-color: var(--tool-bg-color1);
     border-bottom: 1px solid var(--tool-line-color);
+	padding:10px;
 	}
 	.term_block_bar_left{
 		display: flex;
@@ -261,6 +262,18 @@ require_once "../pcdl/html_head.php";
 #toc_content .level_5{
 	padding-left:2em;
 }
+.ui-dialog-titlebar{
+		display: flex;
+    justify-content: space-between;
+	background-color: var(--btn-bg-color);
+    padding: 5px;
+	}
+	.ui-widget-content{
+		background-color: var(--bg-color);
+	}
+	.ui-dialog{
+		box-shadow:  8px 8px 20px var(--border-shadow);
+	}
 	</style>
 
 <style media="screen and (max-width:767px)">
@@ -279,6 +292,8 @@ require_once "../pcdl/html_head.php";
     margin-bottom: auto;
     padding-left: 0.5em;
 	}
+
+
 </style>
 
 <script>
@@ -342,10 +357,17 @@ term_word_link_fun("wiki_goto_word");
 	</div>
 </div>
 </div>
+
+<!-- ui-dialog -->
+<div id="dialog" title="Dialog Title">
+	<div id="edit_dialog_content"></div>
+</div>
+
 <script>
+	note_create();
 	articel_load(_articel_id);
 	articel_load_collect(_articel_id);
-	
+
 	 window.addEventListener('scroll',winScroll);
 	function winScroll(e){ 
 		if(GetPageScroll().y>220){
@@ -379,5 +401,6 @@ function GetPageScroll()
 }
 	</script>
 
+
 </body>
 </html>

+ 49 - 1
app/channal/channal.js

@@ -85,6 +85,12 @@ function my_channal_edit(id) {
           html +=
             "<input type='input' name='name' value='" + result.name + "'/>";
           html += "<textarea name='summary'>" + result.summary + "</textarea>";
+          html +=
+            '<div>	<input id="channal_lang_select" type="input" onchange="channal_lang_change()"  title="type language name/code" code="' +
+            result.lang +
+            '" value="' +
+            result.lang +
+            '" > <input id="channal_lang" type="hidden" name="lang" value=""></div>';
           html +=
             "<input type='hidden' name='status' value='" +
             result.status +
@@ -98,7 +104,7 @@ function my_channal_edit(id) {
           html += "</div>";
 
           $("#channal_info").html(html);
-
+          tran_lang_select_init("channal_lang_select");
           //$("#aritcle_status").html(render_status(result.status));
           $("#channal_title").html(result.name);
           $("#preview_inner").html();
@@ -111,3 +117,45 @@ function my_channal_edit(id) {
     }
   );
 }
+
+function channal_lang_change() {
+  let lang = $("#channal_lang_select").val();
+  if (lang.split("-").length == 3) {
+    $("#channal_lang").val(lang.split("-")[2]);
+  } else {
+    $("#channal_lang").val(lang);
+  }
+}
+
+function my_channal_save() {
+  $.ajax({
+    type: "POST", //方法类型
+    dataType: "json", //预期服务器返回的数据类型
+    url: "../channal/my_channal_post.php", //url
+    data: $("#channal_edit").serialize(),
+    success: function (result) {
+      console.log(result); //打印服务端返回的数据(调试用)
+
+      if (result.status == 0) {
+        alert("保存成功");
+      } else {
+        alert("error:" + result.message);
+      }
+    },
+    error: function (data, status) {
+      alert("异常!" + status + data.responseText);
+      switch (status) {
+        case "timeout":
+          break;
+        case "error":
+          break;
+        case "notmodified":
+          break;
+        case "parsererror":
+          break;
+        default:
+          break;
+      }
+    },
+  });
+}

+ 9 - 5
app/channal/channal_add_dlg.js

@@ -12,10 +12,10 @@ function channal_add_dlg_init(div) {
   html +=
     "<div style='display:flex;justify-content: space-between;padding-top: 1em;'>";
   html += "<div>";
-  html += "<select id='channal_add_dlg_status'>";
-  html += "<option value='3'>公开</option>";
-  html += "<option value='2'>不公开列出</option>";
-  html += "<option value='1'>私有</option>";
+  html += "<select id='channal_add_dlg_lang' name='lang'>";
+  html += "<option value='zh'>Chinese-中文</option>";
+  html += "<option value='en'>English-English</option>";
+  html += "<option value='my'>Mymarnese-</option>";
   html += "</select>";
 
   html += "</div>";
@@ -41,11 +41,15 @@ function channal_add_cancel() {
 }
 
 function channal_add_new() {
+  if ($("#channal_add_title").val() == "") {
+    alert("channal name is empty!");
+    return;
+  }
   $.post(
     "../channal/my_channal_put.php",
     {
       name: $("#channal_add_title").val(),
-      status: $("#channal_add_dlg_status").val(),
+      lang: $("#channal_add_dlg_lang").val(),
     },
     function (data) {
       let error = JSON.parse(data);

+ 3 - 1
app/channal/my_channal_edit.php

@@ -6,6 +6,8 @@ require_once '../studio/index_head.php';
 	<script language="javascript" src="../channal/channal.js"></script>
 	<script language="javascript" src="../public/js/marked.js"></script>
 	<script src="../public/js/jquery-ui-1.12.1/jquery-ui.js"></script>
+	<link type="text/css" rel="stylesheet" href="../public/js/jquery-ui-1.12.1/jquery-ui.css"/>
+	<script language="javascript" src="../lang/tran_lang_select.js"></script>
 
 	<script >
 	var gCurrPage="channal";
@@ -51,7 +53,7 @@ require_once '../studio/index_head.php';
 	?>
 		
 	<div class="index_inner " >
-	<form id="collect_edit" action="##" onsubmit="return false"  method="POST" >
+	<form id="channal_edit" action="##" onsubmit="return false"  method="POST" >
 	<div class="file_list_block">
 		<div class="tool_bar">
 			<div style="display:flex;">

+ 1 - 1
app/channal/my_channal_index.php

@@ -41,8 +41,8 @@ require_once '../studio/index_head.php';
 				<svg class="icon">
 					<use xlink:href="../studio/svg/icon.svg#ic_add_circle"></use>
 				</svg>
-				<div id='channal_add_div' class="float_dlg"></div>
 			</button>
+			<div id='channal_add_div' class="float_dlg"></div>
 		</span>
 		
 		<span class="icon_btn_div">				

+ 56 - 0
app/channal/my_channal_post.php

@@ -0,0 +1,56 @@
+<?php
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../public/function.php';
+require_once '../hostsetting/function.php';
+$respond=array("status"=>0,"message"=>"");
+
+#先查询对此channal是否有权限修改
+   PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+$cooperation = 0;
+if(isset($_POST["id"])){
+    $query = "SELECT owner FROM channal WHERE id=?";
+    $fetch = PDO_FetchOne($query,array($_POST["id"]));
+    if($fetch && $fetch==$_COOKIE["userid"]){
+        #自己的channal
+        $cooperation = 1;
+    }
+    else{
+        $query = "SELECT count(*) FROM cooperation WHERE channal_id= ? and user_id=? ";
+        $fetch = PDO_FetchOne($query,array($_POST["id"],$_COOKIE["userid"]));
+        if($fetch>0){
+            #有协作权限
+            $cooperation = 1;
+        }
+        else{
+            #无协作权限
+            $cooperation = 0;
+        }
+    }
+}
+else{
+    $respond["status"] = 1;
+    $respond["message"] = 'error channal id';
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+if($cooperation==0){
+    $respond["status"] = 1;
+    $respond["message"] = 'error 无修改权限';
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+
+
+$query="UPDATE channal SET name = ? ,  summary = ?,  status = ? , lang = ? , receive_time= ?  , modify_time= ?   where  id = ?  ";
+$sth = $PDO->prepare($query);
+$sth->execute(array($_POST["name"] , $_POST["summary"], $_POST["status"] , $_POST["lang"] ,  mTime() , mTime() , $_POST["id"]));
+$respond=array("status"=>0,"message"=>"");
+if (!$sth || ($sth && $sth->errorCode() != 0)) {
+	$error = PDO_ErrorInfo();
+	$respond['status']=1;
+	$respond['message']=$error[2];
+}
+
+echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+?>

+ 2 - 2
app/channal/my_channal_put.php

@@ -6,9 +6,9 @@ require_once '../hostsetting/function.php';
 $respond=array("status"=>0,"message"=>"");
 if(isset($_COOKIE["userid"])){
 	PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
-	$query="INSERT INTO channal ( id,  owner  , name  , summary ,  status  , create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ?  ) ";
+	$query="INSERT INTO channal ( id,  owner  , name  , summary ,  status  , lang, create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ? , ?  ) ";
 	$sth = $PDO->prepare($query);
-	$sth->execute(array(UUID::v4() , $_COOKIE["userid"] , $_POST["name"] , "" ,$_POST["status"]  ,  mTime() ,  mTime() , mTime() ));
+	$sth->execute(array(UUID::v4() , $_COOKIE["userid"] , $_POST["name"] , "" , 1 ,$_POST["lang"]  ,  mTime() ,  mTime() , mTime() ));
 	$respond=array("status"=>0,"message"=>"");
 	if (!$sth || ($sth && $sth->errorCode() != 0)) {
 		$error = PDO_ErrorInfo();

+ 1 - 1
app/course/list_new.php

@@ -8,7 +8,7 @@ require_once '../ucenter/function.php';
 
 global $PDO;
 PDO_Connect("sqlite:"._FILE_DB_COURSE_);
-$query = "select * from course where 1  order by create_time DESC limit 0,4";
+$query = "select * from course where 1  order by modify_time DESC limit 0,4";
 $Fetch = PDO_FetchAll($query);
 
 foreach($Fetch as $row){

+ 3 - 0
app/course/my_lesson_insert.php

@@ -6,6 +6,9 @@ require_once '../public/function.php';
 global $PDO;
 PDO_Connect("sqlite:"._FILE_DB_COURSE_);
 
+$query="UPDATE course SET  receive_time= ?  , modify_time= ?   where  id = ?  ";
+PDO_Execute($query,array(mTime(),mTime(),$_POST["course_id"]));
+
 $query = "INSERT INTO lesson (id, course_id,  live, replay, title,  subtitle ,  date ,  duration  ,  creator,  tag,  summary,  status,  cover,  teacher, attachment , lang , speech_lang , create_time , modify_time , receive_time ) 
 				 VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
 

+ 5 - 0
app/course/my_lesson_update.php

@@ -5,6 +5,11 @@ require_once '../public/function.php';
 
 global $PDO;
 PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+$query="SELECT course_id from lesson  where  id = ?  ";
+$course_id = PDO_FetchOne($query,array($_POST["lesson"]));
+
+$query="UPDATE course SET  receive_time= ?  , modify_time= ?   where  id = ?  ";
+PDO_Execute($query,array(mTime(),mTime(),$course_id));
 
 $query="UPDATE lesson SET title = ? , subtitle = ? , date = ? , duration = ? , live = ? , replay = ? , summary = ? , teacher = ?  , receive_time= ?  , modify_time= ?   where  id = ?  ";
 $sth = $PDO->prepare($query);

+ 1 - 2
app/guide/guide_icon.svg

@@ -1,8 +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" style="fill: #6baaff;" xml:space="preserve">
+<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" style="fill: #6baaff;" 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>

+ 21 - 0
app/lang/tran_lang_select.js

@@ -0,0 +1,21 @@
+var _tran_lang_select_div;
+function tran_lang_select_init(div) {
+  _tran_lang_select_div = div;
+  $.getJSON("../lang/lang_list.json", function (result) {
+    let lang_list = new Array();
+    let langCode = $("#" + _tran_lang_select_div).attr("code");
+    let strLang;
+    for (const iterator of result) {
+      if (iterator.code == langCode) {
+        strLang = iterator.english + "-" + iterator.name + "-" + iterator.code;
+      }
+      lang_list.push(
+        iterator.english + "-" + iterator.name + "-" + iterator.code
+      );
+    }
+    $("#" + _tran_lang_select_div).val(strLang);
+    $("#" + _tran_lang_select_div).autocomplete({
+      source: lang_list,
+    });
+  });
+}

+ 97 - 79
app/pcdl/css/basic_style.css

@@ -1,21 +1,21 @@
 body {
-    font-family: 'Noto Sans', 'Noto Sans SC', 'Noto Sans TC', Arial, Verdana;
-    font-style: normal;
-    color: var(--main-color);
-    font-weight: 400;
-    font-size: 13px;
-    overflow-x:hidden; 
-    margin:0;
+  font-family: "Noto Sans", "Noto Sans SC", "Noto Sans TC", Arial, Verdana;
+  font-style: normal;
+  color: var(--main-color);
+  font-weight: 400;
+  font-size: 13px;
+  overflow-x: hidden;
+  margin: 0;
 }
 div {
-    -webkit-box-sizing: border-box;
-    -moz-box-sizing: border-box;
-    box-sizing: border-box;
+  -webkit-box-sizing: border-box;
+  -moz-box-sizing: border-box;
+  box-sizing: border-box;
 }
-hr{
-    margin: 14px 0;
-    border:1px solid var(--tool-line-color);
-    transform: scaleY(.4);
+hr {
+  margin: 14px 0;
+  border: 1px solid var(--tool-line-color);
+  transform: scaleY(0.4);
 }
 
 input,
@@ -23,98 +23,116 @@ button,
 textarea,
 select,
 optgroup,
-option, 
+option,
 hr,
-h1, 
-h2, 
+h1,
+h2,
 h3 {
-    font-family: inherit;
-    font-size: inherit;
-    font-style: inherit;
-    font-weight: inherit;
-    color: inherit;
-    background-color: inherit;
-    -webkit-box-sizing: border-box;
-    -moz-box-sizing: border-box;
-    box-sizing: border-box;
+  font-family: inherit;
+  font-size: inherit;
+  font-style: inherit;
+  font-weight: inherit;
+  color: inherit;
+  background-color: inherit;
+  -webkit-box-sizing: border-box;
+  -moz-box-sizing: border-box;
+  box-sizing: border-box;
 }
 
 input[type="text"],
-input[type="input"], 
+input[type="input"],
 textarea {
-    font-weight: 300;
-    width: 100%;
-    border: 1px solid var(--btn-border-line-color);
-    border-radius: 4px;
-    padding: 0.1em 0.3em;
-    font-size: 100%;
-    min-height: 1.2em;
-    margin: 2px 0;
+  font-weight: 300;
+  width: 100%;
+  border: 1px solid var(--btn-border-line-color);
+  border-radius: 4px;
+  padding: 0.1em 0.3em;
+  font-size: 100%;
+  min-height: 1.2em;
+  margin: 2px 0;
 }
 select {
-    font-weight: 400;
-    border: 1px solid #aaaaaa;
-    padding: 2px 4px;
-    min-height: 2em;
-    border-radius: 4px;
-    cursor: pointer;
-    margin: 3px 0;
+  font-weight: 400;
+  border: 1px solid #aaaaaa;
+  padding: 2px 4px;
+  min-height: 2em;
+  border-radius: 4px;
+  cursor: pointer;
+  margin: 3px 0;
 }
 
-ul,
-li {
-    white-space: nowrap;
-    color: inherit;
-    margin: 0px;
-    padding: 0px;
-    word-break: keep-all;
-    text-overflow: ellipsis;
-	list-style-type: none;
+ul li {
+  white-space: nowrap;
+  color: inherit;
+  margin: 0px;
+  padding: 0px;
+  word-break: keep-all;
+  text-overflow: ellipsis;
+  list-style-type: none;
 }
 a,
 a:link,
 a:visited {
-    color: var(--link-color);
-    text-decoration: none;
-    cursor:pointer;
+  color: var(--link-color);
+  text-decoration: none;
+  cursor: pointer;
 }
 
 a:focus {
-    outline: 1px dotted;
+  outline: 1px dotted;
 }
 
 a:hover,
 a:active {
-    color: var(--tool-link-hover-color);
-    outline: none;
+  color: var(--tool-link-hover-color);
+  outline: none;
 }
-.footer_navbar{
-	display: flex;
-    flex-wrap: wrap;
-    width: 100%;
+.footer_navbar {
+  display: flex;
+  flex-wrap: wrap;
+  width: 100%;
 }
 
-.icon{
-    height: 1.4em;
-    width: 1.4em;
-    fill: #555;
-    transition: all 0.2s ease;
+.icon {
+  height: 1.4em;
+  width: 1.4em;
+  fill: #555;
+  transition: all 0.2s ease;
 }
 
-.small_icon{
-    height: 1em;
-    width: 1em;
-    fill: #555;
-    -webkit-transition-duration: 0.2s;
-    transition-duration: 0.2s;
+.small_icon {
+  height: 1em;
+  width: 1em;
+  fill: #555;
+  -webkit-transition-duration: 0.2s;
+  transition-duration: 0.2s;
 }
 
-.broder-1{
-    border: 1px solid var(--border-line-color);
+.broder-1 {
+  border: 1px solid var(--border-line-color);
 }
-.broder-2{
-    border: 2px solid var(--border-line-color);
+.broder-2 {
+  border: 2px solid var(--border-line-color);
+}
+.broder-r {
+  border-radius: 5px;
+}
+
+.tran:hover .edit_button {
+  display: inline-block;
+}
+.edit_button {
+  position: absolute;
+  display: none;
+  width: auto;
+  min-width: 24px;
+  height: auto;
+  min-height: 24px;
+  cursor: pointer;
+  background: url(edit.svg);
+  background-repeat: no-repeat;
+  background-size: contain;
+  margin: 0 6px;
+  margin-left: -24px;
+  color: var(--tool-color);
 }
-.broder-r{
-    border-radius: 5px;
-}

+ 7 - 0
app/pcdl/css/edit.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 24 24" style="fill: #6baaff;" xml:space="preserve">
+		<path
+			d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" />
+</svg>

+ 1 - 1
app/pcdl/reader.php

@@ -941,7 +941,7 @@ function render_sent($sent_data,$sn,$display_mode,$sent_count,$class=""){
 		if($display_mode=="sent"){
 			if((isset($_GET["channal"]) || $_GET["view"]=="sent")  ){
 				if($sent_data["editor"] == $_COOKIE["userid"]){
-					$output .= "<svg class='edit_icon';'><use xlink:href='../studio/svg/icon.svg#ic_mode_edit'></use></svg>";
+					$output .= "<svg class='edit_icon'><use xlink:href='../studio/svg/icon.svg#ic_mode_edit'></use></svg>";
 				}
 				
 			}

+ 2 - 0
app/studio/editor.php

@@ -64,6 +64,8 @@ else{$currDevice="computer";}
 	
 	<script language="javascript" src="module/editor/language/default.js"></script>	
 	<script src="js/jquery-3.3.1.min.js"></script>
+	<script src="../public/js/jquery-ui-1.12.1/jquery-ui.js"></script>
+
 	<script src="../term/term.js"></script>
 	<script src="../term/note.js"></script>
 	<script src="./js/message.js"></script>

+ 212 - 40
app/term/note.js

@@ -4,6 +4,9 @@ var _channal = "";
 var _lang = "";
 var _author = "";
 
+var _arrData;
+var _channalData;
+
 /*
 {{203-1654-23-45@11@en@*}}
 <note>203-1654-23-45@11@en@*</note>
@@ -27,38 +30,32 @@ var _author = "";
 <note id="guid" book=203 para=1654 begin=23 end=45 author=11 lang=en tag=*></note>
 
 */
-
+function note_create() {
+  $("#dialog").dialog({
+    autoOpen: false,
+    width: 550,
+    buttons: [
+      {
+        text: "Save",
+        click: function () {
+          note_sent_save();
+          $(this).dialog("close");
+        },
+      },
+      {
+        text: "Cancel",
+        click: function () {
+          $(this).dialog("close");
+        },
+      },
+    ],
+  });
+}
 function note_init(input) {
   let output = "<div>";
   let newString = input.replace(/\{\{/g, '<note info="');
   newString = newString.replace(/\}\}/g, '"></note>');
   output = marked(newString);
-  /*
-  let arrInput = input.split("\n");
-  for (x in arrInput) {
-    if (arrInput[x].slice(0, 2) == "==" && arrInput[x].slice(-2) == "==") {
-      output += "</div></div>";
-      output += '<div class="submenu1">';
-      output +=
-        '<p class="submenu_title1" onclick="submenu_show_detail(this)">';
-      output += arrInput[x].slice(2, -2);
-      output += '<svg class="icon" style="transform: rotate(45deg);">';
-      output += '<use xlink:href="svg/icon.svg#ic_add"></use>';
-      output += "</svg>";
-      output += "</p>";
-      output += '<div class="submenu_details1" >';
-    } else {
-      let row = arrInput[x];
-      row = row.replace(/\{\{/g, '<note info="');
-      row = row.replace(/\}\}/g, '"></note>');
-      if (row.match("{") && row.match("}")) {
-        row = row.replace("{", "<strong>");
-        row = row.replace("}", "</strong>");
-      }
-      output += row;
-    }
-  }
-  */
   output += "</div>";
   return output;
 }
@@ -115,11 +112,12 @@ function note_refresh_new() {
       function (data, status) {
         if (status == "success") {
           try {
-            let arrData = JSON.parse(data);
-            for (const iterator of arrData) {
+            _arrData = JSON.parse(data);
+            for (const iterator of _arrData) {
               let id = iterator.id;
               let strHtml = "<a name='" + id + "'></a>";
               if (_display && _display == "para") {
+                //段落模式
                 let strPalitext =
                   "<pali book='" +
                   iterator.book +
@@ -145,12 +143,17 @@ function note_refresh_new() {
                   .children(".palitext")
                   .first()
                   .append(strPalitext);
-                let htmlTran =
-                  "<span class='tran'>" +
-                  marked(term_std_str_to_tran(iterator.tran)) +
-                  "</span>";
+                let htmlTran = "";
+                for (const oneTran of iterator.translation) {
+                  htmlTran +=
+                    "<span class='tran'>" +
+                    marked(term_std_str_to_tran(oneTran.text)) +
+                    "</span>";
+                }
+
                 $("#" + id).html(htmlTran);
               } else {
+                //句子模式
                 strHtml += note_json_html(iterator);
                 $("#" + id).html(strHtml);
               }
@@ -214,12 +217,21 @@ function note_channal_list() {
       function (data, status) {
         if (status == "success") {
           try {
-            let arrData = JSON.parse(data);
+            _channalData = JSON.parse(data);
             let strHtml = "";
-            for (const iterator of arrData) {
+            for (const iterator of _channalData) {
               strHtml += render_channal_list(iterator);
             }
             $("#channal_list").html(strHtml);
+            $("[channal_id]").change(function () {
+              let channal_list = new Array();
+              $("[channal_id]").each(function () {
+                if (this.checked) {
+                  channal_list.push($(this).attr("channal_id"));
+                }
+              });
+              set_channal(channal_list.join());
+            });
           } catch (e) {
             console.error(e);
           }
@@ -229,10 +241,27 @@ function note_channal_list() {
   }
 }
 
+function find_channal(id) {
+  for (const iterator of _channalData) {
+    if (id == iterator.id) {
+      return iterator;
+    }
+  }
+  return false;
+}
 function render_channal_list(channalinfo) {
   let output = "";
   output += "<div class='list_with_head'>";
-
+  let checked = "";
+  if (_channal.indexOf(channalinfo.id) >= 0) {
+    checked = "checked";
+  }
+  output +=
+    '<div><input type="checkbox" ' +
+    checked +
+    " channal_id='" +
+    channalinfo.id +
+    "'></div>";
   output += "<div class='head'>";
   output += "<span class='head_img'>";
   output += channalinfo.nickname.slice(0, 2);
@@ -290,10 +319,44 @@ ref
 function note_json_html(in_json) {
   let output = "";
   output += "<div class='palitext'>" + in_json.palitext + "</div>";
-  output +=
-    "<div class='tran'>" +
-    marked(term_std_str_to_tran(in_json.tran)) +
-    "</div>";
+  for (const iterator of in_json.translation) {
+    output += "<div class='tran'>";
+    output +=
+      "<span class='edit_button' onclick=\"note_edit_sentence('" +
+      in_json.book +
+      "' ,'" +
+      in_json.para +
+      "' ,'" +
+      in_json.begin +
+      "' ,'" +
+      in_json.end +
+      "' ,'" +
+      iterator.channal +
+      "')\"></span>";
+
+    output +=
+      "<div class='text' id='tran_text_" +
+      in_json.book +
+      "_" +
+      in_json.para +
+      "_" +
+      in_json.begin +
+      "_" +
+      in_json.end +
+      "_" +
+      iterator.channal +
+      "'>";
+    if (iterator.text == "") {
+      //let channal = find_channal(iterator.channal);
+      output += "<span style='color:var(--border-line-color);'>新建译文</span>";
+    } else {
+      output += marked(term_std_str_to_tran(iterator.text));
+    }
+    output += "</div>";
+
+    output += "</div>";
+  }
+
   output += "<div class='ref'>" + in_json.ref;
   output +=
     "<span class='sent_no'>" +
@@ -308,3 +371,112 @@ function note_json_html(in_json) {
     "</div>";
   return output;
 }
+
+function note_edit_sentence(book, para, begin, end, channal) {
+  let channalInfo;
+  for (const iterator of _channalData) {
+    if (iterator.id == channal) {
+      channalInfo = iterator;
+      break;
+    }
+  }
+  for (const iterator of _arrData) {
+    if (
+      iterator.book == book &&
+      iterator.para == para &&
+      iterator.begin == begin &&
+      iterator.end == end
+    ) {
+      for (const tran of iterator.translation) {
+        if (tran.channal == channal) {
+          let html = "";
+          html +=
+            "<div style='color:blue;'>" +
+            channalInfo.nickname +
+            "/" +
+            channalInfo.name +
+            "</div>";
+          html +=
+            "<textarea id='edit_dialog_text' sent_id='" +
+            tran.id +
+            "' book='" +
+            iterator.book +
+            "' para='" +
+            iterator.para +
+            "' begin='" +
+            iterator.begin +
+            "' end='" +
+            iterator.end +
+            "' channal='" +
+            tran.channal +
+            "' style='width:100%;min-height:260px;'>" +
+            tran.text +
+            "</textarea>";
+          $("#edit_dialog_content").html(html);
+          break;
+        }
+      }
+    }
+  }
+
+  $("#dialog").dialog("open");
+}
+
+function note_sent_save() {
+  let id = $("#edit_dialog_text").attr("sent_id");
+  let book = $("#edit_dialog_text").attr("book");
+  let para = $("#edit_dialog_text").attr("para");
+  let begin = $("#edit_dialog_text").attr("begin");
+  let end = $("#edit_dialog_text").attr("end");
+  let channal = $("#edit_dialog_text").attr("channal");
+  let text = $("#edit_dialog_text").val();
+
+  $.post(
+    "../usent/sent_post.php",
+    {
+      id: id,
+      book: book,
+      para: para,
+      begin: begin,
+      end: end,
+      channal: channal,
+      text: text,
+      lang: "zh",
+    },
+    function (data) {
+      let result = JSON.parse(data);
+      if (result.status > 0) {
+        alert("error" + result.message);
+      } else {
+        alert("成功");
+        $(
+          "#tran_text_" +
+            result.book +
+            "_" +
+            result.para +
+            "_" +
+            result.begin +
+            "_" +
+            result.end +
+            "_" +
+            result.channal
+        ).html(marked(result.text));
+        for (const iterator of _arrData) {
+          if (
+            iterator.book == result.book &&
+            iterator.para == result.para &&
+            iterator.begin == result.begin &&
+            iterator.end == result.end
+          ) {
+            for (const tran of iterator.translation) {
+              if (tran.channal == result.channal) {
+                tran.text = result.text;
+                break;
+              }
+            }
+          }
+        }
+      }
+    }
+  );
+}

+ 26 - 7
app/term/note.php

@@ -79,25 +79,43 @@ foreach ($_data as $key => $value) {
 
 	//find out translation
 	$tran="";
+	$translation = array();
 	try{
 		if(!empty($_setting["channal"])){
 			$queryChannal = " AND channal = ? ";
+			$query="SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0  AND channal = ?  limit 0 ,1 ";
+			$channal = $_setting["channal"];
 		}
 		else{
-			$queryChannal ="";
+			$query="SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0   order by modify_time DESC limit 0 ,1 ";
+			$channal = "";
 		}
-		$query="SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0  $queryChannal order by modify_time DESC limit 0 ,1 ";
+		
 		$stmt = $db_trans_sent->prepare($query);
 		if(empty($_setting["channal"])){
 			$stmt->execute(array($bookId,$para,$begin,$end));
+			$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
+			if($Fetch){
+				$tran = $Fetch["text"];
+				$translation[]=array("id"=>$Fetch["id"],"text"=>$Fetch["text"],"channal"=>$Fetch["channal"]);
+			}
 		}
 		else{
-			$stmt->execute(array($bookId,$para,$begin,$end,$_setting["channal"]));
-		}
-		$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
-		if($Fetch){
-			$tran = $Fetch["text"];
+			$arrChannal = explode(",",$_setting["channal"]);
+			foreach ($arrChannal as $key => $value) {
+				# code...
+				$stmt->execute(array($bookId,$para,$begin,$end,$value));
+				$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
+				if($Fetch){
+					$translation[]=array("id"=>$Fetch["id"],"text"=>$Fetch["text"],"channal"=>$value);
+				}
+				else{
+					$translation[]=array("id"=>"","text"=>"","channal"=>$value);
+				}
+			}
 		}
+		
+
 		$tran_count = 1;
 	}
 	catch (Exception $e) {
@@ -110,6 +128,7 @@ foreach ($_data as $key => $value) {
 	$output[]=array("id"=>$id,
 							   "palitext"=>$palitext,
 							   "tran"=>$tran,
+							   "translation"=>$translation,
 							   "ref"=>$para_path,
 							   "tran_count"=>$tran_count,
 							   "book"=>$bookId,

+ 2 - 1
app/ucenter/setting.php

@@ -55,11 +55,12 @@ require_once '../public/function.php';
 	<title id="page_title">Setting</title>
 
 	<script src="../public/js/jquery-3.5.1.js"></script>
+	<script src="../public/js/jquery-ui-1.12.1/jquery-ui.js"></script>	
 	<script src="../public/js/fixedsticky.js"></script>
 	<script src="../lang/lang.js"></script>
 	<script src="../public/js/comm.js"></script>
 	<script src="../public/js/notify.js"></script>
-	<script src="../public/js/jquery-ui-1.12.1/jquery-ui.js"></script>
+
 	<script src="./setting.js"></script>
 
 </head>

+ 156 - 0
app/usent/sent_post.php

@@ -0,0 +1,156 @@
+<?php
+#更新一个句子
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once "../public/function.php";
+
+$respond=array("status"=>0,"message"=>"");
+$respond['book']=$_POST["book"];
+$respond['para']=$_POST["para"];
+$respond['begin']=$_POST["begin"];
+$respond['end']=$_POST["end"];
+$respond['channal']=$_POST["channal"];
+$respond['text']=$_POST["text"];
+
+#检查是否登陆
+if(!isset($_COOKIE["userid"])){
+    $respond["status"] = 1;
+    $respond["message"] = 'not login';
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+
+#先查询对此channal是否有权限修改
+$cooperation = 0;
+if(isset($_POST["channal"])){
+   PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+    $query = "SELECT owner FROM channal WHERE id=?";
+    $fetch = PDO_FetchOne($query,array($_POST["channal"]));
+    if($fetch && $fetch==$_COOKIE["userid"]){
+        #自己的channal
+        $cooperation = 1;
+    }
+    else{
+        $query = "SELECT count(*) FROM cooperation WHERE channal_id= ? and user_id=? ";
+        $fetch = PDO_FetchOne($query,array($_POST["channal"],$_COOKIE["userid"]));
+        if($fetch>0){
+            #有协作权限
+            $cooperation = 1;
+        }
+        else{
+            #无协作权限
+            $cooperation = 0;
+        }
+    }
+}
+else{
+    $respond["status"] = 1;
+    $respond["message"] = 'error channal id';
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+
+
+PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
+if(isset($_POST["id"])){
+    if(empty($_POST["id"])){
+        #没有id新建
+        if($cooperation == 1){
+            #有权限
+            $query = "INSERT INTO sentence (id, 
+														parent,
+														book,
+														paragraph,
+														begin,
+														end,
+														channal,
+														tag,
+														author,
+														editor,
+														text,
+														language,
+														ver,
+														status,
+														strlen,
+														modify_time,
+														receive_time,
+														create_time
+														) 
+										VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
+            $stmt = $PDO->prepare($query);
+            $stmt->execute(array(UUID::v4(),
+										  "",
+										  $_POST["book"], 
+										  $_POST["para"], 
+										  $_POST["begin"], 
+										  $_POST["end"], 
+										  $_POST["channal"], 
+										  "", 
+										  "[]", 
+										  $_COOKIE["userid"],
+										  $_POST["text"],
+										  $_POST["lang"],
+										  1,
+										  7,
+										  mb_strlen($_POST["text"],"UTF-8"),
+										  mTime(),
+										  mTime(),
+										  mTime()
+                                        ));
+            if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+                /*  识别错误  */
+                $error = PDO_ErrorInfo();
+                $respond['message']=$error[2];
+                $respond['status']=1;
+                echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+                exit;
+            }
+            else{
+                $respond['data']=array();
+            }
+        }
+        else{
+            #没权限
+            $respond['message']="没有权限";
+            $respond['status']=1;
+        }
+    }
+    else{
+        /* 修改现有数据 */
+        #判断是否有修改权限
+        if($cooperation == 1){
+            #有权限
+            $query="UPDATE sentence SET text= ?  , strlen = ? , editor = ? , receive_time= ?  , modify_time= ?   where  id= ?  ";
+            $stmt  = PDO_Execute($query,
+                                            array($_POST["text"],
+                                                    mb_strlen($_POST["text"],"UTF-8"), 
+                                                    $_COOKIE["userid"] ,
+                                                    mTime(),
+                                                    mTime(),
+                                                    $_POST["id"]));
+            if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+                /*  识别错误  */
+                $error = PDO_ErrorInfo();
+                $respond['message']=$error[2];
+                $respond['status']=1;
+                echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+                exit;
+            }
+            else{
+                #没错误
+
+            }
+        }
+        else{
+            #没权限 建议
+            $respond['message']="没有权限";
+            $respond['status']=1;
+        }
+    }
+}
+else{
+# error
+}
+
+echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+?>

+ 3 - 3
app/usent/update.php

@@ -2,9 +2,9 @@
 /*
 get xml doc from db
 */
-include "../path.php";
-include "../public/_pdo.php";
-include "../public/function.php";
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once "../public/function.php";
 
 
 $aData=json_decode($_POST["data"],TRUE);