Explorar el Código

修改逻辑处理

namejr hace 4 años
padre
commit
3003dfa757
Se han modificado 3 ficheros con 105 adiciones y 38 borrados
  1. 9 0
      EBook.Web/Common/mtm_temp.js
  2. 30 29
      EBook.Web/Common/tasklib_book.js
  3. 66 9
      EBook.Web/Test.html

+ 9 - 0
EBook.Web/Common/mtm_temp.js

@@ -1,5 +1,8 @@
 /*¸ßÁÁÎı¾±ê×¢*/
 function Fill(data) {
+    var wordFlag = false;
+    var phraseFlag = false;
+    var sentenceFlag = false;
     var highlightArr = [];
     clearHighlight();
     $.each(data, function (i, item) {
@@ -33,9 +36,11 @@ function Fill(data) {
         }
         $.each(highlightArr, function (i, item) {
             if (item.attr('flag') == 'word') {
+                wordFlag = true;
                 bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "wordStyle").addClass('wordStyle'), true);
             }
             else if (item.attr('flag') == 'phrase') {
+                phraseFlag = true;
                 if (item != null && item.attr('separate') != null) {
                     $("span[separate=" + item.attr('separate') + "]").attr('iskeyklg', 'true').attr("hitstyle", "phraseStyle").addClass('phraseStyle');
                     bindEvent(item, true);
@@ -47,6 +52,7 @@ function Fill(data) {
             }
             else if (item.attr('flag') == 'sentence') {
                 if (item.attr('iskeyklg') == 'true') return;
+                sentenceFlag = true;
                 bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "sentenceStyle").addClass('sentenceStyle')
                     .before('<img src="file:///android_asset/js/sentenceIco.png" class="sentImagcs">'), true);
             }
@@ -66,6 +72,9 @@ function Fill(data) {
                 }
             }
         });
+        if (typeof (showGLWorld) == "function") {
+            showGLWorld(wordFlag, phraseFlag, sentenceFlag);
+        }
     });
 }
 

+ 30 - 29
EBook.Web/Common/tasklib_book.js

