Browse Source

Merge branch 'master' of http://192.168.3.18:3000/CallPro/EBook

# Conflicts:
#	EBook.Web/Common/tasklib_book.js
pengmi 4 years ago
parent
commit
8df7e55fda

+ 179 - 55
EBook.Web/Common/tasklib_book.js

@@ -155,50 +155,9 @@ function showHideAnswerEx(isShowYX, isShowAS) {
 //页面加载完,原文 绑定事件
 function bindEventTeaOrignalYS() {
     var bodyWidth = $(document.body).width();
-    //显示/隐藏习题答案
-    $(".yaoshi").on("click", function () {
-        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 ($(".yaoshi[data-status='0']").length == 0) {
-                //添加回调
-                console.log("全部显示了");
-                 onClickKeyShow();
-            }
-        } 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");
-            });
-            //添加回调
-            onClickKeyHide();
-        }
-    });
     //处理答题点
-    $.each($(".underlineContent"), function (index, item) {
-        $(item).attr("data-text", $(item).html());
+    $.each($(".yaoshi"), function (index, item) {
+        $(item).attr('answer-id', index);
     });
     //给音频绑定一个ID
     $.each($(".audioImg"), function (index, item) {
@@ -213,6 +172,10 @@ function bindEventTeaOrignalYS() {
     $.each($(".oralLanguageImg"), function (index, item) {
         $(item).attr("audiourl", "");
     });
+    //处理参考答案
+    $.each($(".underlineContent"), function (index, item) {
+        $(item).attr("data-text", $(item).html());
+    });
     //去除多余的U空标签
     $.each($("u"), function (index, item) {
         var text = $(item).text();
@@ -223,6 +186,7 @@ function bindEventTeaOrignalYS() {
     });
     //处理暂无参考答案
     $.each($(".yaoshi"), function (index, item) {
+        var parent = $(item).parent();
         var prev = $(item).nextUntil(".yaoshi").find(".underlineContent");
         if (prev.length == 0) {
             var spanHtml = document.createElement("span");
@@ -230,6 +194,11 @@ function bindEventTeaOrignalYS() {
             var uHtml = document.createElement("u");
             uHtml.className = "underlineContent no-answer";
             uHtml.innerText = "暂无参考答案";
+            if ($(parent)[0].tagName == 'P') {
+                if ($(parent).hasClass('correntQue') || $(parent).hasClass('boxQue')) {
+                    uHtml.innerHTML = "   ";
+                }
+            }
             uHtml.setAttribute("data-text", uHtml.innerText);
             $(spanHtml).html(uHtml.outerHTML);
             $(item).after(spanHtml);
@@ -239,11 +208,173 @@ function bindEventTeaOrignalYS() {
     $.each($(".container-table"), function (index, item) {
         $(item).css("width", bodyWidth + "px");
     });
+    //一题多空的答题点标注
+    var checkId = 0;
+    var headid = -1;
+    var groupId = -1;
+    $(".multipleStart").each(function (i, item) {
+        var $startNode = $(item);
+        $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
+            checkId = $(item).find('.yaoshi').attr("answer-id");
+            var gid = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
+            if (index == 0 || groupId != gid) {
+                groupId = gid;
+                headid = checkId;
+            }
+            $(item).find('.yaoshi').attr('parent-anid', headid);
+        });
+    });
 
     //点击喇叭事件,音频播放
     $(".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") {
+            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 {
+            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();
+        }
+    });
     //点击播放事件,视频播放
     $(".videoImg").on("click", function () {
         var curHtml = $(this).parent().find(".videoUrl").html();
@@ -304,7 +435,7 @@ function bindEventYS() {
     $.each($(".container-table"), function (index, item) {
         $(item).css("width", bodyWidth + "px");
     });
-    //获取两个之间的答题点
+    //一题多空的答题点标注
     var checkId = 0;
     var headid = -1;
     var groupId = -1;
@@ -333,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)) {
@@ -399,7 +530,6 @@ function bindEventYS() {
             if ($(".yaoshi[data-status='0']").length == 0) {
                 //添加回调
                 console.log("全部显示了");
-                onClickKeyShow();
             }
         }
         else {
@@ -411,7 +541,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)) {
@@ -1175,9 +1305,9 @@ function scrollAnswer(answerid) {
     //console.log(answerid);
     $(".checkbox").removeClass("select-answer");
     $(".answer-body").removeClass("select-answer");
-    var ansDom = $(".answer-body[answer-id='" + answerid + "']");
+    var ansDom = $(".answer-body[parent-anid='" + answerid + "']");
     if (ansDom.length == 0) {
-        ansDom = $(".checkbox[answer-id='" + answerid + "']");
+        ansDom = $(".checkbox[parent-anid='" + answerid + "']");
     }
     $(ansDom).addClass("select-answer");
     var scroll_offset = $(ansDom).offset(); //得到box这个div层的offset,包含两个值,top和left
@@ -1306,10 +1436,4 @@ function getSelectedText(title) {
         txt = window.document.selection.createRange().text;
     }
     JSInterface.callback(txt, title);
-}
-
-function onClickKeyShow() {
-    //alert(JSON.stringify(data));
-    cancelBubble();
-    plugin.onClickKeyShow();
 }

+ 2 - 0
EBook.Web/EBook.Web.csproj

@@ -110,6 +110,8 @@
     <Content Include="source.html" />
     <Content Include="Source\01.txt" />
     <Content Include="Source\02.txt" />
+    <Content Include="Source\duogouxuan.txt" />
+    <Content Include="Source\gaicuo.txt" />
     <Content Include="TagWord\AudioContent.html" />
     <Content Include="TagWord\AudioTraining.css" />
     <Content Include="TagWord\AudioTraining.js" />

File diff suppressed because it is too large
+ 0 - 0
EBook.Web/Source/duogouxuan.txt


File diff suppressed because it is too large
+ 0 - 0
EBook.Web/Source/gaicuo.txt


+ 1 - 1
EBook.Web/Test.html

@@ -47,7 +47,7 @@
         }
         //加载听说课文
         $("#load-text").on("click", function () {
-            var data = $.ajax({ url: "lghp/duogouxuan.lghp", async: false }).responseText;
+            var data = $.ajax({ url: "lghp/gaicuo.lghp", async: false }).responseText;
             $("#data").html(data);
 
             Fill(JSON.parse(hightcodejson));

+ 1 - 1
EBook.Web/source.html

@@ -24,7 +24,7 @@
         }
         //加载课时原文
         $("#load-text").on("click", function () {
-            var data = $.ajax({ url: "Source/01.txt", async: false }).responseText;
+            var data = $.ajax({ url: "Source/duogouxuan.txt", async: false }).responseText;
             $("#data").html(data);
 
             bindEventTeaOrignalYS();

Some files were not shown because too many files changed in this diff