TextTraining.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. 
  2. $(function () {
  3. //InitPageData("<div><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-align:center; line-height:150%; widows:0; orphans:0; font-size:14pt\"><span style=\"font-family:'Times New Roman'; font-weight:bold\">What Do You Usually Do During the Week?</span></p><p style=\"margin-top:0pt; margin-left:24pt; margin-bottom:0pt; text-indent:-24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">1. </span><span style=\"font-family:'Times New Roman'; font-weight:bold\">A:</span><span style=\"font-family:'Times New Roman'\"> Are you free in the afternoon?</span></p><p style=\"margin-top:0pt; margin-left:24pt; margin-bottom:15.6pt; text-indent:-24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">&#160; </span><span style=\"font-family:'Times New Roman'; font-weight:bold\">B:</span><span style=\"font-family:'Times New Roman'\"> Hmm. Not on Tuesday and Thursday afternoons. I go to work. I teach</span><span style=\"font-family:'Times New Roman'\"> swimming. </span><span style=\"font-family:'Times New Roman'\">I l</span><span style=\"font-family:'Times New Roman'\">ike to swim, so it&#8217;s a fun job.</span></p><p style=\"margin-top:0pt; margin-left:24pt; margin-bottom:0pt; text-indent:-24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">2. </span><span style=\"font-family:'Times New Roman'; font-weight:bold\">A:</span><span style=\"font-family:'Times New Roman'\"> Do you have class every day?</span></p><p style=\"margin-top:0pt; margin-left:24pt; margin-bottom:15.6pt; text-indent:-24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">&#160; </span><span style=\"font-family:'Times New Roman'; font-weight:bold\">B:</span><span style=\"font-family:'Times New Roman'\"> No. On Wednesday morning, I don&#8217;t have any c</span><span style=\"font-family:'Times New Roman'\">lasses. I often meet my friends</span><span style=\"font-family:'Times New Roman'\"> </span><span style=\"font-family:'Times New Roman'\">then. We usually drink coffee and just talk.</span></p><p style=\"margin-top:0pt; margin-left:24pt; margin-bottom:0pt; text-indent:-24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">3. </span><span style=\"font-family:'Times New Roman'; font-weight:bold\">A:</span><span style=\"font-family:'Times New Roman'\"> Are you busy Saturday morning?</span></p><p style=\"margin-top:0pt; margin-left:24pt; margin-bottom:15.6pt; text-indent:-24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">&#160; </span><span style=\"font-family:'Times New Roman'; font-weight:bold\">B:</span><span style=\"font-family:'Times New Roman'\"> Well, on Saturday morning I always sleep late. </span><span style=\"font-family:'Times New Roman'\">Ve</span><span style=\"font-family:'Times New Roman'\">ry</span><span style=\"font-family:'Times New Roman'\"> </span><span style=\"font-family:'Times New Roman'\">late.</span><span style=\"font-family:'Times New Roman'\"> I usually wake up at 6</span><span style=\"font-family:'Times New Roman'\"> </span><span style=\"font-family:'Times New Roman'\">o&#8217;clock for work, so on Saturday morning </span><span style=\"font-family:'Times New Roman'\">I rarely get up before 10 or 11</span><span style=\"font-family:'Times New Roman'\"> </span><span style=\"font-family:'Times New Roman'\">o</span><span style=\"font-family:'Times New Roman'\">&#8217;clock.</span></p><p style=\"margin-top:0pt; margin-left:24pt; margin-bottom:0pt; text-indent:-24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">4. </span><span style=\"font-family:'Times New Roman'; font-weight:bold\">A:</span><span style=\"font-family:'Times New Roman'\"> What do you do on Sunday?</span></p><p style=\"margin-top:0pt; margin-left:24pt; margin-bottom:15.6pt; text-indent:-24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">&#160; </span><span style=\"font-family:'Times New Roman'; font-weight:bold\">B:</span><span style=\"font-family:'Times New Roman'\"> Well, on Sunday I usually go to the park wi</span><span style=\"font-family:'Times New Roman'\">th my friends. Sometimes we eat</span><span style=\"font-family:'Times New Roman'\"> </span><span style=\"font-family:'Times New Roman'\">lunch there. We often bring a soccer ball. It&#8217;s a good place to relax.</span></p></div>", "sleep|get up|wake up|relax|coffee|free|usually|do|week|swim|fun|job|eat|like to|rarely|drink|work|talk|meet|every day", "","http://192.168.3.158:8111", "zxstu36", 1);
  4. //InitPageData("<div><p style=\"margin-top:0pt; margin-bottom:0pt; text-align:center; line-height:150%; widows:0; orphans:0; font-size:14pt\"><span style=\"font-family:'Times New Roman'; font-weight:bold\">Riches</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-align:right; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">By Henry Blair </span><span style=\"font-family:'Times New Roman'\">Graybilt</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">But I warm you against thinking that riches necessarily confer happiness; or that poverty confers unhappiness. Do not begin life supposing that you shall be heart-rich when you are purse-rich. A man's happiness depends primarily upon his disposition. If that be good, riches will bring pleasure; but only vexation if that </span><span style=\"font-family:'Times New Roman'\">be</span><span style=\"font-family:'Times New Roman'\"> evil.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">To lavish money upon shining trifles, to make an idol of one's self for fools to gaze at, to rear mansions beyond our wants, to garnish them for display and not for use, to chatter through the heartless rounds of pleasure, to lounge, to gape, to simper and giggle-can wealth make vanity happy by such folly?</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">But riches indeed bless that heart whose almoner is benevolence. If the taste is refined, if the affections are pure, if conscience is honest, if charity listens to the needy, and generosity relieves them; if the public-spirited hand fosters all that embellishes and all that ennobles society</span><span style=\"font-family:'Times New Roman'\">—</span><span style=\"font-family:'Times New Roman'\">then is the rich man happy.</span></p></div>", "make sth. of sb./sth.|benevolence|disposition|necessarily|unhappiness|conscience|heartless|primarily|and all|chatter|gaze at|mansion|confer|foster|lavish|lounge|refine|trifle|vanity|bless|evil|gaze|rear", "CC04021t3A1ELFBAC|CE140800PA00PFCAC|CE070480UA00UFCAA|CC040250xA00xFAAA|CE1407831A04BFAAA|CE332020TA00TFAAA|CE140802cA03OFCAC|CC040250YA00YFAAA|CC04025DνA0JEFCAC|CE231670PA00PFCAA|CE070630EA00EFAAA|CE090791AA01YFBAA|CE1610606A006FBAA|CE140720KA00KFBAA|CE090890pA00pFCAA|CE100970gA00gFBAA|CC040216OA08iFAAC|CE090890βA011FAAC|CE332022FA031FCAA|CE321970BA00BFBAA|CC04023FxA0LlFAAA|CE070630CA00CFAAA|CE060321CA01aFAAA", "http://192.168.129.130:10103", "zxstu36", 1);
  5. //InitPageData("<div><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-align:center; line-height:150%; font-size:14pt\"><span style=\"font-family:'Times New Roman'; font-weight:bold\">China Plans to Launch Carrier Rocket at Sea</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">China plans to launch a Long March-11 carrier rocket at sea this year, which is expected to lower the cost of entering space.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">The rocket has been named \"CZ-11 WEY\" under an agreement between the China Academy of Launch Vehicle Technology, China Space Foundation and a Chinese automobile producer.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">China's first seaborne rocket launch is scheduled for mid-2019 in the Yellow Sea, said Jin </span><span style=\"font-family:'Times New Roman'\">Xin</span><span style=\"font-family:'Times New Roman'\">, deputy chief commander of the rocket, at a press conference of the China Aerospace Science and Technology Corporation earlier this year.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">A seaborne launch has many advantages over a land launch. For instance, the launch site is flexible and falling rocket remains pose less danger. Using civilian ships to launch rockets at sea would lower launch costs and give it a commercial edge, said experts.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">The seaborne launch technology will help China provide launch services for countries participating in the Belt and Road Initiative.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">The Long March-11, with a length of 20.8 meters and a takeoff weight of about 57.6 tonnes, is the only rocket using solid propellants among China's new generation carrier rockets. It has a relatively simple structure and can be launched in a short time.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">The rocket can carry a payload of up to 350 kg to a sun-synchronous orbit at an altitude of 700 km and 700 kg to a low-Earth orbit at 200 km. It is mainly used to carry small satellites, and can take multiple satellites into orbit at the same time.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">The Long March-11, which made its maiden flight on Sept. 25, 2015, has so far sent 25 satellites into orbit in six launches with high reliability and good performance rates.</span></p><p style=\"margin-top:0pt; margin-bottom:15.6pt; text-indent:24pt; text-align:justify; line-height:150%; widows:0; orphans:0; font-size:12pt\"><span style=\"font-family:'Times New Roman'\">In addition, Chinese space experts are also developing the engine for a modified version of the Long March-11 rocket, which is expected to carry up to 1.5 tonnes of payloads to the sun-synchronous orbit at an altitude of 700 km.</span></p></div>", "automobile|Belt and Road Initiative|civilian|commander|deputy|gain/have an advantage over|instance|maiden|modify|multiple|participate in|pose|propellent|reliability|structure|takeoff|With sth, sb. does sth.", "CE111010dA00dFAAC|CE301860βA011FCAC|CE281680qA00qFAAA|CE281680yA00yFAAC|CE161080IA00IFAAA|CC04021fKA0vCFBAC|CE291821TA01rFAAA|CE322000XA00XFCAA|CE1912916A01UFAAA|CE060421ιA02WFAAA|CC04021bγA0qMFAAA|CE070631BA01ZFAAA|CE2513818A01WKAAC|CE291821ιA02WFBAA|CE291822ζA03rFAAA|CE111012VA03HFAAC|CD0504301A001FAAA", "http://192.168.129.130:10103", "zxstu36", 1);
  6. InitPageData("<P class=\"MsoNormal tq-p\">Don't hate those people who are <EM>perky</EM> (精力充沛的) and efficient after only a few hours of sleep. They can't help it. New research suggests that a genetic <EM>mutation</EM> (基因突变) may explain why some people sleep less. </P><P class=\"MsoNormal tq-p\">In 2001, geneticist Ying-Hui Fu and colleagues identified a mutation in a gene called Per2 that appeared to cause Familial Advanced Sleep-Phase Syndrome (FASPS). People who have this condition sleep a normal 8 hours, but they go to bed earlier than most people, retiring at 6 or 7 in the evening and waking at 3 or 4 in the morning. \"After that was published, a lot of these people with unusual sleep schedules came to us, \" says Fu, who is now at the University of California, San Francisco. \"so we started to collect DNA samples. \" The team now has genetic information from more than 60 families. </P><P class=\"MsoNormal tq-p\">Fu and her colleagues have spent the past several years mining this vast genetic storehouse for more mutations that might affect sleep patterns. In 2005, they uncovered another mutation associated with FASPS. And now they say they have found the first genetic mutation in humans that appears to affect sleep duration rather than sleep timing. The mutation lies in DEC2, a gene that codes for a protein that helps turn off expression of other genes, including some that control circadian <EM>rhythm</EM> (生理节律), the internal <EM>clock</EM> (生物钟) that regulates a person's sleep-wake cycle. The mutation occurred in just two people, a mother and her daughter. The women sleep an average of only 6.25 hours, whereas the rest of the family members sleep a more typical 8 hours. </P><P class=\"MsoNormal tq-p\">To confirm that this mutation shortens sleep, Fu and colleagues engineered mice to carry the mutant form of DEC2. The mutant mice slept about an hour less than normal mice, the team reports on 13 August in Science. The finding also held for fruit flies: Mutant flies slept about 2 hours less than normal flies. </P><P class=\"MsoNormal tq-p\">DEC2 likely isn't the whole story when it comes to short sleep. \"Genetic control of sleep is going to be complex and is going to include multiple types of genes, \" says Shaw, who was not affiliated with (与...... 有关系) the study. But that doesn't diminish the importance of this paper, he notes. \"It's really an amazing piece of work. \" </P><P class=\"MsoNormal tq-p\">\"The findings\", says Fu, \"could lead to better treatments for sleep disorders\". If the mutated form of DEC2 were available in a pill, Fu says she'd take it, noting that she needs about 8 hours of shuteye a night to feel rested. \"All my life I've wanted to be able to sleep less. \"</P>", "FU|gene|mutation|mutate|Fu|DEC|infectious|irregular|multiple|mutant|(be) associated with|have ... effect on|ball games|略读与细读能力|细节理解能力", "CE111010dA00dFAAC|CE301860βA011FCAC|CE281680qA00qFAAA|CE281680yA00yFAAC|CE161080IA00IFAAA|CC04021fKA0vCFBAC|CE291821TA01rFAAA|CE322000XA00XFCAA|CE1912916A01UFAAA|CE060421ιA02WFAAA|CC04021bγA0qMFAAA|CE070631BA01ZFAAA|CE2513818A01WKAAC|CE291821ιA02WFBAA|CE291822ζA03rFAAA|CE111012VA03HFAAC|CD0504301A001FAAA", "http://192.168.129.130:10103", "zxstu36", 1);
  7. //HideTextarea("block");
  8. });
  9. //存储页面信息
  10. var pageVar = {
  11. data: [],
  12. stext: "",
  13. klgArr: [],
  14. klgcodeArr: [],
  15. showFlowBtn: false
  16. }
  17. function getKlgCode(klgtext) {
  18. for (var i = 0; i < pageVar.klgArr.length; i++) {
  19. if (klgtext.toLowerCase() == pageVar.klgArr[i].toLowerCase()) {
  20. return pageVar.klgcodeArr[i];
  21. }
  22. }
  23. return "";
  24. }
  25. //设置页面的展示内容,ismark 是否要标注,0-不标注,1-标注知识点
  26. function InitPageData(html, klg, klgcode, url, userid, ismark) {
  27. var words = html.replace(/(<br[^>]*>)+/gi, "</p><p>");
  28. if (ismark == 1) {
  29. pageVar.klgArr = klg.split("|");
  30. pageVar.klgcodeArr = klgcode.split("|");
  31. //替换所有的换行符
  32. words = words.replace(/\r\n/g, "<br>");
  33. words = words.replace(/\n/g, "<br>");
  34. words = $.MarkKnowledge("<p>" + words + "</p>", klg.split("|"));
  35. if (words !== null && words !== "") {
  36. var reg = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
  37. words = words.replace(reg, function (replacement) { return HTMLEncode(replacement); });
  38. $("#TxtContentData").html(words);
  39. $(".no-text").hide();
  40. //知识点绑定事件
  41. $('.TextMark').click(function () {
  42. $(this).attr("id", $(this).attr("word"));//临时给词汇添加ID
  43. ShowWord(this, url, userid);
  44. });
  45. } else {
  46. $("#TxtContentData").hide();
  47. $(".no-text").show();
  48. }
  49. }
  50. else if (words === null || words === "") {
  51. $("#TxtContentData").hide();
  52. $(".no-text").show();
  53. }
  54. else {
  55. //替换所有的换行符
  56. words = words.replace(/\r\n/g, "<br>");
  57. words = words.replace(/\n/g, "<br>");
  58. $("#TxtContentData").html(words);
  59. $(".no-text").hide();
  60. }
  61. //查看图片大图
  62. $("img").attr("title", "点击查看大图");
  63. $("img").on("click", function () {
  64. if (typeof wpfCallBack != "undefined") {
  65. wpfCallBack.showImage($(this).attr("src"));
  66. }
  67. });
  68. /*选中文本弹出事件*/
  69. $("#TxtContentData").mouseup(function (e) {
  70. window.setTimeout(function () {
  71. if (!pageVar.showFlowBtn) {
  72. return;
  73. }
  74. var x = 10;
  75. var y = 30;
  76. pageVar.stext = "";
  77. if (document.selection) {
  78. var selection = document.selection.createRange();
  79. pageVar.stext = selection.text;
  80. }
  81. else if (window.getSelection()) {
  82. var selection = window.getSelection().getRangeAt(0);
  83. pageVar.stext = selection.toString();
  84. }
  85. /*绘制、定位弹出标签*/
  86. if (pageVar.stext != "") {
  87. var tooltip = "<div id='tooltip'>开始朗读</div>";
  88. $("body").append(tooltip);
  89. $("#tooltip").css({
  90. "top": (e.pageY - y) + "px",
  91. "left": (e.pageX + x) + "px",
  92. "position": "absolute"
  93. }).show("fast");
  94. /*标签点击事件*/
  95. $("#tooltip").mouseup(function (e) {
  96. e.stopPropagation();
  97. $("#tooltip").remove();
  98. if (typeof wpfCallBack != undefined) {
  99. wpfCallBack.textResPreStartRecord(pageVar.stext);
  100. }
  101. });
  102. }
  103. }, 100);
  104. })
  105. $("body").mousedown(function () {
  106. window.setTimeout(function () {
  107. $("#tooltip").remove();
  108. }, 500);
  109. });
  110. if (typeof wpfCallBack != "undefined") {
  111. wpfCallBack.hideMainWindowLoad();
  112. }
  113. }
  114. //设置页面的图片展示
  115. function InitPicture(url) {
  116. $("#TxtContentData").html("<img style='width:100%;' src='" + url + "'/>");
  117. //查看图片大图
  118. $("img").attr("title", "点击查看大图");
  119. $("img").on("click", function () {
  120. if (typeof wpfCallBack != "undefined") {
  121. wpfCallBack.showImage($(this).attr("src"));
  122. }
  123. });
  124. if (typeof wpfCallBack != "undefined") {
  125. wpfCallBack.hideMainWindowLoad();
  126. }
  127. }
  128. function InitTextNoneData() {
  129. $("#TxtContentData").html("<div id='textnonedata'></div>");
  130. if (typeof wpfCallBack != "undefined") {
  131. wpfCallBack.hideMainWindowLoad();
  132. }
  133. }
  134. // 计数资料文本朗读时间
  135. function SumSpeakTextTime(txt) {
  136. text = $("#TxtContentData").text();
  137. var Num = wordStatic(text) * 475;//中速朗读标准 每秒2个到2.5个词汇
  138. if (Num > 3000) {
  139. Num = Num + 2000;
  140. }
  141. else if (Num < 1000) {
  142. Num = Num + 600;
  143. }
  144. else {
  145. Num = Num + Num / 2;
  146. }
  147. return Num;
  148. }
  149. //统计英语词汇个数
  150. function wordStatic(word) {
  151. // 更新计数
  152. var length = 0;
  153. if (word.length > 0) {
  154. // 替换中文字符为空格
  155. word = word.replace(/[\u4e00-\u9fa5]+/g, " ");
  156. // 将换行符,前后空格不计算为词汇数
  157. word = word.replace(/\n|\r|^\s+|\s+$/gi, "");
  158. // 多个空格替换成一个空格
  159. word = word.replace(/\s+/gi, " ");
  160. var match = word.match(/\s/g);
  161. if (match) {
  162. length = match.length + 1;
  163. } else {
  164. length = 1;
  165. }
  166. }
  167. return length;
  168. }
  169. //显示知识点课件
  170. function ShowWord(obj, url, userid) {
  171. var JQThis = $(obj);
  172. var knowlegde = $.trim(JQThis.attr("word"));
  173. var isAdd = 1;
  174. if (typeof wpfCallBack != "undefined") {
  175. isAdd = wpfCallBack.checkKlgStudy(knowlegde) ? 0 : 1;
  176. }
  177. $(obj).KLGTool({
  178. "userid": userid,
  179. "knowledgeCode": getKlgCode(knowlegde),//知识点ID
  180. "knowledge": knowlegde,//知识点文本
  181. "levelCode": "", //水平级别
  182. "isAddReStudy": isAdd,
  183. "Url": url + "/api/Resources/GetNewCoursewareEx",//获取知识点信息的url
  184. addReStudy: function (klgcode) {
  185. if (typeof wpfCallBack != "undefined") {
  186. wpfCallBack.addResStudyKn(klgcode, knowlegde);
  187. }
  188. },//添加到再学习知识点回调
  189. detailAction: function (klgcode) {
  190. if (typeof wpfCallBack != "undefined") {
  191. wpfCallBack.startKlgClient(klgcode);
  192. }
  193. }//详细释义点击事件
  194. });
  195. }
  196. //切换到翻译UI
  197. function HideTextarea(bFlag) {
  198. //去除翻译结果
  199. var anText = $(".TextRage");
  200. if (anText.length > 0) {
  201. $(".TextRage").each(function () {
  202. this.outerHTML = "";
  203. });
  204. $("#TxtContentData br").each(function () {
  205. this.outerHTML = "";
  206. });
  207. }
  208. var text = $("#TxtContentData textarea");
  209. if (text.length > 0) {
  210. $("#TxtContentData textarea").css("display", bFlag);
  211. if (bFlag !== "block") {
  212. $("#TxtContentData textarea").each(function (index, ele) {
  213. var prev = $(ele).prev();
  214. var bom = parseInt($(prev).attr("data-bottom"));
  215. if (bom > 0) {
  216. $(prev).css("marginBottom", bom);
  217. }
  218. });
  219. } else {
  220. $("#TxtContentData textarea").each(function (index, ele) {
  221. var prev = $(ele).prev();
  222. var bom = parseInt($(prev).css("marginBottom"));
  223. if (bom > 5) {
  224. $(prev).attr("data-bottom", bom);
  225. $(prev).css("marginBottom", "2px");
  226. }
  227. });
  228. }
  229. }
  230. else {
  231. if (bFlag === "block") {
  232. var spaceReg = new RegExp("\s*");
  233. var testReg = new RegExp("<span[^>]*>((&\\#xa0;)*|(&nbsp;)*)</span>");
  234. var input = "<textarea onfocus='ChangeText(this,1)' onblur='ChangeText(this,2)' placeholder='请输入翻译内容...'></textarea>"
  235. $("#TxtContentData p").after(function () {
  236. if (this.innerText.replace(/\s*/g, "").length > 0) {
  237. return input;
  238. }
  239. });
  240. $("#TxtContentData br").before(function () {
  241. if ($(this).prev().length > 0) {
  242. if ($(this).prev()[0].nodeName != "BR") {
  243. return input;
  244. }
  245. }
  246. });
  247. $("#TxtContentData o:p").after(function () {
  248. if (this.innerText.replace(/\s*/g, "").length > 0) {
  249. return input;
  250. }
  251. });
  252. $("#TxtContentData textarea").each(function (index, ele) {
  253. var prev = $(ele).prev();
  254. var bom = parseInt($(prev).css("marginBottom"));
  255. if (bom > 5) {
  256. $(prev).attr("data-bottom", bom);
  257. $(prev).css("marginBottom", "2px");
  258. }
  259. });
  260. }
  261. }
  262. //通过网络获取译文
  263. if (pageVar.data.length == 0) {
  264. GetTransText();
  265. }
  266. }
  267. //设置弹出按钮显示标志
  268. function SetIsShowFlowBtn(flag) {
  269. pageVar.showFlowBtn = flag;
  270. }
  271. //输入框默认字
  272. function ChangeText(obj, type) {
  273. var text = $(obj).html();
  274. var defaultValue = "";
  275. text = text.replace(/(\s+)/gi, ' '); //去掉多余空格
  276. text = text.replace(/(^\s*)|(\s*$)/g, ""); //正则去除前后空格
  277. if (1 == type) {
  278. if ("" != text && text != defaultValue) {
  279. }
  280. else {
  281. $(obj).html("");
  282. }
  283. }
  284. else if (2 == type) {
  285. if ("" == text || text == defaultValue) { $(obj).html(defaultValue); }
  286. }
  287. }
  288. //完成翻译
  289. function TransCompleteEx() {
  290. var i = 0;
  291. var AnText = $("#TransContentData p");
  292. $("#TxtContentData textarea").each(function () {
  293. var text = this.value;
  294. var AnThisText = "此段落暂无参考译文。";
  295. if (i < AnText.length) {
  296. for (var m = i; m < AnText.length; m++) {
  297. if (AnText[m].innerText.trim() != "") {
  298. AnThisText = AnText[m].innerText;
  299. i = m;
  300. break;
  301. }
  302. }
  303. }
  304. var sText = "";
  305. if (AnThisText == "此段落暂无参考译文。") {
  306. sText = "<div class=\"TransTag\"><span>参考翻译为:</span><span class='TransNoText'>" + AnThisText + "</span></div></div><br/>";
  307. }
  308. else {
  309. sText = "<div class=\"TransTag\"><span>参考翻译为:</span><span class='TransTextTag'>" + AnThisText + "</span></div></div><br/>";
  310. }
  311. if (text == "" || text == "请输入翻译内容...") {
  312. this.outerHTML = "<div class='TextRage'><div class='AnTansText'><span>你的翻译为:</span><span class='TransNoTextTag'>无翻译内容。</span></div>" + sText;
  313. }
  314. else {
  315. this.outerHTML = "<div class='TextRage'><div class='AnTansText'><span>你的翻译为:</span><span class='TransStuTextTag'>" + HTMLEncode(text) + "</span></div>" + sText;
  316. }
  317. i++;
  318. });
  319. }
  320. //完成翻译
  321. function TransComplete() {
  322. var i = 0;
  323. $("#TxtContentData textarea").each(function () {
  324. var text = this.value;
  325. var AnThisText = "此段落暂无参考译文。";
  326. if (i < pageVar.data.length) {
  327. for (var m = i; m < pageVar.data.length; m++) {
  328. if (pageVar.data[m].dst != "" && pageVar.data[m].dst != undefined) {
  329. AnThisText = pageVar.data[m].dst + "(参考来源于百度翻译)";
  330. i = m;
  331. break;
  332. }
  333. }
  334. }
  335. var sText = "";
  336. if (AnThisText == "此段落暂无参考译文。") {
  337. sText = "<div class=\"TransTag\"><span>参考翻译为:</span><span class='TransNoText'>" + AnThisText + "</span></div></div><br/>";
  338. }
  339. else {
  340. sText = "<div class=\"TransTag\"><span>参考翻译为:</span><span class='TransTextTag'>" + AnThisText + "</span></div></div><br/>";
  341. }
  342. if (text == "" || text == "请输入翻译内容...") {
  343. this.outerHTML = "<div class='TextRage'><div class='AnTansText'><span>你的翻译为:</span><span class='TransNoTextTag'>无翻译内容。</span></div>" + sText;
  344. }
  345. else {
  346. this.outerHTML = "<div class='TextRage'><div class='AnTansText'><span>你的翻译为:</span><span class='TransStuTextTag'>" + HTMLEncode(text) + "</span></div>" + sText;
  347. }
  348. i++;
  349. });
  350. }
  351. //重新翻译
  352. function TransReset() {
  353. HideTextarea("block");
  354. }
  355. //通过网络获取译文
  356. function GetTransText() {
  357. var EnText = $("#TxtContentData p");
  358. if (0 < EnText.length) {
  359. for (var i = 0; i < EnText.length; i++) {
  360. if (EnText[i].innerText.trim() != "") {
  361. pageVar.data.push(EnText[i].innerText.trim().replace(/\s+/g, " "));
  362. }
  363. }
  364. }
  365. if (typeof wpfCallBack != "undefined") {
  366. wpfCallBack.getTranslateText(pageVar.data.join('\n'));
  367. }
  368. }
  369. //设置匹配译文
  370. function SetTransText(data) {
  371. pageVar.data = JSON.parse(data);
  372. }
  373. var closeKLGTool = function () {
  374. $("body").KLGTool("destroy");
  375. }