render.js 133 KB

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