@@ -258,8 +258,9 @@ var isGCFunc = function (NodeHandle) {
 // 处理显示或隐藏答案
 var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
     if (OCFlag) {
+        var showflagS = $(NodeHandle).attr("showflag");
         if ($(NodeHandle).attr("ulflag") == 1) {
-            if (!ThProFlag || (ThProFlag && $(NodeHandle).attr("showflag") == 1)) {
+            if (!ThProFlag || (ThProFlag && showflagS == 1)) {
                 if ($(NodeHandle).text() == "暂无参考答案") {
                     $(NodeHandle).css("color", "#989898").attr("shcode", 1).attr("showflag", "1");
                 }
@@ -272,14 +273,13 @@ var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
             $(NodeHandle).css("color", "#000000").attr("shcode", 1).attr("showflag", "1");
         }
         if ($(NodeHandle).attr("hitstyle") == "wordStyle") {
-            var showflagS = $(NodeHandle).attr("showflag");
             if (styleWPSContrl.wordFlag && showflagS == "1") {
                 $(NodeHandle).css("color", "#db5d00").attr("shcode", 1).attr("showflag", "1");
             }
             else if (showflagS == "1") {
                 var ulflag = $(NodeHandle).attr("ulflag");
                 if (ulflag == "1") {
-                    if (!ThProFlag || (ThProFlag && $(NodeHandle).attr("showflag") == 1)) {
+                    if (!ThProFlag || (ThProFlag && showflagS == 1)) {
                         $(NodeHandle).css("color", "#92D050").attr("shcode", 1).attr("showflag", "1");
                     }
                 }
@@ -289,7 +289,6 @@ var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
             }
         }
         else if ($(NodeHandle).attr("hitstyle") == "phraseStyle") {
-            var showflagS = $(NodeHandle).attr("showflag");
             if (styleWPSContrl.phraseFlag && showflagS == "1") {
                 $(NodeHandle).css("background-color", "#f2db8b").attr("shcode", 1).attr("showflag", "1");
             }
@@ -298,7 +297,6 @@ var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
             }
         }
         else if ($(NodeHandle).attr("hitstyle") == "sentenceStyle") {
-            var showflagS = $(NodeHandle).attr("showflag");
             if (styleWPSContrl.sentenceFlag && showflagS == "1") {
                 $(NodeHandle).css("border-bottom", "2px solid #78ae43").attr("shcode", 1).attr("showflag", "1");
             }
@@ -307,9 +305,10 @@ var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
             }
         }
         $.each($(NodeHandle).find("u,span,p"), function (index, element) {
+            showflagS = $(element).attr("showflag");
             // 处理普通文本
             if ($(element).attr("ulflag") == 1) {
-                if (!ThProFlag || (ThProFlag && $(element).attr("showflag") == 1)) {
+                if (!ThProFlag || (ThProFlag && showflagS == 1)) {
                     if ($(element).text() == "暂无参考答案") {
                         $(element).css("color", "#989898").attr("shcode", 1).attr("showflag", "1");
                     }
@@ -323,37 +322,42 @@ var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
             }
             // 处理高亮
             if ($(element).attr("hitstyle") == "wordStyle") {
-                var showflagS = $(element).attr("showflag");
-                if (styleWPSContrl.wordFlag && showflagS == "1") {
-                    $(element).css("color", "#db5d00").attr("shcode", 1).attr("showflag", "1");
+                if (styleWPSContrl.wordFlag) {
+                    if (!ThProFlag || (ThProFlag && showflagS == 1)) {
+                        $(element).css("color", "#db5d00").attr("shcode", 1).attr("showflag", "1");
+                    }
                 }
-                else if (showflagS == "1") {
-                    var ulflag = $(element).attr("ulflag");
-                    if (ulflag == "1") {
-                        if (!ThProFlag || (ThProFlag && $(element).attr("showflag") == 1)) {
-                            $(element).css("color", "#92D050").attr("shcode", 0).attr("showflag", "1");
+                else {
+                    if (!ThProFlag || (ThProFlag && showflagS == 1)) {
+                        var ulflag = $(element).attr("ulflag");
+                        if (ulflag == "1") {
+                            if (!ThProFlag || (ThProFlag && showflagS == 1)) {
+                                $(element).css("color", "#92D050").attr("shcode", 0).attr("showflag", "1");
+                            }
+                        }
+                        else {
+                            $(element).css("color", "#000000").attr("shcode", 0).attr("showflag", "1");
                         }
-                    }
-                    else {
-                        $(element).css("color", "#000000").attr("shcode", 0).attr("showflag", "1");
                     }
                 }
             }
             else if ($(element).attr("hitstyle") == "phraseStyle") {
-                var showflagS = $(element).attr("showflag");
-                if (styleWPSContrl.phraseFlag && showflagS == "1") {
-                    $(element).css("background-color", "#f2db8b").attr("shcode", 1).attr("showflag", "1");
+                if (styleWPSContrl.phraseFlag) {
+                    if (!ThProFlag || (ThProFlag && showflagS == 1)) {
+                        $(element).css("background-color", "#f2db8b").attr("shcode", 1).attr("showflag", "1");
+                    }
                 }
-                else if (showflagS == "1") {
+                else{
                     $(element).css("background-color", "#ffffff").attr("shcode", 0).attr("showflag", "1");
                 }
             }
             else if ($(element).attr("hitstyle") == "sentenceStyle") {
-                var showflagS = $(element).attr("showflag");
-                if (styleWPSContrl.sentenceFlag && showflagS == "1") {
-                    $(element).css("border-bottom", "2px solid #78ae43").attr("shcode", 1).attr("showflag", "1");
+                if (styleWPSContrl.sentenceFlag) {
+                    if (!ThProFlag || (ThProFlag && showflagS == 1)) {
+                        $(element).css("border-bottom", "2px solid #78ae43").attr("shcode", 1).attr("showflag", "1");
+                    }
                 }
-                else if (showflagS == "1") {
+                else{
                     $(element).css("border-bottom", "2px solid #ffffff").attr("shcode", 0).attr("showflag", "1");
                 }
             }
@@ -1543,11 +1547,8 @@ function showGLWorld(wordFlag, phraseFlag, sentenceFlag) {
     styleWPSContrl.wordFlag = wordFlag;
     styleWPSContrl.phraseFlag = phraseFlag;
     styleWPSContrl.sentenceFlag = sentenceFlag;
-    $.each($(document.body).find(".wordStyle[hitstyle='wordStyle'],.phraseStyle[hitstyle='phraseStyle'],.sentenceStyle[hitstyle='sentenceStyle']"), function (index,element) {
+    $.each($(document.body).find("u[hitstyle='wordStyle'],span[hitstyle='wordStyle'],p[hitstyle='wordStyle'],u[hitstyle='phraseStyle'],span[hitstyle='phraseStyle'],p[hitstyle='phraseStyle'],u[hitstyle='sentenceStyle'],span[hitstyle='sentenceStyle'],p[hitstyle='sentenceStyle']"), function (index, element) {
         dealAnswerFunc(element, true, true);
-        $.each($(element).find("u,span,p"), function (oindex,oelement) {
-            dealAnswerFunc(oelement, true, true);
-        });
     });
 }
 function playVisiableAudioCallBack(type, url) {

+ 66 - 9
EBook.Web/Test.html

@@ -48,15 +48,21 @@
             //加载听说课文
             answerjson = $.ajax({ url: "AnsText/GCZD.json", async: false }).responseText;
             reviewjson = $.ajax({ url: "AnsText/anstext.txt", async: false }).responseText;
-            hightcodejson = $.ajax({ url: "HightCode/BGGL.json", async: false }).responseText;
+            hightcodejson = JSON.parse($.ajax({ url: "HightCode/data202116P.json", async: false }).responseText);
+            for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116S.json", async: false }).responseText).length; i++) {
+                hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116S.json", async: false }).responseText)[i]);
+            }
+            for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116W.json", async: false }).responseText).length; i++) {
+                hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116W.json", async: false }).responseText)[i]);
+            }
         }
         //加载听说课文
         $("#load-text").on("click", function () {
             var data = $.ajax({ url: "lghp/data202116.lghp", async: false }).responseText;
             //var data = $.ajax({ url: "lghp/jieduan.lghp", async: false }).responseText;
             $("#data").html(data);
-
-            Fill(JSON.parse(hightcodejson));
+            console.log(hightcodejson);
+            Fill(hightcodejson);
             bindEventYS();
             //Fill(JSON.parse(hightcodejson));
             //bindCoursewareEvent();
@@ -145,20 +151,71 @@
         var sentenceStyleFlag = true;
         $("#wordStyleID").on("click", function () {
             wordStyleFlag = !wordStyleFlag;
-            hightcodejson = $.ajax({ url: "HightCode/data202116W.json", async: false }).responseText;
-            Fill(JSON.parse(hightcodejson));
+            hightcodejson = null;
+            hightcodejson = [];
+            if (phraseStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116P.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116P.json", async: false }).responseText)[i]);
+                }
+            }
+            if (wordStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116W.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116W.json", async: false }).responseText)[i]);
+                }
+            }
+            if (sentenceStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116S.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116S.json", async: false }).responseText)[i]);
+                }
+            }
+            console.log(hightcodejson);
+            Fill(hightcodejson);
             showGLWorld(wordStyleFlag, phraseStyleFlag, sentenceStyleFlag);
         });
         $("#phraseStyleID").on("click", function () {
             phraseStyleFlag = !phraseStyleFlag;
-            hightcodejson = $.ajax({ url: "HightCode/data202116P.json", async: false }).responseText;
-            Fill(JSON.parse(hightcodejson));
+            hightcodejson = null;
+            hightcodejson = [];
+            if (phraseStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116P.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116P.json", async: false }).responseText)[i]);
+                }
+            }
+            if (wordStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116W.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116W.json", async: false }).responseText)[i]);
+                }
+            }
+            if (sentenceStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116S.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116S.json", async: false }).responseText)[i]);
+                }
+            }
+            console.log(hightcodejson);
+            Fill(hightcodejson);
             showGLWorld(wordStyleFlag, phraseStyleFlag, sentenceStyleFlag);
         });
         $("#sentenceStyleID").on("click", function () {
             sentenceStyleFlag = !sentenceStyleFlag;
-            hightcodejson = $.ajax({ url: "HightCode/data202116S.json", async: false }).responseText;
-            Fill(JSON.parse(hightcodejson));
+            hightcodejson = null;
+            hightcodejson = [];
+            if (phraseStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116P.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116P.json", async: false }).responseText)[i]);
+                }
+            }
+            if (wordStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116W.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116W.json", async: false }).responseText)[i]);
+                }
+            }
+            if (sentenceStyleFlag) {
+                for (var i = 0; i < JSON.parse($.ajax({ url: "HightCode/data202116S.json", async: false }).responseText).length; i++) {
+                    hightcodejson.push(JSON.parse($.ajax({ url: "HightCode/data202116S.json", async: false }).responseText)[i]);
+                }
+            }
+            console.log(hightcodejson);
+            Fill(hightcodejson);
             showGLWorld(wordStyleFlag, phraseStyleFlag, sentenceStyleFlag);
         });
         $("#ShowID").on("click", function () {