render.js 135 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166
  1. var gDisplayCapacity = 20;
  2. var gCurrTopParagraph = 0;
  3. var gVisibleParBegin = 0;
  4. var gVisibleParEnd = 10;
  5. //显示模式
  6. var _display_para_arrange = 0; //0:横向 排列 1:纵向排列
  7. var _display_sbs = 0; //0:逐段 1:逐句
  8. //翻译块显示模式
  9. //在编辑状态下显示预览
  10. var _tran_show_preview_on_edit = true;
  11. //在非编辑状态下显示编辑框
  12. var _tran_show_textarea_esc_edit = true;
  13. var gVisibleParBeginOld = 0;
  14. var gVisibleParEndOld = gDisplayCapacity;
  15. //var gPalitext_length=0
  16. var gtext_max_length = 0;
  17. var g_allparlen_array = new Array();
  18. function palitext_calculator() {
  19. var allText = "";
  20. var allTextLen_array = new Array();
  21. var text_max2_length = 0;
  22. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  23. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  24. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  25. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  26. //bookId=getNodeText(xmlParInfo,"book")
  27. //paragraph=getNodeText(xmlParInfo,"paragraph")
  28. type = getNodeText(xmlParInfo, "type");
  29. if (type == "wbw") {
  30. var wbwTextNode = xmlParData.getElementsByTagName("word");
  31. var para_text_cal = "";
  32. for (var iText = 0; iText < wbwTextNode.length; iText++) {
  33. if (getNodeText(wbwTextNode[iText], "type") != ".ctl.") {
  34. para_text_cal += getNodeText(wbwTextNode[iText], "pali") + " ";
  35. }
  36. }
  37. allText += para_text_cal;
  38. allTextLen_array.push(allText.length);
  39. //gPalitext_length+=para_text_cal.length
  40. if (para_text_cal.length > text_max2_length) {
  41. text_max2_length = para_text_cal.length;
  42. if (text_max2_length > gtext_max_length) {
  43. var num_max_tem = gtext_max_length;
  44. gtext_max_length = text_max2_length;
  45. text_max2_length = num_max_tem;
  46. }
  47. }
  48. }
  49. }
  50. for (i_cal in allTextLen_array) {
  51. g_allparlen_array.push(allTextLen_array[i_cal] / gtext_max_length);
  52. }
  53. gDisplayCapacity = 19 + text_max2_length / gtext_max_length;
  54. if (gDisplayCapacity * gtext_max_length < 5000) {
  55. gDisplayCapacity = 5000 / gtext_max_length;
  56. }
  57. }
  58. //添加新的段落块
  59. function addNewBlockToHTML(bookId, parId, begin = -1, end = -1) {
  60. parHeadingLevel = 0;
  61. parTitle = "";
  62. var divBlock = document.createElement("div");
  63. var typId = document.createAttribute("id");
  64. if (begin == -1 && end == -1) {
  65. //基于段落的块
  66. typId.nodeValue = "par_" + bookId + "_" + (parId - 1);
  67. } else {
  68. //基于句子的块
  69. typId.nodeValue = "par_" + bookId + "_" + (parId - 1) + "_" + begin + "_" + end;
  70. }
  71. divBlock.attributes.setNamedItem(typId);
  72. var typClass = document.createAttribute("class");
  73. typClass.nodeValue = "pardiv";
  74. divBlock.attributes.setNamedItem(typClass);
  75. var output = '<a name="par_begin_' + bookId + "_" + (parId - 1) + '"></a>';
  76. output += ' <div id="head_tool_' + bookId + "_" + (parId - 1) + '" class="head_tool edit_tool">';
  77. output +=
  78. ' <button id="id_heading_add_new" onclick="editor_heading_add_new(\'' +
  79. bookId +
  80. "','" +
  81. parId +
  82. "')\" >" +
  83. gui_string_editor[0] +
  84. "</button>";
  85. output +=
  86. "<input id='page_break_'" +
  87. bookId +
  88. "_" +
  89. (parId - 1) +
  90. ' type="checkbox" onclick="editor_page_break(this,\'' +
  91. bookId +
  92. "','" +
  93. (parId - 1) +
  94. "')\" />" +
  95. gui_string_editor[1];
  96. output += "</div>";
  97. //heading
  98. output += ' <div id="heading_' + bookId + "_" + (parId - 1) + '" class="par_heading"></div>';
  99. //word by word translate block
  100. //内部可以包含多个wbw块
  101. output += ' <div id="wblock_' + bookId + "_" + (parId - 1) + '" class="wbwdiv"></div>';
  102. //translate div
  103. output += ' <div id="tran_' + bookId + "_" + (parId - 1) + '" class="trandiv"></div>';
  104. //word note div
  105. output += ' <div id="wnote_' + bookId + "_" + (parId - 1) + '" class="wnotediv"></div>';
  106. //note div
  107. output += ' <div id="note_' + bookId + "_" + (parId - 1) + '" class="pnotediv"></div>';
  108. //vedio div
  109. output += ' <div id="vedioblock_' + bookId + "_" + (parId - 1) + '" class="vediodiv"></div>';
  110. divBlock.innerHTML = output;
  111. document.getElementById("sutta_text").appendChild(divBlock);
  112. }
  113. function renderToc(bookId, parBegin, parEnd) {
  114. var firstHeadingLevel = getNodeText(gXmlParIndex[parBegin - 1], "level");
  115. var output = "<ul>";
  116. for (var iPar = parBegin; iPar < parEnd; iPar++) {
  117. parTitle = getNodeText(gXmlParIndex[iPar - 1], "title");
  118. parHeadingLevel = getNodeText(gXmlParIndex[iPar - 1], "level");
  119. if (parHeadingLevel > 0) {
  120. output += '<li class="toc_h_' + (parHeadingLevel - firstHeadingLevel + 1) + '">';
  121. output += '<a href="#par-' + bookId + "-" + iPar + '">' + parTitle + "</a>";
  122. output += "</li>";
  123. }
  124. }
  125. output += "</ul>";
  126. return output;
  127. }
  128. function updataWordParContainer(bookId, parId) {
  129. document.getElementById("wblock-" + bookId + "-" + parId + '"').innerHTML = renderWordParContainerInner(
  130. bookId,
  131. parId
  132. );
  133. }
  134. function renderWordParContainerInner(bookId, parId) {
  135. var strHtml = "";
  136. strHtml += '<div class="wbwparblock">';
  137. strHtml += renderWordParBlockInner(packageIndex);
  138. strHtml += "</div>";
  139. }
  140. //根据block数据更新 目录 列表
  141. function updataToc() {
  142. document.getElementById("content").innerHTML = "";
  143. //创建目录空壳
  144. for (let iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
  145. if (gArrayDocParagraph[iPar].level > 0) {
  146. let bookId = gArrayDocParagraph[iPar].book;
  147. let parIndex = gArrayDocParagraph[iPar].paragraph;
  148. let tocId = "toc_" + bookId + "_" + (parIndex - 1);
  149. let str = '<div class="toc_heading">';
  150. str += "<table><tr><td>";
  151. str +=
  152. "<input type='checkbox' checked onclick=\"editor_par_show(this,'" +
  153. bookId +
  154. "','" +
  155. parIndex +
  156. "')\" />";
  157. str += "</td><td>";
  158. str += '<div class="toc_heading_inner" id="' + tocId + '">';
  159. str += "<a onclick=\"editor_goto_link('" + bookId + "'," + parIndex + ')" >[' + parIndex + "]</a>";
  160. str += "</div>";
  161. str += "</td></tr></table>";
  162. str += "</div>";
  163. document.getElementById("content").innerHTML += str;
  164. }
  165. }
  166. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  167. for (let iBlock = 0; iBlock < allBlock.length; iBlock++) {
  168. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  169. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  170. bookId = getNodeText(xmlParInfo, "book");
  171. paragraph = getNodeText(xmlParInfo, "paragraph");
  172. type = getNodeText(xmlParInfo, "type");
  173. if (type == "heading") {
  174. level = getNodeText(xmlParInfo, "level");
  175. //if(level>0)
  176. {
  177. language = getNodeText(xmlParInfo, "language");
  178. bId = getNodeText(xmlParInfo, "id");
  179. strHeadingText = getNodeText(xmlParData, "text");
  180. tocId = "toc_" + bookId + "_" + (paragraph - 1);
  181. /*
  182. var htmlBlock=document.getElementById(tocId)
  183. if(htmlBlock==null){
  184. var str="<div class=\"toc_heading\">";
  185. str += "<table><tr><td>";
  186. str += "<input type='checkbox' checked onclick=\"editor_par_show(this,'"+bookId+"','"+(paragraph-1)+"')\" />";
  187. str += "</td><td>";
  188. str += "<div class=\"toc_heading_inner\" id=\""+tocId+"\"></div>";
  189. str += "</td></tr></table>";
  190. str += "</div>";
  191. document.getElementById("content").innerHTML+=str
  192. }
  193. */
  194. let tocText = '<p class="toc_item_' + level + " " + language + '_text">';
  195. tocText +=
  196. "<a onclick=\"editor_goto_link('" +
  197. bookId +
  198. "'," +
  199. paragraph +
  200. ')" >[' +
  201. paragraph +
  202. "]-" +
  203. strHeadingText +
  204. "</a>";
  205. tocText += "</p>";
  206. $("#toc_" + bookId + "_" + (paragraph - 1)).html(tocText);
  207. }
  208. }
  209. }
  210. palitext_calculator();
  211. }
  212. //向html中插入数据块
  213. function insertBlockToHtml(element) {
  214. xmlParInfo = element.getElementsByTagName("info")[0];
  215. xmlParData = element.getElementsByTagName("data")[0];
  216. let bookId = getNodeText(xmlParInfo, "book");
  217. let paragraph = getNodeText(xmlParInfo, "paragraph");
  218. let base_on = getNodeText(xmlParInfo, "base");
  219. let begin = getNodeText(xmlParInfo, "begin");
  220. let end = getNodeText(xmlParInfo, "end");
  221. type = getNodeText(xmlParInfo, "type");
  222. language = getNodeText(xmlParInfo, "language");
  223. bId = getNodeText(xmlParInfo, "id");
  224. let htmlBlock;
  225. if (base_on == "sentence") {
  226. blockId = "par_" + bookId + "_" + (paragraph - 1) + "_" + begin + "_" + end;
  227. htmlBlock = document.getElementById(blockId);
  228. if (htmlBlock == null) {
  229. addNewBlockToHTML(bookId, paragraph, begin, end);
  230. }
  231. } else {
  232. blockId = "par_" + bookId + "_" + (paragraph - 1);
  233. htmlBlock = document.getElementById(blockId);
  234. if (htmlBlock == null) {
  235. addNewBlockToHTML(bookId, paragraph);
  236. }
  237. }
  238. if (!isParInView(getParIndex(bookId, paragraph))) {
  239. document.getElementById(blockId).style.display = "none";
  240. return;
  241. } else {
  242. document.getElementById(blockId).style.display = "inline-flex";
  243. }
  244. switch (type) {
  245. case "wbw":
  246. var strHtml = renderWordParBlockInner(element);
  247. $("#wnote_" + bookId + "_" + (paragraph - 1)).html(renderNoteShell(element));
  248. var paraDiv = document.createElement("div");
  249. var node = document.createTextNode("");
  250. paraDiv.appendChild(node);
  251. paraDiv.innerHTML = strHtml;
  252. note_refresh_new();
  253. var typ = document.createAttribute("class");
  254. typ.nodeValue = "wbwparblock";
  255. paraDiv.attributes.setNamedItem(typ);
  256. var id = document.createAttribute("id");
  257. id.nodeValue = "id_wbw_" + bId;
  258. paraDiv.attributes.setNamedItem(id);
  259. blockId = "wblock_" + bookId + "_" + (paragraph - 1);
  260. document.getElementById(blockId).appendChild(paraDiv);
  261. refreshWordNoteDiv(element);
  262. refreshNoteNumber();
  263. break;
  264. case "translate":
  265. var strHtml = "";
  266. strHtml = renderTranslateParBlockInner(element);
  267. var paraDiv = document.createElement("div");
  268. var node = document.createTextNode("");
  269. paraDiv.appendChild(node);
  270. paraDiv.innerHTML = strHtml;
  271. var typ = document.createAttribute("class");
  272. typ.nodeValue = "tran_parblock " + language + "_text";
  273. paraDiv.attributes.setNamedItem(typ);
  274. var id = document.createAttribute("id");
  275. id.nodeValue = "id_tran_" + bId;
  276. paraDiv.attributes.setNamedItem(id);
  277. blockId = "tran_" + bookId + "_" + (paragraph - 1);
  278. document.getElementById(blockId).appendChild(paraDiv);
  279. //逐句
  280. if (_display_sbs == 1) {
  281. let eAllSent = document.getElementById(blockId).getElementsByClassName("tran_sent");
  282. for (let iSen = 0; iSen < eAllSent.length; iSen++) {
  283. let senA = eAllSent[iSen].getAttributeNode("sn").value;
  284. let blockId = eAllSent[iSen].getAttributeNode("block").value;
  285. let eSBSDiv = document.getElementById("sent_" + senA);
  286. if (eSBSDiv) {
  287. let eBlockSenDiv = document.getElementById("sent_" + senA + "_" + blockId);
  288. if (!eBlockSenDiv) {
  289. //没有 添加
  290. let divSen = document.createElement("div");
  291. let typ = document.createAttribute("class");
  292. typ.nodeValue = "sbs_sent_block";
  293. divSen.attributes.setNamedItem(typ);
  294. let typId = document.createAttribute("id");
  295. typId.nodeValue = "sent_" + senA + "_" + blockId;
  296. divSen.attributes.setNamedItem(typId);
  297. let sn = document.createAttribute("sn");
  298. sn.nodeValue = senA;
  299. divSen.attributes.setNamedItem(sn);
  300. let block = document.createAttribute("block");
  301. block.nodeValue = blockId;
  302. divSen.attributes.setNamedItem(block);
  303. divSen.innerHTML = eAllSent[iSen].innerHTML;
  304. eSBSDiv.appendChild(divSen);
  305. } else {
  306. eBlockSenDiv.innerHTML = eAllSent[iSen].innerHTML;
  307. }
  308. eAllSent[iSen].innerHTML = "";
  309. }
  310. }
  311. }
  312. break;
  313. case "note":
  314. var strHtml = "";
  315. strHtml = renderNoteParBlockInner(element);
  316. var paraDiv = document.createElement("div");
  317. var node = document.createTextNode("");
  318. paraDiv.appendChild(node);
  319. paraDiv.innerHTML = strHtml;
  320. var typ = document.createAttribute("class");
  321. typ.nodeValue = "note_parblock " + language + "_text";
  322. paraDiv.attributes.setNamedItem(typ);
  323. var id = document.createAttribute("id");
  324. id.nodeValue = "id_note_" + bId;
  325. paraDiv.attributes.setNamedItem(id);
  326. blockId = "note_" + bookId + "_" + (paragraph - 1);
  327. document.getElementById(blockId).appendChild(paraDiv);
  328. document.getElementById(blockId).style.display = "block";
  329. break;
  330. case "heading":
  331. headingLevel = getNodeText(xmlParInfo, "level");
  332. var strHtml = "";
  333. strHtml = renderHeadingBlockInner(element);
  334. var paraDiv = document.createElement("div");
  335. var node = document.createTextNode("");
  336. paraDiv.appendChild(node);
  337. paraDiv.innerHTML = strHtml;
  338. var typ = document.createAttribute("class");
  339. typ.nodeValue = "heading_parblock_" + headingLevel + "_" + language + " " + language + "_text";
  340. paraDiv.attributes.setNamedItem(typ);
  341. var id = document.createAttribute("id");
  342. id.nodeValue = "id_heading_" + bId;
  343. paraDiv.attributes.setNamedItem(id);
  344. blockId = "heading_" + bookId + "_" + (paragraph - 1);
  345. document.getElementById(blockId).appendChild(paraDiv);
  346. document.getElementById(blockId).style.display = "block";
  347. //document.getElementById("id_heading_level_"+bookId+"_"+(paragraph-1)).value=headingLevel;
  348. break;
  349. }
  350. guide_init();
  351. }
  352. function updataHeadingBlockInHtml(book, par) {
  353. document.getElementById("heading_" + book + "_" + (par - 1)).innerHTML = "";
  354. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  355. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  356. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  357. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  358. bookId = getNodeText(xmlParInfo, "book");
  359. paragraph = getNodeText(xmlParInfo, "paragraph");
  360. type = getNodeText(xmlParInfo, "type");
  361. if (type == "heading" && bookId == book && paragraph == par) {
  362. insertBlockToHtml(allBlock[iBlock]);
  363. }
  364. }
  365. }
  366. function renderBlock() {}
  367. /*
  368. 重绘翻译数据块
  369. */
  370. function update_tran_sent(blockId, begin, end) {
  371. let eBlock = document.getElementById("id_tran_" + blockId);
  372. if (eBlock) {
  373. eBlock.innerHTML = renderTranslateParBlockInnerById(blockId);
  374. term_updata_translation();
  375. }
  376. /*
  377. $("#id_tran_"+blockId).html(renderTranslateParBlockInnerById(blockId));
  378. term_updata_translation();
  379. */
  380. }
  381. /*
  382. 更新翻译数据块数据
  383. */
  384. function update_tran_block_text(blockId) {
  385. let block = doc_tran("#" + blockId);
  386. if (block != null) {
  387. let book = block.info("book");
  388. let para = block.info("paragraph");
  389. let sent = block.list();
  390. if (sent != null) {
  391. for (const element of sent) {
  392. let eText = document.getElementById("ta_" + blockId + "_" + element.begin + "_" + element.end);
  393. if (eText) {
  394. eText.innerHTML = element.text;
  395. }
  396. let eLable = document.getElementById(
  397. "tran_pre_" + blockId + "_p" + book + "-" + para + "-" + element.end
  398. );
  399. if (eLable) {
  400. eLable.innerHTML = element.text;
  401. }
  402. }
  403. term_updata_translation();
  404. }
  405. }
  406. }
  407. /*
  408. 重绘翻译数据块
  409. */
  410. function update_tran_block(blockId) {
  411. let eBlock = document.getElementById("id_tran_" + blockId);
  412. if (eBlock) {
  413. eBlock.innerHTML = renderTranslateParBlockInnerById(blockId);
  414. term_updata_translation();
  415. }
  416. /*
  417. $("#id_tran_"+blockId).html(renderTranslateParBlockInnerById(blockId));
  418. term_updata_translation();
  419. */
  420. }
  421. //譯文段落渲染
  422. function renderTranslateParBlockInnerById(blockId) {
  423. var xBlock = gXmlBookDataBody.getElementsByTagName("block");
  424. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  425. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  426. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  427. bId = getNodeText(xmlParInfo, "id");
  428. if (bId == blockId) {
  429. return renderTranslateParBlockInner(xBlock[iBlock]);
  430. }
  431. }
  432. }
  433. //譯文段落渲染
  434. function renderTranslateParBlockInner(elementBlock) {
  435. var output = "";
  436. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  437. var book = getNodeText(xmlParInfo, "book");
  438. var paragraph = getNodeText(xmlParInfo, "paragraph");
  439. var bId = getNodeText(xmlParInfo, "id");
  440. var power = getNodeText(xmlParInfo, "power");
  441. var readonly = getNodeText(xmlParInfo, "readonly");
  442. par_num = paragraph - 1;
  443. type = getNodeText(xmlParInfo, "type");
  444. language = getNodeText(xmlParInfo, "language");
  445. var allSen = elementBlock.getElementsByTagName("sen");
  446. output += "<div>";
  447. for (iSen = 0; iSen < allSen.length; iSen++) {
  448. var senText = getNodeText(allSen[iSen], "text");
  449. var senBegin = getNodeText(allSen[iSen], "begin");
  450. var senEnd = getNodeText(allSen[iSen], "end");
  451. var senA = "p" + book + "-" + paragraph + "-" + senEnd;
  452. output +=
  453. "<div id='tran_sent_" + bId + "_" + senA + "' block='" + bId + "' sn='" + senA + "' class='tran_sent' >";
  454. if (power != "read") {
  455. //可写入模式
  456. if (readonly != 1) {
  457. output +=
  458. "<div class='tran_sent_inner' onmouseenter=\"tran_sent_div_mouseenter('" +
  459. bId +
  460. "','" +
  461. senA +
  462. "')\" >";
  463. }
  464. } else {
  465. output += "<div class='tran_sent_inner' >";
  466. }
  467. output += "<div id='tran_pre_" + bId + "_" + senA + "' class='tran_sent_pre'>";
  468. if (senText == "") {
  469. output += "<span style='color:gray;'>" + gLocal.gui.translation + "</span>";
  470. } else {
  471. output += term_std_str_to_tran(senText);
  472. }
  473. output += "</div>";
  474. output += "<div id='tran_sent_text_div_" + bId + "_" + senA + "' class='tran_sen_textarea'";
  475. //在非编辑状态下 不显示 编辑框
  476. if (_tran_show_textarea_esc_edit == false) {
  477. output += " style='display:none'";
  478. }
  479. output += ">";
  480. //只读权限不显示修改框
  481. if (power != "read") {
  482. //可写入模式
  483. if (readonly != 1) {
  484. //只读模式不显示修改框 只有power=write才考虑只读模式
  485. output += "<textarea id='ta_" + bId + "_" + senBegin + "_" + senEnd + "' ";
  486. output += " onkeyup=\"updateTranslationPreview('" + bId + "_" + senA + "',this)\" ";
  487. output += " onchange=\"tran_text_onchange('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" ";
  488. //output += " onchange=\"sen_save('"+bId+"','"+senBegin+"','"+senEnd+"',this.value)\" ";
  489. output += " onblur=\"tran_sent_div_blur('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" ";
  490. output +=
  491. " onfocus=\"tran_sent_div_onfocus('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" >";
  492. senText = senText.replace(/\<br \/\>/g, "\n\n");
  493. output += term_std_str_to_edit(senText);
  494. output += "</textarea>";
  495. }
  496. }
  497. output += "</div>";
  498. output += '<div class="tran_sent_text_tool_bar">';
  499. //output += "<button onclick=\"tran_sen_save_click('"+bId+"','"+senBegin+"','"+senEnd+"',this)\">Save</button>";
  500. output += "<span></span>";
  501. output +=
  502. "<span onclick=\"show_tran_msg('" +
  503. bId +
  504. "','" +
  505. senBegin +
  506. "','" +
  507. senEnd +
  508. "')\"><span id='' class=\"word_msg\"></span></span>";
  509. output += "</div>";
  510. output += "</div>";
  511. output += "</div>";
  512. output += "</div>";
  513. }
  514. output += "</div>";
  515. return output;
  516. }
  517. function renderTranslateParBlockInnerPreview(strText) {}
  518. function updateTranslationPreview_a(blockId, text) {
  519. let out = "";
  520. let newText = text;
  521. newText = marked(newText);
  522. //newText = term_tran_edit_replace(newText);
  523. //newText = term_edit_to_std_str(newText);
  524. newText = term_std_str_to_tran(newText);
  525. out += newText;
  526. if (out == "") {
  527. out = "<span style='color:#ccbfbf;'>" + gLocal.gui.with_idea + "</span>";
  528. }
  529. $("#tran_pre_" + blockId).html(out);
  530. term_updata_translation();
  531. }
  532. function updateTranslationPreview(blockId, obj) {
  533. let out = "";
  534. let newText = obj.value;
  535. newText = marked(newText);
  536. let channal = $(obj).attr("channal");
  537. let lang = $(obj).attr("lang");
  538. newText = term_std_str_to_tran(newText, channal, getCookie("userid"), lang);
  539. out += newText;
  540. if (out == "") {
  541. out = "<span style='color:#ccbfbf;'>" + gLocal.gui.with_idea + "</span>";
  542. }
  543. $("#tran_pre_" + blockId).html(out);
  544. term_updata_translation();
  545. }
  546. function getSuperTranslateModifyString(inString, par_num, par_guid, language) {
  547. var curr_super_info = getPrevNextTrans_Guid("curr", par_guid);
  548. var arrString = translate_split(curr_super_info.senText, language).string;
  549. var output = "";
  550. var arrString_last = "";
  551. var sent_ID = "";
  552. var arr_sentA_ID = g_arr_Para_ID[par_num];
  553. var y = 0;
  554. for (y in arr_par_sent_num) {
  555. //得到本段句子外殻數0~par_num_last
  556. var arr_sentID = arr_par_sent_num[y].split("_");
  557. if (arr_sentID[1] == par_num) {
  558. var par_num_last = arr_sentID[2];
  559. }
  560. }
  561. if (par_num_last >= arrString.length - 1) {
  562. //外殻數大於等於切分結果,執行充填
  563. for (var x = 0; x < arrString.length; x++) {
  564. //整段渲染
  565. sent_ID = "sent_" + arr_sentA_ID[x];
  566. var superStringPosition_Start = 0;
  567. var superStringPosition_End = 0;
  568. var superString = translate_super_split(arrString[x], language).string;
  569. var language_type = translate_super_split(arrString[x], language).language_type;
  570. var output_super = "";
  571. for (var super_x = 0; super_x < superString.length; super_x++) {
  572. superStringPosition_End = superStringPosition_Start;
  573. superStringPosition_Start += superString[super_x].length;
  574. output_super +=
  575. "<span id='SBS_senA_" +
  576. par_guid +
  577. "_" +
  578. superStringPosition_End +
  579. "' class=\"tran_sen\" style='display:none'>";
  580. output_super += superStringPosition_End + "_" + superStringPosition_Start;
  581. output_super += "</span>";
  582. output_super +=
  583. "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
  584. output_super += superString[super_x];
  585. output_super += '<span class="tooltiptext tooltip-bottom">';
  586. output_super +=
  587. "<button onclick='super_trans_modify(up_sen," +
  588. superStringPosition_Start +
  589. "," +
  590. par_guid +
  591. "," +
  592. language +
  593. ")'>▲</button>";
  594. output_super +=
  595. "<button onclick='super_trans_modify(down_sen," +
  596. superStringPosition_End +
  597. "," +
  598. par_guid +
  599. "," +
  600. language +
  601. ")'>▼</button>";
  602. output_super += "</span></span>";
  603. }
  604. var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
  605. if (document.getElementById(sent_ID).innerHTML.length != 0) {
  606. if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
  607. document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
  608. } else {
  609. document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
  610. }
  611. }
  612. output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
  613. output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
  614. output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
  615. }
  616. } else if (par_num_last < arrString.length - 1) {
  617. //外殻數小於切分結果
  618. for (var x = 0; x < par_num_last; x++) {
  619. //除最後一句,其他充填
  620. //整段渲染
  621. sent_ID = "sent_" + arr_sentA_ID[x];
  622. var superStringPosition_Start = 0;
  623. var superStringPosition_End = 0;
  624. var superString = translate_super_split(arrString[x], language).string;
  625. var language_type = translate_super_split(arrString[x], language).language_type;
  626. var output_super = "";
  627. for (var super_x = 0; super_x < superString.length; super_x++) {
  628. superStringPosition_End = superStringPosition_Start;
  629. superStringPosition_Start += superString[super_x].length;
  630. output_super +=
  631. "<span id='SBS_senA_" +
  632. par_guid +
  633. "_" +
  634. superStringPosition_End +
  635. "' class=\"tran_sen\" style='display:none'>";
  636. output_super += superStringPosition_End + "_" + superStringPosition_Start;
  637. output_super += "</span>";
  638. output_super +=
  639. "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
  640. output_super += superString[super_x];
  641. output_super += '<span class="tooltiptext tooltip-bottom">';
  642. output_super +=
  643. "<button onclick='super_trans_modify(up_sen," +
  644. superStringPosition_Start +
  645. "," +
  646. par_guid +
  647. "," +
  648. language +
  649. ")'>▲</button>";
  650. output_super +=
  651. "<button onclick='super_trans_modify(down_sen," +
  652. superStringPosition_End +
  653. "," +
  654. par_guid +
  655. "," +
  656. language +
  657. ")'>▼</button>";
  658. output_super += "</span></span>";
  659. }
  660. output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
  661. output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
  662. output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
  663. var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
  664. if (document.getElementById(sent_ID).innerHTML.length != 0) {
  665. if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
  666. document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
  667. } else {
  668. document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
  669. }
  670. }
  671. }
  672. var output_super = "";
  673. for (var x = par_num_last; x < arrString.length - 1; x++) {
  674. //最後一句,合併所有譯文
  675. var superString = translate_super_split(arrString[x], language).string;
  676. var language_type = translate_super_split(arrString[x], language).language_type;
  677. for (var super_x = 0; super_x < superString.length; super_x++) {
  678. superStringPosition_End = superStringPosition_Start;
  679. superStringPosition_Start += superString[super_x].length;
  680. output_super +=
  681. "<span id='SBS_senA_" +
  682. par_guid +
  683. "_" +
  684. superStringPosition_End +
  685. "' class=\"tran_sen\" style='display:none'>";
  686. output_super += superStringPosition_End + "_" + superStringPosition_Start;
  687. output_super += "</span>";
  688. output_super +=
  689. "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
  690. output_super += superString[super_x];
  691. output_super += '<span class="tooltiptext tooltip-bottom">';
  692. output_super +=
  693. "<button onclick='super_trans_modify(up_sen," +
  694. superStringPosition_Start +
  695. "," +
  696. par_guid +
  697. "," +
  698. language +
  699. ")'>▲</button>";
  700. output_super +=
  701. "<button onclick='super_trans_modify(down_sen," +
  702. superStringPosition_End +
  703. "," +
  704. par_guid +
  705. "," +
  706. language +
  707. ")'>▼</button>";
  708. output_super += "</span></span>";
  709. }
  710. output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
  711. output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
  712. output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
  713. }
  714. sent_ID = "sent_" + arr_sentA_ID[par_num_last];
  715. var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
  716. if (document.getElementById(sent_ID).innerHTML.length != 0) {
  717. if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
  718. document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
  719. } else {
  720. document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
  721. }
  722. }
  723. }
  724. return output;
  725. }
  726. function super_trans_modify(updown, superStringPosition, par_guid, language) {
  727. //未完成
  728. var prev_super_info = getPrevNextTrans_Guid(prev, par_guid);
  729. var next_super_info = getPrevNextTrans_Guid(next, par_guid);
  730. var curr_super_info = getPrevNextTrans_Guid(curr, par_guid);
  731. var new_prev_super_info = new Object();
  732. var new_next_super_info = new Object();
  733. var new_curr_super_info = new Object();
  734. switch (updown) {
  735. case "up_par":
  736. new_prev_super_info.GUID = prev_super_info.GUID;
  737. new_prev_super_info.senText =
  738. prev_super_info.senText + curr_super_info.senText.replace(/#/g, "").slice(0, superStringPosition);
  739. var new_senText_array = translate_super_split(new_prev_super_info.senText, language);
  740. new_prev_super_info.senA = "0_";
  741. for (new_senText_array_i in new_senText_array) {
  742. new_prev_super_info.senA += new_senText_array[new_senText_array_i].length;
  743. new_prev_super_info.senA += "#" + new_senText_array[new_senText_array_i].length + "_";
  744. if (new_senText_array_i == new_senText_array.length - 1) {
  745. new_prev_super_info.senA += new_senText_array[new_senText_array_i].length;
  746. break;
  747. }
  748. }
  749. new_prev_super_info.senA = (new_prev_super_info.senA + "#").replace(/##/g, "");
  750. new_curr_super_info.GUID = curr_super_info.GUID;
  751. new_curr_super_info.senText = curr_super_info.senText.replace(/#/g, "").slice(superStringPosition);
  752. var new_senText_array = translate_super_split(new_curr_super_info.senText, language);
  753. new_curr_super_info.senA = "";
  754. for (new_senText_array_i in new_senText_array) {
  755. new_curr_super_info.senA += new_senText_array[new_senText_array_i].length;
  756. new_curr_super_info.senA += "#" + new_senText_array[new_senText_array_i].length + "_";
  757. if (new_senText_array_i == new_senText_array.length - 1) {
  758. new_curr_super_info.senA += new_senText_array[new_senText_array_i].length;
  759. break;
  760. }
  761. }
  762. new_curr_super_info.senA = (new_curr_super_info.senA + "#").replace(/##/g, "");
  763. break;
  764. case "down_par":
  765. if (par_num > max_par_num) {
  766. //无效通知
  767. }
  768. break;
  769. }
  770. }
  771. function getPrevNextTrans_Guid(direction, par_guid) {
  772. var allBlock = gXmlBookDataBody.getElementsByTagName("block"); //得到全局block
  773. var prev_super_info = new Object();
  774. var next_super_info = new Object();
  775. var curr_super_info = new Object();
  776. var super_arr_xmlParInfo = new Array();
  777. var super_arr_xmlParData = new Array();
  778. var super_arr_xmlParAllsen = new Array();
  779. var super_arr_xmlParAllloc = new Array();
  780. curr_super_info.GUID = par_guid;
  781. for (var super_iBlock = 0; super_iBlock < allBlock.length; super_iBlock++) {
  782. if (super_iBlock == "length") {
  783. break;
  784. }
  785. var elementBlock = allBlock[super_iBlock]; //得到其中一段的數據
  786. if (elementBlock.getElementsByTagName("sen").length != 0) {
  787. super_arr_xmlParInfo.push(elementBlock.getElementsByTagName("info")[0]);
  788. super_arr_xmlParData.push(elementBlock.getElementsByTagName("data")[0]);
  789. }
  790. }
  791. if (elementBlock.getElementsByTagName("sen").length != 0) {
  792. for (var super_iData in super_arr_xmlParData) {
  793. var super_xmlParAll_Sen = "";
  794. var super_xmlParAll_Loc = "";
  795. for (var super_iSen = 0; super_iSen < super_arr_xmlParData[super_iData].childNodes.length; super_iSen++) {
  796. var super_xmlParData_Detail = super_arr_xmlParData[super_iData].childNodes[super_iSen];
  797. super_xmlParAll_Sen += super_xmlParData_Detail.getElementsByTagName("text")[0].innerHTML + "#";
  798. super_xmlParAll_Loc += super_xmlParData_Detail.getElementsByTagName("a")[0].innerHTML + "#";
  799. }
  800. super_xmlParAll_Sen = (super_xmlParAll_Sen + "#").replace(/##/g, "");
  801. super_xmlParAll_Loc = (super_xmlParAll_Loc + "#").replace(/##/g, "");
  802. super_arr_xmlParAllsen.push(super_xmlParAll_Sen);
  803. super_arr_xmlParAllloc.push(super_xmlParAll_Loc);
  804. }
  805. for (var super_iBlock = 0; super_iBlock < super_arr_xmlParInfo.length; super_iBlock++) {
  806. if (super_iBlock == "length") {
  807. break;
  808. }
  809. var super_GUID = getNodeText(super_arr_xmlParInfo[super_iBlock], "id"); //得到guid
  810. prev_super_info.senText = "";
  811. prev_super_info.senA = "";
  812. curr_super_info.senText = super_arr_xmlParAllsen[super_iBlock];
  813. curr_super_info.senA = super_arr_xmlParAllloc[super_iBlock];
  814. next_super_info.senText = "";
  815. next_super_info.senA = "";
  816. if (super_GUID == par_guid && super_iBlock == 0) {
  817. prev_super_info.GUID = ""; //前一個為空
  818. next_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock + 1], "id"); //得到後一個guid
  819. next_super_info.senText = super_arr_xmlParAllsen[super_iBlock + 1];
  820. next_super_info.senA = super_arr_xmlParAllloc[super_iBlock + 1]; //根據譯文數組得到錨點
  821. break;
  822. } else if (super_GUID == par_guid && super_iBlock > 0 && super_iBlock < super_arr_xmlParAllsen.length - 1) {
  823. prev_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock - 1], "id"); //得到前一個guid
  824. next_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock + 1], "id"); //得到後一個guid
  825. prev_super_info.senText = super_arr_xmlParAllsen[super_iBlock - 1];
  826. prev_super_info.senA = super_arr_xmlParAllloc[super_iBlock - 1]; //根據譯文數組得到錨點
  827. next_super_info.senText = super_arr_xmlParAllsen[super_iBlock + 1];
  828. next_super_info.senA = super_arr_xmlParAllloc[super_iBlock + 1]; //根據譯文數組得到錨點
  829. break;
  830. } else if (super_GUID == par_guid && super_iBlock == super_arr_xmlParAllsen.length - 1) {
  831. prev_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock - 1], "id"); //得到前一個guid
  832. next_super_info.GUID = "";
  833. prev_super_info.senText = super_arr_xmlParAllsen[super_iBlock - 1];
  834. prev_super_info.senA = super_arr_xmlParAllloc[super_iBlock - 1]; //根據譯文數組得到錨點
  835. break;
  836. }
  837. }
  838. } else {
  839. prev_super_info.GUID = "";
  840. prev_super_info.senText = "";
  841. prev_super_info.senA = "";
  842. curr_super_info.GUID = "";
  843. curr_super_info.senText = "";
  844. curr_super_info.senA = "";
  845. next_super_info.GUID = "";
  846. next_super_info.senText = "";
  847. next_super_info.senA = "";
  848. }
  849. switch (direction) {
  850. case "next":
  851. return next_super_info;
  852. break;
  853. case "curr":
  854. return curr_super_info;
  855. break;
  856. case "prev":
  857. return prev_super_info;
  858. break;
  859. }
  860. }
  861. function translate_split(inString, language) {
  862. var newString = "";
  863. var arrString = new Object();
  864. var language_type = "";
  865. if (
  866. language.toLowerCase() == "tw" ||
  867. language.toLowerCase() == "zh" ||
  868. language.toLowerCase() == "sc" ||
  869. language.toLowerCase() == "tc"
  870. ) {
  871. language_type = "ZH";
  872. } else {
  873. language_type = "EN";
  874. }
  875. arrString.language_type = language_type.toLowerCase();
  876. switch (language_type) {
  877. case "ZH":
  878. for (var i_cntransplit in cn_transplit) {
  879. newString = inString;
  880. eval("newString = newString.replace(" + cn_transplit[i_cntransplit] + ")");
  881. }
  882. /*newString = inString.replace(/。/g,"。#");
  883. newString = newString.replace(/;/g,";");
  884. newString = newString.replace(/ /g,"");
  885. newString = newString.replace(/;/g,";#");
  886. newString = newString.replace(/?/g,"?#");
  887. newString = newString.replace(/”“/g,"”#“");
  888. newString = newString.replace(/’‘/g,"’#‘");
  889. newString = newString.replace(/。#”/g,"。”#");
  890. newString = newString.replace(/?#”/g,"?”#");
  891. newString = newString.replace(/?“/g,"?#“");
  892. newString = newString.replace(/:“/g,":#“");
  893. newString = newString.replace(/:「/g,":#「");
  894. newString = newString.replace(/!#’/g,"!’#");
  895. newString = newString.replace(/。#’/g,"。’#");
  896. newString = newString.replace(/?#’/g,"?’#");
  897. newString = newString.replace(/?‘/g,"?#‘");
  898. newString = newString.replace(/:‘/g,":#‘");
  899. newString = newString.replace(/##/g,"#");
  900. */
  901. arrString.string = newString.split("#");
  902. break;
  903. case "EN":
  904. newString = inString;
  905. for (var i_entransplit in en_transplit) {
  906. newString = inString;
  907. eval("newString = newString.replace(" + en_transplit[i_entransplit] + ")");
  908. }
  909. /*newString = inString.replace(/\./g,"\.#");
  910. newString = newString.replace(/;/g,";");
  911. newString = newString.replace(/;/g,";#");
  912. newString = newString.replace(/\?/g,"?#");
  913. newString = newString.replace(/\"\"/g,"”#“");
  914. newString = newString.replace(/.\'\'/g,".”");
  915. newString = newString.replace(/.#\"/g,".”#");
  916. newString = newString.replace(/\?#\"/g,"?”#");
  917. newString = newString.replace(/\?“/g,"?#“");
  918. newString = newString.replace(/,\"/g,",#“");
  919. newString = newString.replace(/!#\'/g,"!’#");
  920. newString = newString.replace(/.#\'/g,".’#");
  921. newString = newString.replace(/?#’/g,"?’#");
  922. newString = newString.replace(/?‘/g,"?#‘");
  923. newString = newString.replace(/##/g,"#");
  924. */
  925. arrString.string = newString.split("#");
  926. break;
  927. }
  928. return arrString;
  929. // body...
  930. }
  931. function translate_super_split(inString) {
  932. var newString = inString;
  933. var arrString = new Object();
  934. var language_type = "";
  935. if (
  936. language.toLowerCase() == "tw" ||
  937. language.toLowerCase() == "zh" ||
  938. language.toLowerCase() == "sc" ||
  939. language.toLowerCase() == "tc"
  940. ) {
  941. language_type = "ZH";
  942. } else {
  943. language_type = "EN";
  944. }
  945. arrString.language_type = language_type.toLowerCase();
  946. switch (language_type) {
  947. case "ZH":
  948. newString = newString.replace(/,/g, ",#");
  949. newString = newString.replace(/!/g, "!#");
  950. newString = newString.replace(/!#”/g, "!”#");
  951. newString = newString.replace(/!#’/g, "!’#");
  952. arrString.string = newString.split("#");
  953. break;
  954. case "EN":
  955. newString = newString.replace(/,/g, ",#");
  956. newString = newString.replace(/!/g, "!#");
  957. arrString.string = newString.split("#");
  958. break;
  959. }
  960. return arrString;
  961. // body...
  962. }
  963. function renderNoteParBlockInner(elementBlock) {
  964. var output = "";
  965. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  966. book = getNodeText(xmlParInfo, "book");
  967. paragraph = getNodeText(xmlParInfo, "paragraph");
  968. bId = getNodeText(xmlParInfo, "id");
  969. type = getNodeText(xmlParInfo, "type");
  970. var allSen = elementBlock.getElementsByTagName("sen");
  971. output +=
  972. '<button type="button" class="edit_note_button imgbutton" onclick="editor_note_edit(\'' +
  973. bId +
  974. "')\"><svg class='icon' style='fill: var(--detail-color);'><use xlink:href='svg/icon.svg#ic_mode_edit'></use></svg></button>";
  975. for (iSen = 0; iSen < allSen.length; iSen++) {
  976. senText = getNodeText(allSen[iSen], "text");
  977. senA = getNodeText(allSen[iSen], "a");
  978. output += '<span id="note_sen_' + bId + "_" + iSen + '" class="note_sen">';
  979. output += senText;
  980. output += "</span>";
  981. }
  982. return output;
  983. }
  984. function renderHeadingBlockInner(elementBlock) {
  985. var output = "";
  986. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  987. book = getNodeText(xmlParInfo, "book");
  988. paragraph = getNodeText(xmlParInfo, "paragraph");
  989. bId = getNodeText(xmlParInfo, "id");
  990. type = getNodeText(xmlParInfo, "type");
  991. var headingData = elementBlock.getElementsByTagName("data")[0];
  992. headingText = getNodeText(headingData, "text");
  993. output += '<span id="id_heading_text_' + bId + '">' + headingText + "</span>";
  994. output +=
  995. '<button type="button" class="edit_tool imgbutton" onclick="editor_heading_edit(\'' +
  996. bId +
  997. "')\"><svg class='icon' style='fill: var(--detail-color);'><use xlink:href='svg/icon.svg#ic_mode_edit'></use></svg></button>";
  998. return output;
  999. }
  1000. function updateWordParBlockInnerAll() {
  1001. var xBlock = gXmlBookDataBody.getElementsByTagName("block");
  1002. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  1003. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  1004. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  1005. mId = getNodeText(xmlParInfo, "id");
  1006. type = getNodeText(xmlParInfo, "type");
  1007. if ((type = "wbw")) {
  1008. updateWordParBlockInner(xBlock[iBlock]);
  1009. }
  1010. }
  1011. }
  1012. function updateWordParBlockInner(elementBlock) {
  1013. var xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  1014. var blockId = getNodeText(xmlParInfo, "id");
  1015. var wbwblock = document.getElementById("id_wbw_" + blockId);
  1016. if (wbwblock) {
  1017. wbwblock.innerHTML = renderWordParBlockInner(elementBlock);
  1018. word_mouse_event();
  1019. note_refresh_new();
  1020. }
  1021. }
  1022. function renderNoteShell(elementBlock) {
  1023. let output = "";
  1024. let allWord = elementBlock.getElementsByTagName("word");
  1025. for (iWord = 0; iWord < allWord.length; iWord++) {
  1026. let wID = getNodeText(allWord[iWord], "id");
  1027. output += '<div id="wn_' + wID + '">';
  1028. output += '<div id="wnn_' + wID + '"></div>';
  1029. output += '<div id="wnr_' + wID + '"></div>';
  1030. output += '<div id="wnc_' + wID + '"></div>';
  1031. output += "</div>";
  1032. }
  1033. return output;
  1034. }
  1035. //句子上面的工具条
  1036. function render_sent_tool_bar(elementBlock, begin) {
  1037. let output = "";
  1038. let axmlParInfo = elementBlock.getElementsByTagName("info")[0];
  1039. let abook = getNodeText(axmlParInfo, "book");
  1040. let aparagraph = getNodeText(axmlParInfo, "paragraph");
  1041. let xallWord = elementBlock.getElementsByTagName("word");
  1042. let iBegin = -1;
  1043. let iEnd = -1;
  1044. let iWordId = 0;
  1045. for (let i = 0; i < xallWord.length; i++) {
  1046. let aID = getNodeText(xallWord[i], "id");
  1047. let aEnter = getNodeText(xallWord[i], "enter");
  1048. let arrId = aID.split("-");
  1049. iWordId = parseInt(arrId[2]);
  1050. if (iWordId > begin && iBegin < 0) {
  1051. iBegin = iWordId;
  1052. }
  1053. if (iWordId > begin && aEnter == "1") {
  1054. //句子末尾
  1055. iEnd = iWordId;
  1056. break;
  1057. }
  1058. }
  1059. if (iEnd == -1) {
  1060. iEnd = iWordId;
  1061. }
  1062. output += "<div class='sent_wbw_trans_bar'>";
  1063. let sentIdString = abook + "-" + aparagraph + "-" + iBegin + "-" + iEnd;
  1064. let sentIdStringLink = "{{" + sentIdString + "}}";
  1065. let sentReaderLink = "";
  1066. if (_display_sbs == 0) {
  1067. //逐段模式
  1068. sentReaderLink = "https://www.wikipali.org/app/reader/?view=para&book=" + abook + "&para=" + aparagraph;
  1069. } else {
  1070. //逐句模式
  1071. sentReaderLink =
  1072. "https://www.wikipali.org/app/reader/?view=sent&book=" +
  1073. abook +
  1074. "&para=" +
  1075. aparagraph +
  1076. "&begin=" +
  1077. iBegin +
  1078. "&end=" +
  1079. iEnd;
  1080. }
  1081. output += "<span style='flex: 7;display: flex;'>";
  1082. output += "<div style='background-color: silver;'>";
  1083. //句子编号
  1084. output += "<span style='font-size: large; font-weight: bolder;' title=" + gLocal.gui.text_num + ">";
  1085. output += sentIdString;
  1086. output += "</span>";
  1087. //功能按钮
  1088. //拷贝到剪贴板
  1089. output +=
  1090. "<button class='icon_btn' onclick=\"copy_to_clipboard('" +
  1091. sentIdStringLink +
  1092. "')\" title=" +
  1093. gLocal.gui.copy_to_clipboard +
  1094. ">";
  1095. output +=
  1096. '<svg style="fill: var(--link-color);" t="1601480724259" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4644"><path d="M791.272727 93.090909H139.636364v837.818182a93.090909 93.090909 0 0 1-93.090909-93.090909V93.090909a93.090909 93.090909 0 0 1 93.090909-93.090909h558.545454a93.090909 93.090909 0 0 1 93.090909 93.090909zM232.727273 186.181818h744.727272v837.818182H232.727273V186.181818z" p-id="4645"></path></svg>';
  1097. output += "</button>";
  1098. //在阅读器中打开
  1099. let reader_open_link = "";
  1100. if (_display_sbs == 0) {
  1101. //逐段模式
  1102. reader_open_link = "../reader/?view=para&book=" + abook + "&para=" + aparagraph;
  1103. } else {
  1104. //逐句模式
  1105. reader_open_link =
  1106. "../reader/?view=sent&book=" + abook + "&para=" + aparagraph + "&begin=" + iBegin + "&end=" + iEnd;
  1107. }
  1108. output +=
  1109. "<button class='icon_btn' onclick=\"window.open('" +
  1110. reader_open_link +
  1111. "')\" target='_blank' title='" +
  1112. gLocal.gui.scan_in_reader +
  1113. "'>";
  1114. output +=
  1115. '<svg style="fill: var(--link-color);" t="1601482753387" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22291"><path d="M703.730499 544.578527a191.730499 191.730499 0 0 1 156.260356 302.806368l122.004508 122.004507a31.955083 31.955083 0 0 1-45.248398 45.184488l-121.940597-121.940598A191.730499 191.730499 0 1 1 703.730499 544.642437z m-6.391017-511.28133c38.857381 0 70.301183 30.67688 70.301183 68.511698v386.912146a255.640665 255.640665 0 1 0-69.022979 503.16474l-563.687667 0.06391c-38.857381 0-70.301183-30.67688-70.301183-68.447788V101.808895C64.628836 63.910166 96.072638 33.233286 134.930019 33.233286h562.409463z m6.391017 575.191496a127.820333 127.820333 0 1 0 0 255.640665 127.820333 127.820333 0 0 0 0-255.640665z m-351.505915 0h-127.820332a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511281h127.820332a31.955083 31.955083 0 0 0 0-63.910166z m0-191.730499h-127.820332a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511282h127.820332a31.955083 31.955083 0 0 0 0-63.910167z m191.730499-191.730499h-319.550831a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511282h319.550831a31.955083 31.955083 0 0 0 0-63.910167z" p-id="22292"></path></svg>';
  1116. output += "</button>";
  1117. //关系图
  1118. output +=
  1119. "<button class='icon_btn' title='" +
  1120. gLocal.gui.relational_map +
  1121. "' class='rel_map' onclick=\"sent_show_rel_map('" +
  1122. abook +
  1123. "','" +
  1124. aparagraph +
  1125. "','" +
  1126. iBegin +
  1127. "','" +
  1128. iEnd +
  1129. "')\">" +
  1130. '<svg style="transform: rotate(-90deg); fill: var(--link-color);" t="1601482033694" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18290"><path d="M903.3 650.8H791.9V511.3H540.5V399.9h167.7c30.9 0 55.9-25.5 55.9-56.4V120.3c0-31.3-25.1-56.4-55.9-56.4H316.4c-30.9 0-55.5 25.1-55.5 56.4 0 0 0 222.8-0.4 223.2 0 31.3 25.1 56.4 55.9 56.4h168.2v111.4H232.8v139.6H120.9c-30.9-0.1-55.9 25-55.9 55.9v196.4c0 30.4 25.1 55.5 55.9 55.9h279.6c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25.1-55.9-55.9-55.9H288.7v-83.7H736v83.7H624.2c-30.9 0-55.9 25.1-55.9 55.9v196.4c0 30.9 25.1 55.9 55.9 55.9h279.1c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25-56-55.9-56z" p-id="18291"></path></svg>' +
  1131. "</button>";
  1132. //拷贝词意到剪贴板
  1133. output +=
  1134. "<button class='icon_btn' title='" +
  1135. "copy meaning" +
  1136. "' class='rel_map' onclick=\"sent_copy_meaning('" +
  1137. abook +
  1138. "','" +
  1139. aparagraph +
  1140. "','" +
  1141. iBegin +
  1142. "','" +
  1143. iEnd +
  1144. "')\">" +
  1145. '<svg style="transform: rotate(-90deg); fill: var(--link-color);" t="1601482033694" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18290"><path d="M903.3 650.8H791.9V511.3H540.5V399.9h167.7c30.9 0 55.9-25.5 55.9-56.4V120.3c0-31.3-25.1-56.4-55.9-56.4H316.4c-30.9 0-55.5 25.1-55.5 56.4 0 0 0 222.8-0.4 223.2 0 31.3 25.1 56.4 55.9 56.4h168.2v111.4H232.8v139.6H120.9c-30.9-0.1-55.9 25-55.9 55.9v196.4c0 30.4 25.1 55.5 55.9 55.9h279.6c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25.1-55.9-55.9-55.9H288.7v-83.7H736v83.7H624.2c-30.9 0-55.9 25.1-55.9 55.9v196.4c0 30.9 25.1 55.9 55.9 55.9h279.1c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25-56-55.9-56z" p-id="18291"></path></svg>' +
  1146. "</button>";
  1147. //功能按钮结束
  1148. output += "</div>";
  1149. output += "<guide gid='sent_func' style='margin:unset;'></guide>";
  1150. output += "</span>";
  1151. output += "<span style='flex: 3;'><guide gid='sent_trans' style='margin:unset;'></guide></span>";
  1152. output += "</div>";
  1153. return output;
  1154. }
  1155. var arr_par_sent_num = new Array();
  1156. var g_arr_Para_ID = new Array();
  1157. function renderWordParBlockInner(elementBlock) {
  1158. var output = "<div style='display:block;width:100%'>";
  1159. var Note_Mark = 0;
  1160. var sent_gramma_i = 0;
  1161. var word_length_count = 0;
  1162. var sent_num = 0;
  1163. var arr_Para_ID = new Array();
  1164. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  1165. let book = getNodeText(xmlParInfo, "book");
  1166. let paragraph = getNodeText(xmlParInfo, "paragraph");
  1167. let par_num = paragraph - 1;
  1168. let type = getNodeText(xmlParInfo, "type");
  1169. let allWord = elementBlock.getElementsByTagName("word");
  1170. output += "<div class='sent_wbw_trans'>";
  1171. output += render_sent_tool_bar(elementBlock, 0);
  1172. output += "<div class='sent_wbw'>";
  1173. let sent_begin = 0;
  1174. let wID;
  1175. let word_id;
  1176. for (let iWord = 0; iWord < allWord.length; iWord++) {
  1177. wID = getNodeText(allWord[iWord], "id");
  1178. let wPali = getNodeText(allWord[iWord], "pali");
  1179. let wReal = getNodeText(allWord[iWord], "real");
  1180. let wType = getNodeText(allWord[iWord], "type");
  1181. let wGramma = getNodeText(allWord[iWord], "gramma");
  1182. let wCase = getNodeText(allWord[iWord], "case");
  1183. let wMean = getNodeText(allWord[iWord], "mean");
  1184. let wParent = getNodeText(allWord[iWord], "parent");
  1185. let wUn = getNodeText(allWord[iWord], "un");
  1186. let wStyle = getNodeText(allWord[iWord], "style");
  1187. let wEnter = getNodeText(allWord[iWord], "enter");
  1188. if ((wType == "" || wType == "?") && wCase != "") {
  1189. wType = wCase.split("#")[0];
  1190. }
  1191. word_id = parseInt(wID.split("-")[2]);
  1192. if (sent_begin == 0) {
  1193. sent_begin = word_id;
  1194. }
  1195. //渲染单词块
  1196. //word div class
  1197. let strMouseEvent = ' onmouseover="on_word_mouse_enter()" onmouseout="on_word_mouse_leave()"';
  1198. if (wType == ".ctl." && wGramma == ".a.") {
  1199. //output += "<div><a name='"+wPali+"'></a></div>";
  1200. output +=
  1201. '<div id="wb' +
  1202. wID +
  1203. "\" class='ctrl sent_gramma_" +
  1204. (sent_gramma_i % 3) +
  1205. "'> <a name='" +
  1206. wPali +
  1207. "'></a>";
  1208. } else if (Note_Mark == 1) {
  1209. output +=
  1210. '<div id="wb' +
  1211. wID +
  1212. "\" class='word org_note sent_gramma_" +
  1213. (sent_gramma_i % 3) +
  1214. "'> <a name='" +
  1215. wPali +
  1216. "'></a>";
  1217. } else {
  1218. if (wReal == "") {
  1219. output +=
  1220. '<div id="wb' + wID + '" class="word_punc un_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //符號
  1221. } else {
  1222. if (wType == ".un.") {
  1223. output +=
  1224. '<div id="wb' + wID + '" class="word un_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //粘音詞
  1225. } else if (wType == ".comp.") {
  1226. output +=
  1227. '<div id="wb' + wID + '" class="word comp_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //複合詞
  1228. } else {
  1229. output += '<div id="wb' + wID + '" class="word sent_gramma_' + (sent_gramma_i % 3) + '" >'; //普通
  1230. }
  1231. }
  1232. }
  1233. //head div class
  1234. output += " <div id='ws_" + wID + "' class='word_head_shell' >";
  1235. if (wUn.length > 0) {
  1236. output += " <div class='word_head un_pali' id=\"whead_" + wID + '">';
  1237. } else {
  1238. output += " <div class='word_head' id=\"whead_" + wID + '">';
  1239. }
  1240. output += renderWordHeadInner(allWord[iWord]);
  1241. output += " </div>";
  1242. output += " </div>";
  1243. output += ' <div id="detail' + wID + '" class="wbody">';
  1244. output += renderWordBodyInner(allWord[iWord]);
  1245. output += " </div>";
  1246. output += "</div>";
  1247. //渲染单词块结束
  1248. word_length_count += wPali.length;
  1249. if (iWord >= 1) {
  1250. var pre_pali_spell = getNodeText(allWord[iWord - 1], "pali");
  1251. var pre_pali_type = getNodeText(allWord[iWord - 1], "type");
  1252. var pre_pali_Gramma = getNodeText(allWord[iWord - 1], "gramma");
  1253. var pre_pali_Case = getNodeText(allWord[iWord - 1], "case");
  1254. if (pre_pali_type == "" && pre_pali_Case != "") {
  1255. pre_pali_type = pre_pali_Case.split("#")[0];
  1256. }
  1257. if (pre_pali_Case != "" && pre_pali_Case.lastIndexOf("$") != -1) {
  1258. var pre_case_array = pre_pali_Case.split("$");
  1259. pre_pali_Case = pre_case_array[pre_case_array.length - 1];
  1260. }
  1261. }
  1262. if (iWord + 2 <= allWord.length) {
  1263. var next_pali_spell = getNodeText(allWord[iWord + 1], "pali");
  1264. var next_pali_type = getNodeText(allWord[iWord + 1], "type");
  1265. var next_pali_Gramma = getNodeText(allWord[iWord + 1], "gramma");
  1266. var next_pali_Case = getNodeText(allWord[iWord + 1], "case");
  1267. if (next_pali_type == "" && next_pali_Case != "") {
  1268. next_pali_type = next_pali_Case.split("#")[0];
  1269. }
  1270. if (next_pali_Case != "" && next_pali_Case.lastIndexOf("$") != -1) {
  1271. var next_case_array = next_pali_Case.split("$");
  1272. next_pali_Case = next_case_array[next_case_array.length - 1];
  1273. }
  1274. }
  1275. if (next_pali_spell == "(") {
  1276. Note_Mark = 1;
  1277. } else if (pre_pali_spell == ")" && Note_Mark == 1) {
  1278. Note_Mark = 0;
  1279. } else {
  1280. }
  1281. if (wEnter == 1) {
  1282. //句子末尾
  1283. var sent_ID = "sent_" + par_num + "_" + sent_num;
  1284. if (_display_sbs == 1) {
  1285. //逐句显示模式
  1286. output += "</div>"; //逐句逐词译块结束
  1287. //逐句翻译块开始
  1288. output += "<div id='sent_div_" + wID + "' class='translate_sent'>";
  1289. output += "<div class='translate_sent_head'>";
  1290. output += "<div class='translate_sent_head_toolbar' style='display:none;'>";
  1291. output += "<span></span>";
  1292. output +=
  1293. "<span onclick=\"show_tran_net('" +
  1294. book +
  1295. "','" +
  1296. paragraph +
  1297. "','" +
  1298. sent_begin +
  1299. "','" +
  1300. word_id +
  1301. "')\"><span id='' class=\"word_msg\">issue</span></span>";
  1302. //
  1303. output += "</div>";
  1304. output += "<div class='translate_sent_head_content'>";
  1305. //句子预览
  1306. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, 0, true);
  1307. if (_my_channal != null) {
  1308. for (const iterator of _my_channal) {
  1309. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, iterator.id, false);
  1310. }
  1311. }
  1312. //句子预览结束
  1313. output += "</div>";
  1314. output +=
  1315. "<div class='trans_text_content' pcds='sent-net' book='" +
  1316. book +
  1317. "' para='" +
  1318. paragraph +
  1319. "' begin='" +
  1320. sent_begin +
  1321. "' end=''>";
  1322. output += "</div>";
  1323. output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
  1324. output += "</div>";
  1325. output += "</div>";
  1326. output += "</div>";
  1327. //逐句翻译块内容结束
  1328. output += "<div class='translate_sent_foot'>";
  1329. output += "</div>";
  1330. output += "</div>";
  1331. //逐句翻译块结束
  1332. output += "</div>"; //逐句块结束
  1333. sent_begin = word_id + 1;
  1334. //下一个逐句块开始
  1335. output += "<div class='sent_wbw_trans'>";
  1336. //output += output += render_sent_tool_bar(elementBlock,word_id);
  1337. let nextBegin = word_id + 1;
  1338. let nextEnd = 0;
  1339. for (let j = iWord + 1; j < allWord.length; j++) {
  1340. let aID = getNodeText(allWord[j], "id");
  1341. let aEnter = getNodeText(allWord[j], "enter");
  1342. let arrId = aID.split("-");
  1343. iWordId = parseInt(arrId[2]);
  1344. if (aEnter == 1) {
  1345. nextEnd = iWordId;
  1346. break;
  1347. }
  1348. }
  1349. if (nextEnd == 0) {
  1350. nextEnd = iWordId;
  1351. }
  1352. output += "<div class='sent_wbw_trans_bar'>";
  1353. let sentIdString = book + "-" + paragraph + "-" + nextBegin + "-" + nextEnd;
  1354. let sentIdStringLink = "{{" + sentIdString + "}}";
  1355. output +=
  1356. "<span style='flex: 7;display: flex;'><div style='background-color: silver;'><span style='font-size: large; font-weight: bolder;' title=" +
  1357. gLocal.gui.text_num +
  1358. ">" +
  1359. sentIdString +
  1360. "</span><button class='icon_btn' onclick=\"copy_to_clipboard('" +
  1361. sentIdStringLink +
  1362. "')\" title=" +
  1363. gLocal.gui.copy_to_clipboard +
  1364. ">";
  1365. output +=
  1366. '<svg style="fill: var(--link-color);" t="1601480724259" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4644"><path d="M791.272727 93.090909H139.636364v837.818182a93.090909 93.090909 0 0 1-93.090909-93.090909V93.090909a93.090909 93.090909 0 0 1 93.090909-93.090909h558.545454a93.090909 93.090909 0 0 1 93.090909 93.090909zM232.727273 186.181818h744.727272v837.818182H232.727273V186.181818z" p-id="4645"></path></svg>';
  1367. output += "</button>";
  1368. output +=
  1369. "<button class='icon_btn' onclick=\"window.open('../reader/?view=sent&book=" +
  1370. book +
  1371. "&para=" +
  1372. paragraph +
  1373. "&begin=" +
  1374. nextBegin +
  1375. "&end=" +
  1376. nextEnd +
  1377. "')\" target='_blank' title='" +
  1378. gLocal.gui.scan_in_reader +
  1379. "'>";
  1380. output +=
  1381. '<svg style="fill: var(--link-color);" t="1601482753387" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="22291"><path d="M703.730499 544.578527a191.730499 191.730499 0 0 1 156.260356 302.806368l122.004508 122.004507a31.955083 31.955083 0 0 1-45.248398 45.184488l-121.940597-121.940598A191.730499 191.730499 0 1 1 703.730499 544.642437z m-6.391017-511.28133c38.857381 0 70.301183 30.67688 70.301183 68.511698v386.912146a255.640665 255.640665 0 1 0-69.022979 503.16474l-563.687667 0.06391c-38.857381 0-70.301183-30.67688-70.301183-68.447788V101.808895C64.628836 63.910166 96.072638 33.233286 134.930019 33.233286h562.409463z m6.391017 575.191496a127.820333 127.820333 0 1 0 0 255.640665 127.820333 127.820333 0 0 0 0-255.640665z m-351.505915 0h-127.820332a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511281h127.820332a31.955083 31.955083 0 0 0 0-63.910166z m0-191.730499h-127.820332a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511282h127.820332a31.955083 31.955083 0 0 0 0-63.910167z m191.730499-191.730499h-319.550831a31.955083 31.955083 0 0 0-5.751915 63.398885l5.751915 0.511282h319.550831a31.955083 31.955083 0 0 0 0-63.910167z" p-id="22292"></path></svg>';
  1382. output += "</button>";
  1383. output +=
  1384. "<button class='icon_btn' title='" +
  1385. gLocal.gui.relational_map +
  1386. "' class='rel_map' onclick=\"sent_show_rel_map('" +
  1387. book +
  1388. "','" +
  1389. paragraph +
  1390. "','" +
  1391. nextBegin +
  1392. "','" +
  1393. nextEnd +
  1394. "')\">" +
  1395. '<svg style="transform: rotate(-90deg); fill: var(--link-color);" t="1601482033694" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18290"><path d="M903.3 650.8H791.9V511.3H540.5V399.9h167.7c30.9 0 55.9-25.5 55.9-56.4V120.3c0-31.3-25.1-56.4-55.9-56.4H316.4c-30.9 0-55.5 25.1-55.5 56.4 0 0 0 222.8-0.4 223.2 0 31.3 25.1 56.4 55.9 56.4h168.2v111.4H232.8v139.6H120.9c-30.9-0.1-55.9 25-55.9 55.9v196.4c0 30.4 25.1 55.5 55.9 55.9h279.6c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25.1-55.9-55.9-55.9H288.7v-83.7H736v83.7H624.2c-30.9 0-55.9 25.1-55.9 55.9v196.4c0 30.9 25.1 55.9 55.9 55.9h279.1c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25-56-55.9-56z" p-id="18291"></path></svg>' +
  1396. "</button>";
  1397. //拷贝词意到剪贴板
  1398. output +=
  1399. "<button class='icon_btn' title='" +
  1400. "copy meaning" +
  1401. "' class='rel_map' onclick=\"sent_copy_meaning('" +
  1402. book +
  1403. "','" +
  1404. paragraph +
  1405. "','" +
  1406. nextBegin +
  1407. "','" +
  1408. nextEnd +
  1409. "')\">" +
  1410. '<svg style="transform: rotate(-90deg); fill: var(--link-color);" t="1601482033694" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18290"><path d="M903.3 650.8H791.9V511.3H540.5V399.9h167.7c30.9 0 55.9-25.5 55.9-56.4V120.3c0-31.3-25.1-56.4-55.9-56.4H316.4c-30.9 0-55.5 25.1-55.5 56.4 0 0 0 222.8-0.4 223.2 0 31.3 25.1 56.4 55.9 56.4h168.2v111.4H232.8v139.6H120.9c-30.9-0.1-55.9 25-55.9 55.9v196.4c0 30.4 25.1 55.5 55.9 55.9h279.6c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25.1-55.9-55.9-55.9H288.7v-83.7H736v83.7H624.2c-30.9 0-55.9 25.1-55.9 55.9v196.4c0 30.9 25.1 55.9 55.9 55.9h279.1c30.9 0 55.9-25.1 55.9-55.9V706.8c0-30.9-25-56-55.9-56z" p-id="18291"></path></svg>' +
  1411. "</button>";
  1412. output += "</div>";
  1413. output += "<guide gid='sent_func' style='margin:unset;'></guide>";
  1414. output += "</span>";
  1415. output += "<span style='flex: 3;'><guide gid='sent_trans' style='margin:unset;'></guide></span>";
  1416. output += "</div>";
  1417. output += "<div class='sent_wbw'>";
  1418. }
  1419. sent_num += 1;
  1420. word_length_count = 0;
  1421. sent_gramma_i = 0;
  1422. arr_Para_ID.push(wID);
  1423. }
  1424. } //循環結束
  1425. output += "</div>";
  1426. //逐句翻译块开始
  1427. output += "<div id='sent_div_" + wID + "' class='translate_sent'>";
  1428. output += "<div class='translate_sent_head'>";
  1429. output += "<div class='translate_sent_head_toolbar'>";
  1430. output += "<span></span>";
  1431. output +=
  1432. "<span onclick=\"show_tran_net('" +
  1433. book +
  1434. "','" +
  1435. paragraph +
  1436. "','" +
  1437. sent_begin +
  1438. "','" +
  1439. word_id +
  1440. "')\"><span id='' class=\"word_msg\">issue</span></span>";
  1441. output += "</div>";
  1442. output += "<div class='translate_sent_head_content'>";
  1443. //逐句译文开始
  1444. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, 0, true);
  1445. if (_my_channal != null) {
  1446. for (const iterator of _my_channal) {
  1447. output += render_tran_sent_block(book, paragraph, sent_begin, word_id, iterator.id, false);
  1448. }
  1449. }
  1450. output += "</div>";
  1451. output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
  1452. output += "</div>";
  1453. //逐句翻译块内容结束
  1454. output += "<div class='translate_sent_foot'>";
  1455. output += "</div>";
  1456. output += "</div>";
  1457. //逐句翻译块结束
  1458. output += "</div>";
  1459. var sent_ID = "sent_" + par_num + "_" + sent_num;
  1460. arr_Para_ID.push(wID);
  1461. arr_par_sent_num.push(sent_ID);
  1462. g_arr_Para_ID[par_num] = arr_Para_ID;
  1463. return output;
  1464. }
  1465. //根据relation 绘制关系图
  1466. function sent_copy_meaning(book, para, begin, end) {
  1467. let wordId = 0;
  1468. let output = "";
  1469. for (wordId = parseInt(begin); wordId <= parseInt(end); wordId++) {
  1470. output += doc_word("#p" + book + "-" + para + "-" + wordId).val("mean");
  1471. }
  1472. copy_to_clipboard(output);
  1473. }
  1474. //根据relation 绘制关系图
  1475. function sent_show_rel_map(book, para, begin, end) {
  1476. let wordId = 0;
  1477. let memind = "graph LR\n";
  1478. let pali_text = "";
  1479. for (wordId = parseInt(begin); wordId <= parseInt(end); wordId++) {
  1480. let rel = doc_word("#p" + book + "-" + para + "-" + wordId).val("rela");
  1481. let pali = doc_word("#p" + book + "-" + para + "-" + wordId).val("real");
  1482. let type = doc_word("#p" + book + "-" + para + "-" + wordId).val("type");
  1483. if (type != ".ctl.") {
  1484. pali_text += pali + " ";
  1485. }
  1486. let wid = "p" + book + "-" + para + "-" + wordId;
  1487. if (rel != "") {
  1488. let relaData = JSON.parse(rel);
  1489. for (const iterator of relaData) {
  1490. let strRel = iterator.relation;
  1491. let dest = iterator.dest_spell;
  1492. let type = doc_word("#" + iterator.dest_id).val("case");
  1493. if (type.indexOf(".v.") >= 0) {
  1494. dest = iterator.dest_id + "[/" + dest + "/]";
  1495. } else {
  1496. dest = iterator.dest_id + "[" + dest + "]";
  1497. }
  1498. if (strRel.indexOf("SV") >= 0 || strRel.indexOf("-P") >= 0) {
  1499. memind += wid + "(" + pali + ")" + " ==> |" + strRel + "|" + dest + "\n";
  1500. } else if (strRel.indexOf("OV") >= 0 || strRel.indexOf("-S") >= 0) {
  1501. memind += dest + " ==> |" + strRel + "|" + wid + "(" + pali + ")" + "\n";
  1502. } else {
  1503. memind += wid + "(" + pali + ")" + " -- " + strRel + " --> " + dest + "\n";
  1504. }
  1505. }
  1506. }
  1507. }
  1508. let graph = mermaid.render("graphDiv", memind);
  1509. document.querySelector("#term_body_parent").innerHTML = '<div class="win_body_inner" id="term_body"></div>'; //清空之前的记录
  1510. document.querySelector("#term_body").outerHTML =
  1511. "<h3 style='padding: 0 1em;'>" + pali_text + "</h3>" + document.querySelector("#term_body").outerHTML;
  1512. document.querySelector("#term_body").innerHTML = graph;
  1513. document.querySelector("#term_win").style.display = "flex";
  1514. document.querySelector(".win_body").style.display = "block";
  1515. }
  1516. //句子编辑块
  1517. function render_tran_sent_block(book, para, begin, end, channal = 0, readonly = true) {
  1518. let usent_count = _user_sent_buffer.getSentNum(book, para, begin, end);
  1519. let netSent = doc_msg_get_trans(book, para, begin, end);
  1520. let sender = "";
  1521. let sChannalName = "";
  1522. let sent_text = "";
  1523. let sent_lang = "en";
  1524. let objSent;
  1525. let thischannal;
  1526. if (channal == 0) {
  1527. //百家言
  1528. if (netSent.length > 0) {
  1529. sender = netSent[netSent.length - 1].sender;
  1530. sent_text += netSent[netSent.length - 1].data.text;
  1531. } else if (usent_count > 0) {
  1532. sender = _user_sent_buffer.getSentText(book, para, begin, end)[0].nickname;
  1533. sChannalName = "channal name";
  1534. sent_text += _user_sent_buffer.getSentText(book, para, begin, end)[0].text;
  1535. }
  1536. } else {
  1537. sender = "通道的名字";
  1538. objSent = _user_sent_buffer.getSentText(book, para, begin, end, channal);
  1539. thischannal = channal_getById(channal);
  1540. if (objSent == false) {
  1541. objSent = new Object();
  1542. objSent.text = "";
  1543. objSent.language = thischannal.lang;
  1544. objSent.id = "";
  1545. objSent.tag = "[]";
  1546. objSent.author = "{}";
  1547. sent_text = "";
  1548. } else {
  1549. sent_text = objSent.text;
  1550. }
  1551. sent_lang = objSent.language;
  1552. }
  1553. let output = "";
  1554. output += "<div class='trans_text_block' style='padding-top:0;";
  1555. if (readonly == false) {
  1556. output += "border-color: #ccd1ff;background-color:unset;";
  1557. }
  1558. output += "'>";
  1559. output += "<div class='trans_text_info' style='border:none;'>";
  1560. if (channal == 0) {
  1561. output += "<span class='author'>" + sender + "</span><span>[滤]</span>";
  1562. } else {
  1563. output += "<span style='width: 100%;display: contents;'>";
  1564. output += "<span>";
  1565. if (thischannal) {
  1566. output += thischannal.name + "-" + thischannal.lang;
  1567. } else {
  1568. output += "未知的频道名";
  1569. }
  1570. output += "</span>";
  1571. output +=
  1572. "<span style='margin-left: auto;' class='send_status' id='send_" +
  1573. book +
  1574. "_" +
  1575. para +
  1576. "_" +
  1577. begin +
  1578. "_" +
  1579. end +
  1580. "_" +
  1581. channal +
  1582. "'></span>";
  1583. }
  1584. output += "</span><span></span>";
  1585. output += "</div>";
  1586. let id = "tran_pre_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal;
  1587. output += "<div class='trans_text_content' tid = '" + id;
  1588. if (channal == 0) {
  1589. output += "' pcds='sent-net-all' ";
  1590. } else {
  1591. output += "' pcds='sent-net' ";
  1592. }
  1593. output +=
  1594. " book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' channal='" + channal + "'>";
  1595. if (readonly) {
  1596. output += note_init(term_std_str_to_tran(sent_text, channal, getCookie("userid"), sent_lang));
  1597. } else {
  1598. output += "<span id='" + id + "' ";
  1599. output += "onclick=\"sent_edit_click('";
  1600. output += book + "','" + para + "','" + begin + "','" + end + "','" + channal + "',)\">";
  1601. if (objSent.text == null || objSent.text == "") {
  1602. output += "<span style='color:gray;'>";
  1603. output += "<svg class='icon' style='fill: var(--detail-color);'>";
  1604. output += "<use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_mode_edit'>";
  1605. output += "</span>";
  1606. } else {
  1607. output += note_init(term_std_str_to_tran(objSent.text, channal, getCookie("userid"), sent_lang));
  1608. }
  1609. output += "</span>";
  1610. }
  1611. output += "</div>";
  1612. //句子预览结束
  1613. //编辑框开始
  1614. if (readonly == false) {
  1615. output += "<div style='display:none;'>";
  1616. let id = book + "_" + para + "_" + begin + "_" + end + "_" + channal;
  1617. output += "<textarea id='trans_sent_edit_" + id + "' ";
  1618. output += " onkeyup = \"updateTranslationPreview('" + id + "',this)\" ";
  1619. output +=
  1620. " onchange=\"trans_text_save('" +
  1621. book +
  1622. "','" +
  1623. para +
  1624. "','" +
  1625. begin +
  1626. "','" +
  1627. end +
  1628. "','" +
  1629. channal +
  1630. "')\"";
  1631. output += "class='trans_sent_edit' style='background-color: #f8f8fa;color: black;border-color: silver;' ";
  1632. output += "sent_id='" + objSent.id + "' ";
  1633. output += "book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' ";
  1634. output +=
  1635. " channal='" +
  1636. channal +
  1637. "' author='" +
  1638. objSent.author +
  1639. "' lang='" +
  1640. objSent.language +
  1641. "' tag='" +
  1642. objSent.tag +
  1643. "' >";
  1644. output += objSent.text;
  1645. output += "</textarea>";
  1646. output += "<div class='trans_text_info' style='justify-content: flex-end;'>";
  1647. output += "<span></span>";
  1648. output += "<button class='icon_btn' ";
  1649. output +=
  1650. "onclick=\"trans_text_save('" +
  1651. book +
  1652. "','" +
  1653. para +
  1654. "','" +
  1655. begin +
  1656. "','" +
  1657. end +
  1658. "','" +
  1659. channal +
  1660. "')\" ";
  1661. output +=
  1662. "title=" +
  1663. gLocal.gui.draft +
  1664. ">" +
  1665. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#ic_save"></use></svg>';
  1666. output += "</button>";
  1667. output += "<button class='icon_btn' ";
  1668. output +=
  1669. "onclick=\"trans_text_send('" +
  1670. book +
  1671. "','" +
  1672. para +
  1673. "','" +
  1674. begin +
  1675. "','" +
  1676. end +
  1677. "','" +
  1678. channal +
  1679. "')\"";
  1680. output +=
  1681. " title=" +
  1682. gLocal.gui.send +
  1683. " disabled>" +
  1684. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#send_by_paper_plane"></use></svg>';
  1685. output += "</button>";
  1686. output += "</div>";
  1687. output += "</div>";
  1688. }
  1689. if (readonly) {
  1690. output += "<div class='trans_text_info'>" + "<span></span>" + "<span><span class='tools'>";
  1691. output +=
  1692. "<button class='icon_btn' title=" +
  1693. gLocal.gui.accept_copy +
  1694. ">" +
  1695. "<svg class='icon' style='fill: var(--link-color); height: 2em; width: 2em; '><use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_move_to_inbox'></use></svg>" +
  1696. "</button>";
  1697. if (channal == 0) {
  1698. //百家言 显示更多按钮
  1699. output +=
  1700. "<button class='icon_btn' onclick=\"show_tran_net('" +
  1701. book +
  1702. "','" +
  1703. para +
  1704. "','" +
  1705. begin +
  1706. "','" +
  1707. end +
  1708. "')\" title=" +
  1709. gLocal.gui.message +
  1710. ">" +
  1711. '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="plugin/system_message/icon.svg#icon_message"></use></svg>' +
  1712. "</button>";
  1713. }
  1714. output += "</span><span>" + usent_count + "</span></span>";
  1715. output += "</div>";
  1716. }
  1717. output += "</div>";
  1718. return output;
  1719. }
  1720. function trans_text_save(book, para, begin, end, channal) {
  1721. let textarea = $("#trans_sent_edit_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal);
  1722. if (textarea) {
  1723. let objsent = new Object();
  1724. objsent.id = textarea.attr("sent_id");
  1725. objsent.book = book;
  1726. objsent.paragraph = para;
  1727. objsent.begin = begin;
  1728. objsent.end = end;
  1729. objsent.channal = channal;
  1730. objsent.author = textarea.attr("author");
  1731. objsent.lang = textarea.attr("lang");
  1732. objsent.text = textarea.val();
  1733. _user_sent_buffer.setSent(objsent);
  1734. }
  1735. }
  1736. function sent_edit_click(book, para, begin, end, channal) {
  1737. $(".trans_sent_edit").parent().hide(200);
  1738. $(
  1739. ".trans_sent_edit[book='" +
  1740. book +
  1741. "'][para='" +
  1742. para +
  1743. "'][begin='" +
  1744. begin +
  1745. "'][end='" +
  1746. end +
  1747. "'][channal='" +
  1748. channal +
  1749. "']"
  1750. )
  1751. .parent()
  1752. .show();
  1753. }
  1754. function magic_sentence_cut() {
  1755. var all_sent_array = document.getElementsByClassName("sent_wbw");
  1756. for (i_magic = 0; i_magic < all_sent_array.length; i_magic++) {
  1757. if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1").length != 0) {
  1758. all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1")[0].className += " sent_cut";
  1759. }
  1760. if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2").length != 0) {
  1761. all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2")[0].className += " sent_cut";
  1762. }
  1763. }
  1764. }
  1765. function updataWordHeadById(wordId) {
  1766. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1767. var iIndex = getWordIndex(wordId);
  1768. if (iIndex >= 0) {
  1769. $("#whead_" + wordId).html(renderWordHeadInner(xAllWord[iIndex]));
  1770. }
  1771. }
  1772. function updataWordHeadByIndex(wordIndex) {
  1773. if (wordIndex > 0) {
  1774. let xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1775. let wordId = getNodeText(xAllWord[wordIndex], "id");
  1776. let obj = document.getElementById("whead_" + wordId);
  1777. if (obj) {
  1778. obj.innerHTML = renderWordHeadInner(xAllWord[wordIndex]);
  1779. }
  1780. }
  1781. }
  1782. function updateWordBodyById(wordId) {
  1783. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1784. var wordIndex = getWordIndex(wordId);
  1785. var obj = document.getElementById("detail" + wordId);
  1786. if (obj) {
  1787. obj.innerHTML = renderWordBodyInner(xAllWord[wordIndex]);
  1788. }
  1789. }
  1790. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  1791. //返回 无
  1792. function modifyWordDetailByWordIndex(wordIndex) {
  1793. xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  1794. wordId = getNodeText(xAllWord[wordIndex], "id");
  1795. try {
  1796. var sDetail = "detail" + wordId;
  1797. var cDetail = document.getElementById(sDetail);
  1798. if (cDetail != null) {
  1799. cDetail.innerHTML = renderWordDetailByElement(xAllWord[wordIndex]);
  1800. }
  1801. } catch (error) {
  1802. debugOutput(error);
  1803. }
  1804. }
  1805. function renderWordHeadInner(element) {
  1806. var output = "";
  1807. var wid = getNodeText(element, "id");
  1808. var wpali = getNodeText(element, "pali");
  1809. var sParent = getNodeText(element, "parent");
  1810. var wId = getNodeText(element, "id");
  1811. var wNote = getNodeText(element, "note");
  1812. wStyle = "v_" + getNodeText(element, "style");
  1813. if (wStyle == "v_bld") {
  1814. if (wpali.indexOf("{") >= 0) {
  1815. wpali = wpali.replace("{", "<span class='v_bld'>");
  1816. wpali = wpali.replace("}", "</span>");
  1817. wStyle = "";
  1818. }
  1819. }
  1820. if (wNote.indexOf("{{") >= 0 && wNote.indexOf("}}") >= 0) {
  1821. wStyle += " note_ref";
  1822. }
  1823. if (wNote.substring(0, 6) == "=term(") {
  1824. wStyle += " term_word_head";
  1825. } else {
  1826. if (sParent.length > 0) {
  1827. if (term_lookup_my(sParent) != false) {
  1828. wStyle += " term_my";
  1829. } else {
  1830. if (term_lookup_all(sParent) != null) {
  1831. wStyle += " term_other";
  1832. }
  1833. }
  1834. }
  1835. }
  1836. var sign_count = 0;
  1837. var letter_count = 0;
  1838. for (i_sign in local_sign_str) {
  1839. if (wpali.lastIndexOf(local_sign_str[i_sign].id) != -1) {
  1840. sign_count += 1;
  1841. } //如果是标点或数字
  1842. else if (wpali.lastIndexOf(local_letter_str[i_sign].id) != -1) {
  1843. letter_count += 1;
  1844. } //如果有字母
  1845. }
  1846. if (sign_count != 0 && letter_count == 0) {
  1847. output += "<a name='w" + wId + "'>";
  1848. } else {
  1849. output += "<a name='w" + wId + "' onclick='on_word_click(\"" + wId + "\")'>";
  1850. }
  1851. if (wpali) output += '<span id="whead1_' + wid + '" class="whead paliword1 ' + wStyle + '">';
  1852. output += wpali;
  1853. output += "</span>";
  1854. output += "</a>";
  1855. if (wNote.length > 0) {
  1856. output += '<span id="wnote_root_' + wid + '"><wnh wid="' + wid + '">[1]</wnh></span>';
  1857. } else {
  1858. output += '<span id="wnote_root_' + wid + '"></span>';
  1859. }
  1860. var newMsg = msg_word_msg_num(wid);
  1861. if (newMsg > 0) {
  1862. output += "<span class='word_msg' onclick=\"word_msg_counter_click('" + wid + "')\">" + newMsg + "</span>";
  1863. }
  1864. output += '<span id="whead2_' + wid + '" class="whead paliword2 ' + wStyle + '">';
  1865. output += "</span>";
  1866. return output;
  1867. }
  1868. function renderWordBodyInner(element) {
  1869. return renderWordDetailByElement(element);
  1870. }
  1871. //新的渲染单词块函数
  1872. function renderWordDetailByElement_edit_a(xmlElement) {
  1873. if (xmlElement == null) {
  1874. return "";
  1875. }
  1876. var wordNode = xmlElement;
  1877. var sPali = getNodeText(wordNode, "pali");
  1878. var sId = getNodeText(wordNode, "id");
  1879. var sReal = getNodeText(wordNode, "real");
  1880. var sMean = getNodeText(wordNode, "mean");
  1881. var sOrg = getNodeText(wordNode, "org");
  1882. var sOm = getNodeText(wordNode, "om");
  1883. var sCase = getNodeText(wordNode, "case");
  1884. var sType = getNodeText(wordNode, "type");
  1885. var sGramma = getNodeText(wordNode, "gramma");
  1886. var sParent = getNodeText(wordNode, "parent");
  1887. var sParentGrammar = getNodeText(wordNode, "pg");
  1888. var sParent2 = getNodeText(wordNode, "parent2");
  1889. var sNote = getNodeText(wordNode, "note");
  1890. var sStatus = getNodeText(wordNode, "status");
  1891. if (sStatus == "") {
  1892. sStatus = 0;
  1893. }
  1894. var wordID = sId;
  1895. if (sCase == "") {
  1896. sCase = sType + "#" + sGramma;
  1897. }
  1898. var _txtOutDetail = "";
  1899. var _bgColor = "";
  1900. var status_bg_color = "status_bg_color_" + sStatus;
  1901. var _caseColor = "";
  1902. //标点符号
  1903. if (sReal.length <= 1) {
  1904. _txtOutDetail += "<div>";
  1905. /*id begin*/
  1906. _txtOutDetail += "<div class='ID'> </div>";
  1907. /*mean begin*/
  1908. _txtOutDetail += "<div class='mean'> </div>";
  1909. /*org begin*/
  1910. _txtOutDetail += "<div class='org'> </div>";
  1911. /*org mean begin*/
  1912. _txtOutDetail += "<div class='om'> </div>";
  1913. /*case begin*/
  1914. _txtOutDetail += "<div class='case'> </div>";
  1915. _txtOutDetail += "</div>";
  1916. return _txtOutDetail;
  1917. }
  1918. var strBookMarkColor = getNodeText(wordNode, "bmc");
  1919. if (strBookMarkColor.length > 2) {
  1920. var icolor = strBookMarkColor.substr(-1);
  1921. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  1922. }
  1923. // Auto Match Begin
  1924. if (sCase == "?" && _bgColor == "") {
  1925. _caseColor = " class='bookmarkcolorx' ";
  1926. }
  1927. if (g_useMode == "read" || g_useMode == "translate") {
  1928. _bgColor = "";
  1929. _caseColor = "";
  1930. if (sOrg == "?") {
  1931. sOrg = " ";
  1932. }
  1933. if (sMean == "?") {
  1934. sMean = " ";
  1935. }
  1936. if (sCase == "?" || sCase == "?#?") {
  1937. sCase = " ";
  1938. }
  1939. }
  1940. //编辑模式开始
  1941. {
  1942. /*gramma*/
  1943. /*find in dict*/
  1944. var arrGramma = new Array();
  1945. var thisWord = sReal;
  1946. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  1947. if (thisWord == g_DictWordList[iDict].Pali) {
  1948. if (
  1949. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  1950. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  1951. ) {
  1952. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  1953. pushNewToList(arrGramma, arrCase);
  1954. }
  1955. }
  1956. }
  1957. if (sCase == "?" || sCase == "?#?") {
  1958. if (arrGramma.length > 0) {
  1959. setNodeText(xmlElement, "case", arrGramma[0]);
  1960. sCase = arrGramma[0];
  1961. } else {
  1962. setNodeText(xmlElement, "case", "?#?");
  1963. sCase = "?#?";
  1964. }
  1965. } else {
  1966. if (sCase.indexOf("#") == -1) {
  1967. sCase = "?#" + sCase;
  1968. setNodeText(xmlElement, "case", "?#" + sCase);
  1969. }
  1970. }
  1971. var currType = sCase.split("#")[0];
  1972. var currGramma = sCase.split("#")[1];
  1973. //end gramma
  1974. if (getNodeText(wordNode, "lock") == "true") {
  1975. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  1976. } else {
  1977. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  1978. }
  1979. //状态颜色
  1980. _txtOutDetail += "<div class='" + status_bg_color + "'>";
  1981. //书签颜色
  1982. _txtOutDetail += "<div " + _bgColor + ">";
  1983. /*id begin*/
  1984. /*
  1985. _txtOutDetail += "<p class='ID'>";
  1986. _txtOutDetail += sId + "&nbsp;";
  1987. _txtOutDetail += "</p>";
  1988. */
  1989. /*id end*/
  1990. /*meaning*/
  1991. //格位公式开始
  1992. //去除格位公式
  1993. var currMeaning = removeFormula(sMean);
  1994. //currMeaning = getLocalFormulaStr(currGramma,currMeaning);
  1995. var orgMeaning = sMean;
  1996. //切割过长意思
  1997. if (sReal.length < 4) {
  1998. currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, 24));
  1999. } else {
  2000. currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, sReal.length * 6));
  2001. }
  2002. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2003. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2004. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2005. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2006. //格位公式结束
  2007. if (sMean.length == 0) {
  2008. renderMeaning = "<span class='word_space_holder'>meaning</span>";
  2009. }
  2010. //渲染下拉菜单
  2011. _txtOutDetail += "<div class='mean'>";
  2012. _txtOutDetail += '<div class="case_dropdown">';
  2013. _txtOutDetail += "<p class='case_dropbtn' >";
  2014. _txtOutDetail += renderMeaning;
  2015. _txtOutDetail += "</p>";
  2016. _txtOutDetail += "<div id='mean_" + wordID + '\' class="case_dropdown-content">';
  2017. _txtOutDetail += "</div>";
  2018. _txtOutDetail += "</div>";
  2019. //render formula menu
  2020. arrFormula = getFormulaList(currGramma);
  2021. _txtOutDetail += '<div class="case_dropdown">';
  2022. _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2023. _txtOutDetail += '<div class="case_dropdown-content">';
  2024. newWord = removeFormula_B(orgMeaning);
  2025. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>[None]</a>";
  2026. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[Auto]</a>";
  2027. for (var i in arrFormula) {
  2028. newWord = removeFormula_B(orgMeaning);
  2029. newWord = arrFormula[i].replace("~", newWord);
  2030. newWord = newWord.replace(/{/g, "[");
  2031. newWord = newWord.replace(/}/g, "]");
  2032. _txtOutDetail +=
  2033. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2034. }
  2035. _txtOutDetail += "</div>";
  2036. _txtOutDetail += "</div>";
  2037. _txtOutDetail += "</div> ";
  2038. /*end of meaning*/
  2039. /*org begin 拆分*/
  2040. _txtOutDetail += "<div class='org' name='w_org'>";
  2041. _txtOutDetail += '<div class="case_dropdown">';
  2042. _txtOutDetail += "<p class='case_dropbtn' >";
  2043. let currOrg;
  2044. if (sOrg.length == 0) {
  2045. currOrg = "<span class='word_space_holder'>parts</span>";
  2046. } else {
  2047. currOrg = sOrg;
  2048. }
  2049. _txtOutDetail += currOrg;
  2050. _txtOutDetail += "</p>";
  2051. _txtOutDetail += '<div class="case_dropdown-content">';
  2052. _txtOutDetail += "<div id='parts_" + sId + "'>Loading</div>";
  2053. _txtOutDetail += "</div>";
  2054. _txtOutDetail += "</div>";
  2055. _txtOutDetail += "</div> ";
  2056. /*end of factors*/
  2057. /*part meaning begin*/
  2058. _txtOutDetail += "<div class='om' name='w_om'>";
  2059. _txtOutDetail += '<div class="case_dropdown">';
  2060. _txtOutDetail += "<p class='case_dropbtn' >";
  2061. sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
  2062. if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
  2063. var currDefualtFM = "";
  2064. var listFactorForFactorMean = sOrg.split("+");
  2065. for (iFactor in listFactorForFactorMean) {
  2066. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
  2067. }
  2068. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  2069. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  2070. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  2071. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
  2072. if (currDefualtFM.slice(-1, -2) == "+") {
  2073. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  2074. }
  2075. currOM = "[a]" + currDefualtFM;
  2076. setNodeText(wordNode, "om", currOM);
  2077. } else {
  2078. currOM = sOm;
  2079. }
  2080. if (currOM.length == 0) {
  2081. currOM = "<span class='word_space_holder''>part mean</span>";
  2082. }
  2083. _txtOutDetail += currOM;
  2084. _txtOutDetail += "</p>";
  2085. _txtOutDetail += '<div class="case_dropdown-content">';
  2086. _txtOutDetail += "<div id='partmean_" + sId + "'></div>";
  2087. _txtOutDetail += "</div>";
  2088. _txtOutDetail += "</div>";
  2089. _txtOutDetail += "</div> ";
  2090. /*org meaning end*/
  2091. /*begin gramma*/
  2092. _txtOutDetail += "<div class='case'>";
  2093. _txtOutDetail += '<div class="case_dropdown">';
  2094. _txtOutDetail += "<p class='case_dropbtn' >";
  2095. var sLocalCase = getLocalGrammaStr(sCase);
  2096. var mArrGramma = sCase.split("#");
  2097. if (mArrGramma.length >= 2) {
  2098. mType = mArrGramma[0];
  2099. mGramma = mArrGramma[1];
  2100. mLocalType = sLocalCase.split("#")[0];
  2101. mLocalGramma = sLocalCase.split("#")[1];
  2102. } else {
  2103. mType = "";
  2104. mGramma = mArrGramma[0];
  2105. mLocalType = "";
  2106. mLocalGramma = sLocalCase.split("#")[0];
  2107. }
  2108. if (mType != "") {
  2109. _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
  2110. }
  2111. _txtOutDetail += cutString(mLocalGramma, 30);
  2112. if (mLocalType.length + mLocalGramma.length == 0) {
  2113. _txtOutDetail += "&nbsp;";
  2114. }
  2115. _txtOutDetail += "</p>";
  2116. _txtOutDetail += '<div class="case_dropdown-content">';
  2117. _txtOutDetail += "<div id='gramma_" + sId + "'></div>";
  2118. _txtOutDetail += "</div>";
  2119. _txtOutDetail += "</div>";
  2120. //连读词按钮
  2121. if (mType == ".un." || mType == ".comp.") {
  2122. nextElement = com_get_nextsibling(xmlElement);
  2123. if (nextElement != null) {
  2124. //下一个元素存在
  2125. if (getNodeText(nextElement, "un") == sId) {
  2126. //若有孩子則显示收起按鈕
  2127. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
  2128. _txtOutDetail +=
  2129. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
  2130. _txtOutDetail += "</button>";
  2131. var parentElement = document.getElementById("wb" + sId);
  2132. if (parentElement) {
  2133. parentElement.classList.add("un_parent");
  2134. }
  2135. } else {
  2136. //無kid展開按鈕
  2137. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2138. _txtOutDetail +=
  2139. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2140. _txtOutDetail += "</button> ";
  2141. }
  2142. } else {
  2143. //下一个元素不存在
  2144. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  2145. _txtOutDetail +=
  2146. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  2147. _txtOutDetail += "</button> ";
  2148. }
  2149. }
  2150. //连读词按钮 结束
  2151. //爷爷和父亲的关系 如pp
  2152. /*
  2153. if(wordGranfatherGramma.length>0 && wordGranfatherGramma.length<6){
  2154. _txtOutDetail += "<span class=\"tooltip\">«"+getLocalGrammaStr(wordGranfatherGramma)+"<span class=\"tooltiptext tooltip-bottom\">"+wordGranfather+"</span>"+"</span> ";
  2155. }
  2156. */
  2157. _txtOutDetail += "</div> ";
  2158. /*end of gramma*/
  2159. _txtOutDetail += "</div>";
  2160. _txtOutDetail += "</div>";
  2161. }
  2162. return _txtOutDetail;
  2163. }
  2164. function renderWordDetailByElement(xmlElement) {
  2165. return renderWordDetailByElement_edit_a(xmlElement);
  2166. if (xmlElement == null) {
  2167. return "";
  2168. }
  2169. wordNode = xmlElement;
  2170. var sPali = getNodeText(wordNode, "pali");
  2171. var sId = getNodeText(wordNode, "id");
  2172. var sReal = getNodeText(wordNode, "real");
  2173. var sMean = getNodeText(wordNode, "mean");
  2174. var sOrg = getNodeText(wordNode, "org");
  2175. var sOm = getNodeText(wordNode, "om");
  2176. var sCase = getNodeText(wordNode, "case");
  2177. var sType = getNodeText(wordNode, "type");
  2178. var sGramma = getNodeText(wordNode, "gramma");
  2179. var sParent = getNodeText(wordNode, "parent");
  2180. var sNote = getNodeText(wordNode, "note");
  2181. wordID = sId;
  2182. if (sCase == "") {
  2183. sCase = sType + "#" + sGramma;
  2184. }
  2185. var _txtOutDetail = "";
  2186. var _bgColor = "";
  2187. var _caseColor = "";
  2188. //标点符号
  2189. if (sReal.length <= 1) {
  2190. _txtOutDetail += "<div>";
  2191. /*id begin*/
  2192. _txtOutDetail += "<div class='ID'> </div>";
  2193. /*mean begin*/
  2194. _txtOutDetail += "<div class='mean'> </div>";
  2195. /*org begin*/
  2196. _txtOutDetail += "<div class='org'> </div>";
  2197. /*org mean begin*/
  2198. _txtOutDetail += "<div class='om'> </div>";
  2199. /*case begin*/
  2200. _txtOutDetail += "<div class='case'> </div>";
  2201. _txtOutDetail += "</div>";
  2202. return _txtOutDetail;
  2203. }
  2204. if (sMean == "?") {
  2205. _bgColor = " class='bookmarkcolorx' ";
  2206. }
  2207. strBookMarkColor = getNodeText(wordNode, "bmc");
  2208. if (strBookMarkColor.length > 2) {
  2209. var icolor = strBookMarkColor.substr(-1);
  2210. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  2211. }
  2212. // Auto Match Begin
  2213. if (sCase == "?" && _bgColor == "") {
  2214. _caseColor = " class='bookmarkcolorx' ";
  2215. }
  2216. if (g_useMode == "read" || g_useMode == "translate") {
  2217. _bgColor = "";
  2218. _caseColor = "";
  2219. if (sOrg == "?") {
  2220. sOrg = " ";
  2221. }
  2222. if (sMean == "?") {
  2223. sMean = " ";
  2224. }
  2225. if (sCase == "?" || sCase == "?#?") {
  2226. sCase = " ";
  2227. }
  2228. }
  2229. if (g_useMode == "read") {
  2230. _txtOutDetail += "<div " + _bgColor + ">";
  2231. /*id begin*/
  2232. _txtOutDetail += "<p class='ID'>";
  2233. _txtOutDetail += sId + "&nbsp;";
  2234. _txtOutDetail += "</p>";
  2235. /*id end*/
  2236. /*meaning begin*/
  2237. var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
  2238. showMean = showMean.replace(/}/g, "</span>");
  2239. showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2240. showMean = showMean.replace(/\]/g, "</span>");
  2241. _txtOutDetail += "<p class='mean'>";
  2242. _txtOutDetail += showMean + "&nbsp;";
  2243. _txtOutDetail += "</p>";
  2244. /*meaning end*/
  2245. /*org begin*/
  2246. _txtOutDetail += "<p class='org'>";
  2247. _txtOutDetail += sOrg + "&nbsp;";
  2248. _txtOutDetail += "</p>";
  2249. /*org end*/
  2250. /*org meaning begin*/
  2251. _txtOutDetail += "<p class='om'>";
  2252. _txtOutDetail += sOm + "&nbsp;";
  2253. _txtOutDetail += "</p>";
  2254. /*org meaning end*/
  2255. /*grmma begin*/
  2256. _txtOutDetail += "<p class='case'>";
  2257. sCase = getLocalGrammaStr(sCase);
  2258. var mGramma = sCase.split("#");
  2259. if (mGramma.length >= 2) {
  2260. mType = sCase.split("#")[0];
  2261. mGramma = sCase.split("#")[1];
  2262. } else {
  2263. mType = "";
  2264. mGramma = sCase.split("#")[0];
  2265. }
  2266. //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
  2267. if (mType != "") {
  2268. _txtOutDetail += "<span class='type'>" + mType + "</span>";
  2269. }
  2270. _txtOutDetail += mGramma;
  2271. _txtOutDetail = _txtOutDetail + "&nbsp;" + "</p>";
  2272. /*grmma end*/
  2273. _txtOutDetail += "</div>";
  2274. }
  2275. //编辑模式开始
  2276. if (g_useMode == "edit") {
  2277. if (getNodeText(wordNode, "lock") == "true") {
  2278. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  2279. } else {
  2280. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  2281. }
  2282. _txtOutDetail += "<div " + _bgColor + ">";
  2283. /*id begin*/
  2284. _txtOutDetail += "<p class='ID'>";
  2285. _txtOutDetail += sId + "&nbsp;";
  2286. _txtOutDetail += "</p>";
  2287. /*id end*/
  2288. /*gramma*/
  2289. /*find in dict*/
  2290. var arrGramma = new Array();
  2291. var thisWord = getNodeText(wordNode, "real");
  2292. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2293. if (thisWord == g_DictWordList[iDict].Pali) {
  2294. if (
  2295. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  2296. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  2297. ) {
  2298. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2299. pushNewToList(arrGramma, arrCase);
  2300. }
  2301. }
  2302. }
  2303. if (sCase == "?" || sCase == "?#?") {
  2304. if (arrGramma.length > 0) {
  2305. setNodeText(xmlElement, "case", arrGramma[0]);
  2306. sCase = arrGramma[0];
  2307. } else {
  2308. setNodeText(xmlElement, "case", "?#?");
  2309. sCase = "?#?";
  2310. }
  2311. } else {
  2312. if (sCase.indexOf("#") == -1) {
  2313. sCase = "?#" + sCase;
  2314. setNodeText(xmlElement, "case", "?#" + sCase);
  2315. }
  2316. }
  2317. var currType = sCase.split("#")[0];
  2318. var currGramma = sCase.split("#")[1];
  2319. //end gramma
  2320. /*meaning*/
  2321. /*find in dict*/
  2322. var arrMeaning = new Array();
  2323. var currMeaning = "";
  2324. var currGrammaMeaning = "";
  2325. var wordParent = "";
  2326. var wordGramma0 = "";
  2327. //self meaning
  2328. var thisWord = getNodeText(wordNode, "real");
  2329. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2330. if (
  2331. thisWord == g_DictWordList[iDict].Pali &&
  2332. g_DictWordList[iDict].Type != ".root." &&
  2333. g_DictWordList[iDict].Type != ".suf." &&
  2334. g_DictWordList[iDict].Type != ".prf."
  2335. ) {
  2336. if (
  2337. wordParent == "" &&
  2338. g_DictWordList[iDict].Parent.length > 0 &&
  2339. g_DictWordList[iDict].Parent != thisWord
  2340. ) {
  2341. wordParent = g_DictWordList[iDict].Parent;
  2342. wordGramma0 = g_DictWordList[iDict].Gramma;
  2343. }
  2344. var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2345. if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
  2346. if (currGrammaMeaning == "") {
  2347. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2348. currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
  2349. }
  2350. }
  2351. }
  2352. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2353. for (var i = 0; i < arrMean.length; i++) {
  2354. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2355. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
  2356. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2357. arrMeaning.push(
  2358. g_DictWordList[iDict].dictID +
  2359. "$" +
  2360. arrMeaning.length +
  2361. "$$" +
  2362. arrMean[i] +
  2363. "$" +
  2364. g_DictWordList[iDict].Language
  2365. );
  2366. }
  2367. }
  2368. }
  2369. }
  2370. }
  2371. var wordGramma1 = "";
  2372. //find in father
  2373. if (wordParent != "") {
  2374. //add parent infomation
  2375. if (sParent == "" || sParent == " ") {
  2376. setNodeText(wordNode, "parent", wordParent);
  2377. sParent = wordParent;
  2378. }
  2379. thisWord = wordParent;
  2380. wordParent = "";
  2381. wordGramma1 = "";
  2382. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2383. if (
  2384. thisWord == g_DictWordList[iDict].Pali &&
  2385. g_DictWordList[iDict].Type != ".v." &&
  2386. g_DictWordList[iDict].Type != ".n." &&
  2387. g_DictWordList[iDict].Type != ".ti." &&
  2388. g_DictWordList[iDict].Type != ".adj." &&
  2389. g_DictWordList[iDict].Type != ".pron." &&
  2390. g_DictWordList[iDict].Type != ".num."
  2391. ) {
  2392. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2393. if (wordParent == "") {
  2394. wordParent = g_DictWordList[iDict].Parent;
  2395. }
  2396. if (wordGramma1 == "") {
  2397. wordGramma1 = g_DictWordList[iDict].Gramma;
  2398. }
  2399. }
  2400. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2401. for (var i = 0; i < arrMean.length; i++) {
  2402. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2403. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
  2404. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2405. arrMeaning.push(
  2406. g_DictWordList[iDict].dictID +
  2407. "$" +
  2408. arrMeaning.length +
  2409. "$*$" +
  2410. getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
  2411. "$" +
  2412. g_DictWordList[iDict].Language
  2413. );
  2414. }
  2415. }
  2416. }
  2417. }
  2418. }
  2419. }
  2420. //爷爷跟父亲的关系 比如 pp
  2421. wordGranfatherGramma = wordGramma1;
  2422. wordGranfather = wordParent;
  2423. //grandfather
  2424. var wordGramma2 = "";
  2425. if (wordParent != "") {
  2426. thisWord = wordParent;
  2427. wordParent = "";
  2428. wordGramma2 = "";
  2429. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2430. if (
  2431. thisWord == g_DictWordList[iDict].Pali &&
  2432. g_DictWordList[iDict].Type != ".v." &&
  2433. g_DictWordList[iDict].Type != ".n." &&
  2434. g_DictWordList[iDict].Type != ".ti." &&
  2435. g_DictWordList[iDict].Type != ".adj." &&
  2436. g_DictWordList[iDict].Type != ".pron." &&
  2437. g_DictWordList[iDict].Type != ".num."
  2438. ) {
  2439. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2440. if (wordParent == "") {
  2441. wordParent = g_DictWordList[iDict].Parent;
  2442. }
  2443. if (wordGramma2 == "") {
  2444. wordGramma2 = g_DictWordList[iDict].Gramma;
  2445. }
  2446. }
  2447. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2448. for (var i = 0; i < arrMean.length; i++) {
  2449. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2450. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
  2451. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2452. arrMeaning.push(
  2453. g_DictWordList[iDict].dictID +
  2454. "$" +
  2455. arrMeaning.length +
  2456. "$**$" +
  2457. getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
  2458. "$" +
  2459. g_DictWordList[iDict].Language
  2460. );
  2461. }
  2462. }
  2463. }
  2464. }
  2465. }
  2466. }
  2467. arrMeaning.sort(sortMeanByDictOrder);
  2468. //arrMeaning.sort(sortMeanByLanguageOrder);
  2469. newMeanList = removeSameWordInArray(arrMeaning);
  2470. sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
  2471. if (sMean == "?") {
  2472. //自动匹配一个意思
  2473. //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
  2474. if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
  2475. currMeaning = currGrammaMeaning;
  2476. } else {
  2477. if (newMeanList.length > 0) {
  2478. currMeaning = newMeanList[0].word;
  2479. } else {
  2480. currMeaning = sMean;
  2481. }
  2482. }
  2483. } else {
  2484. currMeaning = removeFormula(sMean);
  2485. currMeaning = getLocalFormulaStr(currGramma, currMeaning);
  2486. }
  2487. orgMeaning = removeFormula(currMeaning);
  2488. if (sReal.length < 4) {
  2489. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
  2490. } else {
  2491. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
  2492. }
  2493. setNodeText(wordNode, "mean", currMeaning);
  2494. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2495. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2496. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2497. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2498. //渲染下拉菜单
  2499. _txtOutDetail += "<div class='mean'>";
  2500. _txtOutDetail += render_word_mean_menu(wordNode);
  2501. //render formula menu
  2502. arrFormula = getFormulaList(currGramma);
  2503. _txtOutDetail += '<div class="case_dropdown">';
  2504. _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2505. _txtOutDetail += '<div class="case_dropdown-content">';
  2506. newWord = removeFormula_B(orgMeaning);
  2507. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>[None]</a>";
  2508. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[Auto]</a>";
  2509. for (var i in arrFormula) {
  2510. newWord = removeFormula_B(orgMeaning);
  2511. newWord = arrFormula[i].replace("~", newWord);
  2512. newWord = newWord.replace(/{/g, "[");
  2513. newWord = newWord.replace(/}/g, "]");
  2514. _txtOutDetail +=
  2515. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2516. }
  2517. _txtOutDetail += "</div>";
  2518. _txtOutDetail += "</div>";
  2519. _txtOutDetail += "</div> ";
  2520. /*end of meaning*/
  2521. /*org begin 拆分*/
  2522. /*
  2523. =======
  2524. return renderWordDetailByElement_edit_a(xmlElement);
  2525. if (xmlElement == null) {
  2526. return "";
  2527. }
  2528. wordNode = xmlElement;
  2529. var sPali = getNodeText(wordNode, "pali");
  2530. var sId = getNodeText(wordNode, "id");
  2531. var sReal = getNodeText(wordNode, "real");
  2532. var sMean = getNodeText(wordNode, "mean");
  2533. var sOrg = getNodeText(wordNode, "org");
  2534. var sOm = getNodeText(wordNode, "om");
  2535. var sCase = getNodeText(wordNode, "case");
  2536. var sType = getNodeText(wordNode, "type");
  2537. var sGramma = getNodeText(wordNode, "gramma");
  2538. var sParent = getNodeText(wordNode, "parent");
  2539. var sNote = getNodeText(wordNode, "note");
  2540. wordID = sId;
  2541. if (sCase == "") {
  2542. sCase = sType + "#" + sGramma;
  2543. }
  2544. var _txtOutDetail = "";
  2545. var _bgColor = "";
  2546. var _caseColor = "";
  2547. //标点符号
  2548. if (sReal.length <= 1) {
  2549. _txtOutDetail += "<div>";
  2550. /*id begin*/
  2551. _txtOutDetail += "<div class='ID'> </div>";
  2552. /*mean begin*/
  2553. _txtOutDetail += "<div class='mean'> </div>";
  2554. /*org begin*/
  2555. _txtOutDetail += "<div class='org'> </div>";
  2556. /*org mean begin*/
  2557. _txtOutDetail += "<div class='om'> </div>";
  2558. /*case begin*/
  2559. _txtOutDetail += "<div class='case'> </div>";
  2560. _txtOutDetail += "</div>";
  2561. return _txtOutDetail;
  2562. }
  2563. if (sMean == "?") {
  2564. _bgColor = " class='bookmarkcolorx' ";
  2565. }
  2566. strBookMarkColor = getNodeText(wordNode, "bmc");
  2567. if (strBookMarkColor.length > 2) {
  2568. var icolor = strBookMarkColor.substr(-1);
  2569. _bgColor = " class='bookmarkcolor" + icolor + "' ";
  2570. }
  2571. // Auto Match Begin
  2572. if (sCase == "?" && _bgColor == "") {
  2573. _caseColor = " class='bookmarkcolorx' ";
  2574. }
  2575. if (g_useMode == "read" || g_useMode == "translate") {
  2576. _bgColor = "";
  2577. _caseColor = "";
  2578. if (sOrg == "?") {
  2579. sOrg = " ";
  2580. }
  2581. if (sMean == "?") {
  2582. sMean = " ";
  2583. }
  2584. if (sCase == "?" || sCase == "?#?") {
  2585. sCase = " ";
  2586. }
  2587. }
  2588. if (g_useMode == "read") {
  2589. _txtOutDetail += "<div " + _bgColor + ">";
  2590. /*id begin*/
  2591. _txtOutDetail += "<p class='ID'>";
  2592. _txtOutDetail += sId + "&nbsp;";
  2593. _txtOutDetail += "</p>";
  2594. /*id end*/
  2595. /*meaning begin*/
  2596. var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
  2597. showMean = showMean.replace(/}/g, "</span>");
  2598. showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2599. showMean = showMean.replace(/\]/g, "</span>");
  2600. _txtOutDetail += "<p class='mean'>";
  2601. _txtOutDetail += showMean + "&nbsp;";
  2602. _txtOutDetail += "</p>";
  2603. /*meaning end*/
  2604. /*org begin*/
  2605. _txtOutDetail += "<p class='org'>";
  2606. _txtOutDetail += sOrg + "&nbsp;";
  2607. _txtOutDetail += "</p>";
  2608. /*org end*/
  2609. /*org meaning begin*/
  2610. _txtOutDetail += "<p class='om'>";
  2611. _txtOutDetail += sOm + "&nbsp;";
  2612. _txtOutDetail += "</p>";
  2613. /*org meaning end*/
  2614. /*grmma begin*/
  2615. _txtOutDetail += "<p class='case'>";
  2616. sCase = getLocalGrammaStr(sCase);
  2617. var mGramma = sCase.split("#");
  2618. if (mGramma.length >= 2) {
  2619. mType = sCase.split("#")[0];
  2620. mGramma = sCase.split("#")[1];
  2621. } else {
  2622. mType = "";
  2623. mGramma = sCase.split("#")[0];
  2624. }
  2625. //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
  2626. if (mType != "") {
  2627. _txtOutDetail += "<span class='type'>" + mType + "</span>";
  2628. }
  2629. _txtOutDetail += mGramma;
  2630. _txtOutDetail = _txtOutDetail + "&nbsp;" + "</p>";
  2631. /*grmma end*/
  2632. _txtOutDetail += "</div>";
  2633. }
  2634. //编辑模式开始
  2635. if (g_useMode == "edit") {
  2636. if (getNodeText(wordNode, "lock") == "true") {
  2637. _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
  2638. } else {
  2639. _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
  2640. }
  2641. _txtOutDetail += "<div " + _bgColor + ">";
  2642. /*id begin*/
  2643. _txtOutDetail += "<p class='ID'>";
  2644. _txtOutDetail += sId + "&nbsp;";
  2645. _txtOutDetail += "</p>";
  2646. /*id end*/
  2647. /*gramma*/
  2648. /*find in dict*/
  2649. var arrGramma = new Array();
  2650. var thisWord = getNodeText(wordNode, "real");
  2651. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2652. if (thisWord == g_DictWordList[iDict].Pali) {
  2653. if (
  2654. (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
  2655. (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
  2656. ) {
  2657. var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2658. pushNewToList(arrGramma, arrCase);
  2659. }
  2660. }
  2661. }
  2662. if (sCase == "?" || sCase == "?#?") {
  2663. if (arrGramma.length > 0) {
  2664. setNodeText(xmlElement, "case", arrGramma[0]);
  2665. sCase = arrGramma[0];
  2666. } else {
  2667. setNodeText(xmlElement, "case", "?#?");
  2668. sCase = "?#?";
  2669. }
  2670. } else {
  2671. if (sCase.indexOf("#") == -1) {
  2672. sCase = "?#" + sCase;
  2673. setNodeText(xmlElement, "case", "?#" + sCase);
  2674. }
  2675. }
  2676. var currType = sCase.split("#")[0];
  2677. var currGramma = sCase.split("#")[1];
  2678. //end gramma
  2679. /*meaning*/
  2680. /*find in dict*/
  2681. var arrMeaning = new Array();
  2682. var currMeaning = "";
  2683. var currGrammaMeaning = "";
  2684. var wordParent = "";
  2685. var wordGramma0 = "";
  2686. //self meaning
  2687. var thisWord = getNodeText(wordNode, "real");
  2688. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2689. if (
  2690. thisWord == g_DictWordList[iDict].Pali &&
  2691. g_DictWordList[iDict].Type != ".root." &&
  2692. g_DictWordList[iDict].Type != ".suf." &&
  2693. g_DictWordList[iDict].Type != ".prf."
  2694. ) {
  2695. if (
  2696. wordParent == "" &&
  2697. g_DictWordList[iDict].Parent.length > 0 &&
  2698. g_DictWordList[iDict].Parent != thisWord
  2699. ) {
  2700. wordParent = g_DictWordList[iDict].Parent;
  2701. wordGramma0 = g_DictWordList[iDict].Gramma;
  2702. }
  2703. var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
  2704. if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
  2705. if (currGrammaMeaning == "") {
  2706. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2707. currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
  2708. }
  2709. }
  2710. }
  2711. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2712. for (var i = 0; i < arrMean.length; i++) {
  2713. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2714. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
  2715. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2716. arrMeaning.push(
  2717. g_DictWordList[iDict].dictID +
  2718. "$" +
  2719. arrMeaning.length +
  2720. "$$" +
  2721. arrMean[i] +
  2722. "$" +
  2723. g_DictWordList[iDict].Language
  2724. );
  2725. }
  2726. }
  2727. }
  2728. }
  2729. }
  2730. var wordGramma1 = "";
  2731. //find in father
  2732. if (wordParent != "") {
  2733. //add parent infomation
  2734. if (sParent == "" || sParent == " ") {
  2735. setNodeText(wordNode, "parent", wordParent);
  2736. sParent = wordParent;
  2737. }
  2738. thisWord = wordParent;
  2739. wordParent = "";
  2740. wordGramma1 = "";
  2741. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2742. if (
  2743. thisWord == g_DictWordList[iDict].Pali &&
  2744. g_DictWordList[iDict].Type != ".v." &&
  2745. g_DictWordList[iDict].Type != ".n." &&
  2746. g_DictWordList[iDict].Type != ".ti." &&
  2747. g_DictWordList[iDict].Type != ".adj." &&
  2748. g_DictWordList[iDict].Type != ".pron." &&
  2749. g_DictWordList[iDict].Type != ".num."
  2750. ) {
  2751. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2752. if (wordParent == "") {
  2753. wordParent = g_DictWordList[iDict].Parent;
  2754. }
  2755. if (wordGramma1 == "") {
  2756. wordGramma1 = g_DictWordList[iDict].Gramma;
  2757. }
  2758. }
  2759. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2760. for (var i = 0; i < arrMean.length; i++) {
  2761. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2762. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
  2763. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2764. arrMeaning.push(
  2765. g_DictWordList[iDict].dictID +
  2766. "$" +
  2767. arrMeaning.length +
  2768. "$*$" +
  2769. getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
  2770. "$" +
  2771. g_DictWordList[iDict].Language
  2772. );
  2773. }
  2774. }
  2775. }
  2776. }
  2777. }
  2778. }
  2779. //爷爷跟父亲的关系 比如 pp
  2780. wordGranfatherGramma = wordGramma1;
  2781. wordGranfather = wordParent;
  2782. //grandfather
  2783. var wordGramma2 = "";
  2784. if (wordParent != "") {
  2785. thisWord = wordParent;
  2786. wordParent = "";
  2787. wordGramma2 = "";
  2788. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2789. if (
  2790. thisWord == g_DictWordList[iDict].Pali &&
  2791. g_DictWordList[iDict].Type != ".v." &&
  2792. g_DictWordList[iDict].Type != ".n." &&
  2793. g_DictWordList[iDict].Type != ".ti." &&
  2794. g_DictWordList[iDict].Type != ".adj." &&
  2795. g_DictWordList[iDict].Type != ".pron." &&
  2796. g_DictWordList[iDict].Type != ".num."
  2797. ) {
  2798. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2799. if (wordParent == "") {
  2800. wordParent = g_DictWordList[iDict].Parent;
  2801. }
  2802. if (wordGramma2 == "") {
  2803. wordGramma2 = g_DictWordList[iDict].Gramma;
  2804. }
  2805. }
  2806. var arrMean = g_DictWordList[iDict].Mean.split("$");
  2807. for (var i = 0; i < arrMean.length; i++) {
  2808. if (arrMean[i].length > 0 && arrMean[i] != "?") {
  2809. //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
  2810. if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
  2811. arrMeaning.push(
  2812. g_DictWordList[iDict].dictID +
  2813. "$" +
  2814. arrMeaning.length +
  2815. "$**$" +
  2816. getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
  2817. "$" +
  2818. g_DictWordList[iDict].Language
  2819. );
  2820. }
  2821. }
  2822. }
  2823. }
  2824. }
  2825. }
  2826. arrMeaning.sort(sortMeanByDictOrder);
  2827. //arrMeaning.sort(sortMeanByLanguageOrder);
  2828. newMeanList = removeSameWordInArray(arrMeaning);
  2829. sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
  2830. if (sMean == "?") {
  2831. //自动匹配一个意思
  2832. //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
  2833. if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
  2834. currMeaning = currGrammaMeaning;
  2835. } else {
  2836. if (newMeanList.length > 0) {
  2837. currMeaning = newMeanList[0].word;
  2838. } else {
  2839. currMeaning = sMean;
  2840. }
  2841. }
  2842. } else {
  2843. currMeaning = removeFormula(sMean);
  2844. currMeaning = getLocalFormulaStr(currGramma, currMeaning);
  2845. }
  2846. orgMeaning = removeFormula(currMeaning);
  2847. if (sReal.length < 4) {
  2848. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
  2849. } else {
  2850. currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
  2851. }
  2852. setNodeText(wordNode, "mean", currMeaning);
  2853. renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
  2854. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  2855. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  2856. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  2857. //渲染下拉菜单
  2858. _txtOutDetail += "<div class='mean'>";
  2859. _txtOutDetail += render_word_mean_menu(wordNode);
  2860. //render formula menu
  2861. arrFormula = getFormulaList(currGramma);
  2862. _txtOutDetail += '<div class="case_dropdown">';
  2863. _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
  2864. _txtOutDetail += '<div class="case_dropdown-content">';
  2865. newWord = removeFormula_B(orgMeaning);
  2866. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>[None]</a>";
  2867. _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>[Auto]</a>";
  2868. for (var i in arrFormula) {
  2869. newWord = removeFormula_B(orgMeaning);
  2870. newWord = arrFormula[i].replace("~", newWord);
  2871. newWord = newWord.replace(/{/g, "[");
  2872. newWord = newWord.replace(/}/g, "]");
  2873. _txtOutDetail +=
  2874. "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
  2875. }
  2876. _txtOutDetail += "</div>";
  2877. _txtOutDetail += "</div>";
  2878. _txtOutDetail += "</div> ";
  2879. /*end of meaning*/
  2880. /*org begin 拆分*/
  2881. /*
  2882. >>>>>>> bc16896ae743d21de32c24d5ffe63b6be00a315c
  2883. _txtOutDetail += "<p class='org' name='w_org'>";
  2884. _txtOutDetail += sOrg + "&nbsp;";
  2885. _txtOutDetail += "</p> ";
  2886. */
  2887. /*find in dict*/
  2888. var currOrg = "";
  2889. var wordParent = "";
  2890. var arrOrg = new Array();
  2891. var thisWord = getNodeText(wordNode, "real");
  2892. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2893. if (thisWord == g_DictWordList[iDict].Pali) {
  2894. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2895. wordParent = g_DictWordList[iDict].Parent;
  2896. }
  2897. var currOrg = g_DictWordList[iDict].Factors;
  2898. if (currOrg.length > 0 && currOrg != "?") {
  2899. pushNewToList(arrOrg, currOrg);
  2900. //arrOrg.push(currOrg);
  2901. }
  2902. }
  2903. }
  2904. //father
  2905. if (wordParent != "") {
  2906. thisWord = wordParent;
  2907. wordParent = "";
  2908. wordGramma1 = "";
  2909. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2910. if (thisWord == g_DictWordList[iDict].Pali) {
  2911. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2912. if (wordParent == "") {
  2913. wordParent = g_DictWordList[iDict].Parent;
  2914. }
  2915. }
  2916. var currOrg = g_DictWordList[iDict].Factors;
  2917. if (currOrg.length > 0 && currOrg != "?") {
  2918. pushNewToList(arrOrg, currOrg);
  2919. //arrOrg.push(currOrg);
  2920. }
  2921. }
  2922. }
  2923. }
  2924. //grandfather
  2925. if (wordParent != "") {
  2926. thisWord = wordParent;
  2927. wordParent = "";
  2928. wordGramma2 = "";
  2929. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  2930. if (thisWord == g_DictWordList[iDict].Pali) {
  2931. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  2932. if (wordParent == "") {
  2933. wordParent = g_DictWordList[iDict].Parent;
  2934. }
  2935. }
  2936. var currOrg = g_DictWordList[iDict].Factors;
  2937. if (currOrg.length > 0 && currOrg != "?") {
  2938. pushNewToList(arrOrg, currOrg);
  2939. //arrOrg.push(currOrg);
  2940. }
  2941. }
  2942. }
  2943. }
  2944. _txtOutDetail += "<div class='org' name='w_org'>";
  2945. _txtOutDetail += '<div class="case_dropdown">';
  2946. _txtOutDetail += "<p class='case_dropbtn' >";
  2947. if (sOrg == "?") {
  2948. if (arrOrg.length > 0) {
  2949. currOrg = arrOrg[0];
  2950. } else {
  2951. currOrg = sOrg;
  2952. }
  2953. setNodeText(wordNode, "org", currOrg);
  2954. } else {
  2955. currOrg = sOrg;
  2956. }
  2957. _txtOutDetail += currOrg;
  2958. if (arrOrg.length > 0) {
  2959. _txtOutDetail += "<svg class='edit_icon'>";
  2960. _txtOutDetail += "<use xlink:href='svg/icon.svg#ic_down'></use>";
  2961. _txtOutDetail += "</svg>";
  2962. }
  2963. _txtOutDetail += "</p>";
  2964. _txtOutDetail += '<div class="case_dropdown-content">';
  2965. _txtOutDetail +=
  2966. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  2967. wordID +
  2968. '","org","")\'>' +
  2969. gLocal.gui.empty1 +
  2970. "</button>";
  2971. _txtOutDetail +=
  2972. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='show_word_map(\"" +
  2973. wordID +
  2974. "\")'>" +
  2975. gLocal.gui.wordmap +
  2976. "</button>";
  2977. //新加 base 信息 vn
  2978. _txtOutDetail += '<div class="case_dropdown-org">';
  2979. _txtOutDetail += '<div class="case_dropdown-first">';
  2980. _txtOutDetail += "<a style='z-index:250; position:absolute; margin-right:2em;'>";
  2981. _txtOutDetail += sParent + "</a>";
  2982. _txtOutDetail += "<span style='z-index:220' class='case_dropdown-title'>";
  2983. _txtOutDetail += gLocal.gui.more + "»</span>";
  2984. _txtOutDetail += "</div>";
  2985. for (i in arrOrg) {
  2986. _txtOutDetail +=
  2987. "<a onclick='fieldListChanged(\"" + wordID + '","org","' + arrOrg[i] + "\")'>" + arrOrg[i] + "</a>";
  2988. }
  2989. _txtOutDetail += "</div>";
  2990. _txtOutDetail += "</div>";
  2991. _txtOutDetail += "</div>";
  2992. _txtOutDetail += "</div> ";
  2993. /*end of factors*/
  2994. /*part meaning begin*/
  2995. listFactorForFactorMean = currOrg.split("+");
  2996. currDefualtFM = "";
  2997. for (iFactor in listFactorForFactorMean) {
  2998. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
  2999. }
  3000. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  3001. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  3002. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  3003. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
  3004. if (currDefualtFM.slice(-1, -2) == "+") {
  3005. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  3006. }
  3007. /*find in dict*/
  3008. var currOM = "";
  3009. var wordParent = "";
  3010. var arrOM = new Array();
  3011. var thisWord = getNodeText(wordNode, "real");
  3012. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  3013. if (thisWord == g_DictWordList[iDict].Pali) {
  3014. if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
  3015. wordParent = g_DictWordList[iDict].Parent;
  3016. }
  3017. var currOM = g_DictWordList[iDict].FactorMean;
  3018. if (currOM.length > 0 && currOM != "?") {
  3019. pushNewToList(arrOM, currOM);
  3020. //arrOM.push(currOM);
  3021. }
  3022. }
  3023. }
  3024. /*
  3025. //father
  3026. if(wordParent!=""){
  3027. thisWord=wordParent;
  3028. wordParent="";
  3029. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  3030. if(thisWord==g_DictWordList[iDict].Pali){
  3031. if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
  3032. if(wordParent==""){
  3033. wordParent=g_DictWordList[iDict].Parent;
  3034. }
  3035. }
  3036. var currOM=g_DictWordList[iDict].FactorMean;
  3037. if(currOM.length>0 && currOM!="?"){
  3038. pushNewToList(arrOM,currOM);
  3039. }
  3040. }
  3041. }
  3042. }
  3043. //grandfather
  3044. if(wordParent!=""){
  3045. thisWord=wordParent;
  3046. wordParent="";
  3047. wordGramma2="";
  3048. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  3049. if(thisWord==g_DictWordList[iDict].Pali){
  3050. if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
  3051. if(wordParent==""){
  3052. wordParent=g_DictWordList[iDict].Parent;
  3053. }
  3054. }
  3055. var currOM=g_DictWordList[iDict].FactorMean;
  3056. if(currOM.length>0 && currOM!="?"){
  3057. pushNewToList(arrOM,currOM);
  3058. }
  3059. }
  3060. }
  3061. }
  3062. */
  3063. _txtOutDetail += "<div class='om' name='w_om'>";
  3064. _txtOutDetail += '<div class="case_dropdown">';
  3065. _txtOutDetail += "<p class='case_dropbtn' >";
  3066. sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
  3067. if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
  3068. if (arrOM.length > 0) {
  3069. currOM = arrOM[0];
  3070. } else {
  3071. currOM = "[a]" + currDefualtFM;
  3072. }
  3073. setNodeText(wordNode, "om", currOM);
  3074. } else {
  3075. currOM = sOm;
  3076. }
  3077. _txtOutDetail += currOM;
  3078. if (arrOM.length > 0) {
  3079. _txtOutDetail += " ▾";
  3080. }
  3081. _txtOutDetail += "</p>";
  3082. _txtOutDetail += '<div class="case_dropdown-content">';
  3083. _txtOutDetail +=
  3084. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  3085. wordID +
  3086. '","om","")\'>' +
  3087. gLocal.gui.empty1 +
  3088. "</button>";
  3089. _txtOutDetail +=
  3090. "<a onclick='fieldListChanged(\"" +
  3091. wordID +
  3092. '","om","[a]' +
  3093. currDefualtFM +
  3094. "\")'>[" +
  3095. gLocal.gui.auto +
  3096. "]" +
  3097. currDefualtFM +
  3098. "</a>";
  3099. for (i in arrOM) {
  3100. _txtOutDetail +=
  3101. "<a onclick='fieldListChanged(\"" + wordID + '","om","' + arrOM[i] + "\")'>" + arrOM[i] + "</a>";
  3102. }
  3103. _txtOutDetail += "</div>";
  3104. _txtOutDetail += "</div>";
  3105. _txtOutDetail += "</div> ";
  3106. /*org meaning end*/
  3107. /*begin gramma*/
  3108. _txtOutDetail += "<div class='case'>";
  3109. _txtOutDetail += '<div class="case_dropdown">';
  3110. _txtOutDetail += "<p class='case_dropbtn' >";
  3111. sLocalCase = getLocalGrammaStr(sCase);
  3112. var mArrGramma = sCase.split("#");
  3113. if (mArrGramma.length >= 2) {
  3114. mType = mArrGramma[0];
  3115. mGramma = mArrGramma[1];
  3116. mLocalType = sLocalCase.split("#")[0];
  3117. mLocalGramma = sLocalCase.split("#")[1];
  3118. } else {
  3119. mType = "";
  3120. mGramma = mArrGramma[0];
  3121. mLocalType = "";
  3122. mLocalGramma = sLocalCase.split("#")[0];
  3123. }
  3124. if (mType != "") {
  3125. _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
  3126. }
  3127. _txtOutDetail += cutString(mLocalGramma, 30);
  3128. _txtOutDetail += "</p>";
  3129. _txtOutDetail += '<div class="case_dropdown-content">';
  3130. for (i in arrGramma) {
  3131. _txtOutDetail +=
  3132. "<a onclick='fieldListChanged(\"" +
  3133. wordID +
  3134. '","case","' +
  3135. arrGramma[i] +
  3136. "\")'>" +
  3137. cutString(getLocalGrammaStr(arrGramma[i]), 30) +
  3138. "</a>";
  3139. }
  3140. _txtOutDetail += "</div>";
  3141. _txtOutDetail += "</div>";
  3142. //连读词按钮
  3143. if (mType == ".un." || mType == ".comp.") {
  3144. nextElement = com_get_nextsibling(xmlElement);
  3145. if (nextElement != null) {
  3146. //下一个元素存在
  3147. if (getNodeText(nextElement, "un") == sId) {
  3148. //若有孩子則显示收起按鈕
  3149. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
  3150. _txtOutDetail +=
  3151. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
  3152. _txtOutDetail += "</button>";
  3153. var parentElement = document.getElementById("wb" + sId);
  3154. if (parentElement) {
  3155. parentElement.classList.add("un_parent");
  3156. }
  3157. } else {
  3158. //無kid展開按鈕
  3159. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  3160. _txtOutDetail +=
  3161. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  3162. _txtOutDetail += "</button> ";
  3163. }
  3164. } else {
  3165. //下一个元素不存在
  3166. _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
  3167. _txtOutDetail +=
  3168. '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
  3169. _txtOutDetail += "</button> ";
  3170. }
  3171. }
  3172. //连读词按钮 结束
  3173. //爷爷和父亲的关系 如pp
  3174. if (wordGranfatherGramma.length > 0 && wordGranfatherGramma.length < 6) {
  3175. _txtOutDetail +=
  3176. '<span class="tooltip">«' +
  3177. getLocalGrammaStr(wordGranfatherGramma) +
  3178. '<span class="tooltiptext tooltip-bottom">' +
  3179. wordGranfather +
  3180. "</span>" +
  3181. "</span> ";
  3182. }
  3183. _txtOutDetail += "</div> ";
  3184. /*end of gramma*/
  3185. //Auto Match Finished
  3186. _txtOutDetail += "</div>";
  3187. }
  3188. return _txtOutDetail;
  3189. }
  3190. function renderWordNoteDivByParaNo(book, paragraph) {}
  3191. /*
  3192. paragraph word note
  3193. */
  3194. function renderWordNoteDivByElement(elementBlock) {
  3195. let output = "";
  3196. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3197. let book = getNodeText(xmlParInfo, "book");
  3198. let paragraph = getNodeText(xmlParInfo, "paragraph");
  3199. let bId = getNodeText(xmlParInfo, "id");
  3200. let type = getNodeText(xmlParInfo, "type");
  3201. let allWord = elementBlock.getElementsByTagName("word");
  3202. let iNoteCounter = 0;
  3203. for (iWord = 0; iWord < allWord.length; iWord++) {
  3204. let oneNote = "";
  3205. let pali = getNodeText(allWord[iWord], "pali");
  3206. let sNote = getNodeText(allWord[iWord], "note");
  3207. if (sNote != "") {
  3208. oneNote += note_init(sNote);
  3209. }
  3210. let sRela = getNodeText(allWord[iWord], "rela");
  3211. if (sRela != "") {
  3212. oneNote += "<div>" + renderWordRelation(allWord[iWord]) + "</div>";
  3213. }
  3214. id = getNodeText(allWord[iWord], "id");
  3215. if (oneNote == "") {
  3216. //有内容
  3217. $("#wnote_root_" + id).html("");
  3218. } else {
  3219. $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
  3220. output += "<div>";
  3221. output += "<wnc wid='" + id + "'></wnc>";
  3222. output += "<strong>" + pali + ":</strong>";
  3223. output += oneNote;
  3224. output += "</div>";
  3225. }
  3226. }
  3227. return output;
  3228. }
  3229. function refreshWordNoteDiv(elementBlock) {
  3230. let html = renderWordNoteDivByElement(elementBlock);
  3231. let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3232. let book = getNodeText(xmlParInfo, "book");
  3233. let paragraph = parseInt(getNodeText(xmlParInfo, "paragraph"));
  3234. let noteid = "wnote_" + book + "_" + (paragraph - 1);
  3235. try {
  3236. if (html == "") {
  3237. $("#" + noteid).hide();
  3238. } else {
  3239. $("#" + noteid).html(html);
  3240. $("#" + noteid).show();
  3241. }
  3242. } catch (e) {
  3243. console.error(e.message + noteid);
  3244. }
  3245. }
  3246. function refreshWordNote(elementBlock) {
  3247. var output = "";
  3248. xmlParInfo = elementBlock.getElementsByTagName("info")[0];
  3249. book = getNodeText(xmlParInfo, "book");
  3250. paragraph = getNodeText(xmlParInfo, "paragraph");
  3251. bId = getNodeText(xmlParInfo, "id");
  3252. type = getNodeText(xmlParInfo, "type");
  3253. var allWord = elementBlock.getElementsByTagName("word");
  3254. var iNoteCounter = 0;
  3255. for (iWord = 0; iWord < allWord.length; iWord++) {
  3256. pali = getNodeText(allWord[iWord], "pali");
  3257. wnote = note_init(getNodeText(allWord[iWord], "note"));
  3258. id = getNodeText(allWord[iWord], "id");
  3259. var note = wnote;
  3260. if (note.length > 0 && note != "?") {
  3261. iNoteCounter++;
  3262. if (wnote.substring(0, 6) == "=term(") {
  3263. var termId = wnote.slice(6, -1);
  3264. //alert(arrTerm.length);
  3265. if (arrTerm[note]) {
  3266. note = "<term guid='" + termId + "' pos='wbw'>" + arrTerm[termId].note + "</term>";
  3267. } else {
  3268. note = "<term guid='" + termId + "' pos='wbw'></term>";
  3269. }
  3270. }
  3271. output += '<p><a href="#word_note_root_' + id + '" name="word_note_' + id + '">[' + iNoteCounter + "]</a>";
  3272. if (note.match("{") && note.match("}")) {
  3273. note = note.replace("{", "<strong>");
  3274. note = note.replace("}", "</strong>");
  3275. if (note.length > 100) {
  3276. shortNote = note.substring(0, 99);
  3277. otherNode = note.substring(100);
  3278. output +=
  3279. shortNote +
  3280. '<span class="full_note_handle">...<span class="full_note">' +
  3281. otherNode +
  3282. "</span></span>";
  3283. } else {
  3284. output += note;
  3285. }
  3286. } else {
  3287. if (note.length > 100) {
  3288. shortNote = note.substring(0, 99);
  3289. otherNode = note.substring(100);
  3290. output +=
  3291. shortNote +
  3292. '<span class="full_note_handle">...<span class="full_note">' +
  3293. otherNode +
  3294. "</span></span>";
  3295. } else {
  3296. output += "<strong>" + pali + ":</strong>" + note;
  3297. }
  3298. }
  3299. output += "</p>";
  3300. if (termId) {
  3301. document.getElementById("wnote_root_" + id).innerHTML =
  3302. "<a onclick=\"term_show_win('" +
  3303. termId +
  3304. '\')" name="word_note_root_' +
  3305. id +
  3306. '">[' +
  3307. iNoteCounter +
  3308. "]</a>";
  3309. } else {
  3310. document.getElementById("wnote_root_" + id).innerHTML =
  3311. '<a href="#word_note_' + id + '" name="word_note_root_' + id + '">[' + iNoteCounter + "]</a>";
  3312. }
  3313. } else {
  3314. noteRootObj = document.getElementById("wnote_root_" + id);
  3315. if (noteRootObj) {
  3316. document.getElementById("wnote_root_" + id).innerHTML = "";
  3317. }
  3318. }
  3319. }
  3320. if (output == "") {
  3321. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "none";
  3322. } else {
  3323. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "block";
  3324. }
  3325. document.getElementById("wnote_" + book + "_" + (paragraph - 1)).innerHTML = output;
  3326. }
  3327. function updateWordNote(element) {
  3328. let paliword = getNodeText(element, "real");
  3329. let wnote = getNodeText(element, "note");
  3330. wnote = note_init(wnote);
  3331. let id = getNodeText(element, "id");
  3332. if (wnote == "") {
  3333. $("#wnote_root_" + id).html("");
  3334. $("#wnn_" + id).html("");
  3335. } else {
  3336. $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
  3337. let output = "";
  3338. output += "<wnc wid='" + id + "'></wnc>";
  3339. let head = "";
  3340. let content = "";
  3341. if (wnote.match("{") && wnote.match("}")) {
  3342. wnote = wnote.replace("{", "<strong>");
  3343. wnote = wnote.replace("}", "</strong>");
  3344. } else {
  3345. output += "<strong>" + paliword + ":</strong>";
  3346. }
  3347. output += wnote;
  3348. $("#wnn_" + id).html(output);
  3349. }
  3350. }
  3351. function updateWordCommentary(element) {}
  3352. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  3353. //返回 无
  3354. function updataWordBodyByElement(element) {
  3355. try {
  3356. var sId = getNodeText(wordNode, "id");
  3357. var sDetail = "detail" + sId;
  3358. var cDetail = document.getElementById(sDetail);
  3359. if (cDetail != null) {
  3360. cDetail.innerHTML = renderWordDetailByElement(element);
  3361. }
  3362. } catch (error) {
  3363. var_dump(error);
  3364. }
  3365. }
  3366. //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
  3367. //返回 无
  3368. function modifyWordDetailByWordId(wordId) {
  3369. try {
  3370. var sDetail = "detail" + wordId;
  3371. var cDetail = document.getElementById(sDetail);
  3372. if (cDetail != null) {
  3373. cDetail.innerHTML = renderWordDetailById(wordId);
  3374. }
  3375. } catch (error) {
  3376. var_dump(error);
  3377. }
  3378. }
  3379. //根据xmlDocument 对象中的单词GUID返回单词块字符串(不含Pali)
  3380. //返回 字符串
  3381. function renderWordDetailById(wordID) {
  3382. var mXML = gXmlBookDataBody.getElementsByTagName("word");
  3383. var wordIndex = getWordIndex(wordID);
  3384. return renderWordDetailByElement(mXML[wordIndex]);
  3385. }
  3386. function reloadPar(parIndex) {
  3387. bookId = gArrayDocParagraph[parIndex].book;
  3388. parNo = gArrayDocParagraph[parIndex].paragraph;
  3389. var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
  3390. if (htmlBlock.style.display != "none") {
  3391. return false;
  3392. }
  3393. allBlock = gXmlBookDataBody.getElementsByTagName("block");
  3394. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  3395. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  3396. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  3397. currBookId = getNodeText(xmlParInfo, "book");
  3398. currParNo = getNodeText(xmlParInfo, "paragraph");
  3399. if (bookId == currBookId && currParNo == parNo) {
  3400. insertBlockToHtml(allBlock[iBlock]);
  3401. }
  3402. }
  3403. return true;
  3404. }
  3405. function removePar(parIndex) {
  3406. bookId = gArrayDocParagraph[parIndex].book;
  3407. parNo = gArrayDocParagraph[parIndex].paragraph;
  3408. if (gCurrModifyWindowParNo == parIndex) {
  3409. //关闭单词修改窗口
  3410. closeModifyWindow();
  3411. }
  3412. var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
  3413. if (htmlBlock) {
  3414. htmlBlock.style.display = "none";
  3415. document.getElementById("heading_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3416. document.getElementById("wblock_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3417. document.getElementById("tran_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3418. document.getElementById("wnote_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3419. document.getElementById("note_" + bookId + "_" + (parNo - 1)).innerHTML = "";
  3420. }
  3421. }
  3422. function setView(topParIndex) {
  3423. var parInOnePage = 3;
  3424. gCurrTopParagraph = topParIndex;
  3425. gVisibleParBegin = topParIndex - parInOnePage;
  3426. gVisibleParEnd = parInOnePage * 2;
  3427. if (gVisibleParBegin < 0) {
  3428. gVisibleParBegin = 0;
  3429. }
  3430. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3431. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3432. }
  3433. }
  3434. function isParInView(parIndex) {
  3435. if (parIndex >= gVisibleParBegin && parIndex <= gVisibleParEnd) {
  3436. return true;
  3437. } else {
  3438. return false;
  3439. }
  3440. }
  3441. function refresh_Dispaly_Cap() {
  3442. var new_par_length = gPalitext_length / gtext_max_length;
  3443. for (refresh_i in allTextLen_array) {
  3444. gNewArrayDocParagraph.push(allTextLen_array[refresh_i].length / gtext_max_length);
  3445. }
  3446. }
  3447. function prev_page() {
  3448. //向上翻页
  3449. gVisibleParBeginOld = gVisibleParBegin;
  3450. gVisibleParEndOld = gVisibleParEnd;
  3451. if (g_allparlen_array[gVisibleParEnd - 1] - g_allparlen_array[gVisibleParBegin - 1] <= gDisplayCapacity) {
  3452. gVisibleParBegin -= 1;
  3453. } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin - 1] > gDisplayCapacity) {
  3454. gVisibleParBegin -= 1;
  3455. gVisibleParEnd -= 1;
  3456. }
  3457. if (gVisibleParBegin < 0) {
  3458. //如果到顶,则恢复原始值
  3459. gVisibleParBegin = 0;
  3460. //gVisibleParEnd=gDisplayCapacity;
  3461. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3462. //如果到底,则锁死最大值
  3463. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3464. }
  3465. }
  3466. updataView();
  3467. }
  3468. function next_page() {
  3469. //向下翻页
  3470. gVisibleParBeginOld = gVisibleParBegin;
  3471. gVisibleParEndOld = gVisibleParEnd;
  3472. if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] <= gDisplayCapacity) {
  3473. gVisibleParEnd += 1;
  3474. } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] > gDisplayCapacity) {
  3475. gVisibleParBegin += 1;
  3476. gVisibleParEnd += 1;
  3477. }
  3478. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3479. //如果到底
  3480. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3481. //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
  3482. if (gVisibleParBegin < 0) {
  3483. gVisibleParBegin = 0;
  3484. }
  3485. }
  3486. updataView();
  3487. }
  3488. function setNewView(newBegin, newEnd) {
  3489. gVisibleParBeginOld = gVisibleParBegin;
  3490. gVisibleParEndOld = gVisibleParEnd;
  3491. gVisibleParBegin = newBegin;
  3492. gVisibleParEnd = newEnd;
  3493. if (gVisibleParBegin < 0) {
  3494. gVisibleParBegin = 0;
  3495. //gVisibleParEnd=gDisplayCapacity;
  3496. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3497. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3498. }
  3499. }
  3500. if (gVisibleParEnd >= gArrayDocParagraph.length) {
  3501. gVisibleParEnd = gArrayDocParagraph.length - 1;
  3502. //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
  3503. if (gVisibleParBegin < 0) {
  3504. gVisibleParBegin = 0;
  3505. }
  3506. }
  3507. updataView();
  3508. }
  3509. function updataView() {
  3510. var topNewDivArray = Array(); //在顶端新加入的块列表
  3511. for (var iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
  3512. if (isParInView(iPar)) {
  3513. isLoadNew = reloadPar(iPar);
  3514. if (isLoadNew) {
  3515. if (iPar < gVisibleParBeginOld) {
  3516. topNewDivArray.push(iPar);
  3517. }
  3518. }
  3519. } else {
  3520. removePar(iPar);
  3521. }
  3522. }
  3523. word_mouse_event();
  3524. //console.log("updataview");
  3525. console.log(topNewDivArray.toString());
  3526. }
  3527. function render_word_mean_menu2(spell) {
  3528. var wReal = spell;
  3529. var output = "<div>";
  3530. for (var iDict = 0; iDict < mDict[spell].length; iDict++) {
  3531. output += "<div>";
  3532. output += "<span>dict_name</span>";
  3533. var meanGroup = partList2[i].mean.split("$");
  3534. for (var iMean = 0; iMean < meanGroup.length; iMean++) {
  3535. output +=
  3536. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3537. wId +
  3538. '","mean","' +
  3539. meanGroup[iMean] +
  3540. "\")'>" +
  3541. meanGroup[iMean] +
  3542. "</span>";
  3543. }
  3544. output += "</div>";
  3545. }
  3546. output += "</div>";
  3547. return;
  3548. var sWord = new Array(wReal);
  3549. sWord = sWord.concat(render_get_word_parent_list(wReal));
  3550. for (var iWord in sWord) {
  3551. output += '<div class="case_dropdown-first">';
  3552. output +=
  3553. '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
  3554. sWord[iWord] +
  3555. "\")'>";
  3556. output += sWord[iWord] + "</a>";
  3557. output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
  3558. output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
  3559. output += '</span><div class="case_dropdown-detail">';
  3560. var partList = render_get_word_mean_list(sWord[iWord]);
  3561. var L_width_mean = 0;
  3562. var partList2 = repeat_combine(partList);
  3563. //计算字符长度并控制
  3564. for (var i in partList2) {
  3565. var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
  3566. if (L_width_mean < L_width / 1.7) {
  3567. L_width_mean = L_width / 1.7;
  3568. }
  3569. }
  3570. for (var i in partList2) {
  3571. var meanGroup = partList2[i].mean.split("$");
  3572. var htmlMean = "";
  3573. output += "<a style='display:flex; flex-wrap: wrap;'>";
  3574. output +=
  3575. "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
  3576. //output += "<a ><div id='div_dictname_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_dictname+"em; display:flex'>"
  3577. output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
  3578. output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
  3579. output += getLocalDictname(partList2[i].dict) + "</span>";
  3580. output += "</div>";
  3581. output +=
  3582. "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
  3583. //output += "<div id='div_type_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_type+"em; display:flex'>"
  3584. output +=
  3585. "<span id='span_type_" +
  3586. wId +
  3587. "_" +
  3588. iWord +
  3589. "_" +
  3590. i +
  3591. "' style='height: 1.5em;' class='wm_wordtype'>" +
  3592. getLocalGrammaStr(partList2[i].type) +
  3593. "</span>";
  3594. for (var iMean in meanGroup) {
  3595. if (meanGroup[iMean] != "") {
  3596. htmlMean +=
  3597. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3598. wId +
  3599. '","mean","' +
  3600. meanGroup[iMean] +
  3601. "\")'>" +
  3602. meanGroup[iMean] +
  3603. "</span>";
  3604. }
  3605. }
  3606. output += "</div><div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3607. output += "</a>";
  3608. }
  3609. output += "</div></div>";
  3610. }
  3611. output += "</div></div></div>";
  3612. return output;
  3613. }
  3614. function render_word_mean_menu(xElement) {
  3615. var wMean = getNodeText(xElement, "mean");
  3616. var wReal = getNodeText(xElement, "real");
  3617. var wId = getNodeText(xElement, "id");
  3618. var renderMeaning = wMean.replace(/{/g, "<span class='grm_add_mean'>");
  3619. renderMeaning = renderMeaning.replace(/}/g, "</span>");
  3620. renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
  3621. renderMeaning = renderMeaning.replace(/\]/g, "</span>");
  3622. var output = "";
  3623. output += '<div class="case_dropdown">';
  3624. output += "<p class='case_dropbtn' >";
  3625. output += renderMeaning;
  3626. output += "</p>";
  3627. output += '<div class="case_dropdown-content">';
  3628. output +=
  3629. "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
  3630. wId +
  3631. '","mean","")\'>' +
  3632. gLocal.gui.empty1 +
  3633. '</button><div class="case_dropdown-org">';
  3634. var sWord = new Array(wReal);
  3635. sWord = sWord.concat(render_get_word_parent_list(wReal));
  3636. for (var iWord in sWord) {
  3637. output += '<div class="case_dropdown-first">';
  3638. output +=
  3639. '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
  3640. sWord[iWord] +
  3641. "\")'>";
  3642. output += sWord[iWord] + "</a>";
  3643. output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
  3644. output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
  3645. output += "</span>";
  3646. output += '<div class="case_dropdown-detail">';
  3647. var partList = render_get_word_mean_list(sWord[iWord]);
  3648. var L_width_mean = 0;
  3649. var partList2 = repeat_combine(partList);
  3650. for (var i in partList2) {
  3651. var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
  3652. if (L_width_mean < L_width / 1.7) {
  3653. L_width_mean = L_width / 1.7;
  3654. }
  3655. }
  3656. for (var i in partList2) {
  3657. var meanGroup = partList2[i].mean.split("$");
  3658. var htmlMean = "";
  3659. output += "<a style='display:flex; flex-wrap: wrap;'>";
  3660. output +=
  3661. "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
  3662. output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
  3663. output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
  3664. output += getLocalDictname(partList2[i].dict) + "</span>";
  3665. output += "</div>";
  3666. output +=
  3667. "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
  3668. output +=
  3669. "<span id='span_type_" + wId + "_" + iWord + "_" + i + "' style='height: 1.5em;' class='wm_wordtype'>";
  3670. if (partList2[i].type == ".n:base.") {
  3671. output += getLocalGrammaStr(partList2[i].gramma);
  3672. } else {
  3673. output += getLocalGrammaStr(partList2[i].type);
  3674. }
  3675. output += "</span>";
  3676. for (var iMean in meanGroup) {
  3677. if (meanGroup[iMean] != "") {
  3678. htmlMean +=
  3679. "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
  3680. wId +
  3681. '","mean","' +
  3682. meanGroup[iMean] +
  3683. "\")'>" +
  3684. meanGroup[iMean] +
  3685. "</span>";
  3686. }
  3687. }
  3688. output += "</div>";
  3689. output += "<div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3690. output += "</a>";
  3691. }
  3692. output += "</div></div>";
  3693. }
  3694. output += "</div></div></div>";
  3695. return output;
  3696. }
  3697. function render_get_word_mean_list(sWord) {
  3698. var wReal = sWord;
  3699. var output = Array();
  3700. for (var x in g_DictWordList) {
  3701. if (g_DictWordList[x].Pali == wReal || g_DictWordList[x].Real == wReal) {
  3702. if (dict_language_enable.indexOf(g_DictWordList[x].Language) >= 0) {
  3703. if (
  3704. g_DictWordList[x].Mean != "" &&
  3705. g_DictWordList[x].Type != ".part." &&
  3706. g_DictWordList[x].Type != ".root." &&
  3707. g_DictWordList[x].Type != ".suf." &&
  3708. g_DictWordList[x].Type != ".pfx."
  3709. ) {
  3710. var newPart = Object();
  3711. newPart.dict = g_DictWordList[x].dictname;
  3712. newPart.mean = g_DictWordList[x].Mean;
  3713. newPart.type = g_DictWordList[x].Type;
  3714. var bIsExist = false;
  3715. for (var iBuffer in output) {
  3716. if (
  3717. output[iBuffer].dict == newPart.dict &&
  3718. output[iBuffer].type == newPart.type &&
  3719. output[iBuffer].mean == newPart.mean
  3720. ) {
  3721. bIsExist = true;
  3722. break;
  3723. }
  3724. if (newPart.dict == "wbw") {
  3725. if (output[iBuffer].dict == newPart.dict && output[iBuffer].type == newPart.type) {
  3726. output[iBuffer].mean += "$" + newPart.mean;
  3727. bIsExist = true;
  3728. break;
  3729. }
  3730. }
  3731. }
  3732. if (!bIsExist) {
  3733. output.push(newPart);
  3734. }
  3735. }
  3736. }
  3737. }
  3738. }
  3739. return output;
  3740. }
  3741. function render_get_word_parent_list(sWord) {
  3742. var wReal = sWord;
  3743. var output = Array();
  3744. for (var x in g_DictWordList) {
  3745. if (g_DictWordList[x].Pali == wReal) {
  3746. {
  3747. if (g_DictWordList[x].Parent != "" && g_DictWordList[x].Parent != sWord) {
  3748. var newPart = g_DictWordList[x].Parent;
  3749. var bIsExist = false;
  3750. for (var iBuffer in output) {
  3751. if (output[iBuffer] == newPart) {
  3752. bIsExist = true;
  3753. break;
  3754. }
  3755. }
  3756. if (!bIsExist) {
  3757. output.push(newPart);
  3758. }
  3759. }
  3760. }
  3761. }
  3762. }
  3763. return output;
  3764. }
  3765. function repeat_combine(list) {
  3766. var list_new = new Array();
  3767. for (var repeat_combine_i = 0; repeat_combine_i < list.length; repeat_combine_i++) {
  3768. var repeat_string = new Object();
  3769. var repeat_combine_j = 0;
  3770. repeat_string.dict = list[repeat_combine_i].dict;
  3771. repeat_string.type = list[repeat_combine_i].type;
  3772. repeat_string.mean = list[repeat_combine_i].mean;
  3773. for (repeat_combine_j = repeat_combine_i + 1; repeat_combine_j < list.length; repeat_combine_j++) {
  3774. if (
  3775. list[repeat_combine_j].dict == list[repeat_combine_i].dict &&
  3776. list[repeat_combine_j].type == list[repeat_combine_i].type
  3777. ) {
  3778. repeat_string.mean = repeat_string.mean + "$" + list[repeat_combine_j].mean;
  3779. repeat_string.mean = repeat_string.mean.replace(/\$\$/g, "$");
  3780. repeat_string.mean = repeat_string.mean.replace(/\$ /g, "$");
  3781. repeat_string.mean = repeat_string.mean.replace(/ \$/g, "$");
  3782. repeat_combine_i = repeat_combine_j;
  3783. }
  3784. }
  3785. repeat_string.mean = "#" + repeat_string.mean + "#";
  3786. repeat_string.mean = repeat_string.mean.replace(/ #/g, "");
  3787. repeat_string.mean = repeat_string.mean.replace(/# /g, "");
  3788. repeat_string.mean = repeat_string.mean.replace(/\$#/g, "");
  3789. repeat_string.mean = repeat_string.mean.replace(/#\$/g, "");
  3790. repeat_string.mean = repeat_string.mean.replace(/ /g, "");
  3791. repeat_string.mean = repeat_string.mean.replace(/#/g, "");
  3792. list_new.push(repeat_string);
  3793. }
  3794. return list_new;
  3795. }
  3796. function show_pop_note(wordid) {
  3797. let html = $("wnc[wid='" + wordid + "']")
  3798. .parent()
  3799. .html();
  3800. $("#word_note_pop_content").html(
  3801. html
  3802. /*note_init(doc_word("#" + wordid).val("note"))*/
  3803. );
  3804. $("#word_note_pop").show("500");
  3805. }
  3806. function refreshNoteNumber() {
  3807. $("wnh").each(function (index, element) {
  3808. let id = $(this).attr("wid");
  3809. //$(this).html("<a href='#word_note_"+id+"' name=\"word_note_root_"+id+"\">"+(index+1)+"</a>");
  3810. $(this).html("<span onclick=\"show_pop_note('" + id + "')\">" + (index + 1) + "</span>");
  3811. });
  3812. $("wnc").each(function (index, element) {
  3813. let id = $(this).attr("wid");
  3814. $(this).html("<a href='#word_note_root_" + id + "' name=\"word_note_" + id + '">[' + (index + 1) + "]</a>");
  3815. });
  3816. note_refresh_new();
  3817. }