Browse Source

针对视听说进行卡控处理,减少遍历

namejr 4 years ago
parent
commit
596bf40e13
2 changed files with 57 additions and 27 deletions
  1. 1 1
      EBook.Web/Common/mtm_temp.js
  2. 56 26
      EBook.Web/Common/tasklib_book.js

+ 1 - 1
EBook.Web/Common/mtm_temp.js

@@ -73,7 +73,7 @@ function clearHighlight() {
             $(item).removeClass('wordStyle').unbind();
         }
         else if ($(item).attr('flag') == 'phrase') {
-            $(item).removeClass().unbind();
+            $(item).removeClass("phraseStyle").unbind();
         }
         else if ($(item).attr('flag') == 'sentence') {
             $(item).removeClass('sentenceStyle').unbind();

+ 56 - 26
EBook.Web/Common/tasklib_book.js

@@ -303,40 +303,71 @@ var isGCFunc = function (NodeHandle) {
 };
 // 不调用fill需要增加处理(绑定横线内处理)
 var addFillAssist = function () {
-    $.each($(document).find("u,span,p"), function (Iindex, Iitem) {
+    //$.each($(document).find("u,span,p"), function (Iindex, Iitem) {
+    //    // 卡控遍历条件(添加新的class)
+    //    var ClsName = $(Iitem).attr("class");
+    //    var hitStyleFlag = $(Iitem).attr("hitstyle");
+    //    if (ClsName != undefined && (hitStyleFlag == "wordStyle" || hitStyleFlag == "phraseStyle" || hitStyleFlag == "sentenceStyle" || ClsName.indexOf("underlineContent") > -1) && ClsName.indexOf("cAStauts") == -1) {
+    //        $(Iitem).addClass("cAStauts");
+    //        if ($(Iitem).attr("ulflag") == undefined) {
+    //            $(Iitem).attr("ulflag", "0");
+    //        }
+    //        if ($(Iitem).attr("shcode") == undefined) {
+    //            $(Iitem).attr("shcode", 1);
+    //        }
+    //        if ($(Iitem).attr("showflag") == undefined) {
+    //            $(Iitem).attr("showflag", "1");
+    //        }
+    //        if (ClsName != undefined && ClsName.indexOf("underlineContent") > -1) {
+    //            $(Iitem).attr("ulflag", "1");
+    //            $.each($(Iitem).find("u,span,p"), function (index, element) {
+    //                var eClsName = $(element).attr("class");
+    //                var eHitStyleFlag = $(element).attr("hitstyle");
+    //                if (eClsName == undefined || eClsName.indexOf("cAStauts") == -1) {
+    //                    $(element).addClass("cAStauts");
+    //                }
+    //                if ($(element).attr("ulflag") == undefined) {
+    //                    $(element).attr("ulflag", "1");
+    //                }
+    //                if ($(element).attr("shcode") == undefined) {
+    //                    $(element).attr("shcode", 1);
+    //                }
+    //                if ($(element).attr("showflag") == undefined) {
+    //                    $(element).attr("showflag", "1");
+    //                }
+    //            });
+    //        }
+    //    }
+    //});
+    $.each($(document).find(".underlineContent"), function (Iindex, Iitem) {
         // 卡控遍历条件(添加新的class)
         var ClsName = $(Iitem).attr("class");
         var hitStyleFlag = $(Iitem).attr("hitstyle");
-        if (ClsName != undefined && (hitStyleFlag == "wordStyle" || hitStyleFlag == "phraseStyle" || hitStyleFlag == "sentenceStyle" || ClsName.indexOf("underlineContent") > -1) && ClsName.indexOf("cAStauts") == -1) {
+        if (ClsName != undefined && ClsName.indexOf("cAStauts") == -1) {
             $(Iitem).addClass("cAStauts");
-            if ($(Iitem).attr("ulflag") == undefined) {
-                $(Iitem).attr("ulflag", "0");
-            }
             if ($(Iitem).attr("shcode") == undefined) {
                 $(Iitem).attr("shcode", 1);
             }
             if ($(Iitem).attr("showflag") == undefined) {
                 $(Iitem).attr("showflag", "1");
             }
-            if (ClsName != undefined && ClsName.indexOf("underlineContent") > -1) {
-                $(Iitem).attr("ulflag", "1");
-                $.each($(Iitem).find("u,span,p"), function (index, element) {
-                    var eClsName = $(element).attr("class");
-                    var eHitStyleFlag = $(element).attr("hitstyle");
-                    if (eClsName == undefined || eClsName.indexOf("cAStauts") == -1) {
-                        $(element).addClass("cAStauts");
-                    }
-                    if ($(element).attr("ulflag") == undefined) {
-                        $(element).attr("ulflag", "1");
-                    }
-                    if ($(element).attr("shcode") == undefined) {
-                        $(element).attr("shcode", 1);
-                    }
-                    if ($(element).attr("showflag") == undefined) {
-                        $(element).attr("showflag", "1");
-                    }
-                });
-            }
+            $(Iitem).attr("ulflag", "1");
+            $.each($(Iitem).find("u,span,p"), function (index, element) {
+                var eClsName = $(element).attr("class");
+                var eHitStyleFlag = $(element).attr("hitstyle");
+                if (eClsName == undefined || eClsName.indexOf("cAStauts") == -1) {
+                    $(element).addClass("cAStauts");
+                }
+                if ($(element).attr("ulflag") == undefined) {
+                    $(element).attr("ulflag", "1");
+                }
+                if ($(element).attr("shcode") == undefined) {
+                    $(element).attr("shcode", 1);
+                }
+                if ($(element).attr("showflag") == undefined) {
+                    $(element).attr("showflag", "1");
+                }
+            });
         }
     });
     if (typeof (showGLWorld) == "function") {
@@ -764,7 +795,6 @@ function bindEventYS() {
             $(item).find('.yaoshi').attr('parent-anid', headid);
         });
     });
-
     //显示/隐藏习题答案
     $(".yaoshi").on("click", function () {
         var parentAnid = $(this).attr("parent-anid");
@@ -1717,7 +1747,7 @@ function showGLWorld(wordFlag, phraseFlag, sentenceFlag) {
     styleWPSContrl.wordFlag = wordFlag;
     styleWPSContrl.phraseFlag = phraseFlag;
     styleWPSContrl.sentenceFlag = sentenceFlag;
-    $.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) {
+    $.each($(".underlineContent").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);
     });
 }