Przeglądaj źródła

三藏选经本地化

visuddhinanda 5 lat temu
rodzic
commit
a3f410d226

+ 67 - 0
app/inline_dict/inline_dict.js

@@ -0,0 +1,67 @@
+function inlinedict_init(title = "Dict") {
+	$("pali")
+		.contents()
+		.filter(function () {
+			return this.nodeType != 1;
+		})
+		.wrap("<ps/>");
+
+	$("ps").each(function () {
+		let newText = "<pw>" + $(this).html().replace(/ /g, "</pw><pw>") + "</pw>";
+
+		$(this).html(newText);
+	});
+
+	/**
+	$('div').mouseup(function() {
+    var text=getSelectedText();
+    if (text!='') alert(text);
+});
+
+function getSelectedText() {
+    if (window.getSelection) {
+        return window.getSelection().toString();
+    } else if (document.selection) {
+        return document.selection.createRange().text;
+    }
+    return '';
+}​
+
+<div>Here is some text</div>
+	 */
+	$("body").append(
+		'<div id="inlinedict_dlg" title="' +
+			title +
+			'"><div id="inlinedict_dlg_content">' +
+			"<iframe name='inline_dict' height='100%' width='100%' src='../dict/index.php'></iframe>" +
+			"</div></div>"
+	);
+
+	$("#inlinedict_dlg").dialog({
+		autoOpen: false,
+		width: 550,
+		buttons: [
+			{
+				text: "Close",
+				click: function () {
+					$(this).dialog("close");
+				},
+			},
+		],
+	});
+}
+function inlinedict_open(book, para) {
+	$("#inlinedict_dlg").dialog("open");
+	$.get(
+		"../term/related_para.php",
+		{
+			book: book,
+			para: para,
+		},
+		function (data) {
+			let para = JSON.parse(data);
+			let html = related_para_dlg_render(para);
+			$("#related_para_dlg_content").html(html);
+		}
+	);
+}

+ 74 - 0
app/inline_dict/select.html

@@ -0,0 +1,74 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+	<head>
+		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+		<title></title>
+		<script type="text/javascript" src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>
+		<style type="text/css">
+			.tooltip {
+				width: 219px;
+				height: 33px;
+			}
+			.tooltip a {
+				width: 219px;
+				height: 33px;
+				display: block;
+			}
+		</style>
+		<script type="text/javascript">
+			// 获取选中的文本
+			function getSelectText() {
+				var txt = "";
+				if (document.selection) {
+					txt = document.selection.createRange().text;
+				} else {
+					txt = document.getSelection();
+					//txt = window.getSelection();
+				}
+				return $.trim(txt.toString());
+			}
+			function getPosition(e) {
+				var x = 15;
+				var y = 15;
+				var r = getSelectText();
+				if (r) {
+					var bowen = r.toString();
+					var tooltip =
+						"<div id='tooltip' class='tooltip'><a href='javascript:void(0)' target='_blank'>" +
+						bowen +
+						"</a></div>";
+					$("body").append(tooltip);
+					$("#tooltip")
+						.css({
+							top: e.pageY + y + "px",
+							left: e.pageX + x + "px",
+							position: "absolute",
+						})
+						.show("fast");
+				}
+			}
+			$(function () {
+				//将该id下的文章,鼠标选中松开后弹窗
+				$("#selectedArticle")
+					.mouseup(function (e) {
+						var txt = getSelectText();
+						txt = $.trim(txt);
+						getPosition(e);
+					})
+					.mousedown(function () {
+						$("#tooltip").remove();
+					});
+			});
+		</script>
+	</head>
+	<body>
+		<!--在文章内添加 selected-article ID-->
+		<div>
+			<textarea cols="60" rows="8" id="selectedArticle">
+asp、php、asp.net、javascript、jquery、vbscript、dos
+</textarea
+			>
+		</div>
+		asp、php、asp.net、javascript、jquery、vbscript、dos
+	</body>
+</html>

