namejr пре 4 година
родитељ
комит
0005dd67e9
1 измењених фајлова са 141 додато и 34 уклоњено
  1. 141 34
      EBook.Web/Common/tasklib_book.js

+ 141 - 34
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",
@@ -225,50 +225,156 @@ function bindEventTeaOrignalYS() {
         });
     });
 
+    //点击喇叭事件,音频播放
+    $(".audioImg").on("click", function () {
+        audioPlayClick(this);
+    });
+
     //显示/隐藏习题答案
     $(".yaoshi").on("click", function () {
+        var parentAnid = $(this).attr("parent-anid");
         var curDisplay = $(this).nextUntil(".yaoshi").find(".underlineContent").eq(0).css("display");
         if (curDisplay == "undefined" || curDisplay == undefined) return;
-
         if (curDisplay == "none" || $(this).attr("data-status") == "0") {
-            $(this).attr("data-status", "1");
-            $(this).attr("src", PicInfo.yaoshiShowImgUrl);
-            //$(this).nextUntil(".yaoshi").find(".underlineContent").show();
-            //$(this).nextUntil(".yaoshi").find(".underlineContent").css("color", "#92D050");
-            $.each($(this).nextUntil(".yaoshi").find(".underlineContent"), function (index, item) {
-                if (!$(item).hasClass("no-answer")) {
-                    $(item).css("color", "#92D050");
-                }
-                else {
-                    $(item).css("color", "#989898");
-                }
-
-                $(item).find(".wordStyle").css("color", "#db5d00");
-                $(item).find(".phraseStyle").css("background-color", "#f2db8b");
-            });
+            if (parentAnid != undefined) {
+                $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, item) {
+                    $(item).attr("data-status", "1");
+                    $(item).attr("src", PicInfo.yaoshiShowImgUrl);
+                    $.each($(item).parent().find(".underlineContent"), function (cIndex, cItem) {
+                        var underlineContentText = $(cItem).text();  // 获取文本内容
+                        var widthValue = $(cItem).css("width");
+                        var newClsName = $(cItem).next().attr("class");
+                        if (newClsName != "underlineContentShow") {
+                            var addHtml = "";
+                            if (hasChineseWorld(underlineContentText)) {
+                                addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
+                            }
+                            else {
+                                addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
+                            }
+                            $(cItem).css("display", "inline-block").after(addHtml);
+                        }
+                        else {
+                            $(cItem).css("display", "inline-block").next().attr("data-status", "0");
+                        }
+                        if (underlineContentText.indexOf("√") > -1) {
+                            $(this).parent().find(".checkbox").find("input").prop('checked', true);
+                        }
+                        if (!$(item).hasClass("no-answer")) {
+                            $(item).css("color", "#92D050");
+                        }
+                        else {
+                            $(item).css("color", "#989898");
+                        }
+                        $(item).find(".wordStyle").css("color", "#db5d00");
+                        $(item).find(".phraseStyle").css("background-color", "#f2db8b");
+                    });
+                });
+            }
+            else {
+                $(this).attr("data-status", "1");
+                $(this).attr("src", PicInfo.yaoshiShowImgUrl);
+                $.each($(this).nextUntil(".yaoshi").find(".underlineContent"), function (index, item) {
+                    var underlineContentText = $(this).text();  // 获取文本内容
+                    var widthValue = $(item).css("width");
+                    var newClsName = $(item).next().attr("class");
+                    if (newClsName != "underlineContentShow") {
+                        var addHtml = "";
+                        if (hasChineseWorld(underlineContentText)) {
+                            addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
+                        }
+                        else {
+                            addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
+                        }
+                        $(item).css("display", "inline-block").after(addHtml);
+                    }
+                    else {
+                        $(item).css("display", "inline-block").next().attr("data-status", "0");
+                    }
+                    if (underlineContentText.indexOf("√") > -1) {
+                        $(this).parent().find(".checkbox").find("input").prop('checked', true);
+                    }
+                    if (!$(item).hasClass("no-answer")) {
+                        $(item).css("color", "#92D050");
+                    }
+                    else {
+                        $(item).css("color", "#989898");
+                    }
+                    $(item).find(".wordStyle").css("color", "#db5d00");
+                    $(item).find(".phraseStyle").css("background-color", "#f2db8b");
+                });
+            }
             //不再存在已隐藏的钥匙,移动端回调
             if ($(".yaoshi[data-status='0']").length == 0) {
                 //添加回调
                 console.log("全部显示了");
             }
-        } else {
-            $(this).attr("data-status", "0");
-            $(this).attr("src", PicInfo.yaoshiHideImgUrl);
-            //$(this).nextUntil(".yaoshi").find(".underlineContent").hide();
-            //$(this).nextUntil(".yaoshi").find(".underlineContent").css("color", "#ffffff");
-            $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
-                $(item).css("color", "#ffffff");
-                $(item).find(".wordStyle").css("color", "#ffffff");
-                $(item).find(".phraseStyle").css("background-color", "#ffffff");
-            });
+        }
+        else {
+            if (parentAnid != undefined) {
+                $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, item) {
+                    $(item).attr("data-status", "0");
+                    $(item).attr("src", PicInfo.yaoshiHideImgUrl);
+                    $.each($(item).parent().find(".underlineContent"), function (cIndex, cItem) {
+                        var underlineContentText = $(cItem).text();  // 获取文本内容
+                        var widthValue = $(cItem).css("width");
+                        var newClsName = $(cItem).next().attr("class");
+                        if (newClsName != "underlineContentShow") {
+                            var addHtml = "";
+                            if (hasChineseWorld(underlineContentText)) {
+                                addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
+                            }
+                            else {
+                                addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
+                            }
+                            $(cItem).css("display", "none").after(addHtml);
+                            $(cItem).next().attr("data-status", "1");
+                        }
+                        else {
+                            $(cItem).css("display", "none").next().attr("data-status", "1");
+                        }
+                        if (underlineContentText.indexOf("√") > -1) {
+                            $(this).parent().find(".checkbox").find("input").prop('checked', false);
+                        }
+                        $(item).css("color", "#ffffff");
+                        $(item).find(".wordStyle").css("color", "#ffffff");
+                        $(item).find(".phraseStyle").css("background-color", "#ffffff");
+                    });
+                });
+            }
+            else {
+                $(this).attr("data-status", "0");
+                $(this).attr("src", PicInfo.yaoshiHideImgUrl);
+                $.each($(this).nextUntil(".yaoshi").find(".underlineContent"), function (index, item) {
+                    var underlineContentText = $(this).text();  // 获取文本内容
+                    var widthValue = $(item).css("width");
+                    var newClsName = $(item).next().attr("class");
+                    if (newClsName != "underlineContentShow") {
+                        var addHtml = "";
+                        if (hasChineseWorld(underlineContentText)) {
+                            addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
+                        }
+                        else {
+                            addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
+                        }
+                        $(item).css("display", "none").after(addHtml);
+                        $(item).next().attr("data-status", "1");
+                    }
+                    else {
+                        $(item).css("display", "none").next().attr("data-status", "1");
+                    }
+                    if (underlineContentText.indexOf("√") > -1) {
+                        $(this).parent().find(".checkbox").find("input").prop('checked', false);
+                    }
+                    $(item).css("color", "#ffffff");
+                    $(item).find(".wordStyle").css("color", "#ffffff");
+                    $(item).find(".phraseStyle").css("background-color", "#ffffff");
+                });
+            }
             //添加回调
             onClickKeyHide();
         }
     });
