Преглед на файлове

语言选择初步完成

visuddhinanda преди 4 години
родител
ревизия
922a50ca3d
променени са 4 файла, в които са добавени 61 реда и са изтрити 28 реда
  1. 7 6
      app/article/index.php
  2. 9 0
      app/article/mobile.css
  3. 10 3
      app/article/style.css
  4. 35 19
      app/term/note.js

+ 7 - 6
app/article/index.php

@@ -238,12 +238,7 @@ function set_toc_visible(isVisible){
 
 	<div style="margin: auto 0;">
 		<span id="head_span">
-			<select id="select_lang" onchange="lang_changed(this)">
-					<option>全部语言</option>
-					<option>简体中文</option>
-					<option>繁体中文</option>
-					<option>英文</option>
-			</select>
+
 		<?php
 		
 		if(isset($_GET["view"]) && $_GET["view"]=="article"){
@@ -317,6 +312,12 @@ function set_toc_visible(isVisible){
 				<div id="article_path_title"></div>
 			</div>
 			<div id="head_nav_right" >
+				<select id="select_lang" onchange="lang_changed(this)">
+						<option>全部语言</option>
+						<option>简体中文</option>
+						<option>繁体中文</option>
+						<option>英文</option>
+				</select>
 				<div id="article_edition" style="display:flex;">
 					<span  style='font-weight: 700;'>文章版本 </span>
 					<div id="edition_dropdown" class="case_dropdown">

+ 9 - 0
app/article/mobile.css

@@ -75,4 +75,13 @@ note:hover .ref {
     left: 0;
     width: 100%;
     height: 70%;
+}
+#head_nav_right{
+	flex-direction: column;
+}
+
+#select_lang {
+    border: unset;
+    border-radius: unset;
+    border-bottom: 1px solid var(--border-line-color);
 }

+ 10 - 3
app/article/style.css

@@ -199,11 +199,14 @@ img {
 #article_edition {
     padding: 8px;
     margin: 0 4px;
-    border: 1px solid var(--border-line-color);
-    border-radius: 5px;
+    border-bottom: 1px solid var(--border-line-color);
+	display: flex;
+	min-width: 18em;
 }
 
-
+#edition_dropdown {
+    margin-left: 1em;
+}
 #head_nav {
     display: flex;
     justify-content: space-between;
@@ -267,4 +270,8 @@ img {
 	fill: var(--bg-color);
 	height: 2em;
 	width: 2em;
+}
+
+#head_nav_right{
+	display: flex;
 }

+ 35 - 19
app/term/note.js

@@ -362,33 +362,38 @@ function note_channal_list() {
 						set_more_button_display();
 
 						let lang=new Object();
+						let currLang=_lang;
+						let firstChannel="";
+						if(_channal!=""){
+							firstChannel = _channal.split(",")[0];
+						}										
 						for (const iterator of _channalData) {
 							lang[iterator.lang]=1;
+							if(iterator.id==firstChannel){
+								currLang = iterator.lang;
+							}
 						}
-						let htmlLangSelect="<option value='*'>全部语言</option>";
-						let currLang = getCookie("language");
-						if(currLang == "zh-cn"){
-							currLang = "zh-hans";
-						}
-						if(currLang == "zh-tw"){
-							currLang = "zh-hant";
-						}
+						let htmlLangSelect="<option value=''>全部语言</option>";
 						let isLangMatched=false;
 						for (const key in lang) {
 							if (lang.hasOwnProperty.call(lang, key)) {
+								let strLang = key;
+								if(gLocal.language.hasOwnProperty.call(gLocal.language, key)){
+									strLang = gLocal.language[key];
+								}
 								htmlLangSelect += "<option value='"+key+"' ";
 								if(currLang==key){
 									htmlLangSelect += "selected ";
 									isLangMatched = true;
 								}
-								htmlLangSelect +=">"+gLocal.language[key]+"</option>";	
+								htmlLangSelect +=">"+strLang+"</option>";	
 							}
 						}
 						$("#select_lang").html(htmlLangSelect);
 						if(isLangMatched){
 							render_edition_list(currLang);
 						}else{
-							render_edition_list("all");
+							render_edition_list("");
 						}
 					} catch (e) {
 						console.error(e);
@@ -399,25 +404,36 @@ function note_channal_list() {
 	}
 }
 function lang_changed(obj){
-	render_edition_list($(obj).val());
+	_lang = $(obj).val();
+	render_edition_list(_lang);
 }
-function render_edition_list(lang,index=0){
+function render_edition_list(lang=""){
+	let firstChannel="";
+	if(_channal!=""){
+		firstChannel = _channal.split(",")[0];
+	}	
 	let html = "";
 	html += "<div class='case_dropdown-content'>";
-	let firstChannel;
+	let currChannel="选择一个版本";
 	for (const iterator of _channalData) {
-		if(lang=="all" || (lang!="all" && lang==iterator.lang)){
-			if(typeof firstChannel == "undefined"){
-				firstChannel = "<span>"+iterator.name+"</span>";
+		if(iterator.id==firstChannel){
+			currChannel = iterator.name;
+		}
+		if(lang=="" || (lang!="" && lang==iterator.lang)){
+			if (iterator["final"]){
+				html += "<a onclick=\"edition_list_changed('"+iterator.id+"')\">"+iterator.name+"</a>";
 			}
-			html += "<a onclick=\"set_channal('"+iterator.id+"')\">"+iterator.name+"</a>";
 		}
 	}
 	html +="</div>";
-	html = firstChannel + html;
+	html = "<span>"+currChannel+"▼</span>" + html;
 	$("#edition_dropdown").html(html);
 }
-
+function edition_list_changed(channelId){
+	_channal = channelId;
+	render_edition_list(_lang);
+	set_channal(channelId);
+}
 function find_channal(id) {
 	for (const iterator of _channalData) {
 		if (id == iterator.id) {