tasklib_book.js 71 KB

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