Sfoglia il codice sorgente

term 气泡下加更多按钮

visuddhinanda 5 anni fa
parent
commit
5c97b82a62
3 ha cambiato i file con 81 aggiunte e 41 eliminazioni
  1. 1 5
      app/article/index.php
  2. 75 35
      app/term/term.js
  3. 5 1
      app/term/term_popup.js

+ 1 - 5
app/article/index.php

@@ -4,11 +4,7 @@ require_once "../path.php";
 require_once "../pcdl/html_head.php";
 ?>
 <body style="margin: 0;padding: 0;" class="reader_body" >
-	<script src="../term/term.js"></script>
-	<script src="../term/note.js"></script>
-	<script src="../term/term_popup.js"></script>
-	<link type="text/css" rel="stylesheet" href="../term/term.css"/>
-	
+
 	<script src="../channal/channal.js"></script>
 	<script src="./article.js"></script>
 

+ 75 - 35
app/term/term.js

@@ -132,41 +132,6 @@ function note_lookup(word, showto) {
   );
 }
 
-function term_load_preview(guid, showto) {
-  $.get(
-    "../term/term.php",
-    {
-      op: "load_id",
-      id: guid,
-      format: "json",
-    },
-    function (data, status) {
-      let html = "";
-      if (status == "success") {
-        try {
-          let result = JSON.parse(data)[0];
-          html = "<div class='term_block'>";
-
-          html += "<h2>" + result.word + "</h2>";
-          html += "<div class='meaning'>" + result.meaning + "</div>";
-          html +=
-            "<div class='term_note' status='1'>" +
-            note_init(result.note) +
-            "</div>";
-          html +=
-            "<div ><a href='../wiki/wiki.php?word=" +
-            result.word +
-            "' target='_blank'>更多</a></div>";
-          html += "</div>";
-          $("#" + showto).html(html);
-        } catch (e) {
-          console.error("note_lookup_guid_json:" + e + " data:" + data);
-        }
-      }
-    }
-  );
-}
-
 var term_get_word_to_div_callback = null;
 function term_get_word_to_div(strWord, div, callback) {
   term_get_word_to_div_callback = callback;
@@ -856,3 +821,78 @@ function term_get_dict() {
     }
   );
 }
+
+/*
+function term_popup_init() {
+  $(".term_link").each(function () {
+    if ($(this).attr("init") != "1") {
+      if ($(this).text().length > 0) {
+        $(this).css("background", "unset");
+      }
+      let gid = $(this).attr("gid");
+      if ($(this).offset().left < $(document.body).width() / 2) {
+        //出现在左侧
+        $(this).append(
+          '<div id="gid_' +
+            gid +
+            '" class="guide_contence" style="left: -5px;"></div>'
+        );
+        $(".guide_contence:after").css("left", "0");
+      } else {
+        //出现在右侧
+        $(this).append(
+          '<div id="gid_' +
+            gid +
+            '" class="guide_contence" style="right: -5px;"></div>'
+        );
+        $(".guide_contence:after").css("right", "0");
+      }
+      $(this).attr("init", "1");
+    }
+  });
+
+  $(".term_link").mouseenter(function () {
+    if ($(this).children(".guide_contence").first().html().length > 0) {
+      return;
+    }
+    let gid = $(this).attr("gid");
+    term_load_preview(gid, "gid_" + gid);
+  });
+}
+
+function term_load_preview(guid, showto) {
+  $.get(
+    "../term/term.php",
+    {
+      op: "load_id",
+      id: guid,
+      format: "json",
+    },
+    function (data, status) {
+      let html = "";
+      if (status == "success") {
+        try {
+          let result = JSON.parse(data)[0];
+          html = "<div class='term_block'>";
+
+          html += "<h2>" + result.word + "</h2>";
+          html += "<div class='meaning'>" + result.meaning + "</div>";
+          html +=
+            "<div class='term_note' status='1'>" +
+            note_init(result.note) +
+            "</div>";
+          html +=
+            "<div ><a href='../wiki/wiki.php?word=" +
+            result.word +
+            "' target='_blank'>更多</a></div>";
+          html += "</div>";
+          $("#" + showto).html(html);
+        } catch (e) {
+          console.error("note_lookup_guid_json:" + e + " data:" + data);
+        }
+      }
+    }
+  );
+}
+
+*/

+ 5 - 1
app/term/term_popup.js

@@ -57,9 +57,13 @@ function note_lookup_guid_json(guid) {
             "<div class='term_note' status='1'>" +
             note_init(result.note) +
             "</div>";
+          html +=
+            "<div ><a href='../wiki/wiki.php?word=" +
+            result.word +
+            "' target='_blank'>更多</a></div>";
           html += "</div>";
           $("[term-popup='" + guid + "']").html(html);
-          note_refresh_new();
+          //note_refresh_new();
         } catch (e) {
           console.error("note_lookup_guid_json:" + e + " data:" + data);
         }