Browse Source

:art: 百科中 不同的书用不同的底色。

visuddhinanda 5 years ago
parent
commit
dfc09b5e37
2 changed files with 78 additions and 2 deletions
  1. 26 1
      app/term/note.js
  2. 52 1
      app/wiki/wiki.php

+ 26 - 1
app/term/note.js

@@ -55,8 +55,25 @@ function note_init(input) {
   return output;
 }
 
+function note_update_background_style() {
+  var mSentsBook = new Array();
+  var mBgIndex = 1;
+  $("note").each(function () {
+    let info = $(this).attr("info").split("-");
+    if (info.length >= 2) {
+      let book = info[0];
+      $(this).attr("book", book);
+      if (!mSentsBook[book]) {
+        mSentsBook[book] = mBgIndex;
+        mBgIndex++;
+      }
+      $(this).addClass("bg_color_" + mSentsBook[book]);
+    }
+  });
+}
 //
 function note_refresh_new() {
+  note_update_background_style();
   let objNotes = document.querySelectorAll("note");
   let arrSentInfo = new Array();
   for (const iterator of objNotes) {
@@ -65,6 +82,13 @@ function note_refresh_new() {
       id = com_guid();
       iterator.id = id;
       let info = iterator.getAttributeNode("info").value;
+      let arrInfo = info.split("-");
+
+      if (arrInfo.length >= 2) {
+        let book = arrInfo[0];
+        let para = arrInfo[1];
+      }
+
       if (info && info != "") {
         arrSentInfo.push({ id: id, data: info });
       }
@@ -86,7 +110,8 @@ function note_refresh_new() {
             let arrData = JSON.parse(data);
             for (const iterator of arrData) {
               let id = iterator.id;
-              let strHtml = note_json_html(iterator);
+              let strHtml = "<a name='" + id + "'></a>";
+              strHtml += note_json_html(iterator);
               $("#" + id).html(strHtml);
             }
             $(".palitext").click(function () {

+ 52 - 1
app/wiki/wiki.php

@@ -223,13 +223,31 @@ echo "wiki_load_word('{$_get_word}')";
 		overflow-y: scroll;
 	}
 }
-
+.fixed{
+	position:fixed;
+}
+.bg_color_1{
+	background-color:var(--drop-bg-color);
+}
+.bg_color_2{
+	background-color:#6afdb033;
+}
+.bg_color_3{
+	background-color:#6a95fd26;
+}
+.bg_color_4{
+	background-color:#f9e7911c;
+}
+.bg_color_5{
+	background-color:#fe99b91c;
+}
 	</style>
 
 <style media="screen and (max-width:767px)">
 #term_list_right{
 	display:none;
 }
+
 </style>
 
 <script>
@@ -279,6 +297,39 @@ term_word_link_fun("wiki_goto_word");
 <div id="wiki_contents" style="padding: 0 1em;">
 loading...
 </div>
+<script>
+	 window.addEventListener('scroll',winScroll);
+	function winScroll(e){ 
+		if(GetPageScroll().y>150){
+			$("#term_list_right").addClass("fixed");
+		}
+		else{
+			$("#term_list_right").removeClass("fixed") ;
+		}
+		
+	}
+ //滚动条位置
+function GetPageScroll() 
+{ 
+	var pos=new Object();
+	var x, y; 
+	if(window.pageYOffset) 
+	{	// all except IE	
+		y = window.pageYOffset;	
+		x = window.pageXOffset; 
+	} else if(document.documentElement && document.documentElement.scrollTop) 
+	{	// IE 6 Strict	
+		y = document.documentElement.scrollTop;	
+		x = document.documentElement.scrollLeft; 
+	} else if(document.body) {	// all other IE	
+		y = document.body.scrollTop;	
+		x = document.body.scrollLeft;   
+	} 
+	pos.x=x;
+	pos.y=y;
+	return(pos);
+}
+	</script>
 
 </body>
 </html>