Browse Source

提交处理显示

namejr 4 years ago
parent
commit
7dc6be1c13
3 changed files with 157 additions and 119 deletions
  1. 13 11
      EBook.Web/Common/mtm_temp.js
  2. 117 106
      EBook.Web/Common/tasklib_book.js
  3. 27 2
      EBook.Web/Test.html

+ 13 - 11
EBook.Web/Common/mtm_temp.js

@@ -36,28 +36,30 @@ function Fill(data) {
         }
         $.each(highlightArr, function (i, item) {
             if (item.attr('flag') == 'word') {
-                bindEvent(item.attr('iskeyklg', 'true').addClass('wordStyle'), true);
+                bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "wordStyle").addClass('wordStyle'), true);
             }
             else if (item.attr('flag') == 'phrase') {
                 if (item != null && item.attr('separate') != null) {
-                    $("span[separate=" + item.attr('separate') + "]").attr('iskeyklg', 'true').addClass('phraseStyle');
+                    $("span[separate=" + item.attr('separate') + "]").attr('iskeyklg', 'true').attr("hitstyle", "phraseStyle").addClass('phraseStyle');
                     bindEvent(item, true);
                 }
                 else {
-                    bindEvent(item.attr('iskeyklg', 'true').addClass('phraseStyle'), true);
+                    bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "phraseStyle").addClass('phraseStyle'), true);
                     if ($(item).parent().attr('iskeyklg') == 'true' && $(item).parent().attr('flag') == 'phrase') $(item).addClass('border1')
             }
             }
             else if (item.attr('flag') == 'sentence') {
                 if (item.attr('iskeyklg') == 'true') return;
-                bindEvent(item.attr('iskeyklg', 'true').addClass('sentenceStyle')
+                bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "sentenceStyle").addClass('sentenceStyle')
                     .before('<img src="file:///android_asset/js/sentenceIco.png" class="sentImagcs">'), true);
             }
         });
         // °ó¶¨ºáÏßÄÚ´¦Àí
-        $(document).find(".wordStyle,.phraseStyle,.phraseStyle,u,span").attr("uLFlag", "0").attr("shcode", 0).attr("showFlag", "1");
-        $(document).find(".underlineContent").attr("shcode", 0).attr("uLFlag", "1").attr("showFlag", "1");
-        $(document).find(".underlineContent").find(".wordStyle,.phraseStyle,.phraseStyle,u,span").attr("shcode", 0).attr("uLFlag", "1").attr("showFlag", "1");
+        $(document).find(".wordStyle,.phraseStyle,.phraseStyle,u,span,p").attr("ulflag", "0").attr("shcode", 1).attr("showFlag", "1");
+        $(document).find(".underlineContent").attr("shcode", 1).attr("ulflag", "1").attr("showFlag", "1");
+        $.each($(".underlineContent").find(".wordStyle,.phraseStyle,.phraseStyle,u,span,p"), function (index,element) {
+            $(element).attr("shcode", 1).attr("ulflag", "1").attr("showFlag", "1");
+        });
 });
 }
 
