tasklib_book.js 109 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444
  1. //播放音频图片地址
  2. var PicInfo1 = {
  3. answerPointImgUrl: "file:///android_asset/js/update-answer.png",
  4. yaoshiShowImgUrl: "file:///android_asset/js/yaoshi-show.png",
  5. yaoshiHideImgUrl: "file:///android_asset/js/yaoshi-hide.png",
  6. recordPlayImgUrl: "file:///android_asset/js/play.png",
  7. recordPauseImgUrl: "file:///android_asset/js/pause.png",
  8. audioPlayImgUrl: "file:///android_asset/js/dynaiselaba.gif",
  9. audioPauseImgUrl: "file:///android_asset/js/dynaiselaba.png"
  10. }
  11. //本地调用用的资源
  12. var PicInfo = {
  13. answerPointImgUrl: "../Images/update-answer.png",
  14. yaoshiShowImgUrl: "../Images/yaoshi-show.png",
  15. yaoshiHideImgUrl: "../Images/yaoshi-hide.png",
  16. KouYuTagImgUrl: "../Images/KY.png",
  17. recordPlayImgUrl: "../Images/play.png",
  18. recordPauseImgUrl: "../Images/pause.png",
  19. audioPlayImgUrl: "../Images/dynaiselaba.gif",
  20. audioPauseImgUrl: "../Images/dynaiselaba.png"
  21. }
  22. var TestFlag = true; // 调试功能开关
  23. // 处理多选
  24. var dealCheckBox = function () {
  25. $.each($(".checkbox").find("input"), function (index, element) {
  26. var inputId = $(element).attr("id");
  27. var answerText = $(element).attr("answer-text");
  28. var dataStatus = (answerText == undefined || answerText == "") ? 0 : 1;
  29. var htmlStr = "<div class='cBoxCls cBoxCls_" + inputId + "' data-status='" + dataStatus + "' onclick='clickCheckBox(" + inputId + ")'></div>";
  30. $(element).attr("hidden", "hidden").after(htmlStr);
  31. });
  32. };
  33. // 多选点击(多选框是否可选)
  34. var ControlFlag = true;
  35. var clickCheckBox = function (inputId) {
  36. if (!ControlFlag) {
  37. return;
  38. }
  39. var BoxJqStr = ".cBoxCls_" + inputId;
  40. if ($(BoxJqStr).attr("data-status") == "1") {
  41. $(BoxJqStr).attr("data-status", "0");
  42. }
  43. else {
  44. $(BoxJqStr).attr("data-status", "1");
  45. }
  46. $("#" + inputId).click();
  47. // 变动同一个答题点的颜色修改
  48. var JqStr = ".checkbox[answer-id='" + inputId + "']";
  49. var parentAnID = $(JqStr).attr("parent-anid");
  50. JqStr = ".checkbox[parent-anid='" + parentAnID + "']";
  51. $(JqStr).addClass("select-answer");
  52. }
  53. // 判断是否显示答题点高亮(主体课文学生未完成评阅不显示)
  54. var IsStuFills = {
  55. StuID: false, // 身份
  56. ProcessType:0 // 作答状态
  57. };
  58. // 检测安卓和ios
  59. var cTTypeFunc = function () {
  60. var u = navigator.userAgent;
  61. //var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  62. //var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
  63. if (u.indexOf('Android') > -1 || u.indexOf('Adr') > -1) {
  64. return 1;
  65. }
  66. else {
  67. return 2;
  68. }
  69. }();
  70. // 判断是否是主体课文
  71. var IsZTKEStatus = 0;
  72. // #region 表格处理Start
  73. var pressTableFlag = false;
  74. // 获取最大字符长度的字符串(起决定宽度的字符串/将字符去除HTML标签)
  75. var removeHtmlFunc = function (htmlStr, TdWidthVal) {
  76. var ReArr = {
  77. TextStr: "",
  78. WidthVal: 0,
  79. ImgFlag: false,
  80. };
  81. // 清除非长度标签
  82. var pattStr = new RegExp(/<(img){1}.*?>/ig);
  83. var matchesArr = htmlStr.match(pattStr);
  84. if (matchesArr != null && (matchesArr != undefined && matchesArr.length > 0)) {
  85. for (var i = 0; i < matchesArr.length; i++) {
  86. if (matchesArr[i].indexOf("nextpic") == -1) {
  87. var TempWidthVal = 0;
  88. var pattWStr = new RegExp(/width\s?:\s?[0-9|p|x|%]+;/ig);
  89. var matchesWArr = matchesArr[i].match(pattWStr);
  90. if (matchesWArr != null && matchesWArr.length > 0) {
  91. if (matchesWArr[0].indexOf("%") > -1) {
  92. var TWidthVal = parseFloat(matchesWArr[0].replace(/\s/g, "").replace("width:", ""));
  93. TempWidthVal += TdWidthVal * TWidthVal;
  94. }
  95. else {
  96. TempWidthVal += parseFloat(matchesWArr[0].replace(/\s/g, "").replace("width:", "").replace("px", ""));
  97. }
  98. }
  99. pattWStr = new RegExp(/width\s?=\s?["|'|0-9|p|x|%]+/ig);
  100. matchesWArr = matchesArr[i].match(pattWStr);
  101. if (matchesWArr != null && matchesWArr.length > 0) {
  102. if (matchesWArr[0].indexOf("%") > -1) {
  103. var TWidthVal = parseFloat(matchesWArr[0].replace(/\s/g, "").replace("width=", ""));
  104. TempWidthVal += TdWidthVal * TWidthVal;
  105. } else {
  106. TempWidthVal += parseFloat(matchesWArr[0].replace(/\s/g, "").replace("width=", "").replace("px", ""));
  107. }
  108. }
  109. ReArr.WidthVal = TempWidthVal > ReArr.WidthVal ? TempWidthVal : ReArr.WidthVal;
  110. if (ReArr.WidthVal != 0) {
  111. ReArr.ImgFlag = true;
  112. }
  113. }
  114. htmlStr = htmlStr.replace(matchesArr[i], "");
  115. }
  116. }
  117. // 其他处理
  118. pattStr = new RegExp(/(<(p){1}.*?>).*?(<\/\2>)/ig);
  119. matchesArr = htmlStr.match(pattStr);
  120. if (matchesArr != undefined && matchesArr.length > 0) {
  121. // 清除匹配的P标签
  122. for (var i = 0; i < matchesArr.length; i++) {
  123. // 去除多标签
  124. pattStr = new RegExp(/(<([a-z|A-Z]+){1}.*?>).*?(<\/\2>)/i);
  125. var NewhtmlStr = matchesArr[i];
  126. while (pattStr.test(NewhtmlStr)) {
  127. var tTmatchesArr = NewhtmlStr.match(pattStr);
  128. if (tTmatchesArr.length > 0) {
  129. // 存在P标签
  130. NewhtmlStr = NewhtmlStr.replace(tTmatchesArr[1], "").replace(tTmatchesArr[3], "");
  131. }
  132. }
  133. // 去除单标签
  134. pattStr = new RegExp(/(<([a-z|A-Z]+){1}\\s*\/\\s*>)/i);
  135. while (pattStr.test(NewhtmlStr)) {
  136. var tTmatchesArr = NewhtmlStr.match(pattStr);
  137. if (tTmatchesArr.length > 0) {
  138. // 存在P标签
  139. NewhtmlStr = NewhtmlStr.replace(tTmatchesArr[1], "");
  140. }
  141. }
  142. if (i == 0 || (htmlStr.length < NewhtmlStr.length)) {
  143. htmlStr = NewhtmlStr;
  144. }
  145. }
  146. }
  147. else {
  148. pattStr = new RegExp(/(<([a-z|A-Z]+){1}.*?>).*?(<\/\2>)/i); // 去除多标签
  149. while (pattStr.test(htmlStr)) {
  150. var tTmatchesArr = htmlStr.match(pattStr);
  151. if (tTmatchesArr.length > 0) {
  152. // 存在P标签
  153. htmlStr = htmlStr.replace(tTmatchesArr[1], "").replace(tTmatchesArr[3], "");
  154. }
  155. }
  156. // 去除单标签
  157. pattStr = new RegExp(/(<([a-z|A-Z]+){1}\\s*\/\\s*>)/i);
  158. while (pattStr.test(htmlStr)) {
  159. var tTmatchesArr = htmlStr.match(pattStr);
  160. if (tTmatchesArr.length > 0) {
  161. // 存在P标签
  162. htmlStr = htmlStr.replace(tTmatchesArr[1], "");
  163. }
  164. }
  165. }
  166. // 去除多空格
  167. while (htmlStr.match(/\s\s/g)) {
  168. htmlStr = htmlStr.replace(/\s\s/g, " ");
  169. }
  170. while (htmlStr.indexOf("&nbsp;&nbsp;") > -1) {
  171. htmlStr = htmlStr.replace("&nbsp;&nbsp;", "&nbsp;");
  172. }
  173. ReArr.TextStr = htmlStr;
  174. return ReArr;
  175. };
  176. // 动态获取表格最小宽度设置(最小宽度165px)
  177. var GetMinTableVal = function (TSWidth) {
  178. if (TSWidth > 320) {
  179. return 165 + (TSWidth - 320) * 0.09;
  180. }
  181. else {
  182. return 165;
  183. }
  184. };
  185. // 计算存在padding的表格
  186. function GetPadVal(THandel) {
  187. // 判断是否存在border
  188. var BorderVal = 0;
  189. var BorderStr = $(THandel).css("border-right-width");
  190. if (BorderStr != null && BorderStr != "") {
  191. BorderVal = parseFloat(BorderStr.replace("px").replace("PX"));
  192. }
  193. BorderStr = $(THandel).css("border-right-width");
  194. if (BorderStr != null && BorderStr != "") {
  195. BorderVal += parseFloat(BorderStr.replace("px").replace("PX"));
  196. }
  197. // 判断是否存在padding
  198. var PaddingVal = $(THandel).css("padding");
  199. if (PaddingVal == null || PaddingVal == "") {
  200. PaddingVal = parseFloat($(THandel).css("padding-left")) + parseFloat($(THandel).css("padding-right"));
  201. if (PaddingVal == null || PaddingVal == "") {
  202. return BorderVal;
  203. }
  204. return BorderVal + PaddingVal;
  205. }
  206. var PadValArr = PaddingVal.split(" ");
  207. if (PadValArr.length > 2) {
  208. return BorderVal + parseFloat(PadValArr[1]) + parseFloat(PadValArr[3]);
  209. }
  210. else if (PadValArr.length > 1) {
  211. return BorderVal + parseFloat(PadValArr[1]) * 2;
  212. }
  213. else {
  214. return BorderVal + parseFloat(PadValArr[0]) * 2;
  215. }
  216. };
  217. // 处理表格内的图片宽度
  218. var DealImageWFunc = function (Item, WidthVal) {
  219. var pattWStr = new RegExp(/width\s?:\s?[0-9]+%;/ig);
  220. var pattWStr2 = new RegExp(/width\s?=\s?["|'|0-9]+%/ig);
  221. $.each($(Item).find("img").not(".nextpic"), function (index, iItem) {
  222. var HtmlStr = $(iItem).prop("outerHTML");
  223. var matchesWArr = HtmlStr.match(pattWStr);
  224. if (matchesWArr != null && matchesWArr.length > 0) {
  225. if (matchesWArr[0].indexOf("%") > -1) {
  226. var TWidthVal = parseFloat(matchesWArr[0].replace(/\s/g, "").replace("width:", ""));
  227. $(this).css("width", (WidthVal * TWidthVal / 100) + "px");
  228. }
  229. }
  230. var matchesWArr = HtmlStr.match(pattWStr2);
  231. if (matchesWArr != null && matchesWArr.length > 0) {
  232. if (matchesWArr[0].indexOf("%") > -1) {
  233. var TWidthVal = parseFloat(matchesWArr[0].replace(/\s/g, "").replace("\"", "").replace("width=", ""));
  234. $(this).css("width", (WidthVal * TWidthVal / 100) + "px");
  235. }
  236. }
  237. });
  238. };
  239. var AdjustTableFunc = function (sWidthVal, isAStatus) {
  240. if ($("table").length == 0) {
  241. return;
  242. }
  243. // 添加宽度处理
  244. var ScreenWidth = sWidthVal;
  245. var TempMinWidth = GetMinTableVal(ScreenWidth);
  246. $(document.body).append('<span id="pContrainId"></span>');
  247. $("table").find(".yaoshi").addClass("nextpic");
  248. $.each($("table"), function (index, item) {
  249. // 处理表格总宽度
  250. var ArrMaxLen = [];
  251. var TableWidth = 0;
  252. var TotalMaxLen = 0;
  253. var RuleFlag = true;
  254. var HasIndex = 0;
  255. RSArrs = [];
  256. var NewAStatus = (isAStatus == "undefined" || isAStatus == undefined || isAStatus == null) ? 0 : parseInt(isAStatus);
  257. if (NewAStatus == 1) {
  258. // 判断是否存在答题点
  259. NewAStatus = $(item).find(".yaoshi").length > 0 ? 1 : 0;
  260. }
  261. var CheckBoxFlag = $(item).find(".boxQue").length > 0 && $(item).find(".boxQue").length == $(item).find(".yaoshi").length; // 判断是否是只存在多选框,定位对应的列
  262. $.each($(item).find("tr"), function (trIndex, trItem) {
  263. $.each($(trItem).find("td"), function (tdIndex, tdItem) {
  264. var RowSpanNum = parseInt($(tdItem).attr("rowspan"));
  265. var ColSpanNum = parseInt($(tdItem).attr("colspan"));
  266. RowSpanNum = (RowSpanNum == 0 || isNaN(RowSpanNum)) ? 1 : RowSpanNum;
  267. ColSpanNum = (ColSpanNum == 0 || isNaN(ColSpanNum)) ? 1 : ColSpanNum;
  268. if (ColSpanNum > 1) {
  269. RuleFlag = false;
  270. }
  271. if (RowSpanNum > 1) {
  272. var RSArr = {
  273. RSIndex: HasIndex,
  274. RSNumber: RowSpanNum,
  275. RSXIndex: tdIndex,
  276. RSYIndex: trIndex
  277. };
  278. HasIndex += 1;
  279. RSArrs.push(RSArr);
  280. }
  281. var WidthVal = $(tdItem).css("width").replace("px", "");
  282. var RemoveHtmlArr = removeHtmlFunc($(tdItem).html(), WidthVal);
  283. // 附加处理图片宽度
  284. DealImageWFunc(trItem, WidthVal);
  285. $("#pContrainId").text(RemoveHtmlArr.TextStr);
  286. var tdWidthVal = $("#pContrainId").width() + parseFloat(RemoveHtmlArr.WidthVal); // 获取文字宽度
  287. tdWidthVal += GetPadVal($(tdItem)) + 10;
  288. if (!RemoveHtmlArr.ImgFlag && (tdWidthVal > ScreenWidth)) {
  289. tdWidthVal = ScreenWidth;
  290. }
  291. // 判断是否需要设置最小宽度
  292. if (tdWidthVal < TempMinWidth && NewAStatus == 1 && !CheckBoxFlag) {
  293. tdWidthVal = TempMinWidth;
  294. }
  295. if (tdWidthVal < 100 && NewAStatus == 1 && !CheckBoxFlag) {
  296. tdWidthVal = 100;
  297. }
  298. if (ArrMaxLen.length < tdIndex + 1) {
  299. ArrMaxLen.push(0);
  300. }
  301. if (RSArrs.length > 0) {
  302. for (var i = 0; i < RSArrs.length; i++) {
  303. if (RSArrs[i].RSNumber > 1 && RSArrs[i].RSYIndex == trIndex) {
  304. if (ArrMaxLen[tdIndex] < tdWidthVal && ColSpanNum == 1) {
  305. TotalMaxLen += tdWidthVal - ArrMaxLen[tdIndex];
  306. ArrMaxLen[tdIndex] = tdWidthVal;
  307. }
  308. }
  309. }
  310. }
  311. else {
  312. if (ArrMaxLen[tdIndex] < tdWidthVal && ColSpanNum == 1) {
  313. TotalMaxLen += tdWidthVal - ArrMaxLen[tdIndex];
  314. ArrMaxLen[tdIndex] = tdWidthVal;
  315. }
  316. }
  317. });
  318. for (var i = 0; i < RSArrs.length; i++) {
  319. if (RSArrs[i].RSNumber > 1) {
  320. RSArrs[i].RSNumber -= 1;
  321. }
  322. else {
  323. RSArrs.splice(i);
  324. }
  325. }
  326. });
  327. // 判断表格是否只有一行
  328. if ($(item).find("tr").length == 1 && $(item).find("td").length == 1) {
  329. $(item).find("tr").eq(0).find("td").eq(0).css("width", ScreenWidth + "px");
  330. $(item).css("width", ScreenWidth + "px");
  331. }
  332. else {
  333. if (TotalMaxLen < ScreenWidth) {
  334. var AddPx = (ScreenWidth - TotalMaxLen) / ArrMaxLen.length;
  335. AddPx = AddPx > 2 ? AddPx - 2 : AddPx;
  336. for (var i = 0; i < ArrMaxLen.length; i++) {
  337. ArrMaxLen[i] += AddPx;
  338. }
  339. }
  340. var OneFlag = false;
  341. for (var i = 0; i < ArrMaxLen.length; i++) {
  342. if (ArrMaxLen[i] != undefined && ($(item).find("td").length > 1 || $(item).find("tr").length > 1) && RuleFlag) {
  343. if (i < ArrMaxLen.length - 1) {
  344. $(item).find("tr").find("td").eq(i).css("width", ArrMaxLen[i] + "px");
  345. TableWidth += ArrMaxLen[i];
  346. }
  347. else {
  348. $(item).find("tr").find("td").eq(i).css("width", (ArrMaxLen[i] - 10) + "px");
  349. TableWidth += (ArrMaxLen[i] - 10);
  350. }
  351. }
  352. else if (ArrMaxLen[i] != undefined && $(item).find("tr").length == 1 && $(item).find("td").length == 1) {
  353. OneFlag = true;
  354. if (ArrMaxLen.length - 1 == i) {
  355. TableWidth += ArrMaxLen[i] - 10;
  356. }
  357. else {
  358. TableWidth += ArrMaxLen[i];
  359. }
  360. }
  361. }
  362. if (ArrMaxLen != undefined && ($(item).find("td").length > 1 || $(item).find("tr").length > 1) && !RuleFlag) {
  363. var TWAFlag = true;
  364. $.each($(item).find("tr"), function (trIndex, trItem) {
  365. if ($(trItem).find("td").length == ArrMaxLen.length) {
  366. $.each($(trItem).find("td"), function (tdIndex, tdItem) {
  367. if (TWAFlag) {
  368. TableWidth += ArrMaxLen[tdIndex];
  369. }
  370. $(tdItem).css("width", ArrMaxLen[tdIndex] + "px");
  371. });
  372. TWAFlag = false;
  373. }
  374. });
  375. }
  376. if (OneFlag) {
  377. $(item).find("tr").eq(0).find("td").eq(0).css("width", TableWidth + "px");
  378. }
  379. $(item).css("width", TableWidth + "px");
  380. }
  381. // 替换HTML
  382. var ChildhtmlStr = $(item).prop("outerHTML");
  383. var htmlStr = "<div class='TableContainer TContain_" + index + "' data-isaflag='" + NewAStatus + "' data-allcb='" + (CheckBoxFlag ? 1 : 0) + "'></div>";
  384. $(item).after(htmlStr);
  385. $(item).remove();
  386. var JqStr = ".TContain_" + index;
  387. $(JqStr).append(ChildhtmlStr);
  388. });
  389. var BodyWidth = isNaN(parseFloat(ScreenWidth)) ? 0 : parseFloat(ScreenWidth); // 界面宽度
  390. $.each($("table"), function (index, item) {
  391. var TableWidth = isNaN(parseFloat($(item).width())) ? 0 : parseFloat($(item).width()); // 表格宽度
  392. // 替换HTML
  393. var JqStr = ".TContain_" + index;
  394. $(JqStr).css("width", BodyWidth + "px");
  395. if (TableWidth > BodyWidth) {
  396. // 额外显示滚动条
  397. var ShtmlStr = "<div class='PSBar' style='width: " + BodyWidth + "px;'></div>";
  398. $(JqStr).after(ShtmlStr);
  399. var HiddenRate = BodyWidth / TableWidth; // 滚动条比率
  400. var HiddenWidth = BodyWidth - (TableWidth - BodyWidth) * HiddenRate; // 现滚动条大小
  401. var CShtmlStr = "<div class='CSBar' style='width: " + HiddenWidth + "px;'></div>";
  402. $(JqStr).next().append(CShtmlStr);
  403. }
  404. else {
  405. $(JqStr).css("margin-bottom", "15px");
  406. }
  407. });
  408. $.each($(".container-table"), function (index, item) {
  409. $(item).css("width", BodyWidth + "px");
  410. });
  411. // 滚动条事件
  412. $(".TableContainer").on("touchstart", function () {
  413. pressTableFlag = true;
  414. }).on("touchmove", function () {
  415. var TableWidth = isNaN(parseFloat($(this).find("table").width())) ? 0 : parseFloat($(this).find("table").width()); // 表格宽度
  416. var HiddenRate = BodyWidth / TableWidth; // 滚动条比率
  417. var SLeftWdith = isNaN(parseFloat($(this)[0].scrollLeft)) ? 0 : parseFloat($(this)[0].scrollLeft);
  418. SLeftWdith *= HiddenRate;
  419. var NextClsName = $(this).next().attr("class");
  420. if (NextClsName == "PSBar") {
  421. $(this).next().find(".CSBar").css("left", SLeftWdith + "px");
  422. }
  423. });
  424. window.addEventListener("scroll", function (event) {
  425. var ClsName = event.target.className;
  426. if (ClsName == undefined) {
  427. return;
  428. }
  429. ClsName = ClsName.replace("TableContainer ", ".");
  430. var TableWidth = isNaN(parseFloat($(ClsName).find("table").width())) ? 0 : parseFloat($(ClsName).find("table").width()); // 表格宽度
  431. var HiddenRate = BodyWidth / TableWidth; // 滚动条比率
  432. var SLeftWdith = isNaN(parseFloat($(ClsName)[0].scrollLeft)) ? 0 : parseFloat($(ClsName)[0].scrollLeft);
  433. SLeftWdith *= HiddenRate;
  434. var NextClsName = $(ClsName).next().attr("class");
  435. if (NextClsName == "PSBar") {
  436. $(ClsName).next().find(".CSBar").css("left", SLeftWdith + "px");
  437. }
  438. }, true);
  439. $("#pContrainId").remove();
  440. };
  441. // #endregion
  442. // 测试专用(移动端不需要引用)
  443. function AddTestTextFunc(DataStr3) {
  444. $("#ShowTStr").remove();
  445. var HtmlStr = '<div id="ShowTStr" style="width:200px;height:auto;background-color:yellow;color:#000;position:fixed;left:10px;top:100px;">DataStr3=》' + DataStr3 + '</div>';
  446. $(document.body).append(HtmlStr)
  447. }
  448. //#region 听力音频处理
  449. var LimitPreFlag = false; // 限制点击过宽
  450. var AddListenDiv = function (NodeHandle, NIndex, sWidthVal) {
  451. var UrlStr = $(NodeHandle).attr("alt");
  452. var ListenDivWidth = sWidthVal;
  453. ListenDivWidth = (ListenDivWidth > 414 ? 414 : ListenDivWidth);
  454. if (UrlStr != null && UrlStr.indexOf("|") > -1) {
  455. var UrlArr = UrlStr.split("|");
  456. var UrlArrLen = UrlArr.length;
  457. var htmlStr = '<div class="ListenDiv" data-status="1" style="width:' + ListenDivWidth + 'px;"><div class="LDivTop">';
  458. var MaxLeftVal = (ListenDivWidth - 295) / 2; // 自动调整宽度
  459. var selectIndex = 0;
  460. for (var i = 0; i < UrlArr.length; i++) {
  461. var SelectedN = (i == 0 ? 1 : 0);
  462. if (SelectedN) {
  463. selectIndex = i;
  464. }
  465. htmlStr += '<div class="LDivTItem LDivTItem_' + NIndex + ' LDivTItem_' + NIndex + '_' + i + '" data-selected="' + SelectedN + '" onclick="cLSourceFunc(' + NIndex + ',' + i + ')" data-auduourl="' + UrlArr[i] + '" style="margin-left:' + MaxLeftVal + 'px;">听力材料' + (i + 1) + '</div>';
  466. }
  467. htmlStr += '</div><div class="LDivFooter"><div class="LDFPlayS LDFPlayS_' + NIndex + '" data-playstatus="0" onclick="playMusicFunc(' + NIndex + ')"></div><div class="LDFPauseS LDFPauseS_' + NIndex + '" onclick="pauseMusicFunc(' + NIndex + ')"></div><div class="LDFProcS"><div class="LDFPWhite LDFPWhite_' + NIndex + '"></div><div class="LDFProcImg LDFProcImg_' + NIndex + '"></div></div><div class="LDFTimerS" data-mtype="' + cTTypeFunc + '" data-fsFlag="100" data-ismaflag="' + IsZTKEStatus + '"><span class="RunTime RunTime_' + NIndex + '">00:00</span><span>/</span><span class="RunAllTime RunAllTime_' + NIndex + '">00:00</span></div></div><div class="SImg SImg_' + NIndex + '" data-urlindex="' + selectIndex + '" data-urllen="' + UrlArrLen + '" data-mlval="' + MaxLeftVal + '"></div></div>';
  468. }
  469. else if (UrlStr != null) {
  470. var htmlStr = '<div class="ListenDiv" data-status="0" style="width:' + ListenDivWidth + 'px;"><div class="LDivTop" style="width:1px;height:0px;overflow:hidden;"><div class="LDivTItem LDivTItem_' + NIndex + ' LDivTItem_' + NIndex + '_0" data-selected="1" onclick="cLSourceFunc(' + NIndex + ',0)" data-selected="1" data-auduourl="' + UrlStr + '"></div></div><div class="LDivFooter"><div class="LDFPlayS LDFPlayS_' + NIndex + '" data-playstatus="0" onclick="playMusicFunc(' + NIndex + ')"></div><div class="LDFPauseS LDFPauseS_' + NIndex + '" onclick="pauseMusicFunc(' + NIndex + ')"></div><div class="LDFProcS"><div class="LDFPWhite LDFPWhite_' + NIndex + '"></div><div class="LDFProcImg LDFProcImg_' + NIndex + '"></div></div><div class="LDFTimerS" data-mtype="' + cTTypeFunc + '" data-fsFlag="100" data-ismaflag="' + IsZTKEStatus + '"><span class="RunTime RunTime_' + NIndex + '">00:00</span><span>/</span><span class="RunAllTime RunAllTime_' + NIndex + '">00:00</span></div></div></div>';
  471. }
  472. $(NodeHandle).css("width", "1px").css("height", "1px").css("overflow", "hidden").after(htmlStr);
  473. // 添加滑块事件
  474. $(".LDFProcImg")[NIndex].addEventListener("touchstart", TouchStartFunc, false);
  475. $(".LDFProcImg")[NIndex].addEventListener("touchmove", TouchMoveFunc, false);
  476. $(".LDFProcImg")[NIndex].addEventListener("touchend", TouchEndFunc, false);
  477. }
  478. // 切换听力材料
  479. var cLSourceFunc = function (iIndex, oIndex) {
  480. pauseMusicFunc(iIndex);
  481. var jQIStr = ".LDivTItem_" + iIndex;
  482. var jQIOStr = ".LDivTItem_" + iIndex + '_' + oIndex;
  483. $(jQIStr).attr("data-selected", 0);
  484. $(jQIOStr).attr("data-selected", 1);
  485. jQIStr = ".SImg_" + iIndex;
  486. //var dataUrlLen = $(jQIStr).attr("data-urllen");
  487. var LeftPx = 0;
  488. var MLValStr = $(jQIStr).attr("data-mlval");
  489. LeftPx = 50 + oIndex * (85 + parseInt(MLValStr));
  490. $(jQIStr).css("left", LeftPx + "px");
  491. }
  492. // 暂停播放处理
  493. var playMusicFunc = function (iIndex) {
  494. if (LimitPreFlag) {
  495. return;
  496. }
  497. else {
  498. LimitPreFlag = true;
  499. window.setTimeout(function () {
  500. LimitPreFlag = false;
  501. }, 500);
  502. }
  503. $(".select-answer").removeClass("select-answer");
  504. var jQStr = ".LDFPlayS_" + iIndex;
  505. var playStatus = $(jQStr).attr("data-playstatus"); // 检测当前状态,0表示暂停
  506. var AudioUrl = $(jQStr).parent().prev(".LDivTop").find(".LDivTItem[data-selected='1']").attr("data-auduourl");
  507. var AStatus = 0;
  508. if (playStatus == "0") {
  509. StopAllCss();
  510. $(jQStr).attr("data-playstatus", 1);
  511. AStatus = 1;
  512. }
  513. else {
  514. $(jQStr).attr("data-playstatus", 0);
  515. AStatus = 2;
  516. }
  517. var info = {
  518. Id: iIndex, // 第几个
  519. AudioUrl: AudioUrl, // 音频
  520. AStatus: AStatus, // 播放状态:0表示重置,1表示播放,2表示暂停
  521. }
  522. playVisiableAudioCallBack(1, JSON.stringify(info));
  523. }
  524. // 重置播放处理
  525. var pauseMusicFunc = function (iIndex) {
  526. $(".select-answer").removeClass("select-answer");
  527. var jQStr = ".LDFPlayS_" + iIndex;
  528. $(jQStr).attr("data-playstatus", 0);
  529. var jQStr = ".LDFPWhite_" + iIndex;
  530. var TTimeNum = parseInt($(jQStr).attr("data-alltime"));
  531. var AudioUrl = $(jQStr).parent().prev(".LDivTop").find(".LDivTItem[data-selected='1']").attr("data-auduourl");
  532. var info = {
  533. Id: iIndex, // 第几个
  534. AudioUrl: AudioUrl, // 音频
  535. AStatus: 0, // 播放状态:0表示重置,1表示播放,2表示暂停
  536. }
  537. playVisiableAudioCallBack(1, JSON.stringify(info));
  538. }
  539. // 设置滑块的位置
  540. var playImageFunc = function (iIndex, leftVal, allTimes) {
  541. var jQStr = ".LDFProcImg_" + iIndex;
  542. var PWidthVal = $(jQStr).parent().css("width");
  543. // 兼容单位
  544. var PUint = "";
  545. if (PWidthVal.indexOf("px") > -1) {
  546. PUint = "px";
  547. PWidthVal = PWidthVal.replace(PUint, "");
  548. }
  549. else if (PWidthVal.indexOf("pt") > -1) {
  550. PUint = "pt";
  551. PWidthVal = PWidthVal.replace(PUint, "");
  552. }
  553. else if (PWidthVal.indexOf("em") > -1) {
  554. PUint = "em";
  555. PWidthVal = PWidthVal.replace(PUint, "");
  556. }
  557. if (allTimes <= 0) {
  558. $(jQStr).css("left", "-15px"); // 设置滑块滚动
  559. jQStr = ".LDFPWhite_" + iIndex;
  560. $(jQStr).css("width", "0px").attr("data-ctime", "0").attr("data-alltime", "0"); // 白色背景
  561. jQStr = ".RunTime_" + iIndex;
  562. $(jQStr).text(timeToStrFunc(0)); // 设置文字显示
  563. jQStr = ".RunAllTime_" + iIndex;
  564. $(jQStr).text(timeToStrFunc(0)); // 设置文字显示
  565. }
  566. else {
  567. var LeftPx = (leftVal * parseFloat(PWidthVal)) / allTimes;
  568. $(jQStr).css("left", (LeftPx - 15) + PUint); // 设置滑块滚动
  569. jQStr = ".LDFPWhite_" + iIndex;
  570. $(jQStr).css("width", LeftPx + PUint).attr("data-ctime", leftVal).attr("data-alltime", allTimes); // 白色背景
  571. jQStr = ".RunTime_" + iIndex;
  572. $(jQStr).text(timeToStrFunc((leftVal / 1000))); // 设置文字显示
  573. jQStr = ".RunAllTime_" + iIndex;
  574. $(jQStr).text(timeToStrFunc((allTimes / 1000))); // 设置文字显示
  575. }
  576. };
  577. // 时间转换
  578. var timeToStrFunc = function (timerNumber) {
  579. timerNumber = Math.floor(timerNumber);
  580. var ReStr = "";
  581. var TempData = 0;
  582. if (isNaN(timerNumber) || timerNumber == "") {
  583. return "00:00";
  584. }
  585. if (timerNumber >= 3600) {
  586. TempData = Math.floor(timerNumber / 3600);
  587. timerNumber -= TempData * 3600;
  588. ReStr += (TempData < 10 ? ("0" + TempData) : TempData) + ":";
  589. }
  590. if (timerNumber >= 60) {
  591. var TempData = Math.floor(timerNumber / 60);
  592. timerNumber -= TempData * 60;
  593. ReStr += (TempData < 10 ? ("0" + TempData) : TempData) + ":";
  594. }
  595. else {
  596. ReStr += "00:";
  597. }
  598. if (timerNumber < 10) {
  599. ReStr += "0" + timerNumber;
  600. }
  601. else {
  602. ReStr += timerNumber;
  603. }
  604. return ReStr;
  605. };
  606. var TouchStartX = 0;
  607. var TouchMoveX = 0;
  608. var TouchIndex = -1; // 位置标识
  609. var TallTimeNum = 0; // 总时间
  610. var LeftTimeNum = 0; // 总时间
  611. var PWidthValNum = 0; // 总宽度
  612. // 滑块滑动控制(按下去)
  613. function TouchStartFunc(event) {
  614. TouchStartX = event.touches[0].pageX;
  615. TouchMoveX = TouchStartX;
  616. TouchIndex = parseInt($(event.target).attr("class").replace("LDFProcImg LDFProcImg_", ""));
  617. var jQStr = ".LDFPWhite_" + TouchIndex;
  618. TallTimeNum = parseInt($(jQStr).attr("data-alltime"));
  619. LeftTimeNum = parseInt($(".LDFPWhite_" + TouchIndex).attr("data-ctime"));
  620. PWidthValNum = parseFloat($(jQStr).parent().css("width")); // 总宽度
  621. if (TallTimeNum > 0) {
  622. mobileTSFunc(TouchIndex);
  623. }
  624. }
  625. // 滑块滑动
  626. function TouchMoveFunc(event) {
  627. TouchMoveX = event.touches[0].pageX;
  628. TouchMoveY = event.touches[0].pageY;
  629. var TLeftTimeNumber = Math.ceil(TallTimeNum * Math.abs(TouchMoveX - TouchStartX) / PWidthValNum);
  630. if (TouchStartX > TouchMoveX) {
  631. // 左移
  632. if ((LeftTimeNum - TLeftTimeNumber) < 0) {
  633. TLeftTimeNumber = 0;
  634. }
  635. else {
  636. TLeftTimeNumber = LeftTimeNum - TLeftTimeNumber;
  637. }
  638. playImageFunc(TouchIndex, TLeftTimeNumber, TallTimeNum);
  639. }
  640. else {
  641. // 右移
  642. if ((LeftTimeNum + TLeftTimeNumber) > TallTimeNum) {
  643. TLeftTimeNumber = TallTimeNum;
  644. }
  645. else {
  646. TLeftTimeNumber = LeftTimeNum + TLeftTimeNumber;
  647. }
  648. playImageFunc(TouchIndex, TLeftTimeNumber, TallTimeNum);
  649. }
  650. }
  651. // 滑块滑动控制(抬起来)
  652. function TouchEndFunc(event) {
  653. mobileTEFunc(TouchIndex);
  654. }
  655. //#endregion
  656. // #region 高亮揭露学生答案处理
  657. // 答题点:处理暂不显示高亮(答题点下禁止点击弹出窗口)
  658. function dealNotShowFill() {
  659. $.each($(".phraseStyle,.sentenceStyle,.wordStyle"), function (index, iItem) {
  660. // 答题点判断
  661. if ($(this).find(".answer-point-range").length > 0) {
  662. $.each($(this).find(".answer-point-range"), function () {
  663. var HiddenFlag = ($(this).css("display") == 'inline-block') || (IsStuFills.StuID && IsStuFills.ProcessType != 2);
  664. if (HiddenFlag) {
  665. var iItemClsName = $(iItem).attr("class");
  666. if (iItemClsName != null && iItemClsName.indexOf("wordStyle") > -1) {
  667. $(iItem).attr("data-setstatus", "0").attr("data-lstatus", "1");
  668. }
  669. else if (iItemClsName != null && iItemClsName.indexOf("phraseStyle") > -1) {
  670. $(iItem).attr("data-setstatus", "0").attr("data-lstatus", "2");
  671. }
  672. else if (iItemClsName != null && iItemClsName.indexOf("sentenceStyle") > -1) {
  673. $(iItem).attr("data-setstatus", "0").attr("data-lstatus", "3");
  674. $(iItem).prev(".sentImagcs").attr("data-setstatus", "0").attr("data-lstatus", "3");
  675. }
  676. }
  677. });
  678. }
  679. // 作答详情判断$(".answer-text")
  680. if ($(this).find(".answer-text").length > 0) {
  681. $.each($(this).find(".answer-text"), function () {
  682. var HiddenFlag = ($(this).css("display") == 'inline' && $(this).attr("data-astatus") == '0') || (IsStuFills.StuID && IsStuFills.ProcessType != 2);
  683. if (HiddenFlag) {
  684. var iItemClsName = $(iItem).attr("class");
  685. if (iItemClsName != null && iItemClsName.indexOf("wordStyle") > -1) {
  686. $(iItem).attr("data-setstatus", "0").attr("data-lstatus", "1");
  687. }
  688. else if (iItemClsName != null && iItemClsName.indexOf("phraseStyle") > -1) {
  689. $(iItem).attr("data-setstatus", "0").attr("data-lstatus", "2");
  690. }
  691. else if (iItemClsName != null && iItemClsName.indexOf("sentenceStyle") > -1) {
  692. $(iItem).attr("data-setstatus", "0").attr("data-lstatus", "3");
  693. $(iItem).prev(".sentImagcs").attr("data-setstatus", "0").attr("data-lstatus", "3");
  694. }
  695. }
  696. });
  697. }
  698. });
  699. $.each($(".yaoshi"), function (index, item) {
  700. var dataStatus = ($(this).attr("data-status") == "1") ? true : false;
  701. dealRecvHSFill(item, dataStatus);
  702. });
  703. }
  704. // 专门处理外套规则(如:phraseStyle/sentenceStyle/wordStyle套underlineContent),目前只做图片处理
  705. function dealNSFillFunc() {
  706. $.each($(".sentenceStyle"), function (index, iItem) {
  707. var HiddenFlag = true;
  708. $.each($(iItem).children(), function (ondex, oItem) {
  709. var TextVal = $(oItem).text();
  710. // 删除自添加样式
  711. if ($(oItem).find(".answer-audio-range").css("display") == "none") {
  712. TextVal = TextVal.replace($(oItem).find(".answer-audio-range").text(), "");
  713. }
  714. if ($(oItem).find(".answer-point-range").css("display") == "none") {
  715. TextVal = TextVal.replace($(oItem).find(".answer-point-range").text(), "");
  716. }
  717. if (TextVal != undefined && TextVal != null && TextVal != "") {
  718. HiddenFlag = false;
  719. }
  720. });
  721. if (HiddenFlag) {
  722. $(this).prev(".sentImagcs").attr("data-setstatus", "0");
  723. $(this).attr("data-setstatus", "0");
  724. }
  725. });
  726. }
  727. // 恢复已禁止显示高亮处理的点击限制处理(主要是答案回显的时候从答题点变成非答题点的调整)
  728. function dealRecvShowFill() {
  729. $.each($(".phraseStyle[data-lstatus='2']"), function () {
  730. if ($(this).find(".underlineContent").attr("showflag") == "1") {
  731. $(this).attr("data-lstatus", "2");
  732. }
  733. else {
  734. $(this).attr("data-lstatus", "0");
  735. }
  736. });
  737. $.each($(".sentenceStyle[data-lstatus='3']"), function () {
  738. if ($(this).find(".underlineContent").attr("showflag") == "1") {
  739. $(this).attr("data-lstatus", "3");
  740. $(this).prev(".sentImagcs").attr("data-lstatus", "3");
  741. }
  742. else {
  743. $(this).attr("data-lstatus", "0");
  744. $(this).prev(".sentImagcs").attr("data-lstatus", "0");
  745. }
  746. });
  747. $.each($(".wordStyle[data-lstatus='1']"), function () {
  748. if ($(this).attr("showflag") == "1") {
  749. $(this).attr("data-lstatus", "0");
  750. }
  751. else {
  752. $(this).attr("data-lstatus", "1");
  753. }
  754. });
  755. }
  756. // 渲染句型套句型情况
  757. function dealJXQTFunc() {
  758. $(".phraseStyle").attr("data-rsstatus", "0");
  759. $.each($(".phraseStyle[data-setstatus='1']"), function () {
  760. if ($(this).find(".phraseStyle[data-setstatus='1']").length > 0) {
  761. $(this).find(".phraseStyle[data-setstatus='1']").attr("data-rsstatus", "1");
  762. }
  763. });
  764. }
  765. // 重新定位可显示高亮(单个),item是根据钥匙undercontentline传递进来的
  766. // 只是卡控全部隐藏的显示不出来
  767. function dealRecvHSFill(NodeHandle, sHFlag) {
  768. var aSID = $(NodeHandle).attr("answer-id");
  769. if (sHFlag) {
  770. $.each($(".wordStyle"), function (index, item) {
  771. var JQstr = ".underlineContent[asid='" + aSID + "']";
  772. var dRHSFFuncStatus = $(item).attr("data-drhsffunc");
  773. var ShowHFlag = (fillDataNum == 1 ? true : (fillDataNum == 3 ? true : (fillDataNum == 5 ? true : (fillDataNum == 7 ? true : false))));
  774. if ($(this).find(JQstr).length > 0 && dRHSFFuncStatus == "1" && ShowHFlag) {
  775. $(this).attr("data-setstatus", "1").attr("data-lstatus", "0");
  776. $(this).attr("data-drhsffunc", "0");
  777. }
  778. });
  779. $.each($(".phraseStyle"), function (index, item) {
  780. var JQstr = ".underlineContent[asid='" + aSID + "']";
  781. var dRHSFFuncStatus = $(item).attr("data-drhsffunc");
  782. var ShowHFlag = (fillDataNum == 2 ? true : (fillDataNum == 6 ? true : (fillDataNum == 7 ? true : false)));
  783. if ($(this).find(JQstr).length > 0 && dRHSFFuncStatus == "1" && ShowHFlag) {
  784. $(this).attr("data-setstatus", "1").attr("data-lstatus", "0");
  785. $(this).attr("data-drhsffunc", "0");
  786. }
  787. });
  788. $.each($(".sentenceStyle"), function (index, item) {
  789. var JQstr = ".underlineContent[asid='" + aSID + "']";
  790. var dRHSFFuncStatus = $(item).attr("data-drhsffunc");
  791. var ShowHFlag = (fillDataNum == 4 ? true : (fillDataNum == 5 ? true : (fillDataNum == 6 ? true : (fillDataNum == 7 ? true : false))));
  792. if ($(this).find(JQstr).length > 0 && dRHSFFuncStatus == "1" && ShowHFlag) {
  793. $(this).attr("data-setstatus", "1").attr("data-lstatus", "0").attr("data-drhsffunc", "0");
  794. $(this).prev(".sentImagcs").attr("data-setstatus", "1").attr("data-lstatus", "0");
  795. $(this).attr("data-drhsffunc", "0");
  796. $(this).prev(".sentImagcs").attr("data-drhsffunc", "0");
  797. }
  798. });
  799. // 对应的underlineContent子标签必须显示
  800. var JQstr = ".underlineContent[asid='" + aSID + "']";
  801. var ShowHFlag = (fillDataNum == 1 ? true : (fillDataNum == 3 ? true : (fillDataNum == 5 ? true : (fillDataNum == 7 ? true : false))));
  802. if (ShowHFlag) {
  803. $(JQstr).find(".wordStyle").attr("data-setstatus", "1").attr("data-lstatus", "0").attr("data-drhsffunc", "0");
  804. }
  805. ShowHFlag = (fillDataNum == 2 ? true : (fillDataNum == 6 ? true : (fillDataNum == 7 ? true : false)));
  806. if (ShowHFlag) {
  807. $(JQstr).find(".phraseStyle").attr("data-setstatus", "1").attr("data-lstatus", "0").attr("data-drhsffunc", "0");
  808. }
  809. ShowHFlag = (fillDataNum == 4 ? true : (fillDataNum == 5 ? true : (fillDataNum == 6 ? true : (fillDataNum == 7 ? true : false))));
  810. if (ShowHFlag) {
  811. $(JQstr).find(".sentenceStyle,.sentImagcs").attr("data-setstatus", "1").attr("data-lstatus", "0").attr("data-drhsffunc", "0");
  812. }
  813. }
  814. else {
  815. $.each($(".wordStyle"), function (index, item) {
  816. if ($(this).find(".underlineContent").length > 0) {
  817. var JQstr = ".underlineContent[asid='" + aSID + "'][showflag='1']";
  818. // 判断高亮的内容是否全部都已经隐藏(不是那么准确)
  819. var TagValF = $(item).text();
  820. if (TagValF != undefined && TagValF != "") {
  821. $.each($(item).find(JQstr), function (iIndex, iItem) {
  822. var TagValT = $(iItem).text();
  823. if (TagValF.indexOf(TagValT) > -1) {
  824. TagValF = TagValF.replace(TagValF, "");
  825. }
  826. });
  827. }
  828. TagValF = TagValF.replace(/\s/g, "");
  829. if (TagValF == "") {
  830. $(item).attr("data-setstatus", "0").attr("data-lstatus", "1").attr("data-drhsffunc", "1");
  831. }
  832. }
  833. });
  834. $.each($(".phraseStyle"), function (index, item) {
  835. if ($(this).find(".underlineContent").length > 0) {
  836. var JQstr = ".underlineContent[asid='" + aSID + "']";
  837. // 判断高亮的内容是否全部都已经隐藏(不是那么准确)
  838. var TagValF = $(item).text();
  839. if (TagValF != undefined && TagValF != "") {
  840. $.each($(item).find(JQstr), function (iIndex, iItem) {
  841. var TShowFlag = ($(iItem).attr("showflag") == undefined || ($(iItem).attr("showflag") != undefined && $(iItem).attr("showflag") == "0")) ? true : false; // 判断是否隐藏
  842. if (TShowFlag) {
  843. var TagValT = $(iItem).text();
  844. if (TagValF.indexOf(TagValT) > -1) {
  845. TagValF = TagValF.replace(TagValT, "");
  846. }
  847. }
  848. });
  849. }
  850. TagValF = TagValF.replace(/\s/g, "");
  851. if (TagValF == "") {
  852. $(item).attr("data-setstatus", "0").attr("data-lstatus", "2").attr("data-drhsffunc", "1");
  853. }
  854. }
  855. });
  856. $.each($(".sentenceStyle"), function (index, item) {
  857. if ($(this).find(".underlineContent").length > 0) {
  858. var JQstr = ".underlineContent[asid='" + aSID + "']";
  859. // 判断高亮的内容是否全部都已经隐藏(不是那么准确)
  860. var TagValF = $(item).text();
  861. if (TagValF != undefined && TagValF != "") {
  862. $.each($(item).find(JQstr), function (iIndex, iItem) {
  863. var TShowFlag = ($(iItem).attr("showflag") == undefined || ($(iItem).attr("showflag") != undefined && $(iItem).attr("showflag") == "0")) ? true : false; // 判断是否隐藏
  864. if (TShowFlag) {
  865. var TagValT = $(iItem).text();
  866. if (TagValF.indexOf(TagValT) > -1) {
  867. TagValF = TagValF.replace(TagValT, "");
  868. }
  869. }
  870. });
  871. }
  872. TagValF = TagValF.replace(/\s/g, "");
  873. if (TagValF == "") {
  874. $(item).attr("data-setstatus", "0").attr("data-lstatus", "3").attr("data-drhsffunc", "1");
  875. $(item).prev(".sentImagcs").attr("data-setstatus", "0").attr("data-lstatus", "3").attr("data-drhsffunc", "1");
  876. }
  877. }
  878. });
  879. // 对应的underlineContent子标签必须隐藏
  880. var JQstr = ".underlineContent[asid='" + aSID + "']";
  881. $(JQstr).find(".wordStyle").attr("data-setstatus", "0").attr("data-lstatus", "1").attr("data-drhsffunc", "1");
  882. $(JQstr).find(".phraseStyle").attr("data-setstatus", "0").attr("data-lstatus", "2").attr("data-drhsffunc", "1");
  883. $(JQstr).find(".sentenceStyle,.sentImagcs").attr("data-setstatus", "0").attr("data-lstatus", "3").attr("data-drhsffunc", "1");
  884. }
  885. }
  886. // #endregion
  887. // 点击事件样式渲染
  888. var ClickRecFunc = function (pID) {
  889. $(".answer-body").removeClass("select-answer");
  890. var jqStr = ".answer-body[parent-anid='" + pID + "']";
  891. $(jqStr).addClass("select-answer");
  892. if ($(jqStr).attr("data-astatus") == "1") {
  893. var curObj = new Object();
  894. curObj.Id = $(jqStr).attr("answer-id");//答题点ID
  895. curObj.pId = $(jqStr).attr("parent-anid");//答题点ID
  896. curObj.IsKY = $(jqStr).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  897. curObj.AnsText = $(jqStr).attr("answer-anstext");//参考答案
  898. onClickAnswerPoint(JSON.stringify(curObj));
  899. }
  900. };
  901. // 未当前yaoshi的img对应的答题点打上标签
  902. //shcode是否可点击1可点击;ulflag判断是否存在横线内1表示在;showflag是否显示1显示
  903. function AddStatusFunc(NodeHandle, answerID) {
  904. var uLCClsName = $(NodeHandle).attr("class");
  905. var pItem = $(NodeHandle).parent();
  906. if (uLCClsName != undefined && uLCClsName.indexOf("underlineContent") > -1 && uLCClsName.indexOf("noKey") == -1) {
  907. // 直接等于
  908. $(NodeHandle).attr("asid", answerID).attr("shcode", "1").attr("ulflag", "1").attr("showflag", "1");
  909. $.each($(NodeHandle).find("span,p,u,b"), function (index, element) {
  910. $(element).attr("asid", answerID).attr("shcode", "1").attr("ulflag", "1").attr("showflag", "1");
  911. });
  912. }
  913. else if (uLCClsName != undefined && uLCClsName.indexOf("yaoshi") > -1) {
  914. // 到了下一个钥匙
  915. return;
  916. }
  917. else if ($(NodeHandle).find(".yaoshi").length > 0 || $(NodeHandle).find(".underlineContent").length > 0) {
  918. // 存在下个标签
  919. if ($(NodeHandle).find(".yaoshi").length > 0) {
  920. return AddStatusFunc($(NodeHandle).children(":first"), answerID);
  921. }
  922. else {
  923. // 查找子节点的underlineContent
  924. $.each($(NodeHandle).find(".underlineContent").not(".noKey"), function (iIndex, iItem) {
  925. $(this).attr("asid", answerID).attr("shcode", "1").attr("ulflag", "1").attr("showflag", "1");
  926. $.each($(iItem).find("span,p,u,b"), function () {
  927. $(this).attr("asid", answerID).attr("shcode", "1").attr("ulflag", "1").attr("showflag", "1");
  928. });
  929. });
  930. }
  931. }
  932. if ($(NodeHandle).next().length > 0) {
  933. return AddStatusFunc($(NodeHandle).next(), answerID);
  934. }
  935. else {
  936. if (pItem[0] == undefined || pItem[0].tagName.toUpperCase() == "BODY") {
  937. return;
  938. }
  939. else {
  940. return AddStatusFunc(pItem.next(), answerID);
  941. }
  942. }
  943. }
  944. // 不调用fill需要增加处理(绑定横线内处理)
  945. var addFillAssist = function () {
  946. $.each($(".yaoshi"), function (index, element) {
  947. var answerID = $(element).attr("answer-id");
  948. if ($(this).next().length > 0) {
  949. AddStatusFunc($(this).next(), answerID);
  950. }
  951. else {
  952. AddStatusFunc($(this).parent().next(), answerID);
  953. }
  954. });
  955. };
  956. // 处理显示或隐藏答案,(shcode是否可点击1可点击;ulflag判断是否存在横线内1表示在;showflag是否显示1显示)
  957. var dealAnswerFunc = function (NodeHandle) {
  958. // 获取当前钥匙的状态
  959. var showFlag = $(NodeHandle).attr("data-status");
  960. var answerID = $(NodeHandle).attr("answer-id");
  961. var JQStr = "span[asid='" + answerID + "'],p[asid='" + answerID + "'],u[asid='" + answerID + "'],b[asid='" + answerID + "']";
  962. if (showFlag == "0") {
  963. // 由显示转换为隐藏
  964. $(JQStr).attr("showflag", "0");
  965. // 重新渲染高亮
  966. dealRecvHSFill($(NodeHandle), false);
  967. }
  968. else if (showFlag == "1") {
  969. // 由隐藏转换为显示
  970. $(JQStr).attr("showflag", "1");
  971. // 重新渲染高亮
  972. dealRecvHSFill($(NodeHandle), true);
  973. }
  974. var underlineContentText = $(NodeHandle).text(); // 获取文本内容
  975. if (underlineContentText != undefined && underlineContentText.indexOf("√") > -1) {
  976. if (showFlag == "1") {
  977. $(NodeHandle).parent().find(".checkbox").find("input").prop('checked', true);
  978. }
  979. else {
  980. $(NodeHandle).parent().find(".checkbox").find("input").prop('checked', false);
  981. }
  982. }
  983. };
  984. //显示、隐藏钥匙及答案 isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  985. function showHideAnswerEx(isShowYX, isShowAS) {
  986. if (isShowYX) {
  987. $(".yaoshi").show();
  988. }
  989. else {
  990. $(".yaoshi").hide();
  991. // 视听说学生端原文、传统教材都是没有钥匙的(直接隐藏掉)
  992. $(".underlineContent").find("*[showflag='1']").attr("showflag", "0");
  993. //var JQStr = "*[showflag='1']";
  994. //$(JQStr).attr("showflag", "0");
  995. $(".checkbox").find("input").prop('checked', false);
  996. }
  997. if (isShowAS) {
  998. $(".yaoshi").attr("data-status", "1");
  999. $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
  1000. $.each($(".yaoshi"), function (index, item) {
  1001. dealAnswerFunc(item);
  1002. });
  1003. }
  1004. else {
  1005. $(".yaoshi").attr("data-status", "0");
  1006. $(".yaoshi").attr("src", PicInfo.yaoshiHideImgUrl);
  1007. $.each($(".yaoshi"), function (index, item) {
  1008. dealAnswerFunc(item);
  1009. });
  1010. }
  1011. dealJXQTFunc();
  1012. dealNSFillFunc();
  1013. }
  1014. //页面加载完,原文 绑定事件(sWidthVal:屏幕宽度,isAStatus是否含有作答0表示没有,isMAStatus判断是否是主体课文1表示是)
  1015. function bindEventTeaOrignalYS(sWidthVal, isAStatus, isMAStatus) {
  1016. IsZTKEStatus = (isMAStatus == "undefined" || isMAStatus == undefined || isMAStatus == null) ? 0 : parseInt(isMAStatus);
  1017. var bodyWidth = $(document.body).width();
  1018. // 处理文本
  1019. dealUnderLineFunc();
  1020. //处理答题点
  1021. $.each($(".yaoshi"), function (index, item) {
  1022. $(item).attr('answer-id', index).attr("data-status", "1");
  1023. });
  1024. //给音频绑定一个ID
  1025. $.each($(".audioImg"), function (index, item) {
  1026. $(item).attr("audiourl", "");
  1027. $(item).attr('audio-id', index);
  1028. });
  1029. //给视频图标处理
  1030. $.each($(".videoImg"), function (index, item) {
  1031. $(item).attr("audiourl", "");
  1032. });
  1033. //给口语图标处理
  1034. $.each($(".oralLanguageImg"), function (index, item) {
  1035. $(item).attr("audiourl", "");
  1036. });
  1037. //处理参考答案
  1038. $.each($(".underlineContent"), function (index, item) {
  1039. $(item).attr("answer-anstext", $(item).html());
  1040. });
  1041. //去除多余的U空标签
  1042. $.each($("u"), function (index, item) {
  1043. var text = $(item).text();
  1044. text = text.replace(/\s+/g, "");
  1045. if (text == "") {
  1046. $(item).remove();
  1047. }
  1048. });
  1049. //处理暂无参考答案
  1050. $.each($(".yaoshi"), function (index, item) {
  1051. var parent = $(item).parent();
  1052. var prev = $(item).nextUntil(".yaoshi").filter(".underlineContent");
  1053. var prevF = $(item).nextUntil(".yaoshi").find(".underlineContent");
  1054. if (isHasAnswerFunc($(item).next())) {
  1055. var spanHtml = document.createElement("span");
  1056. //添加子节点
  1057. var uHtml = document.createElement("u");
  1058. uHtml.className = "underlineContent no-answer";
  1059. uHtml.innerText = "暂无参考答案";
  1060. //处理改错题及勾选题
  1061. if ($(parent)[0].tagName == 'P') {
  1062. if ($(parent).hasClass('correntQue') || $(parent).hasClass('boxQue')) {
  1063. uHtml.innerHTML = "&nbsp;&nbsp;&nbsp;";
  1064. //改错题,要随机下划线长度
  1065. if ($(parent).hasClass('correntQue')) {
  1066. uHtml.style = "width:" + randomNum(220, 300) + "px;display:inline-block;height: 22px;";
  1067. }
  1068. else {
  1069. uHtml.style = "width:10px;display:inline-block;";
  1070. }
  1071. uHtml.setAttribute("answer-anstext", "");
  1072. }
  1073. }
  1074. $(spanHtml).html(uHtml.outerHTML);
  1075. $(item).after(spanHtml);
  1076. }
  1077. });
  1078. //处理表格宽度
  1079. AdjustTableFunc(sWidthVal, isAStatus);
  1080. // 音频处理
  1081. if (TestFlag) {
  1082. $.each($(".audioImg"), function (index, element) {
  1083. AddListenDiv(element, index, sWidthVal);
  1084. });
  1085. }
  1086. //一题多空的答题点标注
  1087. var checkId = 0;
  1088. var headid = -1;
  1089. var groupId = -1;
  1090. $(".multipleStart").each(function (i, item) {
  1091. var $startNode = $(item);
  1092. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  1093. checkId = $(item).find('.yaoshi').attr("answer-id");
  1094. var gid = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
  1095. if (index == 0 || groupId != gid) {
  1096. groupId = gid;
  1097. headid = checkId;
  1098. }
  1099. $(item).find('.yaoshi').attr('parent-anid', headid);
  1100. });
  1101. });
  1102. //点击喇叭事件,音频播放
  1103. $(".audioImg").on("click", function () {
  1104. audioPlayClick(this);
  1105. });
  1106. //显示/隐藏习题答案
  1107. $(".yaoshi").on("click", function () {
  1108. var parentAnid = $(this).attr("parent-anid");
  1109. var curDisplay = $(this).nextUntil(".yaoshi").find(".underlineContent").eq(0).css("display");
  1110. if (curDisplay == "undefined" || curDisplay == undefined) return;
  1111. if (curDisplay == "none" || $(this).attr("data-status") == "0") {
  1112. if (parentAnid != undefined) {
  1113. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, item) {
  1114. $(item).attr("data-status", "1");
  1115. $(item).attr("src", PicInfo.yaoshiShowImgUrl);
  1116. dealAnswerFunc(item);
  1117. });
  1118. }
  1119. else {
  1120. $(this).attr("data-status", "1");
  1121. $(this).attr("src", PicInfo.yaoshiShowImgUrl);
  1122. dealAnswerFunc(this);
  1123. }
  1124. //不再存在已隐藏的钥匙,移动端回调
  1125. if ($(".yaoshi[data-status='0']").length == 0) {
  1126. //添加回调
  1127. console.log("全部显示了");
  1128. onClickKeyShow();
  1129. }
  1130. }
  1131. else {
  1132. if (parentAnid != undefined) {
  1133. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, item) {
  1134. $(item).attr("data-status", "0");
  1135. $(item).attr("src", PicInfo.yaoshiHideImgUrl);
  1136. dealAnswerFunc($(item));
  1137. });
  1138. }
  1139. else {
  1140. $(this).attr("data-status", "0");
  1141. $(this).attr("src", PicInfo.yaoshiHideImgUrl);
  1142. dealAnswerFunc($(this));
  1143. }
  1144. //添加回调
  1145. onClickKeyHide();
  1146. }
  1147. });
  1148. //点击播放事件,视频播放
  1149. $(".videoImg").on("click", function () {
  1150. $(".select-answer").removeClass("select-answer");
  1151. var curHtml = $(this).parent().find(".videoUrl").html();
  1152. var curAlt = $(this).attr("alt");//播放视频地址
  1153. playVisiableAudioCallBack(2, $(this).attr("alt"));
  1154. });
  1155. addFillAssist();
  1156. }
  1157. //页面加载完,课件 绑定事件(sWidthVal:屏幕宽度,isAStatus是否含有作答0表示没有,isMAStatus判断是否是主体课文1表示是)
  1158. function bindEventYS(sWidthVal, isAStatus, isMAStatus) {
  1159. IsZTKEStatus = (isMAStatus == "undefined" || isMAStatus == undefined || isMAStatus == null) ? 0 : parseInt(isMAStatus);
  1160. var bodyWidth = $(document.body).width();
  1161. //不存在underline 属性下有内容,所以全部隐藏,若有就是源头数据有问题
  1162. $('.underline').css("display", "none");
  1163. // 处理文本
  1164. dealUnderLineFunc();
  1165. $.each($(".yaoshi"), function (index, item) {
  1166. $(item).attr('answer-id', index).attr("data-status", "1");
  1167. });
  1168. //给音频绑定一个ID
  1169. $.each($(".audioImg"), function (index, item) {
  1170. $(item).attr("audiourl", "");
  1171. $(item).attr('audio-id', index);
  1172. });
  1173. //给视频图标处理
  1174. $.each($(".videoImg"), function (index, item) {
  1175. $(item).attr("audiourl", "");
  1176. });
  1177. //给口语图标处理
  1178. $.each($(".oralLanguageImg"), function (index, item) {
  1179. $(item).attr("audiourl", "");
  1180. });
  1181. //去除多余的U空标签
  1182. $.each($("u"), function (index, item) {
  1183. var text = $(item).text();
  1184. text = text.replace(/\s+/g, "");
  1185. if (text == "") {
  1186. $(item).remove();
  1187. }
  1188. });
  1189. //处理暂无参考答案
  1190. $.each($(".yaoshi"), function (index, item) {
  1191. var parent = $(item).parent();
  1192. var prev = $(item).nextAll(".underlineContent");
  1193. if (isHasAnswerFunc($(item).next())) {
  1194. var uHtml = document.createElement("u");
  1195. uHtml.className = "underlineContent no-answer";
  1196. uHtml.innerText = "暂无参考答案";
  1197. //处理改错题及勾选题
  1198. if ($(parent)[0].tagName == 'P') {
  1199. if ($(parent).hasClass('correntQue') || $(parent).hasClass('boxQue')) {
  1200. uHtml.innerHTML = "&nbsp;&nbsp;&nbsp;";
  1201. //改错题,要随机下划线长度
  1202. if ($(parent).hasClass('correntQue')) {
  1203. uHtml.style = "width:" + randomNum(220, 300) + "px;display:inline-block;height: 22px;";
  1204. }
  1205. else {
  1206. uHtml.style = "width:10px;display:inline-block;";
  1207. }
  1208. uHtml.setAttribute("answer-anstext", "");
  1209. }
  1210. }
  1211. $(item).after(uHtml);
  1212. }
  1213. });
  1214. //处理表格宽度
  1215. AdjustTableFunc(sWidthVal, isAStatus);
  1216. // 音频处理
  1217. if (TestFlag) {
  1218. $.each($(".audioImg"), function (index, element) {
  1219. AddListenDiv(element, index, sWidthVal);
  1220. });
  1221. }
  1222. //一题多空的答题点标注
  1223. var checkId = 0;
  1224. var headid = -1;
  1225. var groupId = -1;
  1226. $(".multipleStart").each(function (i, item) {
  1227. var $startNode = $(item);
  1228. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  1229. checkId = $(item).find('.yaoshi').attr("answer-id");
  1230. var gid = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
  1231. if (index == 0 || groupId != gid) {
  1232. groupId = gid;
  1233. headid = checkId;
  1234. }
  1235. $(item).find('.yaoshi').attr('parent-anid', headid);
  1236. });
  1237. });
  1238. //显示/隐藏习题答案
  1239. $(".yaoshi").on("click", function () {
  1240. var parentAnid = $(this).attr("parent-anid");
  1241. if ($(this).attr("data-status") == "0") {
  1242. // 显示处理
  1243. if (parentAnid != undefined) {
  1244. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, fItem) {
  1245. $(fItem).attr("data-status", "1");
  1246. $(fItem).attr("src", PicInfo.yaoshiShowImgUrl);
  1247. dealAnswerFunc($(fItem));
  1248. });
  1249. }
  1250. else {
  1251. $(this).attr("data-status", "1");
  1252. $(this).attr("src", PicInfo.yaoshiShowImgUrl);
  1253. dealAnswerFunc($(this));
  1254. }
  1255. //不再存在已隐藏的钥匙,移动端回调
  1256. if ($(".yaoshi[data-status='0']").length == 0) {
  1257. //添加回调
  1258. onClickKeyShow();
  1259. }
  1260. }
  1261. else {
  1262. // 隐藏处理
  1263. if (parentAnid != undefined) {
  1264. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, fItem) {
  1265. $(fItem).attr("data-status", "0");
  1266. $(fItem).attr("src", PicInfo.yaoshiHideImgUrl);
  1267. dealAnswerFunc($(fItem));
  1268. });
  1269. }
  1270. else {
  1271. $(this).attr("data-status", "0");
  1272. $(this).attr("src", PicInfo.yaoshiHideImgUrl);
  1273. dealAnswerFunc($(this));
  1274. }
  1275. //添加回调
  1276. onClickKeyHide();
  1277. }
  1278. });
  1279. //点击喇叭事件,音频播放
  1280. $(".audioImg").on("click", function () {
  1281. audioPlayClick(this);
  1282. });
  1283. //点击播放事件,视频播放
  1284. $(".videoImg").on("click", function () {
  1285. $(".select-answer").removeClass("select-answer");
  1286. $(this).attr("audiourl", "");
  1287. var curHtml = $(this).parent().find(".videoUrl").html();
  1288. var curAlt = $(this).attr("alt");//播放视频地址
  1289. playVisiableAudioCallBack(2, $(this).attr("alt"));
  1290. });
  1291. }
  1292. // 移动端使用,true:表示点击表格且正在移动,需阻止模块切换
  1293. function getPressFlag() {
  1294. return pressTableFlag;
  1295. }
  1296. // 设置离焦事件
  1297. function resetPressFlag() {
  1298. pressTableFlag = false;
  1299. }
  1300. // 删除叼毛题库原先附加无用属性
  1301. function dealUnderLineFunc() {
  1302. // 打理干净underline
  1303. $('.underline').remove(); // 删除全部
  1304. // 删除全部underlineContent的颜色
  1305. $(".underlineContent").css("color", "");
  1306. }
  1307. // 打补丁(非underlineContent下的span下嵌套underlineContent)
  1308. function dealSULContentFunc(item, Id, pId) {
  1309. var reInfosArr = [];
  1310. // 处理"非underlineContent下的span下嵌套underlineContent"
  1311. var uLCClsName = $(item).attr("class");
  1312. var nItem = $(item).next();
  1313. var pItem = $(item).parent();
  1314. if (uLCClsName != undefined && uLCClsName.indexOf("underlineContent") > -1 && uLCClsName.indexOf("noKey") == -1) {
  1315. // 直接等于
  1316. var info = new Object();
  1317. info.Id = Id;
  1318. info.pId = pId;
  1319. info.AnsText = "";
  1320. info.AnsText = $(item).attr("answer-anstext");
  1321. if (info.AnsText == undefined) {
  1322. info.AnsText = $(item).text();
  1323. }
  1324. reInfosArr.push(info);
  1325. info = null;
  1326. if ($(".tag-span[answer-id='" + Id + "']").length == 0) {
  1327. var uHtml = document.createElement("span");
  1328. uHtml.className = "tag-span";
  1329. uHtml.innerText = "_";
  1330. uHtml.setAttribute("answer-id", Id);
  1331. $(item).after(uHtml);
  1332. }
  1333. $(item).remove();
  1334. }
  1335. else if (uLCClsName != undefined && uLCClsName.indexOf("yaoshi") > -1) {
  1336. // 到了下一个钥匙
  1337. return reInfosArr;
  1338. }
  1339. else if ($(item).find(".yaoshi").length > 0 || $(item).find(".underlineContent").length > 0) {
  1340. // 存在下个标签
  1341. if ($(item).find(".yaoshi").length > 0) {
  1342. var reInfosGet = dealSULContentFunc($(item).children(":first"), Id, pId);
  1343. for (var i = 0; i < reInfosGet.length; i++) {
  1344. reInfosArr.push(reInfosGet[i]);
  1345. }
  1346. return reInfosArr;
  1347. }
  1348. else {
  1349. // 查找子节点的underlineContent
  1350. $.each($(item).find(".underlineContent").not(".noKey"), function (iIndex, iItem) {
  1351. var info = new Object();
  1352. info.Id = Id;
  1353. info.pId = pId;
  1354. info.AnsText = "";
  1355. info.AnsText = $(iItem).attr("answer-anstext");
  1356. if (info.AnsText == undefined) {
  1357. info.AnsText = $(iItem).text();
  1358. }
  1359. reInfosArr.push(info);
  1360. info = null;
  1361. if ($(".tag-span[answer-id='" + Id + "']").length == 0) {
  1362. var uHtml = document.createElement("span");
  1363. uHtml.className = "tag-span";
  1364. uHtml.innerText = "_";
  1365. uHtml.setAttribute("answer-id", Id);
  1366. $(iItem).after(uHtml);
  1367. }
  1368. });
  1369. $(item).find(".underlineContent").not(".noKey").remove();
  1370. }
  1371. }
  1372. if (nItem.length > 0) {
  1373. var reInfosGet = dealSULContentFunc(nItem, Id, pId);
  1374. for (var i = 0; i < reInfosGet.length; i++) {
  1375. reInfosArr.push(reInfosGet[i]);
  1376. }
  1377. }
  1378. else {
  1379. if (pItem[0] == undefined || pItem[0].tagName.toUpperCase() == "BODY") {
  1380. return reInfosArr;
  1381. }
  1382. else {
  1383. var reInfosGet = dealSULContentFunc(pItem.next(), Id, pId);
  1384. for (var i = 0; i < reInfosGet.length; i++) {
  1385. reInfosArr.push(reInfosGet[i]);
  1386. }
  1387. }
  1388. }
  1389. return reInfosArr;
  1390. }
  1391. // 继续打补丁(判断是否需要添加暂无参考答案)
  1392. function isHasAnswerFunc(item) {
  1393. var uLCClsName = $(item).attr("class");
  1394. if (uLCClsName != undefined && uLCClsName.indexOf("underlineContent") > -1) {
  1395. return false; // 存在答案
  1396. }
  1397. else if (uLCClsName != undefined && uLCClsName.indexOf("yaoshi") > -1) {
  1398. // 到了下一个答题点
  1399. return true;
  1400. }
  1401. else if ($(item).length > 0) {
  1402. // 处理子答题点
  1403. var TReStatus = 0;
  1404. $.each($(item).find("span,u,img,p"), function (iIndex, iItem) {
  1405. var iULCClsName = $(iItem).attr("class");
  1406. if (iULCClsName != undefined && iULCClsName.indexOf("underlineContent") > -1) {
  1407. TReStatus = 1; // 返回false
  1408. return false; // 只能return $.each
  1409. }
  1410. else if (iULCClsName != undefined && iULCClsName.indexOf("yaoshi") > -1) {
  1411. TReStatus = 2; // 返回true
  1412. return true; // 只能return $.each
  1413. }
  1414. });
  1415. if (TReStatus > 0) {
  1416. if (TReStatus == 1) {
  1417. return false;
  1418. }
  1419. else {
  1420. return true;
  1421. }
  1422. }
  1423. // 处理子节点完毕(仍然没有),处理同龄
  1424. if ($(item).next()) {
  1425. // 存在同龄节点
  1426. return isHasAnswerFunc($(item).next());
  1427. }
  1428. else {
  1429. // 不存在同龄节点,查找父节点
  1430. if ($(item).parent()[0].tagName.toUpperCase() == "BODY") {
  1431. return true;
  1432. }
  1433. return isHasAnswerFunc($(item).parent().next());
  1434. }
  1435. }
  1436. return true;
  1437. }
  1438. //学生端 处理作答区域
  1439. var answerData = new Array();
  1440. function handleAnswerRange() {
  1441. // 隐藏答案划线
  1442. $(".underlineContentShow").attr("data-status", "0");
  1443. //规范文本格式
  1444. var answerId = "";
  1445. var tempJson = new Array();
  1446. //先处理一题多空的情况,获取两个之间的答题点
  1447. $(".multipleStart").each(function (i, item) {
  1448. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  1449. var checkId = $(item).find('.yaoshi').attr("answer-id");
  1450. var headid = $(item).find('.yaoshi').attr("parent-anid");
  1451. var ischecked = $(item).find(".underlineContent").text().indexOf("√") > -1;
  1452. var answerText = ischecked ? "√" : "";
  1453. //勾选题
  1454. if ($(item).hasClass('boxQue')) {
  1455. $(item).find('.yaoshi').after("<div class='checkbox' answer-id='" + checkId + "' parent-anid='" + headid + "' answer-isky='2' answer-anstext='" + answerText + "' answer-text=''><input id=" + checkId + " type='checkbox'><label for=" + checkId + "></label></div>");
  1456. //$(item).find('input').prop('checked', ischecked);
  1457. $(item).find('.underlineContent').hide();
  1458. }
  1459. //点击事件
  1460. $(item).find('input').bind("click", function () {
  1461. var curObj = new Object();
  1462. curObj.Id = $(this).parent().attr("answer-id");//答题点ID
  1463. curObj.pId = $(this).parent().attr("parent-anid");//答题点ID
  1464. curObj.IsKY = $(this).parent().attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题,2-打勾题
  1465. //curObj.Text = $(this).parent().attr("answer-text");//用户作答内容
  1466. curObj.Score = $(this).parent().attr("answer-score");//作答评分
  1467. curObj.AnsText = $(this).parent().attr("answer-anstext");//参考答案
  1468. curObj.Comment = $(this).parent().attr("answer-comment");//评语
  1469. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  1470. curObj.Text = $(this).prop("checked") ? "√" : "";//用户作答内容
  1471. $(this).parent().attr("answer-text", curObj.Text);//用户作答内容
  1472. $(".checkbox").removeClass("select-answer");
  1473. $(".answer-body").removeClass("select-answer");
  1474. $(this).parent().addClass("select-answer");
  1475. //已作答,弹出作答答案
  1476. if ($(this).parent().data("ans-status") == "1") {
  1477. //移动端添加外部处理
  1478. onClickAnswerPoint(JSON.stringify(curObj));
  1479. }
  1480. else {
  1481. //移动端添加外部处理,弹出作答操作
  1482. onClickAnswerPoint(JSON.stringify(curObj));
  1483. }
  1484. });
  1485. //删除钥匙节点
  1486. $(item).find('.yaoshi').hide();
  1487. });
  1488. });
  1489. dealUnderLineFunc();
  1490. //提取参考答案并规范文本格式
  1491. answerId = "";
  1492. $.each($(".yaoshi"), function (index, item) {
  1493. var tId = $(item).attr("answer-id");
  1494. var tPId = $(item).attr("parent-anid");
  1495. //记录上一次的ID
  1496. if (tId == undefined) {
  1497. tId = answerId;
  1498. }
  1499. else {
  1500. answerId = tId;
  1501. }
  1502. if (tPId == undefined) {
  1503. tPId = answerId;
  1504. }
  1505. // 特殊处理
  1506. var tInfos = dealSULContentFunc($(item).next(), tId, tPId);
  1507. for (var i = 0; i < tInfos.length; i++) {
  1508. // 判断是否是勾选题
  1509. if (tInfos[i].AnsText != null && tInfos[i].AnsText.indexOf("√") > -1) {
  1510. $(".tag-span[answer-id='" + tId + "']").remove();
  1511. }
  1512. tempJson.push(tInfos[i]);
  1513. }
  1514. });
  1515. //合并参考答案数据
  1516. var tempid = "";
  1517. var temppid = "";
  1518. var temptext = "";
  1519. for (var i = 0; i < tempJson.length; i++) {
  1520. if (tempid == tempJson[i].Id) {
  1521. temptext = temptext + tempJson[i].AnsText;
  1522. }
  1523. else {
  1524. if (tempid != "") {
  1525. var info = new Object();
  1526. info.Id = tempid;
  1527. info.pId = temppid;
  1528. info.AnsText = temptext;
  1529. answerData.push(info);
  1530. //重置
  1531. tempid = "";
  1532. temptext = "";
  1533. }
  1534. tempid = tempJson[i].Id;
  1535. temppid = tempJson[i].pId;
  1536. temptext = tempJson[i].AnsText;
  1537. //最后一个存入
  1538. if (i == tempJson.length - 1) {
  1539. var info = new Object();
  1540. info.Id = tempid;
  1541. info.pId = temppid;
  1542. info.AnsText = temptext;
  1543. answerData.push(info);
  1544. }
  1545. }
  1546. }
  1547. //补全答题点
  1548. var Num = 0;
  1549. if (answerData.length > 0) {
  1550. //Num = Number.parseInt(answerData[answerData.length - 1].Id);
  1551. Num = Number.parseInt($(".yaoshi:last").attr('answer-id'));
  1552. for (var i = 0; i < Num + 1; i++) {
  1553. if (i < answerData.length) {
  1554. var index = Number(answerData[i].Id) - i;
  1555. for (var j = 0; j < index; j++) {
  1556. var info = new Object();
  1557. info.Id = (i + j).toString();
  1558. info.pId = info.Id;
  1559. info.AnsText = "";
  1560. answerData.splice(i, 0, info);
  1561. }
  1562. }
  1563. else {
  1564. var info = new Object();
  1565. info.Id = (i).toString();
  1566. info.pId = info.Id;
  1567. info.AnsText = "";
  1568. answerData.splice(i, 0, info);
  1569. }
  1570. }
  1571. }
  1572. //// 重新处理全部答题点(废除处理)
  1573. //$.each($(".yaoshi"), function (index, item) {
  1574. // var Id = $(item).attr("answer-id");
  1575. // var prev = $(item).next();
  1576. // if (!$(prev).hasClass("checkbox")) {
  1577. // if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
  1578. // if ($("span[answer-id='" + Id + "']").length == 0) {
  1579. // var uHtml = document.createElement("span");
  1580. // uHtml.className = "tag-span";
  1581. // uHtml.innerText = "_";
  1582. // uHtml.setAttribute("answer-id", Id);
  1583. // $(item).after(uHtml);
  1584. // }
  1585. // }
  1586. // }
  1587. //});
  1588. //处理口语试题
  1589. $.each($(".oralLanguage").nextUntil(".oralLanguageDone"), function (num, part) {
  1590. if (part.tagName != "p") {
  1591. $.each($(part).find(".tag-span"), function (index, item) {
  1592. $(item).attr("answer-isky", "1");
  1593. });
  1594. }
  1595. else {
  1596. if ($(part).hasClass("underlinePart")) {
  1597. $.each($(part).find(".tag-span"), function (index, item) {
  1598. $(item).attr("answer-isky", "1");
  1599. });
  1600. }
  1601. }
  1602. });
  1603. //添加答题点的点击UI及交互
  1604. $.each($(".tag-span"), function (index, item) {
  1605. var answerText = "";
  1606. var parentId = "";
  1607. var isky = $(item).attr('answer-isky');
  1608. var answerid = $(item).attr('answer-id');
  1609. for (var i = 0; i < answerData.length; i++) {
  1610. if (answerid == answerData[i].Id) {
  1611. parentId = answerData[i].pId;
  1612. answerText = answerData[i].AnsText;
  1613. break;
  1614. }
  1615. }
  1616. // 删除多选框后面的答题点
  1617. prev = $(item).prev();
  1618. if ($(prev).hasClass("checkbox")) {
  1619. $(item).remove();
  1620. }
  1621. else {
  1622. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentId + "' answer-anstext='" + answerText + "' answer-isky='" + isky + "' answer-showanswer='0' data-astatus='0' data-errstatus='0' onclick='ClickRecFunc(" + parentId + ")'><div class='answer-audio-range'><img class='nextpic' src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range'><div class='answer-point-range-div'><img class='nextpic' src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div></div><buttom class='answer-text'></buttom></div>");
  1623. }
  1624. //删除钥匙节点
  1625. var prev = $("img[answer-id='" + answerid + "']");
  1626. if (prev.length > 0) {
  1627. $(prev).remove();
  1628. }
  1629. });
  1630. //添加点击事件
  1631. $(".answer-body").on("click", function () {
  1632. var curObj = new Object();
  1633. curObj.Id = $(this).attr("answer-id");//答题点ID
  1634. curObj.pId = $(this).attr("parent-anid");//答题点ID
  1635. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  1636. curObj.Text = $(this).attr("answer-text");//用户作答内容
  1637. curObj.Score = $(this).attr("answer-score");//作答评分
  1638. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  1639. curObj.Comment = $(this).attr("answer-comment");//评语
  1640. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  1641. $(".checkbox").removeClass("select-answer");
  1642. $(".answer-body").removeClass("select-answer");
  1643. $(this).addClass("select-answer");
  1644. //已作答,弹出作答答案
  1645. if ($(this).data("ans-status") == "1") {
  1646. //移动端添加外部处理
  1647. onClickAnswerPoint(JSON.stringify(curObj));
  1648. }
  1649. else {
  1650. //移动端添加外部处理,弹出作答操作
  1651. onClickAnswerPoint(JSON.stringify(curObj));
  1652. }
  1653. });
  1654. //去除多余的空格横线
  1655. $.each($(".underline"), function (index, item) {
  1656. var text = $(item).text();
  1657. text = text.replace(/\s+/g, "");
  1658. if (text == "") {
  1659. $(item).remove();
  1660. }
  1661. });
  1662. //删除所有钥匙节点
  1663. $("img[class=yaoshi]").remove();
  1664. // 处理多选框样式
  1665. dealCheckBox();
  1666. // data-astatus控制作答样式(0表示未提交,1表示提交,2表示回显);data-errstatus判断是否(1)错误
  1667. $(".answer-body").attr("data-astatus", "0").attr("data-errstatus", "0").attr("mobile-type", cTTypeFunc);
  1668. $(".answer-point-range").attr("mobile-type", cTTypeFunc);
  1669. $(".answer-point-range-div").attr("mobile-type", cTTypeFunc);
  1670. $(".answer-text").attr("data-astatus", "0");
  1671. return answerData;
  1672. }
  1673. //接收学生的作答
  1674. function reviewAnswer(answerJson) {
  1675. if (answerJson != "" && answerJson) {
  1676. var answerObj = JSON.parse(answerJson);
  1677. var selectElement = $(".answer-body[answer-id='" + answerObj.Id + "']");
  1678. var audioElement = $(selectElement).children(".answer-audio-range").children("img").eq(0);
  1679. answerObj.IsKY = $(selectElement).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  1680. //是否为音频作答(Type:1,文本作答,2-图片,3-语音,4-音频导入)
  1681. if ((answerObj.Type == 3 || answerObj.Type == 4) && answerObj.AudioUrl != "") {
  1682. $(selectElement).children(".answer-point-range").hide();
  1683. $(selectElement).children(".answer-audio-range").css("display", "inline-block");
  1684. $(selectElement).children(".answer-audio-range").eq(0).children("span").text("作答音频(" + answerObj.AudioLength + "s)");
  1685. //填充作答内容
  1686. $(selectElement).attr("answer-text", answerObj.Text);
  1687. if (answerObj.Text != "") {
  1688. answerObj.Text = "(" + answerObj.Text + ")";
  1689. $(selectElement).children(".answer-text").show();
  1690. $(selectElement).children(".answer-text").text(answerObj.Text);
  1691. }
  1692. else {
  1693. $(selectElement).children(".answer-text").text("");
  1694. }
  1695. //是否之前存在作答音频
  1696. $(selectElement).attr("answer-url", answerObj.AudioUrl);
  1697. $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
  1698. $(selectElement).children(".answer-audio-range").attr("play-status", "0");
  1699. //独立绑定事件
  1700. $(audioElement).on("click", function () {
  1701. recordAudioClick(this, answerObj.Id, answerObj.AudioUrl);
  1702. });
  1703. $(selectElement).attr("answer-showanswer", "1").attr("data-astatus", "3");
  1704. }
  1705. else {
  1706. $(selectElement).attr("answer-text", answerObj.Text);//填充作答内容
  1707. $(selectElement).children(".answer-audio-range").hide();
  1708. if (answerObj.Text != "") {
  1709. $(selectElement).children(".answer-text").show();
  1710. $(selectElement).children(".answer-point-range").hide();
  1711. $(selectElement).children(".answer-text").text(answerObj.Text);
  1712. $(selectElement).attr("answer-showanswer", "1").attr("data-astatus", "3");
  1713. }
  1714. else {
  1715. $(selectElement).children(".answer-text").hide();
  1716. $(selectElement).children(".answer-text").text("");
  1717. $(selectElement).children(".answer-point-range").show();
  1718. $(selectElement).attr("answer-showanswer", "0").attr("data-astatus", "0");
  1719. }
  1720. }
  1721. }
  1722. }
  1723. //提交,获取所有作答答案及参考答案
  1724. function getAllAnswer() {
  1725. $(".answer-body").attr("data-astatus", "1").attr("data-errstatus", "0"); // 控制作答样式
  1726. $(".answer-text").attr("data-astatus", "1")
  1727. //处理作答
  1728. $.each($(".answer-body"), function (index, item) {
  1729. var isanswer = false;
  1730. var answerid = $(item).attr("answer-id");
  1731. var parentid = $(item).attr("parent-anid");
  1732. //遍历同一小题的作答,如果作答了,整个小题都认为是作答了
  1733. $.each($(".answer-body[parent-anid=" + parentid + "]"), function (n, item) {
  1734. var atext = $(item).children(".answer-text").text();
  1735. if (atext != "" && atext != "未作答") {
  1736. isanswer = true;
  1737. }
  1738. });
  1739. var mytext = $(item).children(".answer-text").text();
  1740. var curDisplay = $(item).children(".answer-audio-range").css("display");
  1741. if (mytext == "" && curDisplay == "none") {
  1742. mytext = "未作答";
  1743. if (isanswer) {
  1744. mytext = "&nbsp;&nbsp;&nbsp;&nbsp;";
  1745. $(item).children(".answer-text").html(mytext);
  1746. $(item).children(".answer-text").addClass("noanswer-border");
  1747. }
  1748. else {
  1749. $(item).children(".answer-text").text(mytext);
  1750. $(item).children(".answer-text").addClass("no-answer");
  1751. $(item).attr("data-errstatus", "1");
  1752. }
  1753. $(item).children(".answer-point-range").hide();
  1754. $(item).children(".answer-text").show();
  1755. }
  1756. else {
  1757. if (mytext == "未作答") {
  1758. $(item).attr("data-errstatus", "1");
  1759. }
  1760. }
  1761. });
  1762. $(".answer-body").removeClass("select-answer");//移除样式
  1763. $(".answer-body").unbind("click");//取消点击绑定事件
  1764. $(".answer-body").children(".answer-audio-range").children("span").unbind("click");//取消点击绑定事件
  1765. //打勾题的还原
  1766. $.each($(".checkbox"), function (num, item) {
  1767. var isanswer = false;
  1768. var answerid = $(item).attr("answer-id");
  1769. var parentid = $(item).attr("parent-anid");
  1770. //遍历同一小题的作答,如果作答了,整个小题都认为是作答了
  1771. $.each($(".checkbox[parent-anid=" + parentid + "]"), function (n, item) {
  1772. var atext = $(item).attr("answer-text");
  1773. if (atext != "" && atext != "未作答") {
  1774. isanswer = true;
  1775. }
  1776. });
  1777. //遍历同一小题的作答,如果作答了,整个小题都认为是作答了
  1778. $.each($(".answer-body[parent-anid=" + parentid + "]"), function (n, item) {
  1779. var atext = $(item).children(".answer-text").text();
  1780. if (atext != "" && atext != "未作答") {
  1781. isanswer = true;
  1782. }
  1783. });
  1784. //提交直接还原作答现场
  1785. var mytext = $(item).attr("answer-text");//我的答案
  1786. var ischecked = mytext.indexOf("√") > -1;
  1787. var answerText = $(item).attr("answer-anstext");//参考答案
  1788. if (mytext == "") {
  1789. mytext = "未作答";
  1790. if (isanswer) {
  1791. mytext = "&nbsp;&nbsp;&nbsp;";
  1792. }
  1793. }
  1794. //mytext = mytext == "" ? "&nbsp;&nbsp;&nbsp;" : mytext;
  1795. if (!isanswer) {
  1796. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2' data-astatus='1' data-errstatus='0' onclick='ClickRecFunc(" + parentid + ")'><div class='answer-audio-range'><img class='nextpic' src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><div class='answer-point-range-div'><img class='nextpic' src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div></div><buttom class='answer-text no-answer' style='display:inline-block;'>" + mytext + "</buttom></div>");
  1797. }
  1798. else {
  1799. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2' data-astatus='1' data-errstatus='0' onclick='ClickRecFunc(" + parentid + ")'><div class='answer-audio-range'><img class='nextpic' src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><div class='answer-point-range-div'><img class='nextpic' src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div></div><buttom class='answer-text' style='display:inline-block;'>" + mytext + "</buttom></div>");
  1800. }
  1801. if (mytext == "未作答") {
  1802. $(".answer-body[answer-id='" + answerid + "']").attr("data-errstatus", "1");
  1803. }
  1804. });
  1805. ControlFlag = false;
  1806. //console.log(JSON.stringify(answerData));
  1807. // 恢复显示所有高亮(这个必须要,不然不知道哪个是开的,那个是关的,除非重新调一次渲染)
  1808. adjustFillFunc(7);
  1809. dealNSFillFunc();
  1810. return answerData;
  1811. }
  1812. //回填所有答案,answerJson:所有作答及参考答案List,statusType:0-可作答,1-已提交,2-查看评阅
  1813. function backupAllAnswer(answerJson, statusType) {
  1814. IsStuFills.ProcessType = statusType;
  1815. if (statusType == 0) {
  1816. ControlFlag = true;
  1817. }
  1818. else {
  1819. ControlFlag = false;
  1820. }
  1821. $(".answer-body").attr("data-astatus", statusType).attr("data-errstatus", "0"); // 实时记录作答状态
  1822. if (answerJson != "" && answerJson) {
  1823. var answerList = JSON.parse(answerJson);
  1824. $.each($(".answer-body"), function (num, item) {
  1825. var index = 0;
  1826. var isanswer = false;
  1827. var answerid = $(item).attr("answer-id");
  1828. var parentid = $(item).attr("parent-anid");
  1829. //查找作答
  1830. for (var i = 0; i < answerList.length; i++) {
  1831. if (answerid == answerList[i].Id) {
  1832. index = i;
  1833. break;
  1834. }
  1835. }
  1836. //一题多空的作答关联查找
  1837. for (var i = 0; i < answerList.length; i++) {
  1838. if (parentid == answerList[i].pId) {
  1839. if (answerList[i].Text != "") {
  1840. isanswer = true;
  1841. break;
  1842. }
  1843. }
  1844. }
  1845. //提交直接还原作答现场
  1846. var mytext = answerList[index].Text;//我的答案
  1847. answerList[index].IsKY = $(item).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  1848. //添加音频控制
  1849. var hasAudio = false;
  1850. var audioElement = $(item).children(".answer-audio-range").children("img").eq(0);
  1851. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  1852. hasAudio = true;
  1853. $(item).children(".answer-point-range").hide();
  1854. $(item).children(".answer-audio-range").css("display", "inline-block");
  1855. $(item).children(".answer-audio-range").children("span").text("作答音频(" + answerList[index].AudioLength + "s)");
  1856. //填充作答内容
  1857. $(item).attr("answer-text", mytext);
  1858. if (mytext != "") {
  1859. mytext = "(" + mytext + ")";
  1860. $(item).children(".answer-text").show();
  1861. $(item).children(".answer-text").text(mytext);
  1862. }
  1863. //音频节点
  1864. $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
  1865. $(item).attr("answer-url", answerList[index].AudioUrl);
  1866. $(item).children(".answer-audio-range").attr("play-status", "0");
  1867. //独立绑定事件
  1868. $(audioElement).on("click", function () {
  1869. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  1870. });
  1871. }
  1872. //可作答状态,作答还原
  1873. if (statusType == 0) {
  1874. //已作答过,还原作答,增加作答后的UI节点
  1875. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  1876. $(item).attr("data-astatus", "3");
  1877. $(item).children(".answer-audio-range").children("span").on("click", function () {
  1878. $(".answer-body").removeClass("select-answer");
  1879. $(item).addClass("select-answer");
  1880. onClickAnswerPoint(JSON.stringify(answerList[index]));
  1881. });
  1882. }
  1883. else {
  1884. $(item).attr("answer-text", mytext);//填充作答内容
  1885. if (mytext != "") {
  1886. $(item).attr("data-astatus", "3");
  1887. $(item).children(".answer-text").show();
  1888. $(item).children(".answer-point-range").hide();
  1889. $(item).children(".answer-text").text(mytext);
  1890. }
  1891. else {
  1892. $(item).attr("data-errstatus", "1");
  1893. }
  1894. }
  1895. }
  1896. //已提交,作答还原
  1897. if (statusType == 1) {
  1898. //取消点击绑定事件
  1899. $(item).unbind('click');
  1900. //填充作答内容
  1901. $(item).attr("answer-text", mytext);
  1902. if (mytext == "" && !hasAudio) {
  1903. mytext = "未作答";
  1904. if (isanswer) {
  1905. mytext = "&nbsp;&nbsp;&nbsp;&nbsp;";
  1906. $(item).children(".answer-text").html(mytext);
  1907. $(item).children(".answer-text").addClass("noanswer-border");
  1908. }
  1909. else {
  1910. $(item).children(".answer-text").text(mytext);
  1911. $(item).children(".answer-text").addClass("no-answer");
  1912. $(item).attr("data-errstatus", "1");
  1913. }
  1914. $(item).children(".answer-text").show();
  1915. }
  1916. else if (mytext == "" && hasAudio) {
  1917. $(item).children(".answer-text").hide();
  1918. }
  1919. else {
  1920. $(item).children(".answer-text").show();
  1921. $(item).children(".answer-text").text(mytext);
  1922. $(item).attr("data-errstatus", "0");
  1923. }
  1924. $(item).children(".answer-point-range").hide();
  1925. }
  1926. //已评阅,查看评阅详情
  1927. if (statusType == 2) {
  1928. //添加音频控制
  1929. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  1930. $(item).attr("data-errstatus", "0");
  1931. //独立绑定事件
  1932. $(item).children(".answer-audio-range").children("span").on("click", function () {
  1933. $(".answer-body").removeClass("select-answer");
  1934. $(item).addClass("select-answer");
  1935. onClickAnswerPoint(JSON.stringify(answerList[index]));
  1936. });
  1937. }
  1938. else {
  1939. $(item).attr("answer-text", mytext);//填充作答内容
  1940. if (mytext == "" && !hasAudio) {
  1941. mytext = "未作答";
  1942. if (isanswer) {
  1943. mytext = "&nbsp;&nbsp;&nbsp;&nbsp;";
  1944. $(item).children(".answer-text").html(mytext);
  1945. $(item).children(".answer-text").addClass("noanswer-border");
  1946. }
  1947. else {
  1948. $(item).children(".answer-text").text(mytext);
  1949. $(item).children(".answer-text").addClass("no-answer");
  1950. $(item).attr("data-errstatus", "1");
  1951. }
  1952. $(item).children(".answer-text").show();
  1953. }
  1954. else if (mytext == "" && hasAudio) {
  1955. $(item).children(".answer-text").hide();
  1956. }
  1957. else {
  1958. $(item).children(".answer-text").show();
  1959. $(item).children(".answer-text").text(mytext);
  1960. if (mytext == "") {
  1961. }
  1962. $(item).attr("data-errstatus", "0");
  1963. }
  1964. $(item).children(".answer-point-range").hide();
  1965. }
  1966. }
  1967. // 添加answer-boy的样式判断
  1968. var DStatusFlag = $(item).find(".answer-point-range").css("display") != "none";
  1969. if (DStatusFlag) {
  1970. $(item).attr("answer-showanswer", "0"); // 修改显示格式
  1971. }
  1972. else {
  1973. $(item).attr("answer-showanswer", "1"); // 修改显示格式
  1974. }
  1975. });
  1976. //打勾题的还原
  1977. $.each($(".checkbox"), function (num, item) {
  1978. //可作答状态,作答还原
  1979. var index = 0;
  1980. var isanswer = false;
  1981. var answerid = $(item).attr("answer-id");
  1982. var parentid = $(item).attr("parent-anid");
  1983. for (var i = 0; i < answerList.length; i++) {
  1984. if (answerid == answerList[i].Id) {
  1985. index = i;
  1986. break;
  1987. }
  1988. }
  1989. //一题多空的作答关联查找
  1990. for (var i = 0; i < answerList.length; i++) {
  1991. if (parentid == answerList[i].pId) {
  1992. if (answerList[i].Text != "") {
  1993. isanswer = true;
  1994. Score = answerList[i].Score;
  1995. break;
  1996. }
  1997. }
  1998. }
  1999. //提交直接还原作答现场
  2000. var mytext = answerList[index].Text;//我的答案
  2001. var ischecked = mytext.indexOf("√") > -1;
  2002. var answerText = $(item).attr("answer-anstext");//参考答案
  2003. $(item).attr("answer-text", mytext);
  2004. $(item).find('input').prop('checked', ischecked);
  2005. //还原打勾效果
  2006. if (ischecked && statusType == 0) {
  2007. $(".cBoxCls_" + answerid).attr("data-status", "1");
  2008. }
  2009. //已提交,已评阅,还原HTML代码,去除checkbox
  2010. if (statusType == 1 || statusType == 2) {
  2011. if (mytext == "") {
  2012. mytext = "未作答";
  2013. if (isanswer) {
  2014. mytext = "&nbsp;&nbsp;&nbsp;";
  2015. }
  2016. }
  2017. //mytext = mytext == "" ? "&nbsp;&nbsp;&nbsp;" : mytext;
  2018. if (!isanswer) {
  2019. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2' answer-text='" + mytext + "' data-astatus='" + statusType + "' data-errstatus='0' onclick='ClickRecFunc(" + parentid + ")'><div class='answer-audio-range'><img class='nextpic' src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><div class='answer-point-range-div'><img class='nextpic' src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div></div><buttom class='answer-text no-answer' style='display:inline-block;'>" + mytext + "</buttom></div>");
  2020. }
  2021. else {
  2022. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2' answer-text='" + mytext + "' data-astatus='" + statusType + "' data-errstatus='0' onclick='ClickRecFunc(" + parentid + ")'><div class='answer-audio-range'><img class='nextpic' src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><div class='answer-point-range-div'><img class='nextpic' src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div></div><buttom class='answer-text' style='display:inline-block;'>" + mytext + "</buttom></div>");
  2023. }
  2024. if (mytext == "未作答") {
  2025. $(".answer-body[answer-id='" + answerid + "']").attr("data-errstatus", "1");
  2026. }
  2027. }
  2028. });
  2029. //点击事件重新绑定
  2030. if (statusType == 0 || statusType == 2) {
  2031. //评阅样式
  2032. if (statusType == 2) {
  2033. $.each($(".answer-body"), function (num, item) {
  2034. var parentid = $(item).attr("parent-anid");
  2035. var answerid = $(".answer-body[parent-anid=" + parentid + "]").attr("answer-id");
  2036. if (answerList[answerid].Score == 0) {
  2037. if (!$(item).children(".answer-text").hasClass("good-answer")) {
  2038. $(item).children(".answer-text").addClass("bad-answer");
  2039. }
  2040. }
  2041. if (answerList[answerid].Score > 0) {
  2042. //遍历同一小题的评阅,并加上样式
  2043. $.each($(".answer-body[parent-anid=" + parentid + "]"), function (n, item) {
  2044. $(item).children(".answer-text").addClass("good-answer");
  2045. });
  2046. }
  2047. });
  2048. //点击事件重新绑定
  2049. $(".answer-body").unbind("click").on("click", function () {
  2050. var curObj = new Object();
  2051. curObj.Id = $(this).attr("answer-id");//答题点ID
  2052. curObj.pId = $(this).attr("parent-anid");//答题点ID
  2053. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  2054. curObj.Text = $(this).attr("answer-text");//用户作答内容
  2055. curObj.Score = $(this).attr("answer-score");//作答评分
  2056. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  2057. curObj.Comment = $(this).attr("answer-comment");//评语
  2058. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  2059. $(".checkbox").removeClass("select-answer");
  2060. $(".answer-body").removeClass("select-answer");
  2061. $(".answer-body[parent-anid=" + curObj.pId + "]").addClass("select-answer");
  2062. //已作答,弹出作答答案
  2063. if ($(this).data("ans-status") == "1") {
  2064. //移动端添加外部处理
  2065. onClickAnswerPoint(JSON.stringify(curObj));
  2066. }
  2067. else {
  2068. //移动端添加外部处理,弹出作答操作
  2069. onClickAnswerPoint(JSON.stringify(curObj));
  2070. }
  2071. });
  2072. }
  2073. $(".answer-body").unbind("click").on("click", function () {
  2074. var curObj = new Object();
  2075. curObj.Id = $(this).attr("answer-id");//答题点ID
  2076. curObj.pId = $(this).attr("parent-anid");//答题点ID
  2077. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  2078. curObj.Text = $(this).attr("answer-text");//用户作答内容
  2079. curObj.Score = $(this).attr("answer-score");//作答评分
  2080. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  2081. curObj.Comment = $(this).attr("answer-comment");//评语
  2082. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  2083. $(".checkbox").removeClass("select-answer");
  2084. $(".answer-body").removeClass("select-answer");
  2085. if (statusType == 2) {
  2086. $(".answer-body[parent-anid=" + curObj.pId + "]").addClass("select-answer");
  2087. }
  2088. else {
  2089. $(this).addClass("select-answer");
  2090. }
  2091. //已作答,弹出作答答案
  2092. if ($(this).data("ans-status") == "1") {
  2093. //移动端添加外部处理
  2094. onClickAnswerPoint(JSON.stringify(curObj));
  2095. }
  2096. else {
  2097. //移动端添加外部处理,弹出作答操作
  2098. onClickAnswerPoint(JSON.stringify(curObj));
  2099. }
  2100. });
  2101. }
  2102. }
  2103. if (statusType == 1 || statusType == 2) {
  2104. $(".answer-text").attr("data-astatus", statusType);
  2105. //dealRecvShowFill();
  2106. // 恢复显示所有高亮(这个必须要,不然不知道哪个是开的,那个是关的,除非重新调一次渲染)
  2107. if (typeof (adjustFillFunc) == "function") {
  2108. adjustFillFunc(7); // 回填无效
  2109. }
  2110. }
  2111. }
  2112. //老师评阅学生作答
  2113. function reviewStuAnswer(answerJson) {
  2114. if (answerJson != "" && answerJson) {
  2115. var answerObj = JSON.parse(answerJson);
  2116. var selectElement = $(".answer-body[answer-id='" + answerObj.Id + "']");
  2117. //$(selectElement).attr("answer-text", answerObj.Text);//用户作答内容
  2118. $(selectElement).attr("answer-score", answerObj.Score);//作答评分
  2119. $(selectElement).attr("answer-anstext ", answerObj.AnsText);//参考答案
  2120. $(selectElement).attr("answer-comment", answerObj.Comment);//评语
  2121. //遍历同一小题的评阅,并加上样式
  2122. $.each($(".answer-body[parent-anid=" + answerObj.pId + "]"), function (n, item) {
  2123. //评阅样式
  2124. if (answerObj.Score == 0) {
  2125. $(item).children(".answer-text").removeClass("good-answer");
  2126. $(item).children(".answer-text").addClass("bad-answer");
  2127. }
  2128. if (answerObj.Score > 0) {
  2129. $(item).children(".answer-text").removeClass("bad-answer");
  2130. $(item).children(".answer-text").addClass("good-answer");
  2131. }
  2132. });
  2133. }
  2134. dealRecvShowFill();
  2135. }
  2136. //处理播放录音,answerid:答题点ID,isPlay:是否播放(0-暂停,1-播放)
  2137. function playRecordAudio(answerid, isPlay) {
  2138. //获取其他正在播放的音频
  2139. var playing = $(".answer-body[answer-id='" + answerid + "']").children(".answer-audio-range");
  2140. if (playing.length > 0) {
  2141. if (isPlay == "1") {
  2142. $(playing).attr("play-status", "1");
  2143. $(playing).find("img").attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  2144. }
  2145. else {
  2146. $(playing).attr("play-status", "0");
  2147. $(playing).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  2148. }
  2149. }
  2150. }
  2151. //滚动到相应DIV
  2152. function scrollAnswer(answerid) {
  2153. //console.log(answerid);
  2154. $(".checkbox").removeClass("select-answer");
  2155. $(".answer-body").removeClass("select-answer");
  2156. var ansDom = $(".answer-body[parent-anid='" + answerid + "']");
  2157. if (ansDom.length == 0) {
  2158. ansDom = $(".checkbox[parent-anid='" + answerid + "']");
  2159. }
  2160. $(ansDom).addClass("select-answer");
  2161. var scroll_offset = $(ansDom).offset(); //得到box这个div层的offset,包含两个值,top和left
  2162. var offset_top = scroll_offset.top;
  2163. if (offset_top > 150) {
  2164. offset_top = offset_top - 200;
  2165. }
  2166. $("body,html").animate({
  2167. scrollTop: offset_top //让body的scrollTop等于pos的top,就实现了滚动
  2168. });
  2169. }
  2170. //暂停播放原文音频
  2171. function pauseTextAudio(audioid) {
  2172. //获取其他正在播放的音频
  2173. var playing = $(".audioImg[audio-id='" + audioid + "']");
  2174. if (playing.length > 0) {
  2175. $(playing).attr("play-status", "0");
  2176. $(playing).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  2177. }
  2178. }
  2179. //原文音频播放按钮点击事件
  2180. function audioPlayClick(myobj) {
  2181. var curHtml = $(myobj).parent().find(".audioUrl").html();
  2182. var curAlt = $(myobj).attr("alt");
  2183. //处理当前按钮的状
  2184. if ($(myobj).attr("play-status") == "1") {
  2185. $(myobj).attr("play-status", "0");
  2186. $(myobj).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  2187. }
  2188. else {
  2189. //停止其他作答音频播放
  2190. var isRecordPlaying = $(".answer-audio-range[play-status='1']");
  2191. if (isRecordPlaying.length > 0) {
  2192. $(isRecordPlaying).attr("play-status", "0");
  2193. $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  2194. }
  2195. //停止其他原文音频播放
  2196. var audioPlaying = $(".audioImg[play-status='1']");
  2197. if (audioPlaying.length > 0) {
  2198. $(audioPlaying).attr("play-status", "0");
  2199. $(audioPlaying).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  2200. }
  2201. //设置播放状态
  2202. $(myobj).attr("play-status", "1");
  2203. $(myobj).attr("src", PicInfo.audioPlayImgUrl);//移动端要根据本地 喇叭 路径替换
  2204. }
  2205. var info = new Object();
  2206. info.Id = $(myobj).attr("audio-id");
  2207. info.AudioUrl = curAlt;
  2208. //移动端添加外部处理
  2209. playVisiableAudioCallBack(1, JSON.stringify(info));
  2210. }
  2211. //作答录音播放按钮点击事件
  2212. function recordAudioClick(myobj, id, url) {
  2213. $(".select-answer").removeClass("select-answer");
  2214. $(myobj).parent().parent("answer-body").addClass("select-answer");
  2215. //处理当前按钮的状态
  2216. if ($(myobj).parent().attr("play-status") == "0") {
  2217. //停止其他作答音频播放
  2218. var isRecordPlaying = $(".answer-audio-range[play-status='1']");
  2219. if (isRecordPlaying.length > 0) {
  2220. $(isRecordPlaying).attr("play-status", "0");
  2221. $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  2222. }
  2223. //停止其他原文音频播放
  2224. var audioPlaying = $(".audioImg[play-status='1']");
  2225. if (audioPlaying.length > 0) {
  2226. $(audioPlaying).attr("play-status", "0");
  2227. $(audioPlaying).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地 喇叭 路径替换
  2228. }
  2229. //设置播放状态
  2230. $(myobj).parent().attr("play-status", "1");
  2231. $(myobj).attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  2232. }
  2233. else {
  2234. $(myobj).parent().attr("play-status", "0");
  2235. $(myobj).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  2236. }
  2237. //移动端添加外部处理,播放录音
  2238. var info = new Object();
  2239. info.Id = id;
  2240. info.AudioUrl = url;
  2241. //移动端添加外部处理,播放录音
  2242. playVisiableAudioCallBack(3, JSON.stringify(info));
  2243. }
  2244. //生成从minNum到maxNum的随机数
  2245. function randomNum(minNum, maxNum) {
  2246. switch (arguments.length) {
  2247. case 1:
  2248. return parseInt(Math.random() * minNum + 1, 10);
  2249. break;
  2250. case 2:
  2251. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  2252. break;
  2253. default:
  2254. return 0;
  2255. break;
  2256. }
  2257. }
  2258. function playVisiableAudioCallBack(type, url) {
  2259. //console.log(url);
  2260. cancelBubble();
  2261. plugin.startPlay(type, url);
  2262. }
  2263. function onClickAnswerPoint(data) {
  2264. //alert(JSON.stringify(data));
  2265. console.log(JSON.stringify(data));
  2266. cancelBubble();
  2267. plugin.onClickAnswerPoint(data);
  2268. }
  2269. function onClickKeyHide() {
  2270. //alert(JSON.stringify(data));
  2271. cancelBubble();
  2272. plugin.onClickKeyHide();
  2273. }
  2274. function onClickKeyShow() {
  2275. //alert(JSON.stringify(data));
  2276. cancelBubble();
  2277. plugin.onClickKeyShow();
  2278. }
  2279. function cancelBubble(e) {
  2280. var evt = e ? e : window.event;
  2281. if (evt.stopPropagation) { //W3C
  2282. evt.stopPropagation();
  2283. } else { //IE
  2284. evt.cancelBubble = true;
  2285. }
  2286. }
  2287. function getSelectedText(title) {
  2288. var txt;
  2289. if (window.getSelection) {
  2290. txt = window.getSelection().toString();
  2291. } else if (window.document.getSelection) {
  2292. txt = window.document.getSelection().toString();
  2293. } else if (window.document.selection) {
  2294. txt = window.document.selection.createRange().text;
  2295. }
  2296. JSInterface.callback(txt, title);
  2297. }
  2298. // 控制播放按钮样式,OCStatus(0表示停止,1表示播放)
  2299. function playCssControl(iIndex, OCStatus) {
  2300. var jQStr = ".LDFPlayS_" + iIndex;
  2301. if (OCStatus == "0") {
  2302. $(jQStr).attr("data-playstatus", 0);
  2303. }
  2304. else {
  2305. $(jQStr).attr("data-playstatus", 1);
  2306. }
  2307. }
  2308. // 控制滑块接口(Id第几个音频,leftVal进度条实时时间(毫秒),allTimes表示总时间(毫秒))
  2309. function showImageFunc(Id, leftVal, allTimes) {
  2310. playImageFunc(Id, leftVal, allTimes);
  2311. }
  2312. // 暂停所有的样式
  2313. function StopAllCss() {
  2314. $.each($(".LDFPlayS"), function (index, item) {
  2315. $(this).attr("data-playstatus", "0");
  2316. });
  2317. };
  2318. // 控制字体大小
  2319. function adjustFontSize(FontSize) {
  2320. $(".LDFTimerS").attr("data-fsFlag", FontSize);
  2321. }
  2322. // 音频进度条按下回调
  2323. function mobileTSFunc(ID) {
  2324. pressTableFlag = true;
  2325. // 移动端回调处理
  2326. plugin.onSeekBarDown(ID); // 安卓
  2327. }
  2328. // 音频进度条松开回调
  2329. function mobileTEFunc(ID) {
  2330. pressTableFlag = false;
  2331. var CurrentTime = parseInt($(".LDFPWhite_" + ID).attr("data-ctime")); // 当前滑动的时间进度
  2332. var jQStr = ".LDFPlayS_" + ID;
  2333. var AudioUrl = $(jQStr).parent().prev(".LDivTop").find(".LDivTItem[data-selected='1']").attr("data-auduourl"); // 路径
  2334. // 移动端回调处理
  2335. plugin.onSeekBarUp(ID, CurrentTime, AudioUrl); // 安卓
  2336. }
  2337. // 移动端统一调用:学生端视听说主体课文
  2338. // sWidthVal:屏幕宽度,isAStatus是否含有作答0表示没有,isMAStatus判断是否是主体课文1表示是
  2339. // data高亮知识点
  2340. function stuEntryFunc(sWidthVal, isAStatus, isMAStatus, data) {
  2341. IsStuFills.StuID = true;
  2342. bindEventYS(sWidthVal, isAStatus, isMAStatus);
  2343. var ReData = handleAnswerRange();
  2344. if (typeof (Fill) == "function") {
  2345. Fill(data);
  2346. }
  2347. dealNSFillFunc();
  2348. return ReData;
  2349. }
  2350. // 移动端统一调用:教师端视听说主体课文
  2351. // sWidthVal:屏幕宽度,isAStatus是否含有作答0表示没有,isMAStatus判断是否是主体课文1表示是
  2352. // data高亮知识点
  2353. // isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  2354. function teaEntryFunc(sWidthVal, isAStatus, isMAStatus, data, isShowYX, isShowAS) {
  2355. bindEventYS(sWidthVal, isAStatus, isMAStatus);
  2356. if (typeof (Fill) == "function") {
  2357. Fill(data);
  2358. }
  2359. showHideAnswerEx(isShowYX, isShowAS);
  2360. }
  2361. // 移动端统一调用:教师/学生端视听说原文
  2362. // sWidthVal:屏幕宽度,isAStatus是否含有作答0表示没有,isMAStatus判断是否是主体课文1表示是
  2363. // isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  2364. function aYWFunc(sWidthVal, isAStatus, isMAStatus, isShowYX, isShowAS) {
  2365. bindEventTeaOrignalYS(sWidthVal, isAStatus, isMAStatus);
  2366. showHideAnswerEx(isShowYX, isShowAS);
  2367. }
  2368. // 移动端统一调用:学生端传统教材
  2369. // sWidthVal:屏幕宽度,isAStatus是否含有作答0表示没有,isMAStatus判断是否是主体课文1表示是
  2370. // isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  2371. function stuCTJCFunc(sWidthVal, isAStatus, isMAStatus, isShowYX, isShowAS) {
  2372. aCTJCFunc(sWidthVal, isAStatus, isMAStatus, isShowYX, isShowAS);
  2373. }
  2374. // 移动端统一调用:教师端传统教材
  2375. // sWidthVal:屏幕宽度,isAStatus是否含有作答0表示没有,isMAStatus判断是否是主体课文1表示是
  2376. // isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  2377. function teaCTJCFunc(sWidthVal, isAStatus, isMAStatus, isShowYX, isShowAS) {
  2378. aCTJCFunc(sWidthVal, isAStatus, isMAStatus, isShowYX, isShowAS);
  2379. }
  2380. // 移动端统一调用:教师/学生端传统教材
  2381. // sWidthVal:屏幕宽度,isAStatus是否含有作答0表示没有,isMAStatus判断是否是主体课文1表示是
  2382. // isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  2383. // data高亮知识点
  2384. var Iindex = 0;
  2385. function aCTJCFunc(sWidthVal, isAStatus, isMAStatus, isShowYX, isShowAS, data) {
  2386. bindEventYS(sWidthVal, isAStatus, isMAStatus);
  2387. if (data == null || data == "") {
  2388. addFillAssist();
  2389. }
  2390. else if (typeof (Fill) == "function") {
  2391. Fill(data);
  2392. }
  2393. showHideAnswerEx(isShowYX, isShowAS);
  2394. }
  2395. // 清除点击样式
  2396. function RemoveCCFunc() {
  2397. $(".wordStyle[data-nowclick='1'],.phraseStyle[data-nowclick='1'],.sentenceStyle[data-nowclick='1'],.sentImagcs[data-nowclick='1']").attr("data-nowclick", "0");
  2398. }