Bläddra i källkod

设置增加图书馆巴利脚本设置

visuddhinanda 5 år sedan
förälder
incheckning
8f3db47b38
6 ändrade filer med 236 tillägg och 154 borttagningar
  1. 4 0
      app/dict/index.php
  2. 2 0
      app/pcdl/html_head.php
  3. 38 22
      app/term/note.js
  4. 23 20
      app/ucenter/default.json
  5. 142 106
      app/ucenter/setting.js
  6. 27 6
      app/ucenter/setting.php

+ 4 - 0
app/dict/index.php

@@ -214,6 +214,10 @@ require_once "../pcdl/html_head.php";
 			-moz-justify-content: center;
 			justify-content: center;
 		}
+
+		.dict_find_gramma guide{
+			color:unset;
+		}
 	</style>
 	<link type="text/css" rel="stylesheet" href="./css/style.css" >
 	<link type="text/css" rel="stylesheet" href="./css/style_mobile.css" media="screen and (max-width:800px)">

+ 2 - 0
app/pcdl/html_head.php

@@ -69,6 +69,8 @@ else{
 	<script src="../guide/guide.js"></script>
 	<link type="text/css" rel="stylesheet" href="../guide/guide.css"/>
 
+	<script src="../ucenter/setting.js"></script>
+
 	<script src="../public/js/marked.js"></script>
 	<script src="../public/js/mermaid.min.js"></script>
 

+ 38 - 22
app/term/note.js

@@ -224,6 +224,7 @@ function note_refresh_new() {
 						note_ref_init();
 						term_get_dict();
 						note_channal_list();
+						refresh_pali_script();
 					} catch (e) {
 						console.error(e);
 					}
@@ -939,31 +940,46 @@ function note_show_pali_sim(SentId) {
 }
 
 function set_pali_script(pos, script) {
-	$(".palitext" + pos).each(function () {
-		let html = $(this).siblings(".palitext_roma").first().html();
-		$(this).html(html);
-	});
+	if (script == "none") {
+		$(".palitext" + pos).html("");
+	} else {
+		$(".palitext" + pos).each(function () {
+			let html = $(this).siblings(".palitext_roma").first().html();
+			$(this).html(html);
+		});
 
-	$(".palitext" + pos)
-		.find("*")
-		.contents()
-		.filter(function () {
-			return this.nodeType != 1;
-		})
-		.wrap("<pl" + pos + "></pl" + pos + ">");
-
-	$(".palitext" + pos)
-		.contents()
-		.filter(function () {
-			return this.nodeType != 1;
-		})
-		.wrap("<pl" + pos + "></pl" + pos + ">");
-
-	$("pl" + pos).html(function (index, oldcontent) {
-		return roman_to_my(oldcontent);
-	});
+		$(".palitext" + pos)
+			.find("*")
+			.contents()
+			.filter(function () {
+				return this.nodeType != 1;
+			})
+			.wrap("<pl" + pos + "></pl" + pos + ">");
+
+		$(".palitext" + pos)
+			.contents()
+			.filter(function () {
+				return this.nodeType != 1;
+			})
+			.wrap("<pl" + pos + "></pl" + pos + ">");
+
+		$("pl" + pos).html(function (index, oldcontent) {
+			return roman_to_my(oldcontent);
+		});
+	}
 }
 
+function refresh_pali_script() {
+	if (_display && _display == "para") {
+		//段落模式
+	} else {
+		//句子模式
+		setting_get("lib.second_script", set_second_scrip);
+	}
+}
+function set_second_scrip(value) {
+	set_pali_script(2, value);
+}
 function slider_show(obj) {
 	$(obj).parent().parent().parent().parent().parent().toggleClass("slider_show_shell");
 }

+ 23 - 20
app/ucenter/default.json

@@ -1,22 +1,25 @@
 {
-  "account.head": 0,
-  "_ui.lang": ["en", "zh-hans", "zh-hant"],
-  "ui.lang": ["en", "zh-hans", "zh-hant", "si", "my"],
-  "_studio.translation.lang": ["en", "zh-hans", "zh-hant", "si", "my"],
-  "studio.translation.lang": ["en", "zh-hans", "zh-hant"],
-  "studio.translation.autosave": true,
-  "_dict.lang": ["en", "zh", "zh-hans", "zh-hant", "si"],
-  "dict.lang": ["zh", "en"],
-  "_dict.list": [
-    {
-      "id": "regular",
-      "name": "dict_sys_regular",
-      "table": "/system/sys_regular.db"
-    },
-    { "id": "bhmf", "table": "bhmf.db" },
-    { "id": "bhmf", "table": "bhmf.db" },
-    { "id": "bhmf", "table": "bhmf.db" }
-  ],
-  "dict.whitelist": ["@kosalla", "@mine"],
-  "dict.blacklist": ["@all", "bhmf"]
+	"account.head": 0,
+	"_ui.lang": ["en", "zh-hans", "zh-hant"],
+	"ui.lang": ["en", "zh-hans", "zh-hant", "si", "my"],
+	"_studio.translation.lang": ["en", "zh-hans", "zh-hant", "si", "my"],
+	"studio.translation.lang": ["en", "zh-hans", "zh-hant"],
+	"studio.translation.autosave": true,
+	"_dict.lang": ["en", "zh", "zh-hans", "zh-hant", "si"],
+	"dict.lang": ["zh", "en"],
+	"_dict.list": [
+		{
+			"id": "regular",
+			"name": "dict_sys_regular",
+			"table": "/system/sys_regular.db"
+		},
+		{ "id": "bhmf", "table": "bhmf.db" },
+		{ "id": "bhmf", "table": "bhmf.db" },
+		{ "id": "bhmf", "table": "bhmf.db" }
+	],
+	"dict.whitelist": ["@kosalla", "@mine"],
+	"dict.blacklist": ["@all", "bhmf"],
+	"lib.first_script": "roma",
+	"lib.second_script": "none",
+	"lib.pali_script": ["none", "roma", "my"]
 }

+ 142 - 106
app/ucenter/setting.js

@@ -1,126 +1,162 @@
 var setting;
 function setting_head_render(file) {
-  let html = '<svg class="head_icon" style="height: 3em;width: 3em;">';
-  html += '<use xlink:href="../head/images/"' + file + "></use>";
-  html += "</svg>";
-  $("#head_img").html(html);
+	let html = '<svg class="head_icon" style="height: 3em;width: 3em;">';
+	html += '<use xlink:href="../head/images/"' + file + "></use>";
+	html += "</svg>";
+	$("#head_img").html(html);
 }
 function setting_onload() {
-  $.post("get_setting.php", {}, function (data, status) {
-    try {
-      setting = JSON.parse(data);
-      let html;
+	$.post("get_setting.php", {}, function (data, status) {
+		try {
+			setting = JSON.parse(data);
+			let html;
 
-      html = "";
-      html += gLocal.gui.interface_language + ":";
-      $("#setting_general").html(html);
+			//通用设置
+			html = "";
+			html += gLocal.gui.interface_language + ":";
+			$("#setting_general").html(html);
+			//通用设置结束
 
-      html = "";
-      html += gLocal.gui.translation_language + ":";
+			//Library 设置
 
-      $("#setting_studio").html(html);
+			html = "";
+			html += "<h3>显示/Display</h3>";
+			html += "<div>巴利原文1" + setting_render_paliscript("lib.first_script") + "</div>";
+			html += "<div>巴利原文2" + setting_render_paliscript("lib.second_script") + "</div>";
 
-      let dict_lang_others = new Array();
-      for (const iterator of setting["_dict.lang"]) {
-        if (setting["dict.lang"].indexOf(iterator) == -1) {
-          dict_lang_others.push(iterator);
-        }
-      }
-      html = "";
-      html += gLocal.gui.magic_dict_language + ":";
-      html += "<div style='display:flex;'>";
+			$("#setting_library").html(html);
+			//Library 设置结束
 
-      html += "<fieldset style='width:10em;'>";
-      html += "<legend>" + gLocal.gui.priority + "</legend>";
-      html += "<ul id='ul_dict_lang1' class='dict_lang'>";
-      let i = 0;
-      for (const iterator of setting["dict.lang"]) {
-        html +=
-          "<li id='dict_lang1_li_" +
-          i +
-          "' value='" +
-          iterator +
-          "'>" +
-          lang_get_org_name(iterator) +
-          "</li>";
-        i++;
-      }
-      html += "</ul>";
-      html += "</fieldset>";
+			//Studio 设置
+			html = "";
+			html += gLocal.gui.translation_language + ":";
 
-      html += "<fieldset style='width:10em;'>";
-      html += "<legend>" + gLocal.gui.no_need + "</legend>";
-      html += "<ul id='ul_dict_lang2' class='dict_lang'>";
-      i = 0;
-      for (const iterator of dict_lang_others) {
-        html +=
-          "<li id='dict_lang2_li_" +
-          i +
-          "' value='" +
-          iterator +
-          "'>" +
-          lang_get_org_name(iterator) +
-          "</li>";
-        i++;
-      }
-      html += "</ul>";
-      html += "</fieldset>";
-      html += "</div>";
-      $("#setting_dictionary").html(html);
+			$("#setting_studio").html(html);
+			//Studio 设置结束
 
-      $("#ul_dict_lang1, #ul_dict_lang2")
-        .sortable({
-          connectWith: ".dict_lang",
-        })
-        .disableSelection();
-      $("#ul_dict_lang1").sortable({
-        update: function (event, ui) {
-          let sortedIDs = $("#ul_dict_lang1").sortable("toArray");
-          let newLang = new Array();
-          for (const iSorted of sortedIDs) {
-            newLang.push($("#" + iSorted).attr("value"));
-          }
-          setting["dict.lang"] = newLang;
-          setting_save();
-        },
-      });
-    } catch (e) {}
-  });
+			let dict_lang_others = new Array();
+			for (const iterator of setting["_dict.lang"]) {
+				if (setting["dict.lang"].indexOf(iterator) == -1) {
+					dict_lang_others.push(iterator);
+				}
+			}
+			html = "";
+			html += gLocal.gui.magic_dict_language + ":";
+			html += "<div style='display:flex;'>";
+
+			html += "<fieldset style='width:10em;'>";
+			html += "<legend>" + gLocal.gui.priority + "</legend>";
+			html += "<ul id='ul_dict_lang1' class='dict_lang'>";
+			let i = 0;
+			for (const iterator of setting["dict.lang"]) {
+				html +=
+					"<li id='dict_lang1_li_" +
+					i +
+					"' value='" +
+					iterator +
+					"'>" +
+					lang_get_org_name(iterator) +
+					"</li>";
+				i++;
+			}
+			html += "</ul>";
+			html += "</fieldset>";
+
+			html += "<fieldset style='width:10em;'>";
+			html += "<legend>" + gLocal.gui.no_need + "</legend>";
+			html += "<ul id='ul_dict_lang2' class='dict_lang'>";
+			i = 0;
+			for (const iterator of dict_lang_others) {
+				html +=
+					"<li id='dict_lang2_li_" +
+					i +
+					"' value='" +
+					iterator +
+					"'>" +
+					lang_get_org_name(iterator) +
+					"</li>";
+				i++;
+			}
+			html += "</ul>";
+			html += "</fieldset>";
+			html += "</div>";
+			$("#setting_dictionary").html(html);
+
+			$("#ul_dict_lang1, #ul_dict_lang2")
+				.sortable({
+					connectWith: ".dict_lang",
+				})
+				.disableSelection();
+			$("#ul_dict_lang1").sortable({
+				update: function (event, ui) {
+					let sortedIDs = $("#ul_dict_lang1").sortable("toArray");
+					let newLang = new Array();
+					for (const iSorted of sortedIDs) {
+						newLang.push($("#" + iSorted).attr("value"));
+					}
+					setting["dict.lang"] = newLang;
+					setting_save();
+				},
+			});
+		} catch (e) {}
+	});
 }
 function li_remove() {
-  $(this).parent().remove();
+	$(this).parent().remove();
 }
 var get_callback;
 function setting_get(key, callback) {
-  get_callback = callback;
-  $.post(
-    "../ucenter/get_setting.php",
-    {
-      key: key,
-    },
-    function (data, status) {
-      try {
-        let arrSetting = JSON.parse(data);
-        if (arrSetting.hasOwnProperty(key)) {
-          get_callback(arrSetting[key]);
-        } else {
-          get_callback(false);
-        }
-      } catch (e) {
-        get_callback(false);
-      }
-    }
-  );
+	get_callback = callback;
+	$.post(
+		"../ucenter/get_setting.php",
+		{
+			key: key,
+		},
+		function (data, status) {
+			try {
+				let arrSetting = JSON.parse(data);
+				if (arrSetting.hasOwnProperty(key)) {
+					get_callback(arrSetting[key]);
+				} else {
+					get_callback(false);
+				}
+			} catch (e) {
+				get_callback(false);
+			}
+		}
+	);
 }
 
 function setting_save() {
-  $.post(
-    "set_setting.php",
-    {
-      data: JSON.stringify(setting),
-    },
-    function (data, status) {
-      ntf_show(data);
-    }
-  );
+	$.post(
+		"set_setting.php",
+		{
+			data: JSON.stringify(setting),
+		},
+		function (data, status) {
+			ntf_show(data);
+		}
+	);
+}
+
+function setting_paliscript_change(set) {
+	let x = document.getElementById(set);
+	setting[set] = x.options[x.selectedIndex].text;
+	setting_save();
+}
+function setting_render_paliscript(set) {
+	let html = "";
+	html += "<select id='" + set + "' onchange=\"setting_paliscript_change('" + set + "')\">";
+	for (const iterator of setting["lib.pali_script"]) {
+		html += "<option value='" + iterator + "'";
+		if (iterator == setting[set]) {
+			html += "selected='selected'";
+		}
+		html += ">";
+		html += iterator;
+		html += "</option>";
+	}
+	html += "</select>";
+
+	return html;
 }

+ 27 - 6
app/ucenter/setting.php

@@ -221,6 +221,11 @@ para:hover{
     min-height: 4em;
 	margin:0.5em;
 }
+.setting_shell{
+	border-bottom: 1px solid gray;
+    margin-bottom: 3em;
+    padding-bottom: 3em;
+}
 </style>
 		<!-- tool bar begin-->
 		<div id="main_tool_bar" class='reader_toolbar'>
@@ -240,7 +245,8 @@ para:hover{
 
 		
 	<div id="main_text_view" style="padding-bottom: 10em;">
-        <?php 
+		<?php 
+			echo "<div id='setting_account_shell' class='setting_shell'>";
             echo "<a name='account'></a>";
 			echo "<h2>{$_local->gui->account}</h2>";
 			echo "头像:<span id='head_img'></span>";
@@ -249,23 +255,38 @@ para:hover{
             echo "{$_local->gui->nick_name}:{$_COOKIE["nickname"]} <button>修改</button><br />";
             echo "{$_local->gui->e_mail}:{$_COOKIE["email"]}<button>修改</button><br />";
             echo "<a href='../ucenter/pwd_set.php'>{$_local->gui->change_password}</a><br>";
-            echo "<a href='login.php?op=logout'>{$_local->gui->logout}</a>";
+			echo "<a href='login.php?op=logout'>{$_local->gui->logout}</a>";
+			echo "</div>";
+			
 
+			echo "<div id='setting_general_shell' class='setting_shell'>";
+			echo "<a name='general'></a>";
             echo "<h2>{$_local->gui->general}</h2>";
             echo "<div id='setting_general' class='setting_content'>";
-            echo "</div>";
+			echo "</div>";
+			echo "</div>";
+
+			
+			echo "<div id='setting_library_shell' class='setting_shell'>";
+			echo "<a name='library'></a>";
+            echo "<h2>{$_local->gui->library}</h2>";
+            echo "<div id='setting_library' class='setting_content'>";
+            echo "</div>";			
+            echo "</div>";			
 
+			echo "<div id='setting_studio_shell' class='setting_shell'>";
+			echo "<a name='studio'></a>";
             echo "<h2>{$_local->gui->studio}</h2>";
             echo "<div id='setting_studio' class='setting_content'>";
             echo "</div>";
-            
-            echo "<h2>{$_local->gui->library}</h2>";
-            echo "<div id='setting_library' class='setting_content'>";
             echo "</div>";
 
+			echo "<div id='setting_dictionary_shell' class='setting_shell'>";
+			echo "<a name='dictionary'></a>";
             echo "<h2>{$_local->gui->dictionary}</h2>";
             echo "<div id='setting_dictionary' class='setting_content'>";
             echo "</div>";
+            echo "</div>";
 
         ?>