Explorar o código

同步支持选择

visuddhinanda %!s(int64=4) %!d(string=hai) anos
pai
achega
a0b2222748

+ 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);
+
+?>