@@ -98,7 +100,7 @@ function bindEvent(ele, opt) {
                             //plugin.call(code);
                             //alert($(this).attr("hitCode"));
                             var sHCode = $(this).attr("shcode");
-                            if (sHCode != 1) {
+                            if (sHCode == 1) {
                                 test($(this).attr("hitCode"));
                             }
                         }
@@ -111,7 +113,7 @@ function bindEvent(ele, opt) {
                         //plugin.call(code);
                         //alert($(this).attr("hitCode"));
                         var sHCode = $(this).attr("shcode");
-                        if (sHCode != 1) {
+                        if (sHCode == 1) {
                             test($(this).attr("hitCode"));
                         }
                     }
@@ -124,7 +126,7 @@ function bindEvent(ele, opt) {
                         //plugin.call(code);
                         //alert($(this).attr("hitCode"));
                         var sHCode = $(this).attr("shcode");
-                        if (sHCode != 1) {
+                        if (sHCode == 1) {
                             test($(this).attr("hitCode"));
                         }
                     }
@@ -134,7 +136,7 @@ function bindEvent(ele, opt) {
                         //plugin.call(code);
                         //alert($(this).attr("hitCode"));
                         var sHCode = $(this).attr("shcode");
-                        if (sHCode != 1) {
+                        if (sHCode == 1) {
                             test($(this).next().attr("hitCode"));
                         }
                     }

+ 117 - 106
EBook.Web/Common/tasklib_book.js

@@ -1,5 +1,5 @@
 //播放音频图片地址
-var PicInfo = {
+var PicInfo1 = {
     answerPointImgUrl: "file:///android_asset/js/update-answer.png",
     yaoshiShowImgUrl: "file:///android_asset/js/yaoshi-show.png",
     yaoshiHideImgUrl: "file:///android_asset/js/yaoshi-hide.png",
@@ -10,7 +10,7 @@ var PicInfo = {
 }
 
 //本地调用用的资源
-var PicInfo1 = {
+var PicInfo = {
     answerPointImgUrl: "../Images/update-answer.png",
     yaoshiShowImgUrl: "../Images/yaoshi-show.png",
     yaoshiHideImgUrl: "../Images/yaoshi-hide.png",
@@ -254,123 +254,134 @@ var isGCFunc = function (NodeHandle) {
     }
     return isFlag;
 };
-
-// 处理高亮
-var dealGLShowFunc = function (NodeHandle) {
-
-    if (styleWPSContrl.wordFlag) {
-        $(NodeHandle).find(".wordStyle[showFlag='1']").css("color", "#db5d00");
-    }
-    else {
-        $(NodeHandle).find(".wordStyle[showFlag='1'][uLFlag='1']").css("color", "#92D050");
-        $(NodeHandle).find(".wordStyle[showFlag='1'][uLFlag='0']").css("color", "#000000");
-    }
-    //$.each($(NodeHandle).find(".wordStyle"), function (index, element) {
-    //    var showFlagS = $(element).attr("showFlag");
-    //    if (styleWPSContrl.wordFlag && showFlagS == "1") {
-    //        $(element).css("color", "#db5d00");
-    //    }
-    //    else if (showFlagS == "1") {
-    //        var uLFlag = $(element).attr("uLFlag");
-    //        if (uLFlag == "1") {
-    //            $(element).css("color", "#92D050");
-    //        }
-    //        else {
-    //            $(element).css("color", "#000000");
-    //        }
-    //    }
-    //});
-    if (styleWPSContrl.phraseFlag) {
-        $(NodeHandle).find(".phraseStyle[showFlag='1']").css("background-color", "#f2db8b");
-    }
-    else {
-        $(NodeHandle).find(".phraseStyle[showFlag='1']").css("background-color", "#ffffff");
-    }
-    //$.each($(NodeHandle).find(".phraseStyle"), function (index, element) {
-    //    var showFlagS = $(element).attr("showFlag");
-    //    if (styleWPSContrl.phraseFlag && showFlagS == "1") {
-    //        $(element).css("background-color", "#f2db8b");
-    //    }
-    //    else if (showFlagS == "1") {
-    //        $(element).css("background-color", "#ffffff");
-    //    }
-    //});
-    if (styleWPSContrl.sentenceFlag) {
-        $(NodeHandle).find(".sentenceStyle[showFlag='1']").css("border-bottom", "2px solid #78ae43");
-    }
-    else {
-        $(NodeHandle).find(".sentenceStyle[showFlag='1']").css("border-bottom", "2px solid #ffffff");
-    }
-    //$.each($(NodeHandle).find(".sentenceStyle"), function (index, element) {
-    //    var showFlagS = $(element).attr("showFlag");
-    //    if (styleWPSContrl.sentenceFlag && showFlagS == "1") {
-    //        $(element).css("border-bottom", "2px solid #78ae43");
-    //    }
-    //    else if (showFlagS == "1") {
-    //        $(element).css("border-bottom", "2px solid #ffffff");
-    //    }
-    //});
-};
-
-// 处理显示或隐藏答案(shcode是否可点击1可点击;uLFlag判断是否存在横线内1表示在;showFlag是否显示1显示)
+//(shcode是否可点击1可点击;ulflag判断是否存在横线内1表示在;showflag是否显示1显示)
+// 处理显示或隐藏答案
 var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
     if (OCFlag) {
-        var uLFlag = $(NodeHandle).attr("uLFlag");
-        if (uLFlag == "1") {
-            var showFlagS = $(NodeHandle).attr("showFlag");
-            if ((showFlagS == "0" && !ThProFlag) || (showFlagS == "1" && ThProFlag)) {
-                $(NodeHandle).css("color", "#92D050").css("border-bottom", "1px solid #979797").css("background-color", "#transparent").attr("shcode", 0).attr("showFlag", "1");
-            }
-            else {
-                $(NodeHandle).css("color", "#ffffff").css("border-bottom", "1px solid #979797").css("background-color", "#transparent").attr("shcode", 1).attr("showFlag", "0");
+        if ($(NodeHandle).attr("ulflag") == 1) {
+            if (!ThProFlag || (ThProFlag&&$(NodeHandle).attr("showflag") == 1)) {
+                if ($(NodeHandle).text() == "暂无参考答案") {
+                    $(NodeHandle).css("color", "#989898").attr("shcode", 1).attr("showflag", "1");
+                }
+                else {
+                    $(NodeHandle).css("color", "#92D050").attr("shcode", 1).attr("showflag", "1");
+                }
             }
         }
         else {
-            $(NodeHandle).css("color", "#000000").css("border-bottom", "none").css("background-color", "transparent").attr("shcode", 0).attr("showFlag", "1");
+            $(NodeHandle).css("color", "#000000").attr("shcode", 1).attr("showflag", "1");
         }
-
-        $(NodeHandle).find(".wordStyle[uLFlag='0'],.phraseStyle[uLFlag='0'],.sentenceStyle[uLFlag='0'],u[uLFlag='0'],span[uLFlag='0']").css("color", "#000000").css("border-bottom", "none").css("background-color", "transparent").attr("shcode", 0).attr("showFlag", "1");
-        if (ThProFlag) {
-            $(NodeHandle).find(".wordStyle[uLFlag='1'][showFlag='1'],.phraseStyle[uLFlag='1'][showFlag='1'],.sentenceStyle[uLFlag='1'][showFlag='1'],u[uLFlag='1'][showFlag='1'],span[uLFlag='1'][showFlag='1']").css("color", "#000000").css("border-bottom", "none").css("background-color", "transparent").attr("shcode", 0).attr("showFlag", "1");
-            $(NodeHandle).find(".wordStyle[uLFlag='1'][showFlag='0'],.phraseStyle[uLFlag='1'][showFlag='0'],.sentenceStyle[uLFlag='1'][showFlag='0'],u[uLFlag='1'][showFlag='0'],span[uLFlag='1'][showFlag='0']").css("color", "#ffffff").css("border-bottom", "1px solid #979797").css("background-color", "transparent").attr("shcode", 1).attr("showFlag", "0");
+        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)) {
+                        $(NodeHandle).css("color", "#92D050").attr("shcode", 1).attr("showflag", "1");
+                    }
+                }
+                else {
+                    $(NodeHandle).css("color", "#000000").attr("shcode", 1).attr("showflag", "1");
+                }
+            }
         }
-        else {
-            $(NodeHandle).find(".wordStyle[uLFlag='1'][showFlag='0'],.phraseStyle[uLFlag='1'][showFlag='0'],.sentenceStyle[uLFlag='1'][showFlag='0'],u[uLFlag='1'][showFlag='0'],span[uLFlag='1'][showFlag='0']").css("color", "#000000").css("border-bottom", "none").css("background-color", "transparent").attr("shcode", 0).attr("showFlag", "1");
-            $(NodeHandle).find(".wordStyle[uLFlag='1'][showFlag='1'],.phraseStyle[uLFlag='1'][showFlag='1'],.sentenceStyle[uLFlag='1'][showFlag='1'],u[uLFlag='1'][showFlag='1'],span[uLFlag='1'][showFlag='1']").css("color", "#ffffff").css("border-bottom", "1px solid #979797").css("background-color", "transparent").attr("shcode", 1).attr("showFlag", "0");
+        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");
+            }
+            else if (showflagS == "1") {
+                $(NodeHandle).css("background-color", "#ffffff").attr("shcode", 1).attr("showflag", "1");
+            }
+        }
+        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");
+            }
+            else if (showflagS == "1") {
+                $(NodeHandle).css("border-bottom", "2px solid #ffffff").attr("shcode", 1).attr("showflag", "1");
+            }
         }
-        //$.each($(NodeHandle).find(".wordStyle,.phraseStyle,.sentenceStyle,u,span"), function (index, element) {
-        //    uLFlag = $(element).attr("uLFlag");
-        //    if (uLFlag == "1") {
-        //        var showFlagS = $(element).attr("showFlag");
-        //        if ((showFlagS == "0" && !ThProFlag) || (showFlagS == "1" && ThProFlag)) {
-        //            $(element).css("color", "#92D050").css("border-bottom", "1px solid #979797").css("background-color", "transparent").attr("shcode", 0).attr("showFlag", "1");
-        //        }
-        //        else {
-        //            $(element).css("color", "#ffffff").css("border-bottom", "1px solid #979797").css("background-color", "transparent").attr("shcode", 1).attr("showFlag", "0");
-        //        }
-        //    }
-        //    else {
-        //        $(element).css("color", "#000000").css("border-bottom", "none").css("background-color", "transparent").attr("shcode", 0).attr("showFlag", "1");
-        //    }
-        //});
-        // 处理高亮
-        dealGLShowFunc(NodeHandle);
+        $.each($(NodeHandle).find("u,span,p"), function (index, element) {
+            // 处理普通文本
+            if ($(element).attr("ulflag") == 1) {
+                if (!ThProFlag || (ThProFlag && $(element).attr("showflag") == 1)) {
+                    if ($(element).text() == "暂无参考答案") {
+                        $(element).css("color", "#989898").attr("shcode", 1).attr("showflag", "1");
+                    }
+                    else {
+                        $(element).css("color", "#92D050").attr("shcode", 1).attr("showflag", "1");
+                    }
+                }
+            }
+            else {
+                $(element).css("color", "#000000").attr("shcode", 1).attr("showflag", "1");
+            }
+            // 处理高亮
+            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");
+                }
+                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 {
+                        $(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");
+                }
+                else if (showflagS == "1") {
+                    $(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");
+                }
+                else if (showflagS == "1") {
+                    $(element).css("border-bottom", "2px solid #ffffff").attr("shcode", 0).attr("showflag", "1");
+                }
+            }
+        });
     }
     else {
-        var uLFlag = $(NodeHandle).attr("uLFlag");
-        if (uLFlag == "1") {
-            $(NodeHandle).css("color", "#ffffff").css("border-bottom", "1px solid #979797").css("background-color", "#ffffff").attr("shcode", 1).attr("showFlag", "0");
+        $(NodeHandle).css("color", "#ffffff").attr("shcode", 1).attr("showflag", "0");
+        if ($(NodeHandle).attr("hitstyle") == "wordStyle") {
+            $(NodeHandle).attr("shcode", 0).attr("showflag", "0");
         }
-        else {
-            $(NodeHandle).css("color", "#ffffff").css("border-bottom", "1px solid #979797").css("background-color", "#ffffff").attr("shcode", 0).attr("showFlag", "0");
+        else if ($(NodeHandle).attr("hitstyle") == "phraseStyle") {
+            $(NodeHandle).css("background-color", "#ffffff").attr("shcode", 0).attr("showflag", "0");
         }
-        $.each($(NodeHandle).find(".wordStyle,.phraseStyle,.sentenceStyle,u,span"), function (index, element) {
-            uLFlag = $(element).attr("uLFlag");
-            if (uLFlag == "1") {
-                $(element).css("color", "#ffffff").css("border-bottom", "1px solid #979797").css("background-color", "#ffffff").attr("shcode", 1).attr("showFlag", "0");
+        else if ($(NodeHandle).attr("hitstyle") == "sentenceStyle") {
+            $(NodeHandle).css("border-bottom", "2px solid #ffffff").attr("shcode", 0).attr("showflag", "0");
+        }
+        $.each($(NodeHandle).find("u,span,p"), function (index,element) {
+            // 处理普通文本
+            $(element).css("color", "#ffffff").attr("shcode", 1).attr("showflag", "0");  // 合并处理
+            // 处理高亮
+            if ($(element).attr("hitstyle") == "wordStyle") {
+                $(element).attr("shcode", 0).attr("showflag", "0");
             }
-            else {
-                $(element).css("color", "#ffffff").css("border-bottom", "1px solid #979797").css("background-color", "#ffffff").attr("shcode", 0).attr("showFlag", "0");
+            else if ($(element).attr("hitstyle") == "phraseStyle") {
+                $(element).css("background-color", "#ffffff").attr("shcode", 0).attr("showflag", "0");
+            }
+            else if ($(element).attr("hitstyle") == "sentenceStyle") {
+                $(element).css("border-bottom", "2px solid #ffffff").attr("shcode", 0).attr("showflag", "0");
             }
         });
     }

+ 27 - 2
EBook.Web/Test.html

@@ -21,6 +21,11 @@
         <button id="backup-review">回填评阅数据</button>
         <button id="scroll-review">定位滚动数据</button>
         <button id="test-ui">测试UI效果</button>
+        <button id="wordStyleID">单词</button>
+        <button id="phraseStyleID">短语</button>
+        <button id="sentenceStyleID">句型</button>
+        <button id="ShowID">全显示</button>
+        <button id="HiddenID">隐藏</button>
     </div>
     <!--<input type="text" style="border:0px; border-bottom:solid #fbfbfb 1px; border-radius: 3px;padding-left:5px; color:#6ab7ff;" value="测试的" />-->
 
@@ -47,7 +52,7 @@
         }
         //加载听说课文
         $("#load-text").on("click", function () {
-            var data = $.ajax({ url: "lghp/GCZD.lghp", async: false }).responseText;
+            var data = $.ajax({ url: "lghp/gouxuan.lghp", async: false }).responseText;
             $("#data").html(data);
 
             //Fill(JSON.parse(hightcodejson));
@@ -134,7 +139,27 @@
             var clonediv = $(".btn-play").prop("outerHTML");
             $(".test-p").html($(".test-p").html() + clonediv);
         });
-
+        var wordStyleFlag = true;
+        var phraseStyleFlag = true;
+        var sentenceStyleFlag = true;
+        $("#wordStyleID").on("click", function () {
+            wordStyleFlag = !wordStyleFlag;
+            showGLWorld(wordStyleFlag, phraseStyleFlag, sentenceStyleFlag);
+        });
+        $("#phraseStyleID").on("click", function () {
+            phraseStyleFlag = !phraseStyleFlag;
+            showGLWorld(wordStyleFlag, phraseStyleFlag, sentenceStyleFlag);
+        });
+        $("#sentenceStyleID").on("click", function () {
+            sentenceStyleFlag = !sentenceStyleFlag;
+            showGLWorld(wordStyleFlag, phraseStyleFlag, sentenceStyleFlag);
+        });
+        $("#ShowID").on("click", function () {
+            showGLWorld(true, true, true);
+        });
+        $("#HiddenID").on("click", function () {
+            showGLWorld(false, false, false);
+        });
         //生成从minNum到maxNum的随机数
         function randomNum(minNum, maxNum) {
             switch (arguments.length) {