+ 21 - 0
app/inline_dict/select2.html

@@ -0,0 +1,21 @@
+<html>
+       <body>
+           <div id="container" style="border: 1px solid #333" contentEditable="true" onMouseUp="checkMe()">Type text    here</div>
+
+       </body>
+       <script language="javascript">
+       function checkMe() {
+           var txt = "";
+
+           if (window.getSelection) {
+               txt = window.getSelection();
+           } else if (document.getSelection) {
+               txt = document.getSelection();
+           } else if (document.selection) {
+               txt = document.selection.createRange().text;
+           }
+
+           alert("Selected text is " + txt);
+       }
+       </script>
+</html>

+ 2 - 2
app/pali_sent/sim_sent.php

@@ -254,8 +254,8 @@ function sents_similar_to_id($id) {
 	else{
 		$from_id = 0;
 	}
-	if($from<4){
-		$from = 4;
+	if($from<2){
+		$from = 2;
 	}
 	if($to>255){
 		$to = 255;

+ 9 - 8
app/palicanon/index.php

@@ -20,7 +20,8 @@ include "../pcdl/html_head.php";
             font-size: 150%;
             text-align: center;
             margin: 5em 0;
-            transition: all 600ms ease
+            transition: all 600ms ease;
+            text-transform: capitalize;
         }
 
         #main_tag span {
@@ -129,13 +130,13 @@ include "../pcdl/html_head.php";
     echo "<div style='font-size:140%'>";
     echo "</div>";
     echo '<div id="main_tag"  style="">';
-    echo '<span tag="sutta">Sutta</span>';
-    echo '<span tag="vinaya">Vinaya</span>';
-    echo '<span tag="abhidhamma">Abhidhamma</span>';
-    echo '<span tag="mūla">Mūla</span>';
-    echo '<span tag="aṭṭhakathā">Aṭṭhakathā</span>';
-    echo '<span tag="ṭīkā">ṭīkā</span>';
-    echo '<span tag="añña">añña</span>';
+    echo '<span tag="sutta" title="sutta"></span>';
+    echo '<span tag="vinaya"  title="vinaya"></span>';
+    echo '<span tag="abhidhamma" title="abhidhamma"></span>';
+    echo '<span tag="mūla" title="mūla"></span>';
+    echo '<span tag="aṭṭhakathā" title="aṭṭhakathā"></span>';
+    echo '<span tag="ṭīkā" title="ṭīkā"></span>';
+    echo '<span tag="añña" title="añña"></span>';
     echo '</div>';
     echo '<div id="tag_selected"></div>';
     echo '<div level="0" class="tag_others"></div>';

+ 168 - 145
app/palicanon/palicanon.js

@@ -7,173 +7,196 @@ var arrMyTerm = new Array();
 palicanon_load_term();
 
 function palicanon_onload() {
-    $("span[tag]").click(function() {
-        $(this).siblings().removeClass("select");
-        $(this).addClass("select");
-        main_tag = $(this).attr("tag");
-        list_tag = new Array();
-        tag_changed();
-        render_tag_list();
-    });
+	$("span[tag]").click(function () {
+		$(this).siblings().removeClass("select");
+		$(this).addClass("select");
+		main_tag = $(this).attr("tag");
+		list_tag = new Array();
+		tag_changed();
+		render_tag_list();
+	});
 
-    $("#tag_input").keypress(function() {
-        tag_render_others();
-    });
+	$("#tag_input").keypress(function () {
+		tag_render_others();
+	});
 }
 
 function palicanon_load_term() {
-    $.post(
-        "../term/get_term_index.php", {
-            lang: "zh-hans",
-        },
-        function(data) {
-            let result = JSON.parse(data);
-            if (result.status == 0) {
-                arrMyTerm = result.data;
-            } else {
-                alert(result.error);
-            }
-        }
-    );
+	$.post(
+		"../term/get_term_index.php",
+		{
+			lang: getCookie("language"),
+		},
+		function (data) {
+			let result = JSON.parse(data);
+			if (result.status == 0) {
+				arrMyTerm = result.data;
+				render_main_tag();
+			} else {
+				alert(result.error);
+			}
+		}
+	);
 }
 
+function render_main_tag() {
+	$("#main_tag")
+		.children()
+		.each(function () {
+			$(this).html(tag_get_local_word($(this).attr("tag")));
+		});
+}
 function tag_changed() {
-    let strTags = "";
-    if (list_tag.length > 0) {
-        strTags = main_tag + "," + list_tag.join();
-    } else {
-        strTags = main_tag;
-    }
-    console.log(strTags);
-    $.get(
-        "book_tag.php", {
-            tag: strTags,
-        },
-        function(data, status) {
-            let arrBookList = JSON.parse(data);
-            let html = "";
-            allTags = new Array();
-            for (const iterator of arrBookList) {
-                let tag0 = "";
-                let tags = iterator[0].tag.split("::");
-                let currTag = new Array();
-                currTag[main_tag] = 1;
-                for (const scondTag of list_tag) {
-                    currTag[scondTag] = 1;
-                }
-                for (let tag of tags) {
-                    if (tag.slice(0, 1) == ":") {
-                        tag = tag.slice(1);
-                    }
-                    if (tag.slice(-1) == ":") {
-                        tag = tag.slice(0, -1);
-                    }
-                    if (currTagLevel0.hasOwnProperty(tag)) {
-                        tag0 = tag;
-                    }
-                    if (!currTag.hasOwnProperty(tag)) {
-                        if (allTags.hasOwnProperty(tag)) {
-                            allTags[tag] += 1;
-                        } else {
-                            allTags[tag] = 1;
-                        }
-                    }
-                }
+	let strTags = "";
+	if (list_tag.length > 0) {
+		strTags = main_tag + "," + list_tag.join();
+	} else {
+		strTags = main_tag;
+	}
+	console.log(strTags);
+	$.get(
+		"book_tag.php",
+		{
+			tag: strTags,
+		},
+		function (data, status) {
+			let arrBookList = JSON.parse(data);
+			let html = "";
+			allTags = new Array();
+			for (const iterator of arrBookList) {
+				let tag0 = "";
+				let tags = iterator[0].tag.split("::");
+				let currTag = new Array();
+				currTag[main_tag] = 1;
+				for (const scondTag of list_tag) {
+					currTag[scondTag] = 1;
+				}
+				for (let tag of tags) {
+					if (tag.slice(0, 1) == ":") {
+						tag = tag.slice(1);
+					}
+					if (tag.slice(-1) == ":") {
+						tag = tag.slice(0, -1);
+					}
+					if (currTagLevel0.hasOwnProperty(tag)) {
+						tag0 = tag;
+					}
+					if (!currTag.hasOwnProperty(tag)) {
+						if (allTags.hasOwnProperty(tag)) {
+							allTags[tag] += 1;
+						} else {
+							allTags[tag] = 1;
+						}
+					}
+				}
 
-                //html += "<div style='width:100%;'>";
-                html += "<div class='sutta_row' >";
-                html += "<div class='sutta_box'>" + tag0 + "</div>";
-                html +=
-                    "<div class='sutta_box'><a href='../reader/?view=chapter&book=" +
-                    iterator[0].book +
-                    "&para=" +
-                    iterator[0].para +
-                    "' target = '_blank'>" +
-                    iterator[0].title +
-                    "</a></div>";
-                html += "<div class='sutta_box'>book:" + iterator[0].book + " para:" + iterator[0].para + "</div>";
-                html += "<div class='sutta_tag'>tag=" + iterator[0].tag + "</div>";
-                html += "</div>";
-                //html += "</div>";
-            }
+				//html += "<div style='width:100%;'>";
+				html += "<div class='sutta_row' >";
+				html += "<div class='sutta_box'>" + tag0 + "</div>";
+				html +=
+					"<div class='sutta_box'><a href='../reader/?view=chapter&book=" +
+					iterator[0].book +
+					"&para=" +
+					iterator[0].para +
+					"' target = '_blank'>" +
+					iterator[0].title +
+					"</a></div>";
+				html += "<div class='sutta_box'>book:" + iterator[0].book + " para:" + iterator[0].para + "</div>";
+				html += "<div class='sutta_tag'>tag=" + iterator[0].tag + "</div>";
+				html += "</div>";
+				//html += "</div>";
+			}
 
-            let newTags = new Array();
-            for (const oneTag in allTags) {
-                if (allTags[oneTag] < arrBookList.length) {
-                    newTags[oneTag] = allTags[oneTag];
-                }
-            }
-            allTags = newTags;
-            allTags.sort(sortNumber);
-            tag_render_others();
-            $("#book_list").html(html);
-        }
-    );
+			let newTags = new Array();
+			for (const oneTag in allTags) {
+				if (allTags[oneTag] < arrBookList.length) {
+					newTags[oneTag] = allTags[oneTag];
+				}
+			}
+			allTags = newTags;
+			allTags.sort(sortNumber);
+			tag_render_others();
+			$("#book_list").html(html);
+		}
+	);
+}
+function tag_get_local_word(word) {
+	let termKey = term_lookup_my(word, "", getCookie("userid"), getCookie("language"));
+	if (termKey) {
+		return termKey.meaning;
+	} else {
+		return word;
+	}
 }
-
 function tag_render_others() {
-    let strOthersTag = "";
-    currTagLevel0 = new Array();
-    $(".tag_others").html("");
+	let strOthersTag = "";
+	currTagLevel0 = new Array();
+	$(".tag_others").html("");
 
-    document.getElementById('main_tag').style.margin = 1 + "em";
-    document.getElementById('main_tag').style.fontSize = 100 + "%";
+	document.getElementById("main_tag").style.margin = 1 + "em";
+	document.getElementById("main_tag").style.fontSize = 100 + "%";
 
-    for (const key in allTags) {
-        if (allTags.hasOwnProperty(key)) {
-            if ($("#tag_input").val().length > 0) {
-                if (key.indexOf($("#tag_input").val()) >= 0) {
-                    strOthersTag = "<button class=\"canon-tag\" onclick =\"tag_click('" + key + "')\" >" + key + "</button>";
-                }
-            } else {
-                let termKey = term_lookup_my(key, "", getCookie("userid"), "zh-cn");
-                let keyname = key;
-                if (termKey) {
-                    keyname = termKey.meaning;
-                }
-                strOthersTag = "<button class=\"canon-tag\" onclick =\"tag_click('" + key + "')\" >" + keyname + "</button>";
-            }
-            let thisLevel = 100;
-            if (tag_level.hasOwnProperty(key)) {
-                thisLevel = tag_level[key].level;
-                if (tag_level[key].level == 0) {
-                    currTagLevel0[key] = 1;
-                }
-            }
-            $(".tag_others[level='" + thisLevel + "']").html(
-                $(".tag_others[level='" + thisLevel + "']").html() + strOthersTag
-            );
-        }
-    }
+	for (const key in allTags) {
+		if (allTags.hasOwnProperty(key)) {
+			if ($("#tag_input").val().length > 0) {
+				if (key.indexOf($("#tag_input").val()) >= 0) {
+					strOthersTag =
+						'<button class="canon-tag" onclick ="tag_click(\'' + key + "')\" >" + key + "</button>";
+				}
+			} else {
+				let keyname = tag_get_local_word(key);
+				strOthersTag =
+					'<button class="canon-tag" title="' +
+					key +
+					'" onclick ="tag_click(\'' +
+					key +
+					"')\" >" +
+					keyname +
+					"</button>";
+			}
+			let thisLevel = 100;
+			if (tag_level.hasOwnProperty(key)) {
+				thisLevel = tag_level[key].level;
+				if (tag_level[key].level == 0) {
+					currTagLevel0[key] = 1;
+				}
+			}
+			$(".tag_others[level='" + thisLevel + "']").html(
+				$(".tag_others[level='" + thisLevel + "']").html() + strOthersTag
+			);
+		}
+	}
 }
 
 function tag_click(tag) {
-    list_tag.push(tag);
-    render_tag_list();
-    tag_changed();
+	list_tag.push(tag);
+	render_tag_list();
+	tag_changed();
 }
 
 function render_tag_list() {
-    let strListTag = gLocal.gui.selected + ":";
-    for (const iterator of list_tag) {
-        strListTag += "<tag><span class=\"textt\">" + iterator + "</span>";
-        strListTag += "<span class=\"tag-delete\" onclick =\"tag_remove('" + iterator + "')\">✕</span></tag>";
-    }
-    strListTag +=
-        "<div style='display:inline-block;width:20em;'><input id='tag_input' type='input' placeholder='tag' size='20'  /></div>";
-    $("#tag_selected").html(strListTag);
+	let strListTag = gLocal.gui.selected + ":";
+	for (const iterator of list_tag) {
+		strListTag += '<tag><span class="textt" title="' + iterator + '">' + tag_get_local_word(iterator) + "</span>";
+		strListTag += '<span class="tag-delete" onclick ="tag_remove(\'' + iterator + "')\">✕</span></tag>";
+	}
+	strListTag +=
+		"<div style='display:inline-block;width:20em;'>" +
+		"<input id='tag_input' type='input' placeholder='tag' size='20'  />" +
+		"</div>";
+	$("#tag_selected").html(strListTag);
 }
 
 function tag_remove(tag) {
-    for (let i = 0; i < list_tag.length; i++) {
-        if (list_tag[i] == tag) {
-            list_tag.splice(i, 1);
-        }
-    }
-    render_tag_list();
-    tag_changed();
+	for (let i = 0; i < list_tag.length; i++) {
+		if (list_tag[i] == tag) {
+			list_tag.splice(i, 1);
+		}
+	}
+	render_tag_list();
+	tag_changed();
 }
 
 function sortNumber(a, b) {
-    return b - a;
-}
+	return b - a;
+}

+ 2 - 1
app/pcdl/html_head.php

@@ -98,7 +98,8 @@ else{
 	<script src="../term/pali_sim_sent.js"></script>
 	<link type="text/css" rel="stylesheet" href="../term/pali_sim_dlg.css"/>
 	<script src="../term/related_para.js"></script>
-
+	
+	<script src="../inline_dict/inline_dict.js"></script>
 
 	<script src="../widget/click_dropdown.js"></script>
 	<link type="text/css" rel="stylesheet" href="../widget/click_dropdown.css"/>

Plik diff jest za duży
+ 592 - 592
app/public/book_tag/en.json


+ 2 - 1
app/public/book_tag/tag_list.json

@@ -51,6 +51,7 @@
 	"pācityādiyojanā": { "level": 3 },
 	"nettippakaraṇa": { "level": 3 },
 	"mūlasikkhā": { "level": 2 },
+	"pāḷi": { "level": 3 },
 	"milindapañha": { "level": 3 },
 	"manorathapūraṇī": { "level": 3 },
 	"majjhimanikāya": { "level": 1 },
@@ -64,7 +65,7 @@
 	"jātaka": { "level": 3 },
 	"itivuttaka": { "level": 3 },
 	"dīghanikāya": { "level": 1 },
-	"khuddaka": { "level": 1 },
+	"khuddakanikāya": { "level": 1 },
 	"dhātukathā": { "level": 2 },
 	"dhammasaṅgaṇī": { "level": 2 },
 	"dhammapada": { "level": 3 },

+ 9 - 0
app/term/get_term_index.php

@@ -30,6 +30,15 @@ if(isset($_POST["word"])){
 else{
     $query ="select * from (select word,meaning,language,owner,count(*) as co from term where language=? group by word,meaning order by co DESC) where 1 group by word";
     $output["data"] = PDO_FetchAll($query,array($lang));
+    $pos = mb_strpos($lang,"-",0,"UTF-8");
+    if($pos){
+        $lang_family= mb_substr($lang,0,$pos,"UTF-8");
+        $query ="select * from (select word,meaning,language,owner,count(*) as co from term where language like ? group by word,meaning order by co DESC) where 1 group by word";
+        $otherlang = PDO_FetchAll($query,array($lang_family."%"));
+        foreach ($otherlang as $key => $value) {
+            $output["data"][]=$value;
+        }
+    }
 }
 
 echo json_encode($output, JSON_UNESCAPED_UNICODE);

+ 4 - 0
app/term/term.css

@@ -525,3 +525,7 @@ note:hover .note_tool_bar {
 	background: #c6c6c6;
 	text-decoration: none;
 }
+
+pw {
+	padding-right: 0.5em;
+}

+ 27 - 28
app/term/term.js

@@ -93,21 +93,20 @@ function term_get_my_std_str(strMean) {
 }
 
 function note_lookup(word, showto) {
-	$("#" + showto).load("../term/term.php?op=search&word=" + word + "&username=" + getCookie("username"), function (
-		responseTxt,
-		statusTxt,
-		xhr
-	) {
-		if (statusTxt == "success") {
-			$(".term_note").each(function (index, element) {
-				$(this).html(note_init($(this).html()));
-				$(this).attr("status", 1);
-				note_refresh_new();
-			});
-		} else if (statusTxt == "error") {
-			console.error("Error: " + xhr.status + ": " + xhr.statusText);
+	$("#" + showto).load(
+		"../term/term.php?op=search&word=" + word + "&username=" + getCookie("username"),
+		function (responseTxt, statusTxt, xhr) {
+			if (statusTxt == "success") {
+				$(".term_note").each(function (index, element) {
+					$(this).html(note_init($(this).html()));
+					$(this).attr("status", 1);
+					note_refresh_new();
+				});
+			} else if (statusTxt == "error") {
+				console.error("Error: " + xhr.status + ": " + xhr.statusText);
+			}
 		}
-	});
+	);
 }
 
 var term_get_word_to_div_callback = null;
@@ -392,8 +391,9 @@ function term_lookup_my(pali, channal = "", owner = "", lang = "") {
 			}
 		}
 	}
-	//我自己的相同语言
+
 	if (owner != "") {
+		//我自己的相同语言
 		for (const iterator of arrMyTerm) {
 			if (iterator.word == pali && owner == iterator.owner && iterator.language == lang) {
 				return iterator;
@@ -409,25 +409,24 @@ function term_lookup_my(pali, channal = "", owner = "", lang = "") {
 				}
 			}
 		}
+	}
 
-		//别人的相同语言
-		for (const iterator of arrMyTerm) {
-			if (iterator.word == pali && iterator.language == lang) {
-				return iterator;
-			}
+	//别人的相同语言
+	for (const iterator of arrMyTerm) {
+		if (iterator.word == pali && iterator.language == lang) {
+			return iterator;
 		}
+	}
 
-		//找别人的相似语言
-		for (const iterator of arrMyTerm) {
-			if (pali == iterator.word) {
-				let thisLangFamily = iterator.language.split("-")[0];
-				if (thisLangFamily == langFamily) {
-					return iterator;
-				}
+	//找别人的相似语言
+	for (const iterator of arrMyTerm) {
+		if (pali == iterator.word) {
+			let thisLangFamily = iterator.language.split("-")[0];
+			if (thisLangFamily == langFamily) {
+				return iterator;
 			}
 		}
 	}
-	//找自己的相似语言
 	return false;
 }
 

Plik diff jest za duży
+ 7 - 7
pali_title/125_title.csv


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików