lujianhong преди 4 години
родител
ревизия
af9a134222
променени са 2 файла, в които са добавени 86 реда и са изтрити 72 реда
  1. 5 34
      EBook.Web/Common/mtm_temp.js
  2. 81 38
      EBook.Web/Common/tasklib_book.js

+ 5 - 34
EBook.Web/Common/mtm_temp.js

@@ -1,8 +1,5 @@
 /*高亮文本标注*/
 function Fill(data) {
-    var wordFlag = false;
-    var phraseFlag = false;
-    var sentenceFlag = false;
     var highlightArr = [];
     clearHighlight();
     $.each(data, function (i, item) {
@@ -36,11 +33,11 @@ function Fill(data) {
         }
         $.each(highlightArr, function (i, item) {
             if (item.attr('flag') == 'word') {
-                wordFlag = true;
+                styleWPSContrl.wordFlag = true;
                 bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "wordStyle").addClass('wordStyle'), true);
             }
             else if (item.attr('flag') == 'phrase') {
-                phraseFlag = true;
+                styleWPSContrl.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);
@@ -52,41 +49,15 @@ function Fill(data) {
             }
             else if (item.attr('flag') == 'sentence') {
                 if (item.attr('iskeyklg') == 'true') return;
-                sentenceFlag = true;
+                styleWPSContrl.sentenceFlag = true;
                 bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "sentenceStyle").addClass('sentenceStyle')
                     .before('<img src="file:///android_asset/js/sentenceIco.png" class="sentImagcs">'), true);
             }
         });
     });
     // 绑定横线内处理
-    $.each($(document).find("u,span,p"), function (Iindex, Iitem) {
-        var ClsName = $(Iitem).attr("class");
-        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) {
-                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") {
-        showGLWorld(wordFlag, phraseFlag, sentenceFlag);
+    if (typeof (addFillAssist) == "function") {
+        addFillAssist();
     }
 }
 

+ 81 - 38
EBook.Web/Common/tasklib_book.js

@@ -29,8 +29,8 @@ var styleWPSContrl = {
 
 // 表格处理Start
 var pressTableFlag = false;
-var GetPadVal = function () {
-    var PaddingVal = $(document.body).css("padding");
+var GetPadVal = function (THandel) {
+    var PaddingVal = $(THandel).css("padding");
     var PadValArr = PaddingVal.split(" ");
     if (PadValArr.length > 2) {
         return parseFloat(PadValArr[1]) + parseFloat(PadValArr[3]);
@@ -134,7 +134,8 @@ var AdjustTableFunc = function () {
             $.each($(trItem).find("td"), function (tdIndex, tdItem) {
                 var tdtext = removeHtmlFunc($(tdItem).html());
                 $("#pContrainId").text(tdtext);
-                var tdWidthVal = $("#pContrainId").width();
+                var tdWidthVal = $("#pContrainId").width();  // 获取文字宽度
+                tdWidthVal += GetPadVal(tdItem);
                 if (tdWidthVal > (ScreenWidth / 2)) {
                     tdWidthVal = (ScreenWidth / 2);
                 }
@@ -152,8 +153,8 @@ var AdjustTableFunc = function () {
         });
         // 判断表格是否只有一行
         if ($(item).find("tr").length == 1 && $(item).find("tr").eq(0).find("td").length == 1) {
-            $(item).find("tr").eq(0).find("td").eq(0).css("width", (ScreenWidth - 4 - GetPadVal()) + "px");
-            $(item).css("width", (ScreenWidth - 4 - GetPadVal()) + "px");
+            $(item).find("tr").eq(0).find("td").eq(0).css("width", (ScreenWidth - 4 - GetPadVal(document.body)) + "px");
+            $(item).css("width", (ScreenWidth - 4 - GetPadVal(document.body)) + "px");
         }
         else {
             if (TotalMaxLen < ScreenWidth) {
@@ -209,7 +210,7 @@ var AdjustTableFunc = function () {
         Index += 1;
     });
     $(document.body).css("width", ScreenWidth + "px");
-    var BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width()) - GetPadVal());  // 界面宽度
+    var BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width()) - GetPadVal(document.body));  // 界面宽度
     var Index = 0;
     $.each($("table"), function (index, item) {
         var TableWidth = isNaN(parseFloat($(item).width())) ? 0 : parseFloat($(item).width());  // 表格宽度
@@ -235,7 +236,7 @@ var AdjustTableFunc = function () {
         pressTableFlag = true;
     }).on("touchmove", function () {
         var TableWidth = isNaN(parseFloat($(this).find("table").width())) ? 0 : parseFloat($(this).find("table").width());  // 表格宽度
-        BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width() - GetPadVal()));  // 界面宽度
+        BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width() - GetPadVal(document.body)));  // 界面宽度
         var HiddenRate = BodyWidth / TableWidth;  // 滚动条比率
         var SLeftWdith = isNaN(parseFloat($(this)[0].scrollLeft)) ? 0 : parseFloat($(this)[0].scrollLeft);
         SLeftWdith *= HiddenRate;
@@ -251,7 +252,7 @@ var AdjustTableFunc = function () {
         }
         ClsName = ClsName.replace("TableContainer ", ".");
         var TableWidth = isNaN(parseFloat($(ClsName).find("table").width())) ? 0 : parseFloat($(ClsName).find("table").width());  // 表格宽度
-        BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width() - GetPadVal()));  // 界面宽度
+        BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width() - GetPadVal(document.body)));  // 界面宽度
         var HiddenRate = BodyWidth / TableWidth;  // 滚动条比率
         var SLeftWdith = isNaN(parseFloat($(ClsName)[0].scrollLeft)) ? 0 : parseFloat($(ClsName)[0].scrollLeft);
         SLeftWdith *= HiddenRate;
