tasklib_book.js 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531
  1. //播放音频图片地址
  2. var PicInfo = {
  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 PicInfo1 = {
  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. // 高亮
  23. var styleWPSContrl = {
  24. wordFlag: true,
  25. phraseFlag: true,
  26. sentenceFlag: true
  27. }
  28. // 表格处理Start
  29. var pressTableFlag = false;
  30. var GetPadVal = function () {
  31. var PaddingVal = $(document.body).css("padding");
  32. var PadValArr = PaddingVal.split(" ");
  33. if (PadValArr.length > 2) {
  34. return parseFloat(PadValArr[1]) + parseFloat(PadValArr[3]);
  35. }
  36. else if (PadValArr.length > 1) {
  37. return parseFloat(PadValArr[1]) * 2;
  38. }
  39. else {
  40. return parseFloat(PadValArr[0]) * 2;
  41. }
  42. };
  43. // 获取最大字符长度的字符串(起决定宽度的字符串/将字符去除HTML标签)(使用)
  44. var removeHtmlFunc = function (HtmlStr) {
  45. // 清除非长度标签
  46. var pattStr = new RegExp(/<(img){1}.*?>/ig);
  47. var matchesArr = HtmlStr.match(pattStr);
  48. if (matchesArr != null && matchesArr.length > 0) {
  49. for (var i = 0; i < matchesArr.length; i++) {
  50. HtmlStr = HtmlStr.replace(matchesArr[i], "");
  51. }
  52. }
  53. pattStr = new RegExp(/(<(p){1}.*?>).*?(<\/\2>)/ig);
  54. matchesArr = HtmlStr.match(pattStr);
  55. // 判断是否存在p标签
  56. if (matchesArr != null || matchesArr.length > 0) {
  57. pattStr = new RegExp(/(<(p|b|span|u){1}.*?>).*?(<\/\2>)/i);
  58. for (var i = 0; i < matchesArr.length; i++) {
  59. var NewHtmlStr = matchesArr[i];
  60. while (pattStr.test(NewHtmlStr)) {
  61. var TmatchesArr = NewHtmlStr.match(pattStr);
  62. if (TmatchesArr.length > 0) {
  63. // 存在P标签
  64. NewHtmlStr = NewHtmlStr.replace(TmatchesArr[1], "").replace(TmatchesArr[3], "");
  65. }
  66. }
  67. if (i == 0 || (HtmlStr.length < NewHtmlStr.length)) {
  68. HtmlStr = NewHtmlStr;
  69. }
  70. }
  71. }
  72. else {
  73. pattStr = new RegExp(/(<(b|span|u){1}.*?>).*?(<\/\2>)/i);
  74. if (pattStr.test(HtmlStr)) {
  75. while (pattStr.test(HtmlStr)) {
  76. var matchesArr = HtmlStr.match(pattStr);
  77. if (matchesArr.length > 0) {
  78. HtmlStr = HtmlStr.replace(matchesArr[1], "").replace(matchesArr[3], "");
  79. }
  80. }
  81. }
  82. }
  83. return HtmlStr;
  84. };
  85. // 获取最大字符长度的字符串(起决定宽度的字符串/将字符去除HTML标签)(替换,不用)
  86. var dealTdTextFunc = function (HtmlStr) {
  87. var ReStr = "";
  88. var ReNumber = 0;
  89. var pattStr = new RegExp(/<P.*?<\/P>/i);
  90. if (pattStr.test(HtmlStr)) {
  91. while (pattStr.test(HtmlStr)) {
  92. var matchesArr = HtmlStr.match(pattStr);
  93. $("#pContrainId").html(matchesArr[0]);
  94. HtmlStr = HtmlStr.replace(matchesArr[0], "");
  95. if (ReNumber <= $("#pContrainId").text().length) {
  96. ReNumber = $("#pContrainId").text().length;
  97. ReStr = $("#pContrainId").text();
  98. }
  99. }
  100. }
  101. else {
  102. $("#pContrainId").html(HtmlStr);
  103. ReStr = $("#pContrainId").text();
  104. }
  105. return ReStr;
  106. };
  107. var AdjustTableFunc = function () {
  108. // 添加宽度处理
  109. var ScreenWidth = $(document.body).width();
  110. $(document.body).css("width", "999999px");
  111. $(document.body).append('<span id="pContrainId"></span>');
  112. var Index = 0;
  113. $.each($("table"), function (index, item) {
  114. // 处理表格总宽度
  115. var ArrMaxLen = [];
  116. var TableWidth = 0;
  117. var TotalMaxLen = 0;
  118. var RuleFlag = true;
  119. $.each($(item).find("tr"), function (trIndex, trItem) {
  120. $.each($(trItem).find("td"), function (tdIndex, tdItem) {
  121. var tdtext = removeHtmlFunc($(tdItem).html());
  122. $("#pContrainId").text(tdtext);
  123. var tdWidthVal = $("#pContrainId").width();
  124. if (ArrMaxLen.length < tdIndex + 1) {
  125. if (trIndex != 0) {
  126. RuleFlag = false;
  127. }
  128. ArrMaxLen.push(0);
  129. }
  130. if (ArrMaxLen[tdIndex] < tdWidthVal) {
  131. TotalMaxLen += tdWidthVal - ArrMaxLen[tdIndex];
  132. ArrMaxLen[tdIndex] = tdWidthVal;
  133. }
  134. });
  135. });
  136. // 判断表格是否只有一行
  137. if ($(item).find("tr").length == 1 && $(item).find("tr").eq(0).find("td").length == 1) {
  138. $(item).find("tr").eq(0).find("td").eq(0).css("width", (ScreenWidth - 4 - GetPadVal()) + "px");
  139. $(item).css("width", (ScreenWidth - 4 - GetPadVal()) + "px");
  140. }
  141. else {
  142. if (TotalMaxLen < ScreenWidth) {
  143. var AddPx = (ScreenWidth - TotalMaxLen) / ArrMaxLen.length;
  144. AddPx = AddPx > 2 ? AddPx - 2 : AddPx;
  145. for (var i = 0; i < ArrMaxLen.length; i++) {
  146. ArrMaxLen[i] += AddPx;
  147. }
  148. }
  149. var OneFlag = false;
  150. for (var i = 0; i < ArrMaxLen.length; i++) {
  151. if (ArrMaxLen[i] != undefined && $(item).find("tr").eq(0).find("td").length > 1 && RuleFlag) {
  152. $(item).find("tr").eq(0).find("td").eq(i).css("width", ArrMaxLen[i] + "px");
  153. TableWidth += ArrMaxLen[i];
  154. }
  155. else if (ArrMaxLen[i] != undefined && $(item).find("tr").eq(0).find("td").length > 1 && !RuleFlag) {
  156. TableWidth += ArrMaxLen[i];
  157. var NotRuleWidth = 0;
  158. if (i == ArrMaxLen.length - 1) {
  159. NotRuleWidth = TableWidth / $(item).find("tr").eq(0).find("td").length;
  160. }
  161. $.each($(item).find("tr").eq(0).find("td"), function (tdIndex, tdItem) {
  162. $(tdItem).css("width", NotRuleWidth + "px");
  163. });
  164. }
  165. else if (ArrMaxLen[i] != undefined && $(item).find("tr").eq(0).find("td").length == 1) {
  166. OneFlag = true;
  167. TableWidth += ArrMaxLen[i];
  168. }
  169. }
  170. if (OneFlag) {
  171. $(item).find("tr").eq(0).find("td").eq(0).css("width", TableWidth + "px");
  172. }
  173. $(item).css("width", TableWidth + "px");
  174. }
  175. // 替换HTML
  176. var ChildHtmlStr = $(item).prop("outerHTML");
  177. var HtmlStr = "<div class='TableContainer TContain_" + Index + "'></div>";
  178. $(item).after(HtmlStr);
  179. $(item).remove();
  180. var JqStr = ".TContain_" + Index;
  181. $(JqStr).append(ChildHtmlStr);
  182. Index += 1;
  183. });
  184. $(document.body).css("width", ScreenWidth + "px");
  185. var BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width()) - GetPadVal()); // 界面宽度
  186. var Index = 0;
  187. $.each($("table"), function (index, item) {
  188. var TableWidth = isNaN(parseFloat($(item).width())) ? 0 : parseFloat($(item).width()); // 表格宽度
  189. // 替换HTML
  190. var JqStr = ".TContain_" + Index;
  191. $(JqStr).css("width", BodyWidth + "px");
  192. if (TableWidth > BodyWidth) {
  193. // 额外显示滚动条
  194. var SHtmlStr = "<div class='PSBar' style='width: " + BodyWidth + "px;'></div>";
  195. $(JqStr).after(SHtmlStr);
  196. var HiddenRate = BodyWidth / TableWidth; // 滚动条比率
  197. var HiddenWidth = BodyWidth - (TableWidth - BodyWidth) * HiddenRate; // 现滚动条大小
  198. var CSHtmlStr = "<div class='CSBar' style='width: " + HiddenWidth + "px;'></div>";
  199. $(JqStr).next().append(CSHtmlStr);
  200. }
  201. Index += 1;
  202. });
  203. $.each($(".container-table"), function (index, item) {
  204. $(item).css("width", BodyWidth + "px");
  205. });
  206. // 滚动条事件
  207. $(".TableContainer").on("touchstart", function () {
  208. pressTableFlag = true;
  209. }).on("touchmove", function () {
  210. var TableWidth = isNaN(parseFloat($(this).find("table").width())) ? 0 : parseFloat($(this).find("table").width()); // 表格宽度
  211. BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width() - GetPadVal())); // 界面宽度
  212. var HiddenRate = BodyWidth / TableWidth; // 滚动条比率
  213. var SLeftWdith = isNaN(parseFloat($(this)[0].scrollLeft)) ? 0 : parseFloat($(this)[0].scrollLeft);
  214. SLeftWdith *= HiddenRate;
  215. var NextClsName = $(this).next().attr("class");
  216. if (NextClsName == "PSBar") {
  217. $(this).next().find(".CSBar").css("left", SLeftWdith + "px");
  218. }
  219. });
  220. window.addEventListener("scroll", function (event) {
  221. var ClsName = event.target.className;
  222. if (ClsName == undefined) {
  223. return;
  224. }
  225. ClsName = ClsName.replace("TableContainer ", ".");
  226. var TableWidth = isNaN(parseFloat($(ClsName).find("table").width())) ? 0 : parseFloat($(ClsName).find("table").width()); // 表格宽度
  227. BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width() - GetPadVal())); // 界面宽度
  228. var HiddenRate = BodyWidth / TableWidth; // 滚动条比率
  229. var SLeftWdith = isNaN(parseFloat($(ClsName)[0].scrollLeft)) ? 0 : parseFloat($(ClsName)[0].scrollLeft);
  230. SLeftWdith *= HiddenRate;
  231. var NextClsName = $(ClsName).next().attr("class");
  232. if (NextClsName == "PSBar") {
  233. $(ClsName).next().find(".CSBar").css("left", SLeftWdith + "px");
  234. }
  235. }, true);
  236. $("#pContrainId").remove();
  237. };
  238. // 表格处理End
  239. // 判断是否在横线内
  240. var isGCFunc = function (NodeHandle) {
  241. var isFlag = false;
  242. var PClsName = $(NodeHandle).attr("class");
  243. var tagName = $(NodeHandle).prop("tagName");
  244. while (tagName != undefined && tagName != "BODY" && ((PClsName != undefined && PClsName.indexOf("underlineContent") == -1) || PClsName == undefined)) {
  245. NodeHandle = $(NodeHandle).parent();
  246. PClsName = $(NodeHandle).attr("class");
  247. tagName = $(NodeHandle).prop("tagName");
  248. }
  249. if (PClsName != undefined && PClsName.indexOf("underlineContent") > -1) {
  250. isFlag = true;
  251. }
  252. return isFlag;
  253. };
  254. // 处理高亮
  255. var dealGLShowFunc = function (NodeHandle) {
  256. if (styleWPSContrl.wordFlag) {
  257. $(NodeHandle).find(".wordStyle").css("color", "#db5d00");
  258. }
  259. else {
  260. $.each($(NodeHandle).find(".wordStyle"), function (index, element) {
  261. if (isGCFunc(element)) {
  262. $(element).css("color", "#92D050");
  263. }
  264. else {
  265. $(element).css("color", "#000000");
  266. }
  267. });
  268. }
  269. if (styleWPSContrl.phraseFlag) {
  270. $(NodeHandle).find(".phraseStyle").css("background-color", "#f2db8b");
  271. }
  272. else {
  273. $(NodeHandle).find(".phraseStyle").css("background-color", "#fff");
  274. }
  275. if (styleWPSContrl.sentenceFlag) {
  276. $(NodeHandle).find(".sentenceStyle").css("border-bottom", "2px solid #78ae43");
  277. }
  278. else {
  279. $(NodeHandle).find(".sentenceStyle").css("border-bottom", "2px solid #fff");
  280. }
  281. };
  282. // 处理显示或隐藏答案
  283. var dealAnswerFunc = function (NodeHandle, OCFlag) {
  284. var FontSizeValue = $(NodeHandle).css("font-size");
  285. var underlineContentText = $(NodeHandle).text(); // 获取文本内容
  286. var widthValue = $(NodeHandle).css("width");
  287. var newClsName = $(NodeHandle).next().attr("class");
  288. if (newClsName != "underlineContentShow") {
  289. var addHtml = "";
  290. if (hasChineseWorld(underlineContentText)) {
  291. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";font-size:" + FontSizeValue + ";line-height:" + FontSizeValue + ";height:" + FontSizeValue + ";' data-status='0'>&emsp;</span>";
  292. }
  293. else {
  294. addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";font-size:" + FontSizeValue + ";line-height:" + FontSizeValue + ";height:" + FontSizeValue + ";' data-status='0'>&nbsp;</span>";
  295. }
  296. if (OCFlag) {
  297. $(NodeHandle).css("display", "inline-block").after(addHtml);
  298. // 处理高亮
  299. dealGLShowFunc(NodeHandle);
  300. }
  301. else {
  302. $(NodeHandle).css("display", "none").after(addHtml);
  303. $(NodeHandle).next().attr("data-status", "1");
  304. }
  305. }
  306. else {
  307. if (OCFlag) {
  308. $(NodeHandle).css("display", "inline-block").next().attr("data-status", "0");
  309. // 处理高亮
  310. dealGLShowFunc(NodeHandle);
  311. }
  312. else {
  313. $(NodeHandle).css("display", "none").next().attr("data-status", "1");
  314. }
  315. }
  316. if (underlineContentText.indexOf("√") > -1) {
  317. if (OCFlag) {
  318. $(NodeHandle).parent().find(".checkbox").find("input").prop('checked', true);
  319. }
  320. else {
  321. $(NodeHandle).parent().find(".checkbox").find("input").prop('checked', false);
  322. }
  323. }
  324. };
  325. //显示、隐藏答案
  326. function showHideAnswer(flag) {
  327. if (flag) {
  328. $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
  329. $.each($(".underlineContent"), function (index, item) {
  330. dealAnswerFunc(item, true);
  331. });
  332. }
  333. else {
  334. $(".yaoshi").attr("src", PicInfo.yaoshiHideImgUrl);
  335. $.each($(".underlineContent,.underlineContent.no-answer"), function (index, item) {
  336. dealAnswerFunc(item, false);
  337. });
  338. }
  339. }
  340. ///显示、隐藏钥匙及答案 isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  341. function showHideAnswerEx(isShowYX, isShowAS) {
  342. if (isShowYX) {
  343. $(".yaoshi").show();
  344. }
  345. else {
  346. $(".yaoshi").hide();
  347. }
  348. if (isShowAS) {
  349. $.each($(".underlineContent"), function (index, item) {
  350. dealAnswerFunc(item, true);
  351. });
  352. $(".yaoshi").attr("data-status", "1");
  353. $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
  354. }
  355. else {
  356. $.each($(".underlineContent,.underlineContent.no-answer"), function (index, item) {
  357. dealAnswerFunc(item, false);
  358. });
  359. $(".yaoshi").attr("data-status", "0");
  360. $(".yaoshi").attr("src", PicInfo.yaoshiHideImgUrl);
  361. }
  362. }
  363. //页面加载完,原文 绑定事件
  364. function bindEventTeaOrignalYS() {
  365. var bodyWidth = $(document.body).width();
  366. //处理答题点
  367. $.each($(".yaoshi"), function (index, item) {
  368. $(item).attr('answer-id', index);
  369. });
  370. //给音频绑定一个ID
  371. $.each($(".audioImg"), function (index, item) {
  372. $(item).attr("audiourl", "");
  373. $(item).attr('audio-id', index);
  374. });
  375. //给视频图标处理
  376. $.each($(".videoImg"), function (index, item) {
  377. $(item).attr("audiourl", "");
  378. });
  379. //给口语图标处理
  380. $.each($(".oralLanguageImg"), function (index, item) {
  381. $(item).attr("audiourl", "");
  382. });
  383. //处理参考答案
  384. $.each($(".underlineContent"), function (index, item) {
  385. $(item).attr("answer-anstext", $(item).html());
  386. });
  387. //去除多余的U空标签
  388. $.each($("u"), function (index, item) {
  389. var text = $(item).text();
  390. text = text.replace(/\s+/g, "");
  391. if (text == "") {
  392. $(item).remove();
  393. }
  394. });
  395. //处理暂无参考答案
  396. $.each($(".yaoshi"), function (index, item) {
  397. var parent = $(item).parent();
  398. var prev = $(item).nextUntil(".yaoshi").find(".underlineContent");
  399. if (prev.length == 0) {
  400. var spanHtml = document.createElement("span");
  401. //添加子节点
  402. var uHtml = document.createElement("u");
  403. uHtml.className = "underlineContent no-answer";
  404. uHtml.innerText = "暂无参考答案";
  405. //处理改错题及勾选题
  406. if ($(parent)[0].tagName == 'P') {
  407. if ($(parent).hasClass('correntQue') || $(parent).hasClass('boxQue')) {
  408. uHtml.innerHTML = "&nbsp;&nbsp;&nbsp;";
  409. //改错题,要随机下划线长度
  410. if ($(parent).hasClass('correntQue')) {
  411. uHtml.style = "width:" + randomNum(220, 300) + "px;";
  412. }
  413. uHtml.setAttribute("answer-anstext", "");
  414. }
  415. }
  416. $(spanHtml).html(uHtml.outerHTML);
  417. $(item).after(spanHtml);
  418. }
  419. });
  420. //处理表格宽度
  421. AdjustTableFunc();
  422. //一题多空的答题点标注
  423. var checkId = 0;
  424. var headid = -1;
  425. var groupId = -1;
  426. $(".multipleStart").each(function (i, item) {
  427. var $startNode = $(item);
  428. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  429. checkId = $(item).find('.yaoshi').attr("answer-id");
  430. var gid = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
  431. if (index == 0 || groupId != gid) {
  432. groupId = gid;
  433. headid = checkId;
  434. }
  435. $(item).find('.yaoshi').attr('parent-anid', headid);
  436. });
  437. });
  438. //点击喇叭事件,音频播放
  439. $(".audioImg").on("click", function () {
  440. audioPlayClick(this);
  441. });
  442. //显示/隐藏习题答案
  443. $(".yaoshi").on("click", function () {
  444. var parentAnid = $(this).attr("parent-anid");
  445. var curDisplay = $(this).nextUntil(".yaoshi").find(".underlineContent").eq(0).css("display");
  446. if (curDisplay == "undefined" || curDisplay == undefined) return;
  447. if (curDisplay == "none" || $(this).attr("data-status") == "0") {
  448. if (parentAnid != undefined) {
  449. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, item) {
  450. $(item).attr("data-status", "1");
  451. $(item).attr("src", PicInfo.yaoshiShowImgUrl);
  452. $.each($(item).parent().find(".underlineContent"), function (cIndex, cItem) {
  453. dealAnswerFunc(cItem, true);
  454. });
  455. });
  456. }
  457. else {
  458. $(this).attr("data-status", "1");
  459. $(this).attr("src", PicInfo.yaoshiShowImgUrl);
  460. $.each($(this).nextUntil(".yaoshi").find(".underlineContent"), function (index, item) {
  461. dealAnswerFunc(item, true);
  462. });
  463. }
  464. //不再存在已隐藏的钥匙,移动端回调
  465. if ($(".yaoshi[data-status='0']").length == 0) {
  466. //添加回调
  467. console.log("全部显示了");
  468. onClickKeyShow();
  469. }
  470. }
  471. else {
  472. if (parentAnid != undefined) {
  473. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, item) {
  474. $(item).attr("data-status", "0");
  475. $(item).attr("src", PicInfo.yaoshiHideImgUrl);
  476. $.each($(item).parent().find(".underlineContent"), function (cIndex, cItem) {
  477. dealAnswerFunc(cItem, false);
  478. });
  479. });
  480. }
  481. else {
  482. $(this).attr("data-status", "0");
  483. $(this).attr("src", PicInfo.yaoshiHideImgUrl);
  484. $.each($(this).nextUntil(".yaoshi").find(".underlineContent"), function (index, item) {
  485. dealAnswerFunc(item, false);
  486. });
  487. }
  488. //添加回调
  489. onClickKeyHide();
  490. }
  491. });
  492. //点击播放事件,视频播放
  493. $(".videoImg").on("click", function () {
  494. var curHtml = $(this).parent().find(".videoUrl").html();
  495. var curAlt = $(this).attr("alt");//播放视频地址
  496. playVisiableAudioCallBack(2, $(this).attr("alt"));
  497. });
  498. }
  499. //页面加载完,课件 绑定事件
  500. function bindEventYS() {
  501. var bodyWidth = $(document.body).width();
  502. //不存在underline 属性下有内容,所以全部隐藏,若有就是源头数据有问题
  503. $('.underline').css("display", "none");
  504. $.each($(".yaoshi"), function (index, item) {
  505. $(item).attr('answer-id', index);
  506. });
  507. //给音频绑定一个ID
  508. $.each($(".audioImg"), function (index, item) {
  509. $(item).attr("audiourl", "");
  510. $(item).attr('audio-id', index);
  511. });
  512. //给视频图标处理
  513. $.each($(".videoImg"), function (index, item) {
  514. $(item).attr("audiourl", "");
  515. });
  516. //给口语图标处理
  517. $.each($(".oralLanguageImg"), function (index, item) {
  518. $(item).attr("audiourl", "");
  519. });
  520. //去除多余的U空标签
  521. $.each($("u"), function (index, item) {
  522. var text = $(item).text();
  523. text = text.replace(/\s+/g, "");
  524. if (text == "") {
  525. $(item).remove();
  526. }
  527. });
  528. //处理暂无参考答案
  529. $.each($(".yaoshi"), function (index, item) {
  530. var parent = $(item).parent();
  531. var prev = $(item).nextAll(".underlineContent");
  532. if (prev.length == 0) {
  533. var uHtml = document.createElement("u");
  534. uHtml.className = "underlineContent no-answer";
  535. uHtml.innerText = "暂无参考答案";
  536. //处理改错题及勾选题
  537. if ($(parent)[0].tagName == 'P') {
  538. if ($(parent).hasClass('correntQue') || $(parent).hasClass('boxQue')) {
  539. uHtml.innerHTML = "&nbsp;&nbsp;&nbsp;";
  540. //改错题,要随机下划线长度
  541. if ($(parent).hasClass('correntQue')) {
  542. uHtml.style = "width:" + randomNum(220, 300) + "px;";
  543. }
  544. uHtml.setAttribute("answer-anstext", "");
  545. }
  546. }
  547. $(item).after(uHtml);
  548. }
  549. });
  550. //处理表格宽度
  551. AdjustTableFunc();
  552. //一题多空的答题点标注
  553. var checkId = 0;
  554. var headid = -1;
  555. var groupId = -1;
  556. $(".multipleStart").each(function (i, item) {
  557. var $startNode = $(item);
  558. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  559. checkId = $(item).find('.yaoshi').attr("answer-id");
  560. var gid = $(item).attr('class').replace(/.*group(\d+).*/g, "$1");
  561. if (index == 0 || groupId != gid) {
  562. groupId = gid;
  563. headid = checkId;
  564. }
  565. $(item).find('.yaoshi').attr('parent-anid', headid);
  566. });
  567. });
  568. //显示/隐藏习题答案
  569. $(".yaoshi").on("click", function () {
  570. var parentAnid = $(this).attr("parent-anid");
  571. if ($(this).attr("data-status") == "0") {
  572. // 显示处理
  573. if (parentAnid != undefined) {
  574. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, fItem) {
  575. $(fItem).attr("data-status", "1");
  576. $(fItem).attr("src", PicInfo.yaoshiShowImgUrl);
  577. $.each($(fItem).parent().find(".underlineContent"), function (index, item) {
  578. dealAnswerFunc(item, true);
  579. });
  580. });
  581. }
  582. else {
  583. $(this).attr("data-status", "1");
  584. $(this).attr("src", PicInfo.yaoshiShowImgUrl);
  585. //$(this).nextUntil(".yaoshi").filter(".underlineContent").css("color", "#92D050");
  586. $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
  587. dealAnswerFunc(item, true);
  588. });
  589. }
  590. //不再存在已隐藏的钥匙,移动端回调
  591. if ($(".yaoshi[data-status='0']").length == 0) {
  592. //添加回调
  593. onClickKeyShow();
  594. }
  595. }
  596. else {
  597. // 隐藏处理
  598. if (parentAnid != undefined) {
  599. $.each($(this).parents().find(".yaoshi[parent-anid='" + parentAnid + "']"), function (index, fItem) {
  600. $(fItem).attr("data-status", "0");
  601. $(fItem).attr("src", PicInfo.yaoshiHideImgUrl);
  602. $.each($(fItem).parent().find(".underlineContent"), function (index, item) {
  603. dealAnswerFunc(item, false);
  604. });
  605. });
  606. }
  607. else {
  608. $(this).attr("data-status", "0");
  609. $(this).attr("src", PicInfo.yaoshiHideImgUrl);
  610. //$(this).nextUntil(".yaoshi").filter(".underlineContent").css("color", "#ffffff");
  611. $.each($(this).nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
  612. dealAnswerFunc(item, false);
  613. });
  614. }
  615. //添加回调
  616. onClickKeyHide();
  617. }
  618. });
  619. //点击喇叭事件,音频播放
  620. $(".audioImg").on("click", function () {
  621. audioPlayClick(this);
  622. });
  623. //点击播放事件,视频播放
  624. $(".videoImg").on("click", function () {
  625. $(this).attr("audiourl", "");
  626. var curHtml = $(this).parent().find(".videoUrl").html();
  627. var curAlt = $(this).attr("alt");//播放视频地址
  628. playVisiableAudioCallBack(2, $(this).attr("alt"));
  629. });
  630. }
  631. // 移动端使用,true:表示点击表格且正在移动,需阻止模块切换
  632. function getPressFlag() {
  633. return pressTableFlag;
  634. }
  635. // 滚动条渲染
  636. // 设置离焦事件
  637. function resetPressFlag() {
  638. pressTableFlag = false;
  639. }
  640. // 判断是否存在中文(true表示存在)
  641. var hasChineseWorld = function (dataStr) {
  642. if (escape(dataStr).indexOf("%u") < 0) {
  643. return false;
  644. }
  645. else {
  646. return true;
  647. }
  648. };
  649. //学生端 处理作答区域
  650. var answerData = new Array();
  651. function handleAnswerRange() {
  652. // 隐藏答案划线
  653. $(".underlineContentShow").attr("data-status", "0");
  654. //规范文本格式
  655. var answerId = "";
  656. var tempJson = new Array();
  657. //先处理一题多空的情况,获取两个之间的答题点
  658. $(".multipleStart").each(function (i, item) {
  659. $.merge($(item).nextUntil(".multipleEnd").filter("[class*='group']"), $(item).nextUntil(".multipleEnd").find("[class*='group']")).each(function (index, item) {
  660. var checkId = $(item).find('.yaoshi').attr("answer-id");
  661. var headid = $(item).find('.yaoshi').attr("parent-anid");
  662. var ischecked = $(item).find(".underlineContent").text().indexOf("√") > -1;
  663. var answerText = ischecked ? "√" : "";
  664. //勾选题
  665. if ($(item).hasClass('boxQue')) {
  666. $(item).find('.yaoshi').after("<div class='checkbox' answer-id='" + checkId + "' parent-anid='" + headid + "' answer-isky='2' answer-anstext=" + answerText + "><input id=" + checkId + " type='checkbox'><label for=" + checkId + "></label></div>");
  667. //$(item).find('input').prop('checked', ischecked);
  668. $(item).find('.underlineContent').hide();
  669. }
  670. //点击事件
  671. $(item).find('input').bind("click", function () {
  672. var curObj = new Object();
  673. curObj.Id = $(this).parent().attr("answer-id");//答题点ID
  674. curObj.pId = $(this).parent().attr("parent-anid");//答题点ID
  675. curObj.IsKY = $(this).parent().attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题,2-打勾题
  676. //curObj.Text = $(this).parent().attr("answer-text");//用户作答内容
  677. curObj.Score = $(this).parent().attr("answer-score");//作答评分
  678. curObj.AnsText = $(this).parent().attr("answer-anstext");//参考答案
  679. curObj.Comment = $(this).parent().attr("answer-comment");//评语
  680. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  681. curObj.Text = $(this).prop("checked") ? "√" : "";//用户作答内容
  682. $(this).parent().attr("answer-text", curObj.Text);//用户作答内容
  683. $(".checkbox").removeClass("select-answer");
  684. $(".answer-body").removeClass("select-answer");
  685. $(this).parent().addClass("select-answer");
  686. //已作答,弹出作答答案
  687. if ($(this).parent().data("ans-status") == "1") {
  688. //移动端添加外部处理
  689. onClickAnswerPoint(JSON.stringify(curObj));
  690. }
  691. else {
  692. //移动端添加外部处理,弹出作答操作
  693. onClickAnswerPoint(JSON.stringify(curObj));
  694. }
  695. });
  696. //删除钥匙节点
  697. $(item).find('.yaoshi').hide();
  698. });
  699. });
  700. //所有underline不做处理
  701. $.each($(".yaoshi").nextUntil(".yaoshi").filter(".underline"), function (index, item) {
  702. tempId = $(item).prevAll(".yaoshi").attr("answer-id");
  703. //记录上一次的ID
  704. if (tempId == undefined) {
  705. tempId = answerId;
  706. }
  707. else {
  708. answerId = tempId;
  709. }
  710. var prev = $(item).prev();
  711. if ((prev.length == 0 || $(prev).attr("class") != "tag-span") && $(prev).attr("class") != "underlineContent") {
  712. if ($("span[answer-id='" + tempId + "']").length == 0) {
  713. $(item).prop("outerHTML", "<span answer-id='" + tempId + "' class='tag-span' answer-isky='0'>_</span>");
  714. }
  715. }
  716. $(item).remove();
  717. });
  718. //提取参考答案并规范文本格式
  719. answerId = "";
  720. $.each($(".yaoshi").nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
  721. var info = new Object();
  722. info.Id = $(item).prevAll(".yaoshi").attr("answer-id");
  723. info.pId = $(item).prevAll(".yaoshi").attr("parent-anid");
  724. //记录上一次的ID
  725. if (info.Id == undefined) {
  726. info.Id = answerId;
  727. }
  728. else {
  729. answerId = info.Id;
  730. }
  731. if (info.pId == undefined) {
  732. info.pId = answerId;
  733. }
  734. info.AnsText = $(item).attr("answer-anstext");
  735. if (info.AnsText == undefined) {
  736. info.AnsText = $(item).text();
  737. }
  738. tempJson.push(info);
  739. var prev = $(item).prev();
  740. if (!$(prev).hasClass("checkbox")) {
  741. if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
  742. //替换答案
  743. $(item).prop("outerHTML", "<span answer-id='" + info.Id + "' class='tag-span' answer-isky='0'>_</span>");
  744. }
  745. else {
  746. $(item).remove();
  747. }
  748. }
  749. });
  750. $.each($(".yaoshi"), function (index, item) {
  751. var Id = $(item).attr("answer-id");
  752. var prev = $(item).next();
  753. if (!$(prev).hasClass("checkbox")) {
  754. if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
  755. if ($("span[answer-id='" + Id + "']").length == 0) {
  756. var uHtml = document.createElement("span");
  757. uHtml.className = "tag-span";
  758. uHtml.innerText = "_";
  759. uHtml.setAttribute("answer-id", Id);
  760. $(item).after(uHtml);
  761. }
  762. }
  763. }
  764. });
  765. //处理口语试题
  766. $.each($(".oralLanguage").nextUntil(".oralLanguageDone"), function (num, part) {
  767. if (part.tagName != "p") {
  768. $.each($(part).find(".tag-span"), function (index, item) {
  769. $(item).attr("answer-isky", "1");
  770. });
  771. }
  772. else {
  773. if ($(part).hasClass("underlinePart")) {
  774. $.each($(part).find(".tag-span"), function (index, item) {
  775. $(item).attr("answer-isky", "1");
  776. });
  777. }
  778. }
  779. });
  780. //合并参考答案数据
  781. var tempid = "";
  782. var temppid = "";
  783. var temptext = "";
  784. for (var i = 0; i < tempJson.length; i++) {
  785. if (tempid == tempJson[i].Id) {
  786. temptext = temptext + tempJson[i].AnsText;
  787. }
  788. else {
  789. if (tempid != "") {
  790. var info = new Object();
  791. info.Id = tempid;
  792. info.pId = temppid;
  793. info.AnsText = temptext;
  794. answerData.push(info);
  795. //重置
  796. tempid = "";
  797. temptext = "";
  798. }
  799. tempid = tempJson[i].Id;
  800. temppid = tempJson[i].pId;
  801. temptext = tempJson[i].AnsText;
  802. //最后一个存入
  803. if (i == tempJson.length - 1) {
  804. var info = new Object();
  805. info.Id = tempid;
  806. info.pId = temppid;
  807. info.AnsText = temptext;
  808. answerData.push(info);
  809. }
  810. }
  811. }
  812. //补全答题点
  813. var Num = 0;
  814. if (answerData.length > 0) {
  815. //Num = Number.parseInt(answerData[answerData.length - 1].Id);
  816. Num = Number.parseInt($(".yaoshi:last").attr('answer-id'));
  817. for (var i = 0; i < Num + 1; i++) {
  818. if (i < answerData.length) {
  819. var index = Number(answerData[i].Id) - i;
  820. for (var j = 0; j < index; j++) {
  821. var info = new Object();
  822. info.Id = (i + j).toString();
  823. info.pId = info.Id;
  824. info.AnsText = "";
  825. answerData.splice(i, 0, info);
  826. }
  827. }
  828. else {
  829. var info = new Object();
  830. info.Id = (i).toString();
  831. info.pId = info.Id;
  832. info.AnsText = "";
  833. answerData.splice(i, 0, info);
  834. }
  835. }
  836. }
  837. //添加答题点的点击UI及交互
  838. $.each($(".tag-span"), function (index, item) {
  839. var answerText = "";
  840. var parentId = "";
  841. var isky = $(item).attr('answer-isky');
  842. var answerid = $(item).attr('answer-id');
  843. for (var i = 0; i < answerData.length; i++) {
  844. if (answerid == answerData[i].Id) {
  845. parentId = answerData[i].pId;
  846. answerText = answerData[i].AnsText;
  847. break;
  848. }
  849. }
  850. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentId + "' answer-anstext='" + answerText + "' answer-isky='" + isky + "' answer-showanswer='0'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text'></buttom></div>");
  851. //删除钥匙节点
  852. var prev = $("img[answer-id='" + answerid + "']");
  853. if (prev.length > 0) {
  854. $(prev).remove();
  855. }
  856. });
  857. //添加点击事件
  858. $(".answer-body").on("click", function () {
  859. var curObj = new Object();
  860. curObj.Id = $(this).attr("answer-id");//答题点ID
  861. curObj.pId = $(this).attr("parent-anid");//答题点ID
  862. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  863. curObj.Text = $(this).attr("answer-text");//用户作答内容
  864. curObj.Score = $(this).attr("answer-score");//作答评分
  865. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  866. curObj.Comment = $(this).attr("answer-comment");//评语
  867. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  868. $(".checkbox").removeClass("select-answer");
  869. $(".answer-body").removeClass("select-answer");
  870. $(this).addClass("select-answer");
  871. //已作答,弹出作答答案
  872. if ($(this).data("ans-status") == "1") {
  873. //移动端添加外部处理
  874. onClickAnswerPoint(JSON.stringify(curObj));
  875. }
  876. else {
  877. //移动端添加外部处理,弹出作答操作
  878. onClickAnswerPoint(JSON.stringify(curObj));
  879. }
  880. });
  881. //去除多余的空格横线
  882. $.each($(".underline"), function (index, item) {
  883. var text = $(item).text();
  884. text = text.replace(/\s+/g, "");
  885. if (text == "") {
  886. $(item).remove();
  887. }
  888. });
  889. //删除所有钥匙节点
  890. $("img[class=yaoshi]").remove();
  891. //console.log(JSON.stringify(answerData));
  892. return answerData;
  893. }
  894. //接收学生的作答
  895. function reviewAnswer(answerJson) {
  896. if (answerJson != "" && answerJson) {
  897. var answerObj = JSON.parse(answerJson);
  898. var selectElement = $(".answer-body[answer-id='" + answerObj.Id + "']");
  899. var audioElement = $(selectElement).children(".answer-audio-range").children("img").eq(0);
  900. answerObj.IsKY = $(selectElement).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  901. //是否为音频作答
  902. if ((answerObj.Type == 3 || answerObj.Type == 4) && answerObj.AudioUrl != "") {
  903. $(selectElement).children(".answer-point-range").hide();
  904. $(selectElement).children(".answer-audio-range").css("display", "inline-block");
  905. $(selectElement).children(".answer-audio-range").children("span").text("作答音频(" + answerObj.AudioLength + "s)");
  906. //填充作答内容
  907. $(selectElement).attr("answer-text", answerObj.Text);
  908. if (answerObj.Text != "") {
  909. answerObj.Text = "(" + answerObj.Text + ")";
  910. $(selectElement).children(".answer-text").show();
  911. $(selectElement).children(".answer-text").text(answerObj.Text);
  912. }
  913. //是否之前存在作答音频
  914. $(selectElement).attr("answer-url", answerObj.AudioUrl);
  915. $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
  916. $(selectElement).children(".answer-audio-range").attr("play-status", "0");
  917. //独立绑定事件
  918. $(audioElement).on("click", function () {
  919. recordAudioClick(this, answerObj.Id, answerObj.AudioUrl);
  920. });
  921. $(selectElement).children(".answer-audio-range").children("span").on("click", function () {
  922. $(".answer-body").removeClass("select-answer");
  923. $(selectElement).addClass("select-answer");
  924. onClickAnswerPoint(JSON.stringify(answerObj));
  925. });
  926. }
  927. else {
  928. $(selectElement).attr("answer-text", answerObj.Text);//填充作答内容
  929. $(selectElement).children(".answer-audio-range").hide();
  930. if (answerObj.Text != "") {
  931. $(selectElement).children(".answer-text").show();
  932. $(selectElement).children(".answer-point-range").hide();
  933. $(selectElement).children(".answer-text").text(answerObj.Text);
  934. }
  935. else {
  936. $(selectElement).children(".answer-text").hide();
  937. $(selectElement).children(".answer-point-range").show();
  938. }
  939. }
  940. }
  941. }
  942. //提交,获取所有作答答案及参考答案
  943. function getAllAnswer() {
  944. //处理作答
  945. $.each($(".answer-body"), function (index, item) {
  946. var answerid = $(item).attr("answer-id");
  947. var parentid = $(item).attr("parent-anid");
  948. var mytext = $(item).children(".answer-text").text();
  949. var curDisplay = $(item).children(".answer-audio-range").css("display");
  950. if (mytext == "" && curDisplay == "none") {
  951. mytext = "未作答";
  952. if (parentid != answerid) {
  953. mytext = "&nbsp;&nbsp;&nbsp;&nbsp;";
  954. $(item).children(".answer-text").html(mytext);
  955. $(item).children(".answer-text").addClass("noanswer-border");
  956. }
  957. else {
  958. $(item).children(".answer-text").text(mytext);
  959. $(item).children(".answer-text").addClass("no-answer");
  960. }
  961. $(item).children(".answer-point-range").hide();
  962. $(item).children(".answer-text").show();
  963. }
  964. });
  965. $(".answer-body").removeClass("select-answer");//移除样式
  966. $(".answer-body").unbind("click");//取消点击绑定事件
  967. $(".answer-body").children(".answer-audio-range").children("span").unbind("click");//取消点击绑定事件
  968. //打勾题的还原
  969. $.each($(".checkbox"), function (num, item) {
  970. var answerid = $(item).attr("answer-id");
  971. var parentid = $(item).attr("parent-anid");
  972. //提交直接还原作答现场
  973. var mytext = $(item).attr("answer-text");//我的答案
  974. var ischecked = mytext.indexOf("√") > -1;
  975. var answerText = $(item).attr("answer-anstext");//参考答案
  976. mytext = mytext == "" ? "__" : mytext;
  977. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text' style='display:block;'>" + mytext + "</buttom></div>");
  978. });
  979. //console.log(JSON.stringify(answerData));
  980. return answerData;
  981. }
  982. //回填所有答案,answerJson:所有作答及参考答案List,statusType:0-可作答,1-已提交,2-查看评阅
  983. function backupAllAnswer(answerJson, statusType) {
  984. if (answerJson != "" && answerJson) {
  985. var answerList = JSON.parse(answerJson);
  986. $.each($(".answer-body"), function (num, item) {
  987. //查找
  988. var index = 0;
  989. var answerid = $(item).attr("answer-id");
  990. var parentid = $(item).attr("parent-anid");
  991. for (var i = 0; i < answerList.length; i++) {
  992. if (answerid == answerList[i].Id) {
  993. index = i;
  994. break;
  995. }
  996. }
  997. //提交直接还原作答现场
  998. var mytext = answerList[index].Text;//我的答案
  999. answerList[index].IsKY = $(item).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  1000. //添加音频控制
  1001. var hasAudio = false;
  1002. var audioElement = $(item).children(".answer-audio-range").children("img").eq(0);
  1003. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  1004. hasAudio = true;
  1005. $(item).children(".answer-point-range").hide();
  1006. $(item).children(".answer-audio-range").css("display", "inline-block");
  1007. $(item).children(".answer-audio-range").children("span").text("作答音频(" + answerList[index].AudioLength + "s)");
  1008. //填充作答内容
  1009. $(item).attr("answer-text", mytext);
  1010. if (mytext != "") {
  1011. mytext = "(" + mytext + ")";
  1012. $(item).children(".answer-text").show();
  1013. $(item).children(".answer-text").text(mytext);
  1014. }
  1015. //音频节点
  1016. $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
  1017. $(item).attr("answer-url", answerList[index].AudioUrl);
  1018. $(item).children(".answer-audio-range").attr("play-status", "0");
  1019. //独立绑定事件
  1020. $(audioElement).on("click", function () {
  1021. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  1022. });
  1023. }
  1024. //可作答状态,作答还原
  1025. if (statusType == 0) {
  1026. //已作答过,还原作答,增加作答后的UI节点
  1027. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  1028. $(item).children(".answer-audio-range").children("span").on("click", function () {
  1029. $(".answer-body").removeClass("select-answer");
  1030. $(item).addClass("select-answer");
  1031. onClickAnswerPoint(JSON.stringify(answerList[index]));
  1032. });
  1033. }
  1034. else {
  1035. $(item).attr("answer-text", mytext);//填充作答内容
  1036. if (mytext != "") {
  1037. $(item).children(".answer-text").show();
  1038. $(item).children(".answer-point-range").hide();
  1039. $(item).children(".answer-text").text(mytext);
  1040. }
  1041. }
  1042. }
  1043. //已提交,作答还原
  1044. if (statusType == 1) {
  1045. //取消点击绑定事件
  1046. $(item).unbind('click');
  1047. //填充作答内容
  1048. $(item).attr("answer-text", mytext);
  1049. if (mytext == "" && !hasAudio) {
  1050. mytext = "未作答";
  1051. if (parentid != answerid) {
  1052. mytext = "&nbsp;&nbsp;&nbsp;&nbsp;";
  1053. $(item).children(".answer-text").html(mytext);
  1054. $(item).children(".answer-text").addClass("noanswer-border");
  1055. }
  1056. else {
  1057. $(item).children(".answer-text").text(mytext);
  1058. $(item).children(".answer-text").addClass("no-answer");
  1059. }
  1060. $(item).children(".answer-text").show();
  1061. }
  1062. else if (mytext == "" && hasAudio) {
  1063. $(item).children(".answer-text").hide();
  1064. }
  1065. else {
  1066. $(item).children(".answer-text").show();
  1067. $(item).children(".answer-text").text(mytext);
  1068. }
  1069. $(item).children(".answer-point-range").hide();
  1070. }
  1071. //已评阅,查看评阅详情
  1072. if (statusType == 2) {
  1073. //添加音频控制
  1074. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  1075. //独立绑定事件
  1076. $(item).children(".answer-audio-range").children("span").on("click", function () {
  1077. $(".answer-body").removeClass("select-answer");
  1078. $(item).addClass("select-answer");
  1079. onClickAnswerPoint(JSON.stringify(answerList[index]));
  1080. });
  1081. }
  1082. else {
  1083. $(item).attr("answer-text", mytext);//填充作答内容
  1084. if (mytext == "" && !hasAudio) {
  1085. mytext = "未作答";
  1086. if (parentid != answerid) {
  1087. mytext = "&nbsp;&nbsp;&nbsp;&nbsp;";
  1088. $(item).children(".answer-text").html(mytext);
  1089. $(item).children(".answer-text").addClass("noanswer-border");
  1090. }
  1091. else {
  1092. $(item).children(".answer-text").text(mytext);
  1093. $(item).children(".answer-text").addClass("no-answer");
  1094. }
  1095. $(item).children(".answer-text").show();
  1096. }
  1097. else if (mytext == "" && hasAudio) {
  1098. $(item).children(".answer-text").hide();
  1099. }
  1100. else {
  1101. $(item).children(".answer-text").show();
  1102. $(item).children(".answer-text").text(mytext);
  1103. }
  1104. $(item).children(".answer-point-range").hide();
  1105. }
  1106. //评阅样式
  1107. if (answerList[index].Score == 0 && answerList[index].Text != "") {
  1108. $(item).children(".answer-text").addClass("bad-answer");
  1109. }
  1110. if (answerList[index].Score > 0) {
  1111. $(item).children(".answer-text").addClass("good-answer");
  1112. }
  1113. }
  1114. // 添加answer-boy的样式判断
  1115. var DStatusFlag = $(item).find(".answer-point-range").css("display") != "none";
  1116. if (DStatusFlag) {
  1117. $(item).attr("answer-showanswer", "0"); // 修改显示格式
  1118. }
  1119. else {
  1120. $(item).attr("answer-showanswer", "1"); // 修改显示格式
  1121. }
  1122. });
  1123. //打勾题的还原
  1124. $.each($(".checkbox"), function (num, item) {
  1125. //可作答状态,作答还原
  1126. var index = 0;
  1127. var answerid = $(item).attr("answer-id");
  1128. var parentid = $(item).attr("parent-anid");
  1129. for (var i = 0; i < answerList.length; i++) {
  1130. if (answerid == answerList[i].Id) {
  1131. index = i;
  1132. break;
  1133. }
  1134. }
  1135. //提交直接还原作答现场
  1136. var mytext = answerList[index].Text;//我的答案
  1137. var ischecked = mytext.indexOf("√") > -1;
  1138. var answerText = $(item).attr("answer-anstext");//参考答案
  1139. $(item).attr("answer-text", mytext);
  1140. $(item).find('input').prop('checked', ischecked);
  1141. //已提交,已评阅,还原HTML代码,去除checkbox
  1142. if (statusType == 1 || statusType == 2) {
  1143. mytext = mytext == "" ? "__" : mytext;
  1144. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2' answer-text='" + mytext + "'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text' style='display:block;'>" + mytext + "</buttom></div>");
  1145. }
  1146. });
  1147. //点击事件重新绑定
  1148. if (statusType == 0 || statusType == 2) {
  1149. $(".answer-body").unbind("click").on("click", function () {
  1150. var curObj = new Object();
  1151. curObj.Id = $(this).attr("answer-id");//答题点ID
  1152. curObj.pId = $(this).attr("parent-anid");//答题点ID
  1153. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  1154. curObj.Text = $(this).attr("answer-text");//用户作答内容
  1155. curObj.Score = $(this).attr("answer-score");//作答评分
  1156. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  1157. curObj.Comment = $(this).attr("answer-comment");//评语
  1158. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  1159. $(".checkbox").removeClass("select-answer");
  1160. $(".answer-body").removeClass("select-answer");
  1161. if (statusType == 2) {
  1162. $(".answer-body[parent-anid=" + curObj.pId + "]").addClass("select-answer");
  1163. }
  1164. else {
  1165. $(this).addClass("select-answer");
  1166. }
  1167. //已作答,弹出作答答案
  1168. if ($(this).data("ans-status") == "1") {
  1169. //移动端添加外部处理
  1170. onClickAnswerPoint(JSON.stringify(curObj));
  1171. }
  1172. else {
  1173. //移动端添加外部处理,弹出作答操作
  1174. onClickAnswerPoint(JSON.stringify(curObj));
  1175. }
  1176. });
  1177. }
  1178. }
  1179. }
  1180. //老师评阅学生作答
  1181. function reviewStuAnswer(answerJson) {
  1182. if (answerJson != "" && answerJson) {
  1183. var answerObj = JSON.parse(answerJson);
  1184. var selectElement = $(".answer-body[answer-id='" + answerObj.Id + "']");
  1185. //$(selectElement).attr("answer-text", answerObj.Text);//用户作答内容
  1186. $(selectElement).attr("answer-score", answerObj.Score);//作答评分
  1187. $(selectElement).attr("answer-anstext ", answerObj.AnsText);//参考答案
  1188. $(selectElement).attr("answer-comment", answerObj.Comment);//评语
  1189. //评阅样式
  1190. if (answerObj.Score == 0) {
  1191. $(selectElement).children(".answer-text").removeClass("good-answer");
  1192. $(selectElement).children(".answer-text").addClass("bad-answer");
  1193. }
  1194. if (answerObj.Score > 0) {
  1195. $(selectElement).children(".answer-text").removeClass("bad-answer");
  1196. $(selectElement).children(".answer-text").addClass("good-answer");
  1197. }
  1198. }
  1199. }
  1200. //回填所有评阅信息,answerJson:所有作答及参考答案评阅信息List
  1201. function backupAllReview(answerJson) {
  1202. if (answerJson != "" && answerJson) {
  1203. var answerList = JSON.parse(answerJson);
  1204. $.each($(".answer-body"), function (num, item) {
  1205. //查找
  1206. var index = 0;
  1207. var answerid = $(item).attr("answer-id");
  1208. var parentid = $(item).attr("parent-anid");
  1209. for (var i = 0; i < answerList.length; i++) {
  1210. if (answerid == answerList[i].Id) {
  1211. index = i;
  1212. break;
  1213. }
  1214. }
  1215. //$(item).attr("answer-id", answerList[index].Id);//答题点ID
  1216. //$(item).attr("answer-text", answerList[index].Text);//用户作答内容
  1217. $(item).attr("answer-score", answerList[index].Score);//作答评分
  1218. $(item).attr("answer-anstext", answerList[index].AnsText);//参考答案
  1219. $(item).attr("answer-comment", answerList[index].Comment);//评语
  1220. //提交直接还原作答现场
  1221. var mytext = answerList[index].Text;//我的答案
  1222. var audioElement = $(item).children(".answer-audio-range").children("img").eq(0);
  1223. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  1224. $(item).children(".answer-point-range").hide();
  1225. $(item).children(".answer-audio-range").css("display", "inline-block");
  1226. $(item).children(".answer-audio-range").children("span").text("作答音频(" + answerList[index].AudioLength + "s)");
  1227. //填充作答内容
  1228. $(item).attr("answer-text", mytext);
  1229. if (mytext != "") {
  1230. mytext = "(" + mytext + ")";
  1231. $(item).children(".answer-text").show();
  1232. $(item).children(".answer-text").text(mytext);
  1233. }
  1234. //是否之前存在作答音频
  1235. $(audioElement).attr("src", PicInfo.recordPlayImgUrl);
  1236. $(item).attr("answer-url", answerList[index].AudioUrl);
  1237. $(item).children(".answer-audio-range").attr("play-status", "0");
  1238. //独立绑定事件
  1239. $(audioElement).on("click", function () {
  1240. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  1241. });
  1242. $(item).children(".answer-audio-range").children("span").on("click", function () {
  1243. $(".answer-body").removeClass("select-answer");
  1244. $(item).addClass("select-answer");
  1245. onClickAnswerPoint(JSON.stringify(answerList[index]));
  1246. });
  1247. }
  1248. else {
  1249. $(item).attr("answer-text", mytext);//填充作答内容
  1250. if (mytext == "") {
  1251. mytext = "未作答";
  1252. if (parentid != answerid) {
  1253. mytext = "&nbsp;&nbsp;&nbsp;&nbsp;";
  1254. $(item).children(".answer-text").html(mytext);
  1255. $(item).children(".answer-text").addClass("noanswer-border");
  1256. }
  1257. else {
  1258. $(item).children(".answer-text").text(mytext);
  1259. $(item).children(".answer-text").addClass("no-answer");
  1260. }
  1261. }
  1262. else {
  1263. $(item).children(".answer-text").text(mytext);
  1264. }
  1265. $(item).children(".answer-text").show();
  1266. $(item).children(".answer-point-range").hide();
  1267. }
  1268. //评阅样式
  1269. if (answerList[index].Score == 0) {
  1270. $(item).children(".answer-text").addClass("bad-answer");
  1271. }
  1272. if (answerList[index].Score > 0) {
  1273. $(item).children(".answer-text").addClass("good-answer");
  1274. }
  1275. });
  1276. //打勾题的还原
  1277. $.each($(".checkbox"), function (num, item) {
  1278. //查找
  1279. var index = 0;
  1280. var answerid = $(item).attr("answer-id");
  1281. var parentid = $(item).attr("parent-anid");
  1282. for (var i = 0; i < answerList.length; i++) {
  1283. if (answerid == answerList[i].Id) {
  1284. index = i;
  1285. break;
  1286. }
  1287. }
  1288. //提交直接还原作答现场
  1289. var mytext = answerList[index].Text;//我的答案
  1290. var ischecked = mytext.indexOf("√") > -1;
  1291. var answerText = $(item).attr("answer-anstext");//参考答案
  1292. mytext = mytext == "" ? "__" : mytext;
  1293. $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' parent-anid='" + parentid + "' answer-anstext='" + answerText + "' answer-isky='2' answer-text='" + mytext + "'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range' style='display:none;'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text' style='display:block;'>" + mytext + "</buttom></div>");
  1294. });
  1295. //点击事件重新绑定
  1296. $(".answer-body").unbind("click").on("click", function () {
  1297. var curObj = new Object();
  1298. curObj.Id = $(this).attr("answer-id");//答题点ID
  1299. curObj.pId = $(this).attr("parent-anid");//答题点ID
  1300. curObj.IsKY = $(this).attr("answer-isky");//是否是口语试题,0-不是口语题,1-是口语题
  1301. curObj.Text = $(this).attr("answer-text");//用户作答内容
  1302. curObj.Score = $(this).attr("answer-score");//作答评分
  1303. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  1304. curObj.Comment = $(this).attr("answer-comment");//评语
  1305. curObj.pId = curObj.pId ? curObj.pId : curObj.Id;//组ID
  1306. $(".checkbox").removeClass("select-answer");
  1307. $(".answer-body").removeClass("select-answer");
  1308. //$(this).addClass("select-answer");
  1309. $(".answer-body[parent-anid=" + curObj.pId + "]").addClass("select-answer");
  1310. //已作答,弹出作答答案
  1311. if ($(this).data("ans-status") == "1") {
  1312. //移动端添加外部处理
  1313. onClickAnswerPoint(JSON.stringify(curObj));
  1314. }
  1315. else {
  1316. //移动端添加外部处理,弹出作答操作
  1317. onClickAnswerPoint(JSON.stringify(curObj));
  1318. }
  1319. });
  1320. }
  1321. }
  1322. //处理播放录音,answerid:答题点ID,isPlay:是否播放(0-暂停,1-播放)
  1323. function playRecordAudio(answerid, isPlay) {
  1324. //获取其他正在播放的音频
  1325. var playing = $(".answer-body[answer-id='" + answerid + "']").children(".answer-audio-range");
  1326. if (playing.length > 0) {
  1327. if (isPlay == "1") {
  1328. $(playing).attr("play-status", "1");
  1329. $(playing).find("img").attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  1330. }
  1331. else {
  1332. $(playing).attr("play-status", "0");
  1333. $(playing).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  1334. }
  1335. }
  1336. }
  1337. //滚动到相应DIV
  1338. function scrollAnswer(answerid) {
  1339. //console.log(answerid);
  1340. $(".checkbox").removeClass("select-answer");
  1341. $(".answer-body").removeClass("select-answer");
  1342. var ansDom = $(".answer-body[parent-anid='" + answerid + "']");
  1343. if (ansDom.length == 0) {
  1344. ansDom = $(".checkbox[parent-anid='" + answerid + "']");
  1345. }
  1346. $(ansDom).addClass("select-answer");
  1347. var scroll_offset = $(ansDom).offset(); //得到box这个div层的offset,包含两个值,top和left
  1348. var offset_top = scroll_offset.top;
  1349. if (offset_top > 150) {
  1350. offset_top = offset_top - 200;
  1351. }
  1352. $("body,html").animate({
  1353. scrollTop: offset_top //让body的scrollTop等于pos的top,就实现了滚动
  1354. });
  1355. }
  1356. //暂停播放原文音频
  1357. function pauseTextAudio(audioid) {
  1358. //获取其他正在播放的音频
  1359. var playing = $(".audioImg[audio-id='" + audioid + "']");
  1360. if (playing.length > 0) {
  1361. $(playing).attr("play-status", "0");
  1362. $(playing).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  1363. }
  1364. }
  1365. //原文音频播放按钮点击事件
  1366. function audioPlayClick(myobj) {
  1367. var curHtml = $(myobj).parent().find(".audioUrl").html();
  1368. var curAlt = $(myobj).attr("alt");
  1369. //处理当前按钮的状
  1370. if ($(myobj).attr("play-status") == "1") {
  1371. $(myobj).attr("play-status", "0");
  1372. $(myobj).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  1373. }
  1374. else {
  1375. //停止其他作答音频播放
  1376. var isRecordPlaying = $(".answer-audio-range[play-status='1']");
  1377. if (isRecordPlaying.length > 0) {
  1378. $(isRecordPlaying).attr("play-status", "0");
  1379. $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  1380. }
  1381. //停止其他原文音频播放
  1382. var audioPlaying = $(".audioImg[play-status='1']");
  1383. if (audioPlaying.length > 0) {
  1384. $(audioPlaying).attr("play-status", "0");
  1385. $(audioPlaying).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  1386. }
  1387. //设置播放状态
  1388. $(myobj).attr("play-status", "1");
  1389. $(myobj).attr("src", PicInfo.audioPlayImgUrl);//移动端要根据本地 喇叭 路径替换
  1390. }
  1391. var info = new Object();
  1392. info.Id = $(myobj).attr("audio-id");
  1393. info.AudioUrl = curAlt;
  1394. //移动端添加外部处理
  1395. playVisiableAudioCallBack(1, JSON.stringify(info));
  1396. }
  1397. //作答录音播放按钮点击事件
  1398. function recordAudioClick(myobj, id, url) {
  1399. //处理当前按钮的状态
  1400. if ($(myobj).parent().attr("play-status") == "0") {
  1401. //停止其他作答音频播放
  1402. var isRecordPlaying = $(".answer-audio-range[play-status='1']");
  1403. if (isRecordPlaying.length > 0) {
  1404. $(isRecordPlaying).attr("play-status", "0");
  1405. $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  1406. }
  1407. //停止其他原文音频播放
  1408. var audioPlaying = $(".audioImg[play-status='1']");
  1409. if (audioPlaying.length > 0) {
  1410. $(audioPlaying).attr("play-status", "0");
  1411. $(audioPlaying).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地 喇叭 路径替换
  1412. }
  1413. //设置播放状态
  1414. $(myobj).parent().attr("play-status", "1");
  1415. $(myobj).attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  1416. }
  1417. else {
  1418. $(myobj).parent().attr("play-status", "0");
  1419. $(myobj).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  1420. }
  1421. //移动端添加外部处理,播放录音
  1422. var info = new Object();
  1423. info.Id = id;
  1424. info.AudioUrl = url;
  1425. //移动端添加外部处理,播放录音
  1426. playVisiableAudioCallBack(3, JSON.stringify(info));
  1427. }
  1428. //生成从minNum到maxNum的随机数
  1429. function randomNum(minNum, maxNum) {
  1430. switch (arguments.length) {
  1431. case 1:
  1432. return parseInt(Math.random() * minNum + 1, 10);
  1433. break;
  1434. case 2:
  1435. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  1436. break;
  1437. default:
  1438. return 0;
  1439. break;
  1440. }
  1441. }
  1442. // 传递显示单词wordFlag/句子phraseFlag/句型sentenceFlag,true表示高亮,false表示不高亮
  1443. function showGLWorld(wordFlag, phraseFlag, sentenceFlag) {
  1444. styleWPSContrl.wordFlag = wordFlag;
  1445. styleWPSContrl.phraseFlag = phraseFlag;
  1446. styleWPSContrl.sentenceFlag = sentenceFlag;
  1447. dealGLShowFunc(document);
  1448. }
  1449. function playVisiableAudioCallBack(type, url) {
  1450. //console.log(url);
  1451. cancelBubble();
  1452. plugin.startPlay(type, url);
  1453. }
  1454. function onClickAnswerPoint(data) {
  1455. //alert(JSON.stringify(data));
  1456. console.log(JSON.stringify(data));
  1457. cancelBubble();
  1458. plugin.onClickAnswerPoint(data);
  1459. }
  1460. function onClickKeyHide() {
  1461. //alert(JSON.stringify(data));
  1462. cancelBubble();
  1463. plugin.onClickKeyHide();
  1464. }
  1465. function onClickKeyShow() {
  1466. //alert(JSON.stringify(data));
  1467. cancelBubble();
  1468. plugin.onClickKeyShow();
  1469. }
  1470. function cancelBubble(e) {
  1471. var evt = e ? e : window.event;
  1472. if (evt.stopPropagation) { //W3C
  1473. evt.stopPropagation();
  1474. } else { //IE
  1475. evt.cancelBubble = true;
  1476. }
  1477. }
  1478. function getSelectedText(title) {
  1479. var txt;
  1480. if (window.getSelection) {
  1481. txt = window.getSelection().toString();
  1482. } else if (window.document.getSelection) {
  1483. txt = window.document.getSelection().toString();
  1484. } else if (window.document.selection) {
  1485. txt = window.document.selection.createRange().text;
  1486. }
  1487. JSInterface.callback(txt, title);
  1488. }