-    //点击喇叭事件,音频播放
-    $(".audioImg").on("click", function () {
-        audioPlayClick(this);
-    });
     //点击播放事件,视频播放
     $(".videoImg").on("click", function () {
         var curHtml = $(this).parent().find(".videoUrl").html();
@@ -358,7 +464,7 @@ function bindEventYS() {
                     $.each($(fItem).parent().find(".underlineContent"), function (index, item) {
                         var underlineContentText = $(this).text();  // 获取文本内容
                         var widthValue = $(item).css("width");
-                        var newClsName = $(item).next().attr("class");
+                        var newClsName = $(item).parent().find(".underlineContent").next().attr("class");
                         if (newClsName != "underlineContentShow") {
                             var addHtml = "";
                             if (hasChineseWorld(underlineContentText)) {
@@ -435,7 +541,8 @@ function bindEventYS() {
                     $.each($(fItem).parent().find(".underlineContent"), function (index, item) {
                         var underlineContentText = $(this).text();  // 获取文本内容
                         var widthValue = $(item).css("width");
-                        var newClsName = $(item).next().attr("class");
+                        var newClsName = $(item).parent().find(".underlineContent").next().attr("class");
+                        console.log("newClsName11" + newClsName)
                         if (newClsName != "underlineContentShow") {
                             var addHtml = "";
                             if (hasChineseWorld(underlineContentText)) {