book.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. //播放音频图片地址
  2. var PicInfo = {
  3. yaoshiImgUrl: "yaoshi.png",
  4. recordPlayImgUrl: "play.png",
  5. recordPauseImgUrl: "pause.png",
  6. audioPlayImgUrl: "dynaiselaba.gif",
  7. audioPauseImgUrl: "dynaiselaba.png"
  8. }
  9. //显示、隐藏答案
  10. function showHideAnswer(flag) {
  11. if (flag) {
  12. $(".underlineContent").show();
  13. }
  14. else {
  15. $(".underlineContent").hide();
  16. }
  17. }
  18. //显示、隐藏钥匙及答案 isShowYX:显示和隐藏钥匙,isShowAS:显示和隐藏答案
  19. function showHideAnswerEx(isShowYX, isShowAS) {
  20. if (isShowYX) {
  21. $(".yaoshi").show();
  22. }
  23. else {
  24. $(".yaoshi").hide();
  25. }
  26. if (isShowAS) {
  27. $.each($(".underlineContent"), function (index, item) {
  28. $(item).html($(item).attr("data-text"));
  29. });
  30. }
  31. else {
  32. $.each($(".underlineContent"), function (index, item) {
  33. var count = 0;
  34. var text = $(item).attr("data-text");
  35. $(item).html(text.toString().replace(/./g, function (match, group) {
  36. //最多替换30个
  37. if (count < 30) {
  38. count++;
  39. return "&nbsp;";
  40. }
  41. }));
  42. });
  43. }
  44. }
  45. //原文 页面加载完,绑定事件
  46. function bindBookTextEvent() {
  47. //显示/隐藏习题答案
  48. $(".yaoshi").on("click", function () {
  49. var curDisplay = $(this).nextUntil(".yaoshi").find(".underlineContent").eq(0).css("display");
  50. if (curDisplay == "undefined" || curDisplay == undefined) return;
  51. if (curDisplay == "none") {
  52. $(this).nextUntil(".yaoshi").find(".underlineContent").show()
  53. } else {
  54. $(this).nextUntil(".yaoshi").find(".underlineContent").hide();
  55. }
  56. });
  57. //处理答题点
  58. $.each($(".underlineContent"), function (index, item) {
  59. $(item).attr("data-text", $(item).html());
  60. });
  61. //给音频绑定一个ID
  62. $.each($(".audioImg"), function (index, item) {
  63. $(item).attr('audio-id', index);
  64. });
  65. //点击喇叭事件,音频播放
  66. $(".audioImg").on("click", function () {
  67. audioPlayClick(this);
  68. });
  69. //点击播放事件,视频播放
  70. $(".videoImg").on("click", function () {
  71. var curHtml = $(this).parent().find(".videoUrl").html();
  72. var curAlt = $(this).attr("alt");//播放视频地址
  73. //移动端添加外部处理
  74. });
  75. //处理表格样式
  76. $("td").attr("style", "");
  77. //处理文章标题的样式
  78. $("p").eq(2).addClass("p-title-top");
  79. }
  80. //主体课文 页面加载完,绑定事件
  81. function bindCoursewareEvent() {
  82. //给每个答题点加上ID
  83. $.each($(".yaoshi"), function (index, item) {
  84. $(item).attr('answer-id', index);
  85. $(item).attr("src", PicInfo.yaoshiImgUrl);//移动端要根据本地 喇叭 路径替换
  86. });
  87. //给音频绑定一个ID
  88. $.each($(".audioImg"), function (index, item) {
  89. $(item).attr('audio-id', index);
  90. $(item).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  91. });
  92. //显示/隐藏习题答案
  93. $(".yaoshi").on("click", function () {
  94. if ($(this).data("status") == "0") {
  95. $(this).data("status", "1");
  96. $(this).nextUntil(".yaoshi").filter(".underlineContent").show();
  97. }
  98. else {
  99. $(this).data("status", "0");
  100. $(this).nextUntil(".yaoshi").filter(".underlineContent").hide();
  101. }
  102. });
  103. //点击喇叭事件,音频播放
  104. $(".audioImg").on("click", function () {
  105. audioPlayClick(this);
  106. });
  107. //点击播放事件,视频播放
  108. $(".videoImg").on("click", function () {
  109. var curHtml = $(this).parent().find(".videoUrl").html();
  110. var curAlt = $(this).attr("alt");//播放视频地址
  111. //移动端添加外部处理
  112. });
  113. //处理表格样式
  114. $("td").attr("style", "");
  115. //处理文章标题的样式
  116. $("p").eq(2).addClass("p-title-top");
  117. }
  118. //学生端 处理作答区域
  119. var answerData = new Array();
  120. function handleAnswerRange() {
  121. //规范文本格式
  122. var answerId = "";
  123. var tempJson = new Array();
  124. $.each($(".yaoshi").nextUntil(".yaoshi").filter(".underline"), function (index, item) {
  125. tempId = $(item).prevAll(".yaoshi").attr("answer-id");
  126. //记录上一次的ID
  127. if (tempId == undefined) {
  128. tempId = answerId;
  129. }
  130. else {
  131. answerId = tempId;
  132. }
  133. var prev = $(item).prev();
  134. if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
  135. if ($("span[answer-id='" + tempId + "']").length == 0) {
  136. $(item).prop("outerHTML", "<span answer-id='" + tempId + "' class='tag-span'>_</span>");
  137. }
  138. }
  139. $(item).remove();
  140. });
  141. //提取参考答案并规范文本格式
  142. answerId = "";
  143. $.each($(".yaoshi").nextUntil(".yaoshi").filter(".underlineContent"), function (index, item) {
  144. var info = new Object();
  145. info.answerId = $(item).prevAll(".yaoshi").attr("answer-id");
  146. //记录上一次的ID
  147. if (info.answerId == undefined) {
  148. info.answerId = answerId;
  149. }
  150. else {
  151. answerId = info.answerId;
  152. }
  153. info.answerText = $(item).text();
  154. tempJson.push(info);
  155. var prev = $(item).prev();
  156. if (prev.length == 0 || $(prev).attr("class") != "tag-span") {
  157. //替换答案
  158. $(item).prop("outerHTML", "<span answer-id='" + info.answerId + "' class='tag-span'>_</span>");
  159. }
  160. else {
  161. $(item).remove();
  162. }
  163. });
  164. //合并参考答案数据
  165. var tempid = "";
  166. var temptext = "";
  167. for (var i = 0; i < tempJson.length; i++) {
  168. if (tempid == tempJson[i].answerId) {
  169. temptext = temptext + tempJson[i].answerText;
  170. }
  171. else {
  172. if (tempid != "") {
  173. var info = new Object();
  174. info.answerId = tempid;
  175. info.answerText = temptext;
  176. answerData.push(info);
  177. //重置
  178. tempid = "";
  179. temptext = "";
  180. }
  181. tempid = tempJson[i].answerId;
  182. temptext = tempJson[i].answerText;
  183. //最后一个存入
  184. if (i == tempJson.length - 1) {
  185. var info = new Object();
  186. info.answerId = tempid;
  187. info.answerText = temptext;
  188. answerData.push(info);
  189. }
  190. }
  191. }
  192. //补全答题点
  193. var Num = 0;
  194. if (answerData.length > 0) {
  195. Num = Number.parseInt(answerData[answerData.length-1].answerId);
  196. for (var i = 0; i < Num; i++) {
  197. var index = Number(answerData[i].answerId) - i;
  198. for (var j = 0; j < index; j++) {
  199. var info = new Object();
  200. info.answerId = (i+j).toString();
  201. info.answerText = "";
  202. answerData.splice(i, 0, info);
  203. }
  204. }
  205. }
  206. //添加答题点的点击UI及交互
  207. $.each($(".tag-span"), function (index, item) {
  208. var answerText = "";
  209. var answerid = $(item).attr('answer-id');
  210. for (var i = 0; i < answerData.length; i++) {
  211. if (answerid == answerData[i].answerId) {
  212. answerText = answerData[i].answerText;
  213. break;
  214. }
  215. }
  216. $(item).prop("outerHTML", "<buttom answer-id='" + answerid + "' answer-text='" + answerText + "' class='answertext'>点击此处作答</buttom>");
  217. //删除钥匙节点
  218. var prev = $("img[answer-id='" + answerid + "']");
  219. if (prev.length > 0) {
  220. $(prev).remove();
  221. }
  222. });
  223. //添加点击事件
  224. $(".answertext").on("click", function () {
  225. var curObj = new Object();
  226. curObj.Id = $(this).attr("answer-id");//答题点ID
  227. curObj.Text = $(this).attr("answer-text");//用户作答内容
  228. curObj.Score = $(this).attr("answer-score");//作答评分
  229. curObj.AnsText = $(this).attr("answer-anstext");//参考答案
  230. curObj.Comment = $(this).attr("answer-comment");//评语
  231. //已作答,弹出作答答案
  232. if ($(this).data("ans-status") == "1") {
  233. //移动端添加外部处理
  234. alert($(this).text());
  235. }
  236. else {
  237. //移动端添加外部处理,弹出作答操作
  238. }
  239. });
  240. }
  241. //接收学生的作答
  242. function reviewAnswer(answerJson) {
  243. //测试数据
  244. //answerJson = "{\"AudioLength\":0,\"Id\":\"2\",\"Text\":\"i am how i know\",\"Type\":1}";
  245. //answerJson = "{\"AudioLength\":3,\"AudioUrl\":\"http://172.16.41.241:10103/http_TBookEditor51/exerciseAnswerAudio/2020-11-06_09-31-19.wav\",\"Id\":\"4\",\"Text\":\"i know how i know \",\"Type\":3}";
  246. //answerJson = "{\"AudioLength\":0,\"AudioUrl\":\"\",\"Id\":\"15\",\"Text\":\"llll\",\"Type\":1}";
  247. if (answerJson != "" && answerJson) {
  248. var answerObj = JSON.parse(answerJson);
  249. var selectElement = $(".answertext[answer-id='" + answerObj.Id + "']");
  250. var audioElement = $(".btn-play[answer-id='" + answerObj.Id + "']>span");
  251. //是否是音频作答
  252. if ((answerObj.Type == 3 || answerObj.Type == 4) && answerObj.AudioUrl != "") {
  253. answerObj.Text = answerObj.Text == "" ? "" : "(" + answerObj.Text + ")";
  254. $(selectElement).text(answerObj.Text);
  255. //是否之前存在作答音频
  256. if (audioElement.length > 0) {
  257. $(audioElement).text("作答音频(" + answerObj.AudioLength + "s)");
  258. $(audioElement).parent().attr("answer-url", answerObj.AudioUrl);
  259. }
  260. else {
  261. var divHtml = document.createElement("div");
  262. divHtml.className = "btn-play";
  263. divHtml.innerHTML = "<img src='" + PicInfo.recordPlayImgUrl + "'/><span>作答音频(" + answerObj.AudioLength + "s)</span>";
  264. divHtml.setAttribute("answer-id", answerObj.Id);
  265. divHtml.setAttribute("answer-url", answerObj.AudioUrl);
  266. divHtml.setAttribute("play-status", "0");
  267. //增加节点
  268. $(selectElement).before(divHtml);
  269. //独立绑定事件
  270. $(selectElement).prev().children("img").on("click", function () {
  271. recordAudioClick(this, answerObj.Id, answerObj.AudioUrl);
  272. });
  273. $(selectElement).prev().children("span").on("click", function () {
  274. //移动端的修改
  275. alert(answerObj.AudioUrl);
  276. });
  277. }
  278. }
  279. else {
  280. answerObj.Text = answerObj.Text == "" ? "点击此处作答" : answerObj.Text;
  281. $(selectElement).text(answerObj.Text);
  282. //之前作答存在音频,但是现在没有音频传入,要删除音频节点
  283. if (audioElement.length > 0) {
  284. $(".btn-play[answer-id='" + answerObj.Id + "']").unbind('click');
  285. $(".btn-play[answer-id='" + answerObj.Id + "']").remove();
  286. }
  287. }
  288. }
  289. }
  290. //提交,获取所有作答答案及参考答案
  291. function getAllAnswer() {
  292. //alert(JSON.stringify(answerData));
  293. //处理作答及参考答案回显
  294. $.each($(".answertext"), function (index, item) {
  295. //$(item).unbind('click');//取消点击绑定事件
  296. //var answerid = $(item).attr('answer-id');//答题点ID
  297. var mytext = $(item).text();//我的答案
  298. //var answertext = $(item).attr("answer-text");//参考答案
  299. if (mytext == "点击此处作答") {
  300. mytext = "未作答";
  301. $(item).text(mytext);
  302. }
  303. //var ansDiv = document.createElement("label");
  304. //ansDiv.className = "my-answer";
  305. //ansDiv.innerHTML = "<span>【我的答案】</span>";
  306. //var prev = $(item).prev();
  307. //if (prev.length > 0 && $(prev).attr("class") == "btn-play") {
  308. // $(prev).before(ansDiv);
  309. // var ansText = document.createElement("label");
  310. // ansText.className = "my-answer";
  311. // ansText.innerHTML = "<span>" + mytext + "</span>";
  312. // $(item).after(ansText);
  313. //}
  314. //else {
  315. // ansDiv.innerHTML = ansDiv.innerHTML + mytext;
  316. // $(item).before(ansDiv);
  317. //}
  318. //var textDiv = document.createElement("label");
  319. //textDiv.className = "text-answer";
  320. //textDiv.innerHTML = "【参考答案】" + answertext;
  321. //$(item).remove();
  322. });
  323. $(".answertext").unbind('click');//取消点击绑定事件
  324. $(".btn-play>span").unbind('click');//取消点击绑定事件
  325. return answerData;
  326. }
  327. //回填所有答案,answerJson:所有作答及参考答案List,statusType:0-可作答,1-已提交,2-查看评阅
  328. function backupAllAnswer(answerJson, statusType) {
  329. //测试数据
  330. //isSubmit = true;
  331. //answerJson = "[{\"AudioLength\":11,\"AudioUrl\":\"http://172.16.41.241:10103/http_TBookEditor51/exerciseAnswerAudio/2020-11-10_11-18-54.mp3\",\"Id\":\"2\",\"Text\":\"\",\"Type\":3}]";
  332. if (answerJson != "" && answerJson) {
  333. var answerList = JSON.parse(answerJson);
  334. answerList = JSON.parse(answerList);
  335. //获取Dom一个个回填
  336. $.each($(".answertext"), function (index, item) {
  337. //提交直接还原作答现场
  338. var mytext = answerList[index].Text;//我的答案
  339. //可作答状态,作答还原
  340. if (statusType == 0) {
  341. //已作答过,还原作答,增加作答后的UI节点
  342. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  343. mytext = mytext == "" ? mytext : "(" + mytext + ")";
  344. $(item).text(mytext);
  345. //添加音频节点
  346. var divHtml = document.createElement("div");
  347. divHtml.className = "btn-play";
  348. divHtml.innerHTML = "<img src='" + PicInfo.recordPlayImgUrl + "'/><span>作答音频(" + answerList[index].AudioLength + "s)</span>";
  349. divHtml.setAttribute("answer-id", answerList[index].Id);
  350. divHtml.setAttribute("answer-url", answerList[index].AudioUrl);
  351. divHtml.setAttribute("play-status", "0");
  352. //增加节点
  353. $(item).before(divHtml);
  354. //独立绑定事件
  355. $(item).prev().children("img").on("click", function () {
  356. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  357. });
  358. $(item).prev().children("span").on("click", function () {
  359. //移动端的修改
  360. });
  361. }
  362. else {
  363. //文本作答
  364. mytext = mytext == "" ? "点击此处作答" : mytext;//我的答案
  365. $(item).text(mytext);
  366. }
  367. }
  368. //已提交,作答还原
  369. if (statusType == 1) {
  370. $(item).unbind('click');//取消点击绑定事件
  371. //添加音频控制
  372. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  373. mytext = mytext == "" ? mytext : "(" + mytext + ")";
  374. $(item).text(mytext);
  375. //添加音频节点
  376. var divHtml = document.createElement("div");
  377. divHtml.className = "btn-play";
  378. divHtml.innerHTML = "<img src='" + PicInfo.recordPlayImgUrl + "'/><span>作答音频(" + answerList[index].AudioLength + "s)</span>";
  379. divHtml.setAttribute("answer-id", answerList[index].Id);
  380. divHtml.setAttribute("answer-url", answerList[index].AudioUrl);
  381. divHtml.setAttribute("play-status", "0");
  382. //增加节点
  383. $(item).before(divHtml);
  384. //独立绑定事件
  385. $(item).prev().children("img").on("click", function () {
  386. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  387. });
  388. }
  389. else {
  390. //文本作答
  391. if (mytext == "") {
  392. mytext = "未作答";
  393. $(item).addClass("no-answer");
  394. }
  395. $(item).text(mytext);
  396. }
  397. }
  398. //已评阅,查看评阅详情
  399. if (statusType == 2) {
  400. //添加音频控制
  401. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  402. mytext = mytext == "" ? mytext : "(" + mytext + ")";
  403. $(item).text(mytext);
  404. //添加音频节点
  405. var divHtml = document.createElement("div");
  406. divHtml.className = "btn-play";
  407. divHtml.innerHTML = "<img src='" + PicInfo.recordPlayImgUrl + "'/><span>作答音频(" + answerList[index].AudioLength + "s)</span>";
  408. divHtml.setAttribute("answer-id", answerList[index].Id);
  409. divHtml.setAttribute("answer-url", answerList[index].AudioUrl);
  410. divHtml.setAttribute("play-status", "0");
  411. //增加节点
  412. $(item).before(divHtml);
  413. //独立绑定事件
  414. $(item).prev().children("img").on("click", function () {
  415. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  416. });
  417. $(item).prev().children("span").on("click", function () {
  418. //移动端的修改
  419. });
  420. }
  421. else {
  422. //文本作答
  423. if (mytext == "") {
  424. mytext = "未作答";
  425. $(item).addClass("no-answer");
  426. }
  427. $(item).text(mytext);
  428. }
  429. }
  430. });
  431. }
  432. }
  433. //老师评阅学生作答
  434. function reviewStuAnswer(answerJson) {
  435. if (answerJson != "" && answerJson) {
  436. var answerObj = JSON.parse(answerJson);
  437. var selectElement = $(".answertext[answer-id='" + answerObj.Id + "']");
  438. $(selectElement).attr("answer-text", answerObj.Text);//用户作答内容
  439. $(selectElement).attr("answer-score", answerObj.Score);//作答评分
  440. $(selectElement).attr("answer-anstext ", answerObj.AnsText);//参考答案
  441. $(selectElement).attr("answer-comment", answerObj.Comment);//评语
  442. }
  443. }
  444. //回填所有评阅信息,answerJson:所有作答及参考答案评阅信息List
  445. function backupAllReview(answerJson) {
  446. //测试数据
  447. //answerJson = "[{\"AudioLength\":11,\"AudioUrl\":\"http://172.16.41.241:10103/http_TBookEditor51/exerciseAnswerAudio/2020-11-10_11-18-54.mp3\",\"Id\":\"2\",\"Text\":\"\",\"Type\":3}]";
  448. if (answerJson != "" && answerJson) {
  449. var answerList = JSON.parse(answerJson);
  450. answerList = JSON.parse(answerList);
  451. //获取Dom一个个回填
  452. $.each($(".answertext"), function (index, item) {
  453. //$(item).attr("answer-id", answerList[index].Id);//答题点ID
  454. $(item).attr("answer-text", answerList[index].Text);//用户作答内容
  455. $(item).attr("answer-score", answerList[index].Score);//作答评分
  456. $(item).attr("answer-anstext ", answerList[index].AnsText);//参考答案
  457. $(item).attr("answer-comment", answerList[index].Comment);//评语
  458. //提交直接还原作答现场
  459. var mytext = answerList[index].Text;//我的答案
  460. if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
  461. mytext = mytext == "" ? mytext : "(" + mytext + ")";
  462. $(item).text(mytext);
  463. //添加音频节点
  464. var divHtml = document.createElement("div");
  465. divHtml.className = "btn-play";
  466. divHtml.innerHTML = "<img src='" + PicInfo.recordPlayImgUrl + "'/><span>作答音频(" + answerList[index].AudioLength + "s)</span>";
  467. divHtml.setAttribute("answer-id", answerList[index].Id);
  468. divHtml.setAttribute("answer-url", answerList[index].AudioUrl);
  469. divHtml.setAttribute("play-status", "0");
  470. //增加节点
  471. $(item).before(divHtml);
  472. //独立绑定事件
  473. $(item).prev().children("img").on("click", function () {
  474. recordAudioClick(this, answerList[index].Id, answerList[index].AudioUrl);
  475. });
  476. $(item).prev().children("span").on("click", function () {
  477. //移动端的修改
  478. alert(JSON.stringify(answerList[index]));
  479. });
  480. }
  481. else {
  482. if (mytext == "") {
  483. mytext = "未作答";
  484. $(item).addClass("no-answer");
  485. }
  486. $(item).text(mytext);
  487. }
  488. });
  489. }
  490. }
  491. //处理播放录音,answerid:答题点ID,isPlay:是否播放(0-暂停,1-播放)
  492. function playRecordAudio(answerid, isPlay) {
  493. //获取其他正在播放的音频
  494. var playing = $(".btn-play[answer-id='" + answerid + "']");
  495. if (playing.length > 0) {
  496. if (isPlay == "1") {
  497. $(playing).attr("play-status", "1");
  498. $(playing).find("img").attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  499. }
  500. else {
  501. $(playing).attr("play-status", "0");
  502. $(playing).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  503. }
  504. }
  505. }
  506. //暂停播放原文音频
  507. function pauseTextAudio(audioid) {
  508. //获取其他正在播放的音频
  509. var playing = $(".audioImg[audio-id='" + audioid + "']");
  510. if (playing.length > 0) {
  511. $(playing).attr("play-status", "0");
  512. $(playing).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  513. }
  514. }
  515. //原文音频播放按钮点击事件
  516. function audioPlayClick(myobj) {
  517. var curHtml = $(myobj).parent().find(".audioUrl").html();
  518. var curAlt = $(myobj).attr("alt");
  519. //处理当前按钮的状
  520. if ($(myobj).attr("play-status") == "1") {
  521. $(myobj).attr("play-status", "0");
  522. $(myobj).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  523. }
  524. else {
  525. //停止其他作答音频播放
  526. var isRecordPlaying = $(".btn-play[play-status='1']");
  527. if (isRecordPlaying.length > 0) {
  528. $(isRecordPlaying).attr("play-status", "0");
  529. $(isRecordPlaying).find("img").attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  530. }
  531. //停止其他原文音频播放
  532. var audioPlaying = $(".audioImg[play-status='1']");
  533. if (audioPlaying.length > 0) {
  534. $(audioPlaying).attr("play-status", "0");
  535. $(audioPlaying).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  536. }
  537. //设置播放状态
  538. $(myobj).attr("play-status", "1");
  539. $(myobj).attr("src", PicInfo.audioPlayImgUrl);//移动端要根据本地 喇叭 路径替换
  540. }
  541. var info = new Object();
  542. info.Id = $(myobj).attr("audio-id");
  543. info.AudioUrl = curAlt;
  544. //移动端添加外部处理
  545. alert(JSON.stringify(info));
  546. }
  547. //作答录音播放按钮点击事件
  548. function recordAudioClick(myobj, id, url) {
  549. //处理当前按钮的状态
  550. if ($(myobj).parent().attr("play-status") == "0") {
  551. //停止其他作答音频播放
  552. var isRecordPlaying = $(".btn-play[play-status='1']");
  553. if (isRecordPlaying.length > 0) {
  554. $(isRecordPlaying).attr("play-status", "0");
  555. $(isRecordPlaying).find("img").attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  556. }
  557. //停止其他原文音频播放
  558. var audioPlaying = $(".audioImg[play-status='1']");
  559. if (audioPlaying.length > 0) {
  560. $(audioPlaying).attr("play-status", "0");
  561. $(audioPlaying).attr("src", PicInfo.audioPauseImgUrl);//移动端要根据本地 喇叭 路径替换
  562. }
  563. //设置播放状态
  564. $(myobj).parent().attr("play-status", "1");
  565. $(myobj).attr("src", PicInfo.recordPauseImgUrl);//移动端要根据本地路径替换
  566. }
  567. else {
  568. $(myobj).parent().attr("play-status", "0");
  569. $(myobj).attr("src", PicInfo.recordPlayImgUrl);//移动端要根据本地路径替换
  570. }
  571. //移动端添加外部处理,播放录音
  572. var info = new Object();
  573. info.Id = id;
  574. info.AudioUrl = url;
  575. //移动端添加外部处理,播放录音
  576. alert(JSON.stringify(info));
  577. }