visuddhinanda 5 лет назад
Родитель
Сommit
0b49ea1bf8
7 измененных файлов с 196 добавлено и 25 удалено
  1. 1 0
      app/article/index.php
  2. 2 0
      app/pcdl/html_head.php
  3. 44 4
      app/term/channal_list.php
  4. 55 19
      app/term/note.js
  5. 8 2
      app/term/term_popup.js
  6. 30 0
      app/term/term_post.php
  7. 56 0
      app/term/term_put.php

+ 1 - 0
app/article/index.php

@@ -370,6 +370,7 @@ term_word_link_fun("wiki_goto_word");
 <script>
 	$(document).ready(function(){
 	note_create();
+	term_edit_dlg_init();
 	articel_load(_articel_id);
 	articel_load_collect(_articel_id);
 	click_dropdown_init();

+ 2 - 0
app/pcdl/html_head.php

@@ -51,6 +51,8 @@ else{
 	<script src="../term/note.js"></script>
 	<script src="../term/term_popup.js"></script>
 	<link type="text/css" rel="stylesheet" href="../term/term.css"/>
+	<script src="../term/term_edit_dlg.js"></script>
+	<link type="text/css" rel="stylesheet" href="../term/term_edit_dlg.css"/>	
 	
 	<script >
 	<?php require_once '../public/load_lang_js.php';?>

+ 44 - 4
app/term/channal_list.php

@@ -23,10 +23,16 @@ $dns = "sqlite:"._FILE_DB_SENTENCE_;
 $db_trans_sent = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
 $db_trans_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
 
+$dns = "sqlite:"._FILE_DB_PALI_SENTENCE_;
+$db_pali_sent = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$db_pali_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
 
 $channal = array();
 
+$final = array();
+$article_len=0;
 foreach ($_data as $key => $value) {
+	$pali_letter = array();
 	# code...
 	$id = $value["id"];
 	$arrInfo = str_getcsv($value["data"],"@");
@@ -39,20 +45,37 @@ foreach ($_data as $key => $value) {
 	//find out translation
 	$tran="";
 	try{
+		# 查询句子长度
+		$pali_letter["id"]=$arrInfo[0];
+		$query="SELECT length FROM pali_sent WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  ";
+		$stmt = $db_pali_sent->prepare($query);
+		$stmt->execute(array($bookId,$para,$begin,$end));
+		$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
+		if($Fetch){
+			$pali_letter["len"]=$Fetch["length"];
+			$article_len+=$Fetch["length"];
+		}
+		else{
+			$pali_letter["len"]=0;
+		}
+
 		$query="SELECT channal FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0  group by channal  limit 0 ,20 ";
 		$stmt = $db_trans_sent->prepare($query);
 		$stmt->execute(array($bookId,$para,$begin,$end));
 		$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
 		foreach ($Fetch as $key => $value) {
-            # code...
+			# code...
+			$pali_letter[$value["channal"]]=1;
             if(isset($channal[$value["channal"]])){
-                $channal[$value["channal"]] ++;
+				$channal[$value["channal"]] ++;
 			}
 			else{
 				$channal[$value["channal"]] = 1;
 			}
             
-        }
+		}
+		
+		$final[]=$pali_letter;
 	}
 	catch (Exception $e) {
 		$tran = $e->getMessage();
@@ -64,13 +87,30 @@ foreach ($_data as $key => $value) {
 }
 
 foreach ($channal as $key => $value) {
-    # code...
+	# 计算句子的完成分布
+	$arr_sent_final = array();
+	foreach ($final as  $final_value) {
+		# code...
+		$sent_final = array();
+		$sent_final["id"]=$final_value["id"];
+		$sent_final["len"]=$final_value["len"];
+		if(isset($final_value[$key]) && $final_value[$key]==1){
+			$sent_final["final"]=true;
+		}
+		else{
+			$sent_final["final"]=false;
+		}
+		$arr_sent_final[] = $sent_final;
+	}
     $channalInfo = $_channal->getChannal($key);
     $name = $_userinfo->getName($channalInfo["owner"]);
     $channalInfo["username"] = $name["username"];
 	$channalInfo["nickname"] = $name["nickname"];
 	$channalInfo["count"] = $value;
 	$channalInfo["all"] = count($_data);
+	$channalInfo["final"] =$arr_sent_final;
+	$channalInfo["article_len"] =$article_len;
+
     $output[]= $channalInfo;
 }
 

+ 55 - 19
app/term/note.js

@@ -232,7 +232,6 @@ function note_refresh_new() {
 
 function note_channal_list() {
   console.log("note_channal_list start");
-  let objNotes = document.querySelectorAll("note");
   let arrSentInfo = new Array();
   $("note").each(function () {
     let info = $(this).attr("info");
@@ -240,16 +239,7 @@ function note_channal_list() {
       arrSentInfo.push({ id: "", data: info });
     }
   });
-  /*
-  for (const iterator of objNotes) {
-    {
-      let info = iterator.getAttributeNode("info").value;
-      if (info && info != "") {
-        arrSentInfo.push({ id: "", data: info });
-      }
-    }
-  }
-*/
+
   if (arrSentInfo.length > 0) {
     $.post(
       "../term/channal_list.php",
@@ -349,15 +339,61 @@ function render_channal_list(channalinfo) {
   output += channalinfo["nickname"] + "/";
   output += "@" + channalinfo["username"];
   output += "</div>";
-  output += "<div style='background-color: #e0dfdffa;'>";
-  output +=
-    "<span  style='display: inline-block;background-color: #65ff65;width: " +
-    (channalinfo["count"] * 100) / channalinfo["all"] +
-    "%;'>";
-  output += channalinfo["count"] + "/" + channalinfo["all"];
-  output += "</span>";
 
-  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);
+    output +=
+      '<svg viewBox="0 0 ' + svg_width + " " + svg_height + '" width="100%" >';
+
+    let curr_x = 0;
+    let allFinal = 0;
+    for (const iterator of channalinfo["final"]) {
+      let stroke_width = parseInt(iterator.len);
+      output += "<rect ";
+      output += ' x="' + curr_x + '"';
+      output += ' y="0"';
+      output += ' height="' + svg_height + '"';
+      output += ' width="' + stroke_width + '"';
+
+      if (iterator.final == true) {
+        allFinal += stroke_width;
+        output += ' style="stroke-width: 0; fill: rgb(0, 128, 6);"';
+      } else {
+        output += ' style="stroke-width: 0; fill: rgb(230, 230, 230);"';
+      }
+      output += "/>";
+
+      curr_x += stroke_width;
+    }
+    output +=
+      "<rect  x='0' y='0'  width='" +
+      svg_width +
+      "' height='" +
+      svg_height / 5 +
+      "'  style='stroke-width: 0; fill: rgb(230, 230, 230);'/>";
+    output +=
+      "<rect  x='0' y='0'  width='" +
+      allFinal +
+      "' height='" +
+      svg_height / 5 +
+      "'  style='stroke-width: 0; fill: rgb(100, 228, 100);'/>";
+    output +=
+      '<text x="0" y="' +
+      svg_height +
+      '" font-size="' +
+      svg_height * 0.8 +
+      '">';
+    output += channalinfo["count"] + "/" + channalinfo["all"];
+    output += "</text>";
+    output += "<svg>";
+    output += "</div>";
+    //进度结束
+  }
+
   output += "</div>";
   output += "</div>";
   return output;

+ 8 - 2
app/term/term_popup.js

@@ -57,10 +57,16 @@ function note_lookup_guid_json(guid) {
             "<div class='term_note' status='1'>" +
             note_init(result.note) +
             "</div>";
+          html += "<div >";
           html +=
-            "<div ><a href='../wiki/wiki.php?word=" +
+            "<a href='../wiki/wiki.php?word=" +
             result.word +
-            "' target='_blank'>更多</a></div>";
+            "' target='_blank'>更多</a>";
+          html +=
+            "<button onclick=\"term_edit_dlg_open('" +
+            result.guid +
+            "')\">修改</button>";
+          html += "</div>";
           html += "</div>";
           $("[term-popup='" + guid + "']").html(html);
           //note_refresh_new();

+ 30 - 0
app/term/term_post.php

@@ -1,3 +1,33 @@
 <?php
 
+$respond=array("status"=>0,"message"=>"");
+if($_POST["id"]!=""){
+    $query="UPDATE term SET meaning= ? ,other_meaning = ? , tag= ? ,channal = ? ,  language = ? , note = ? , receive_time= ?, modify_time= ?   where guid= ? ";
+    $stmt = @PDO_Execute($query,array($_POST["mean"],
+                                                                $_POST["mean2"],
+                                                                $_POST["tag"],
+                                                                $_POST["channal"],
+                                                                $_POST["language"],
+                                                                $_POST["note"],
+                                                                mTime(),
+                                                                mTime(),
+                                                                $_POST["id"]
+                                                            ));
+    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+        $error = PDO_ErrorInfo();
+        $respond['status']=1;
+        $respond['message']=$error[2].$query;
+    }
+    else{
+        $respond['status']=0;
+        $respond['message']=$word;
+    }		
+}
+else{
+
+}
+    
+
+    echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+
 ?>

+ 56 - 0
app/term/term_put.php

@@ -0,0 +1,56 @@
+<?php
+		$currTime=sprintf("%d",microtime(true)*1000);
+		if(isset($_GET["modify_time"])){
+			$mTime=$_GET["modify_time"];
+		}
+		else{
+			$mTime=mTime();
+		}
+		if($_GET["guid"]!=""){
+			$query="UPDATE term SET meaning= ? ,other_meaning = ? , tag= ? ,channal = ? ,  language = ? , note = ? , receive_time= ?, modify_time= ?   where guid= ? ";
+			$stmt = @PDO_Execute($query,array($_GET["mean"],
+																		$_GET["mean2"],
+																		$_GET["tag"],
+																		$_GET["channal"],
+																		$_GET["language"],
+																		$_GET["note"],
+																		mTime(),
+																		$mTime,
+																		$_GET["guid"]
+																	));
+		}
+		else{
+			$parm = array();
+			$parm[]=UUID::v4();
+			$parm[]=$_GET["word"];
+			$parm[]=pali2english($word);
+			$parm[]=$_GET["mean"];
+			$parm[]=$_GET["mean2"];
+			$parm[]=$_GET["tag"];			
+			$parm[]=$_GET["channal"];			
+			$parm[]=$_GET["language"];			
+			$parm[]=$_GET["note"];
+			$parm[]=$_COOKIE["userid"];
+			$parm[]=0;
+			$parm[]=mTime();
+			$parm[]=mTime();
+			$parm[]=mTime();
+			$query="INSERT INTO term (id, guid, word, word_en, meaning, other_meaning, tag, channal, language,note,owner,hit,create_time,modify_time,receive_time ) 
+															VALUES (NULL, ? , ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "; 
+
+			$stmt = @PDO_Execute($query,$parm);
+		}
+			
+			$respond=array("status"=>0,"message"=>"");
+			if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+				$error = PDO_ErrorInfo();
+				$respond['status']=1;
+				$respond['message']=$error[2].$query;
+			}
+			else{
+				$respond['status']=0;
+				$respond['message']=$word;
+			}		
+			echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+
+?>