render.js 135 KB

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