@@ -279,8 +280,50 @@ var isGCFunc = function (NodeHandle) {
     }
     return isFlag;
 };
-//(shcode是否可点击1可点击;ulflag判断是否存在横线内1表示在;showflag是否显示1显示)
-// 处理显示或隐藏答案
+// 不调用fill需要增加处理(绑定横线内处理)
+var addFillAssist = function () {
+    $.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");
+                }
+            });
+        }
+    });
+    if (typeof (showGLWorld) == "function") {
+        showGLWorld(styleWPSContrl.wordFlag, styleWPSContrl.phraseFlag, styleWPSContrl.sentenceFlag);
+    }
+};
+
+// 处理显示或隐藏答案,(shcode是否可点击1可点击;ulflag判断是否存在横线内1表示在;showflag是否显示1显示)
 var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
     if (OCFlag) {
         var showflagS = $(NodeHandle).attr("showflag");
@@ -332,7 +375,7 @@ var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
             }
         }
         if (!ThProFlag) {
-            $.each($(NodeHandle).find("u,span,p"), function (index, element) {
+            $.each($(NodeHandle).find(".cAStauts"), function (index, element) {
                 showflagS = $(element).attr("showflag");
                 // 处理普通文本
                 if ($(element).attr("ulflag") == 1) {
@@ -403,7 +446,7 @@ var dealAnswerFunc = function (NodeHandle, OCFlag, ThProFlag) {
         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) {
+        $.each($(NodeHandle).find(".cAStauts"), function (index, element) {
             // 处理普通文本
             $(element).css("color", "#ffffff").attr("shcode", 1).attr("showflag", "0");  // 合并处理
             // 处理高亮
@@ -445,7 +488,7 @@ function showHideAnswer(flag) {
     }
 }
 
-///显示、隐藏钥匙及答案 isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
+//显示、隐藏钥匙及答案 isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
 function showHideAnswerEx(isShowYX, isShowAS) {
     if (isShowYX) {
         $(".yaoshi").show();
@@ -456,7 +499,7 @@ function showHideAnswerEx(isShowYX, isShowAS) {
     if (isShowAS) {
         $.each($(".underlineContent"), function (index, item) {
             dealAnswerFunc(item, true, false);
-        });
+    });
         $(".yaoshi").attr("data-status", "1");
         $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
     }
@@ -517,7 +560,7 @@ function bindEventTeaOrignalYS() {
                     uHtml.innerHTML = "&nbsp;&nbsp;&nbsp;";
                     //改错题,要随机下划线长度
                     if ($(parent).hasClass('correntQue')) {
-                        uHtml.style = "width:" + randomNum(220, 300) + "px;";
+                        uHtml.style = "width:" +randomNum(220, 300) + "px;";
                     }
                     uHtml.setAttribute("answer-anstext", "");
                 }
@@ -526,7 +569,7 @@ function bindEventTeaOrignalYS() {
             $(item).after(spanHtml);
         }
     });
-    //处理表格宽度
+        //处理表格宽度
     AdjustTableFunc();
     //一题多空的答题点标注
     var checkId = 0;
@@ -592,7 +635,7 @@ function bindEventTeaOrignalYS() {
                 $(this).attr("src", PicInfo.yaoshiHideImgUrl);
                 $.each($(this).nextUntil(".yaoshi").find(".underlineContent"), function (index, item) {
                     dealAnswerFunc(item, false, false);
-                });
+            });
             }
             //添加回调
             onClickKeyHide();
@@ -604,6 +647,7 @@ function bindEventTeaOrignalYS() {
         var curAlt = $(this).attr("alt");//播放视频地址
         playVisiableAudioCallBack(2, $(this).attr("alt"));
     });
+    addFillAssist();
 }
 
 //页面加载完,课件 绑定事件
@@ -649,7 +693,7 @@ function bindEventYS() {
                     uHtml.innerHTML = "&nbsp;&nbsp;&nbsp;";
                     //改错题,要随机下划线长度
                     if ($(parent).hasClass('correntQue')) {
-                        uHtml.style = "width:" + randomNum(220, 300) + "px;";
+                        uHtml.style = "width:" +randomNum(220, 300) + "px;";
                     }
                     uHtml.setAttribute("answer-anstext", "");
                 }
@@ -744,7 +788,6 @@ function bindEventYS() {
 function getPressFlag() {
     return pressTableFlag;
 }
-// 滚动条渲染
 
 // 设置离焦事件
 function resetPressFlag() {
@@ -847,7 +890,7 @@ function handleAnswerRange() {
         if (!$(prev).hasClass("checkbox")) {
             if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
                 //替换答案
-                $(item).prop("outerHTML", "<span answer-id='" + info.Id + "' class='tag-span' answer-isky='0'>_</span>");
+                $(item).prop("outerHTML", "<span answer-id='" +info.Id + "' class='tag-span' answer-isky='0'>_</span>");
             }
             else {
                 $(item).remove();
@@ -892,7 +935,7 @@ function handleAnswerRange() {
     var temptext = "";
     for (var i = 0; i < tempJson.length; i++) {
         if (tempid == tempJson[i].Id) {
-            temptext = temptext + tempJson[i].AnsText;
+            temptext = temptext +tempJson[i].AnsText;
         }
         else {
             if (tempid != "") {
@@ -909,7 +952,7 @@ function handleAnswerRange() {
             temppid = tempJson[i].pId;
             temptext = tempJson[i].AnsText;
             //最后一个存入
-            if (i == tempJson.length - 1) {
+            if (i == tempJson.length -1) {
                 var info = new Object();
                 info.Id = tempid;
                 info.pId = temppid;
@@ -924,12 +967,12 @@ function handleAnswerRange() {
     if (answerData.length > 0) {
         //Num = Number.parseInt(answerData[answerData.length - 1].Id);
         Num = Number.parseInt($(".yaoshi:last").attr('answer-id'));
-        for (var i = 0; i < Num + 1; i++) {
+        for (var i = 0; i < Num +1; i++) {
             if (i < answerData.length) {
-                var index = Number(answerData[i].Id) - i;
+                var index = Number(answerData[i].Id) -i;
                 for (var j = 0; j < index; j++) {
                     var info = new Object();
-                    info.Id = (i + j).toString();
+                    info.Id = (i +j).toString();
                     info.pId = info.Id;
                     info.AnsText = "";
                     answerData.splice(i, 0, info);
@@ -959,7 +1002,7 @@ function handleAnswerRange() {
                 break;
             }
         }
-        $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentId + "' answer-anstext='" + answerText + "' answer-isky='" + isky + "' answer-showanswer='0'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text'></buttom></div>");
+        $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentId + "' answer-anstext='" + answerText + "' answer-isky='" + isky + "' answer-showanswer='0'><div class='answer-audio-range'><img src='" +PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range'><img src='" +PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text'></buttom></div>");
         //删除钥匙节点
         var prev = $("img[answer-id='" + answerid + "']");
         if (prev.length > 0) {
@@ -1010,7 +1053,7 @@ function handleAnswerRange() {
 function reviewAnswer(answerJson) {
     if (answerJson != "" && answerJson) {
         var answerObj = JSON.parse(answerJson);
-        var selectElement = $(".answer-body[answer-id='" + answerObj.Id + "']");
+        var selectElement = $(".answer-body[answer-id='" +answerObj.Id + "']");
         var audioElement = $(selectElement).children(".answer-audio-range").children("img").eq(0);
         answerObj.IsKY = $(selectElement).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
 
@@ -1018,11 +1061,11 @@ function reviewAnswer(answerJson) {
         if ((answerObj.Type == 3 || answerObj.Type == 4) && answerObj.AudioUrl != "") {
             $(selectElement).children(".answer-point-range").hide();
             $(selectElement).children(".answer-audio-range").css("display", "inline-block");
-            $(selectElement).children(".answer-audio-range").children("span").text("作答音频(" + answerObj.AudioLength + "s)");
+            $(selectElement).children(".answer-audio-range").children("span").text("作答音频(" +answerObj.AudioLength + "s)");
             //填充作答内容
             $(selectElement).attr("answer-text", answerObj.Text);
             if (answerObj.Text != "") {
-                answerObj.Text = "(" + answerObj.Text + ")";
+                answerObj.Text = "(" +answerObj.Text + ")";
                 $(selectElement).children(".answer-text").show();
                 $(selectElement).children(".answer-text").text(answerObj.Text);
             }
@@ -1094,7 +1137,7 @@ function getAllAnswer() {
             else {
                 $(item).children(".answer-text").text(mytext);
                 $(item).children(".answer-text").addClass("no-answer");
-            }
+        }
             $(item).children(".answer-point-range").hide();
             $(item).children(".answer-text").show();
         }
@@ -1152,7 +1195,7 @@ function backupAllAnswer(answerJson, statusType) {
                 hasAudio = true;
                 $(item).children(".answer-point-range").hide();
                 $(item).children(".answer-audio-range").css("display", "inline-block");
-                $(item).children(".answer-audio-range").children("span").text("作答音频(" + answerList[index].AudioLength + "s)");
+                $(item).children(".answer-audio-range").children("span").text("作答音频(" +answerList[index].AudioLength + "s)");
                 //填充作答内容
                 $(item).attr("answer-text", mytext);
                 if (mytext != "") {
@@ -1313,7 +1356,7 @@ function backupAllAnswer(answerJson, statusType) {
                 $(".checkbox").removeClass("select-answer");
                 $(".answer-body").removeClass("select-answer");
                 if (statusType == 2) {
-                    $(".answer-body[parent-anid=" + curObj.pId + "]").addClass("select-answer");
+                    $(".answer-body[parent-anid=" +curObj.pId + "]").addClass("select-answer");
                 }
                 else {
                     $(this).addClass("select-answer");
@@ -1336,7 +1379,7 @@ function backupAllAnswer(answerJson, statusType) {
 function reviewStuAnswer(answerJson) {
     if (answerJson != "" && answerJson) {
         var answerObj = JSON.parse(answerJson);
-        var selectElement = $(".answer-body[answer-id='" + answerObj.Id + "']");
+        var selectElement = $(".answer-body[answer-id='" +answerObj.Id + "']");
 
         //$(selectElement).attr("answer-text", answerObj.Text);//用户作答内容
         $(selectElement).attr("answer-score", answerObj.Score);//作答评分
@@ -1392,7 +1435,7 @@ function backupAllReview(answerJson) {
             if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
                 $(item).children(".answer-point-range").hide();
                 $(item).children(".answer-audio-range").css("display", "inline-block");
-                $(item).children(".answer-audio-range").children("span").text("作答音频(" + answerList[index].AudioLength + "s)");
+                $(item).children(".answer-audio-range").children("span").text("作答音频(" +answerList[index].AudioLength + "s)");
                 //填充作答内容
                 $(item).attr("answer-text", mytext);
                 if (mytext != "") {
@@ -1491,7 +1534,7 @@ function backupAllReview(answerJson) {
             $(".checkbox").removeClass("select-answer");
             $(".answer-body").removeClass("select-answer");
             //$(this).addClass("select-answer");
-            $(".answer-body[parent-anid=" + curObj.pId + "]").addClass("select-answer");
+            $(".answer-body[parent-anid=" +curObj.pId + "]").addClass("select-answer");
             //已作答,弹出作答答案
             if ($(this).data("ans-status") == "1") {
                 //移动端添加外部处理
@@ -1533,10 +1576,10 @@ function scrollAnswer(answerid) {
     var scroll_offset = $(ansDom).offset(); //得到box这个div层的offset,包含两个值,top和left
     var offset_top = scroll_offset.top;
     if (offset_top > 150) {
-        offset_top = offset_top - 200;
+        offset_top = offset_top -200;
     }
     $("body,html").animate({
-        scrollTop: offset_top //让body的scrollTop等于pos的top,就实现了滚动
+            scrollTop: offset_top //让body的scrollTop等于pos的top,就实现了滚动
     });
 }
 
@@ -1622,7 +1665,7 @@ function randomNum(minNum, maxNum) {
             return parseInt(Math.random() * minNum + 1, 10);
             break;
         case 2:
-            return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
+            return parseInt(Math.random() * (maxNum - minNum + 1) +minNum, 10);
             break;
         default:
             return 0;