| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181 |
- var gRenderPageLimit = 1; //限制 1 不限制 设为1000
- var gDisplayCapacity = 20 * gRenderPageLimit;
- var gCurrTopParagraph = 0;
- var gVisibleParBegin = 0;
- var gVisibleParEnd = 10 * gRenderPageLimit;
- //显示模式
- var _display_para_arrange = 0; //0:横向 排列 1:纵向排列
- var _display_sbs = 0; //0:逐段 1:逐句
- //翻译块显示模式
- //在编辑状态下显示预览
- var _tran_show_preview_on_edit = true;
- //在非编辑状态下显示编辑框
- var _tran_show_textarea_esc_edit = true;
- var gVisibleParBeginOld = 0;
- var gVisibleParEndOld = gDisplayCapacity;
- //var gPalitext_length=0
- var gtext_max_length = 0;
- var g_allparlen_array = new Array();
- function palitext_calculator() {
- var allText = "";
- var allTextLen_array = new Array();
- var text_max2_length = 0;
- allBlock = gXmlBookDataBody.getElementsByTagName("block");
- for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
- xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
- xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
- //bookId=getNodeText(xmlParInfo,"book")
- //paragraph=getNodeText(xmlParInfo,"paragraph")
- type = getNodeText(xmlParInfo, "type");
- if (type == "wbw") {
- var wbwTextNode = xmlParData.getElementsByTagName("word");
- var para_text_cal = "";
- for (var iText = 0; iText < wbwTextNode.length; iText++) {
- if (getNodeText(wbwTextNode[iText], "type") != ".ctl.") {
- para_text_cal += getNodeText(wbwTextNode[iText], "pali") + " ";
- }
- }
- allText += para_text_cal;
- allTextLen_array.push(allText.length);
- //gPalitext_length+=para_text_cal.length
- if (para_text_cal.length > text_max2_length) {
- text_max2_length = para_text_cal.length;
- if (text_max2_length > gtext_max_length) {
- var num_max_tem = gtext_max_length;
- gtext_max_length = text_max2_length;
- text_max2_length = num_max_tem;
- }
- }
- }
- }
- for (i_cal in allTextLen_array) {
- g_allparlen_array.push(allTextLen_array[i_cal] / gtext_max_length);
- }
- gDisplayCapacity = 19 * gRenderPageLimit + text_max2_length / gtext_max_length;
- if (gDisplayCapacity * gtext_max_length < 5000 * gRenderPageLimit) {
- gDisplayCapacity = (5000 * gRenderPageLimit) / gtext_max_length;
- }
- }
- //添加新的段落块
- function addNewBlockToHTML(bookId, parId, begin = -1, end = -1) {
- parHeadingLevel = 0;
- parTitle = "";
- var divBlock = document.createElement("div");
- var typId = document.createAttribute("id");
- if (begin == -1 && end == -1) {
- //基于段落的块
- typId.nodeValue = "par_" + bookId + "_" + (parId - 1);
- } else {
- //基于句子的块
- typId.nodeValue = "par_" + bookId + "_" + (parId - 1) + "_" + begin + "_" + end;
- }
- divBlock.attributes.setNamedItem(typId);
- var typClass = document.createAttribute("class");
- typClass.nodeValue = "pardiv";
- divBlock.attributes.setNamedItem(typClass);
- var output = '<a name="par_begin_' + bookId + "_" + (parId - 1) + '"></a>';
- output += ' <div id="head_tool_' + bookId + "_" + (parId - 1) + '" class="head_tool edit_tool">';
- output +=
- ' <button id="id_heading_add_new" onclick="editor_heading_add_new(\'' +
- bookId +
- "','" +
- parId +
- "')\" >" +
- gui_string_editor[0] +
- "</button>";
- output +=
- "<input id='page_break_'" +
- bookId +
- "_" +
- (parId - 1) +
- ' type="checkbox" onclick="editor_page_break(this,\'' +
- bookId +
- "','" +
- (parId - 1) +
- "')\" />" +
- gui_string_editor[1];
- output += "</div>";
- //heading
- output += ' <div id="heading_' + bookId + "_" + (parId - 1) + '" class="par_heading"></div>';
- //word by word translate block
- //内部可以包含多个wbw块
- output += ' <div id="wblock_' + bookId + "_" + (parId - 1) + '" class="wbwdiv"></div>';
- //translate div
- output += ' <div id="tran_' + bookId + "_" + (parId - 1) + '" class="trandiv"></div>';
- //word note div
- output += ' <div id="wnote_' + bookId + "_" + (parId - 1) + '" class="wnotediv"></div>';
- //note div
- output += ' <div id="note_' + bookId + "_" + (parId - 1) + '" class="pnotediv"></div>';
- //vedio div
- output += ' <div id="vedioblock_' + bookId + "_" + (parId - 1) + '" class="vediodiv"></div>';
- divBlock.innerHTML = output;
- document.getElementById("sutta_text").appendChild(divBlock);
- }
- function renderToc(bookId, parBegin, parEnd) {
- var firstHeadingLevel = getNodeText(gXmlParIndex[parBegin - 1], "level");
- var output = "<ul>";
- for (var iPar = parBegin; iPar < parEnd; iPar++) {
- parTitle = getNodeText(gXmlParIndex[iPar - 1], "title");
- parHeadingLevel = getNodeText(gXmlParIndex[iPar - 1], "level");
- if (parHeadingLevel > 0) {
- output += '<li class="toc_h_' + (parHeadingLevel - firstHeadingLevel + 1) + '">';
- output += '<a href="#par-' + bookId + "-" + iPar + '">' + parTitle + "</a>";
- output += "</li>";
- }
- }
- output += "</ul>";
- return output;
- }
- function updataWordParContainer(bookId, parId) {
- document.getElementById("wblock-" + bookId + "-" + parId + '"').innerHTML = renderWordParContainerInner(
- bookId,
- parId
- );
- }
- function renderWordParContainerInner(bookId, parId) {
- var strHtml = "";
- strHtml += '<div class="wbwparblock">';
- strHtml += renderWordParBlockInner(packageIndex);
- strHtml += "</div>";
- }
- //根据block数据更新 目录 列表
- function updataToc() {
- document.getElementById("content").innerHTML = "";
- //创建目录空壳
- for (let iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
- if (gArrayDocParagraph[iPar].level > 0) {
- let bookId = gArrayDocParagraph[iPar].book;
- let parIndex = gArrayDocParagraph[iPar].paragraph;
- let tocId = "toc_" + bookId + "_" + (parIndex - 1);
- let str = '<div class="toc_heading">';
- str += "<table><tr><td>";
- str +=
- "<input type='checkbox' checked onclick=\"editor_par_show(this,'" +
- bookId +
- "','" +
- parIndex +
- "')\" />";
- str += "</td><td>";
- str += '<div class="toc_heading_inner" id="' + tocId + '">';
- str += "<a onclick=\"editor_goto_link('" + bookId + "'," + parIndex + ')" >[' + parIndex + "]</a>";
- str += "</div>";
- str += "</td></tr></table>";
- str += "</div>";
- document.getElementById("content").innerHTML += str;
- }
- }
- allBlock = gXmlBookDataBody.getElementsByTagName("block");
- for (let iBlock = 0; iBlock < allBlock.length; iBlock++) {
- xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
- xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
- bookId = getNodeText(xmlParInfo, "book");
- paragraph = getNodeText(xmlParInfo, "paragraph");
- type = getNodeText(xmlParInfo, "type");
- if (type == "heading") {
- level = getNodeText(xmlParInfo, "level");
- //if(level>0)
- {
- language = getNodeText(xmlParInfo, "language");
- bId = getNodeText(xmlParInfo, "id");
- strHeadingText = getNodeText(xmlParData, "text");
- tocId = "toc_" + bookId + "_" + (paragraph - 1);
- /*
- var htmlBlock=document.getElementById(tocId)
- if(htmlBlock==null){
- var str="<div class=\"toc_heading\">";
- str += "<table><tr><td>";
- str += "<input type='checkbox' checked onclick=\"editor_par_show(this,'"+bookId+"','"+(paragraph-1)+"')\" />";
- str += "</td><td>";
- str += "<div class=\"toc_heading_inner\" id=\""+tocId+"\"></div>";
- str += "</td></tr></table>";
- str += "</div>";
- document.getElementById("content").innerHTML+=str
- }
- */
- let tocText = '<p class="toc_item_' + level + " " + language + '_text">';
- tocText +=
- "<a onclick=\"editor_goto_link('" +
- bookId +
- "'," +
- paragraph +
- ')" >[' +
- paragraph +
- "]-" +
- strHeadingText +
- "</a>";
- tocText += "</p>";
- $("#toc_" + bookId + "_" + (paragraph - 1)).html(tocText);
- }
- }
- }
- palitext_calculator();
- }
- //向html中插入数据块
- function insertBlockToHtml(element) {
- xmlParInfo = element.getElementsByTagName("info")[0];
- xmlParData = element.getElementsByTagName("data")[0];
- let bookId = getNodeText(xmlParInfo, "book");
- let paragraph = getNodeText(xmlParInfo, "paragraph");
- let base_on = getNodeText(xmlParInfo, "base");
- let begin = getNodeText(xmlParInfo, "begin");
- let end = getNodeText(xmlParInfo, "end");
- type = getNodeText(xmlParInfo, "type");
- language = getNodeText(xmlParInfo, "language");
- bId = getNodeText(xmlParInfo, "id");
- let htmlBlock;
- if (base_on == "sentence") {
- blockId = "par_" + bookId + "_" + (paragraph - 1) + "_" + begin + "_" + end;
- htmlBlock = document.getElementById(blockId);
- if (htmlBlock == null) {
- addNewBlockToHTML(bookId, paragraph, begin, end);
- }
- } else {
- blockId = "par_" + bookId + "_" + (paragraph - 1);
- htmlBlock = document.getElementById(blockId);
- if (htmlBlock == null) {
- addNewBlockToHTML(bookId, paragraph);
- }
- }
- if (!isParInView(getParIndex(bookId, paragraph))) {
- document.getElementById(blockId).style.display = "none";
- return;
- } else {
- document.getElementById(blockId).style.display = "inline-flex";
- }
- switch (type) {
- case "wbw":
- var strHtml = renderWordParBlockInner(element);
- $("#wnote_" + bookId + "_" + (paragraph - 1)).html(renderNoteShell(element));
- var paraDiv = document.createElement("div");
- var node = document.createTextNode("");
- paraDiv.appendChild(node);
- paraDiv.innerHTML = strHtml;
- note_refresh_new();
- var typ = document.createAttribute("class");
- typ.nodeValue = "wbwparblock";
- paraDiv.attributes.setNamedItem(typ);
- var id = document.createAttribute("id");
- id.nodeValue = "id_wbw_" + bId;
- paraDiv.attributes.setNamedItem(id);
- blockId = "wblock_" + bookId + "_" + (paragraph - 1);
- document.getElementById(blockId).appendChild(paraDiv);
- refreshWordNoteDiv(element);
- refreshNoteNumber();
- break;
- case "translate":
- var strHtml = "";
- strHtml = renderTranslateParBlockInner(element);
- var paraDiv = document.createElement("div");
- var node = document.createTextNode("");
- paraDiv.appendChild(node);
- paraDiv.innerHTML = strHtml;
- var typ = document.createAttribute("class");
- typ.nodeValue = "tran_parblock " + language + "_text";
- paraDiv.attributes.setNamedItem(typ);
- var id = document.createAttribute("id");
- id.nodeValue = "id_tran_" + bId;
- paraDiv.attributes.setNamedItem(id);
- blockId = "tran_" + bookId + "_" + (paragraph - 1);
- document.getElementById(blockId).appendChild(paraDiv);
- //逐句
- if (_display_sbs == 1) {
- let eAllSent = document.getElementById(blockId).getElementsByClassName("tran_sent");
- for (let iSen = 0; iSen < eAllSent.length; iSen++) {
- let senA = eAllSent[iSen].getAttributeNode("sn").value;
- let blockId = eAllSent[iSen].getAttributeNode("block").value;
- let eSBSDiv = document.getElementById("sent_" + senA);
- if (eSBSDiv) {
- let eBlockSenDiv = document.getElementById("sent_" + senA + "_" + blockId);
- if (!eBlockSenDiv) {
- //没有 添加
- let divSen = document.createElement("div");
- let typ = document.createAttribute("class");
- typ.nodeValue = "sbs_sent_block";
- divSen.attributes.setNamedItem(typ);
- let typId = document.createAttribute("id");
- typId.nodeValue = "sent_" + senA + "_" + blockId;
- divSen.attributes.setNamedItem(typId);
- let sn = document.createAttribute("sn");
- sn.nodeValue = senA;
- divSen.attributes.setNamedItem(sn);
- let block = document.createAttribute("block");
- block.nodeValue = blockId;
- divSen.attributes.setNamedItem(block);
- divSen.innerHTML = eAllSent[iSen].innerHTML;
- eSBSDiv.appendChild(divSen);
- } else {
- eBlockSenDiv.innerHTML = eAllSent[iSen].innerHTML;
- }
- eAllSent[iSen].innerHTML = "";
- }
- }
- }
- break;
- case "note":
- var strHtml = "";
- strHtml = renderNoteParBlockInner(element);
- var paraDiv = document.createElement("div");
- var node = document.createTextNode("");
- paraDiv.appendChild(node);
- paraDiv.innerHTML = strHtml;
- var typ = document.createAttribute("class");
- typ.nodeValue = "note_parblock " + language + "_text";
- paraDiv.attributes.setNamedItem(typ);
- var id = document.createAttribute("id");
- id.nodeValue = "id_note_" + bId;
- paraDiv.attributes.setNamedItem(id);
- blockId = "note_" + bookId + "_" + (paragraph - 1);
- document.getElementById(blockId).appendChild(paraDiv);
- document.getElementById(blockId).style.display = "block";
- break;
- case "heading":
- headingLevel = getNodeText(xmlParInfo, "level");
- var strHtml = "";
- strHtml = renderHeadingBlockInner(element);
- var paraDiv = document.createElement("div");
- var node = document.createTextNode("");
- paraDiv.appendChild(node);
- paraDiv.innerHTML = strHtml;
- var typ = document.createAttribute("class");
- typ.nodeValue = "heading_parblock_" + headingLevel + "_" + language + " " + language + "_text";
- paraDiv.attributes.setNamedItem(typ);
- var id = document.createAttribute("id");
- id.nodeValue = "id_heading_" + bId;
- paraDiv.attributes.setNamedItem(id);
- blockId = "heading_" + bookId + "_" + (paragraph - 1);
- document.getElementById(blockId).appendChild(paraDiv);
- document.getElementById(blockId).style.display = "block";
- //document.getElementById("id_heading_level_"+bookId+"_"+(paragraph-1)).value=headingLevel;
- break;
- }
- guide_init();
- }
- function updataHeadingBlockInHtml(book, par) {
- document.getElementById("heading_" + book + "_" + (par - 1)).innerHTML = "";
- allBlock = gXmlBookDataBody.getElementsByTagName("block");
- for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
- xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
- xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
- bookId = getNodeText(xmlParInfo, "book");
- paragraph = getNodeText(xmlParInfo, "paragraph");
- type = getNodeText(xmlParInfo, "type");
- if (type == "heading" && bookId == book && paragraph == par) {
- insertBlockToHtml(allBlock[iBlock]);
- }
- }
- }
- function renderBlock() {}
- /*
- 重绘翻译数据块
- */
- function update_tran_sent(blockId, begin, end) {
- let eBlock = document.getElementById("id_tran_" + blockId);
- if (eBlock) {
- eBlock.innerHTML = renderTranslateParBlockInnerById(blockId);
- term_updata_translation();
- }
- /*
- $("#id_tran_"+blockId).html(renderTranslateParBlockInnerById(blockId));
- term_updata_translation();
- */
- }
- /*
- 更新翻译数据块数据
- */
- function update_tran_block_text(blockId) {
- let block = doc_tran("#" + blockId);
- if (block != null) {
- let book = block.info("book");
- let para = block.info("paragraph");
- let sent = block.list();
- if (sent != null) {
- for (const element of sent) {
- let eText = document.getElementById("ta_" + blockId + "_" + element.begin + "_" + element.end);
- if (eText) {
- eText.innerHTML = element.text;
- }
- let eLable = document.getElementById(
- "tran_pre_" + blockId + "_p" + book + "-" + para + "-" + element.end
- );
- if (eLable) {
- eLable.innerHTML = element.text;
- }
- }
- term_updata_translation();
- }
- }
- }
- /*
- 重绘翻译数据块
- */
- function update_tran_block(blockId) {
- let eBlock = document.getElementById("id_tran_" + blockId);
- if (eBlock) {
- eBlock.innerHTML = renderTranslateParBlockInnerById(blockId);
- term_updata_translation();
- }
- /*
- $("#id_tran_"+blockId).html(renderTranslateParBlockInnerById(blockId));
- term_updata_translation();
- */
- }
- //譯文段落渲染
- function renderTranslateParBlockInnerById(blockId) {
- var xBlock = gXmlBookDataBody.getElementsByTagName("block");
- for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
- xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
- xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
- bId = getNodeText(xmlParInfo, "id");
- if (bId == blockId) {
- return renderTranslateParBlockInner(xBlock[iBlock]);
- }
- }
- }
- //譯文段落渲染
- function renderTranslateParBlockInner(elementBlock) {
- var output = "";
- xmlParInfo = elementBlock.getElementsByTagName("info")[0];
- var book = getNodeText(xmlParInfo, "book");
- var paragraph = getNodeText(xmlParInfo, "paragraph");
- var bId = getNodeText(xmlParInfo, "id");
- var power = getNodeText(xmlParInfo, "power");
- var readonly = getNodeText(xmlParInfo, "readonly");
- par_num = paragraph - 1;
- type = getNodeText(xmlParInfo, "type");
- language = getNodeText(xmlParInfo, "language");
- var allSen = elementBlock.getElementsByTagName("sen");
- output += "<div>";
- for (iSen = 0; iSen < allSen.length; iSen++) {
- var senText = getNodeText(allSen[iSen], "text");
- var senBegin = getNodeText(allSen[iSen], "begin");
- var senEnd = getNodeText(allSen[iSen], "end");
- var senA = "p" + book + "-" + paragraph + "-" + senEnd;
- output +=
- "<div id='tran_sent_" + bId + "_" + senA + "' block='" + bId + "' sn='" + senA + "' class='tran_sent' >";
- if (power != "read") {
- //可写入模式
- if (readonly != 1) {
- output +=
- "<div class='tran_sent_inner' onmouseenter=\"tran_sent_div_mouseenter('" +
- bId +
- "','" +
- senA +
- "')\" >";
- }
- } else {
- output += "<div class='tran_sent_inner' >";
- }
- output += "<div id='tran_pre_" + bId + "_" + senA + "' class='tran_sent_pre'>";
- if (senText == "") {
- output += "<span style='color:gray;'>" + gLocal.gui.translation + "</span>";
- } else {
- output += term_std_str_to_tran(senText);
- }
- output += "</div>";
- output += "<div id='tran_sent_text_div_" + bId + "_" + senA + "' class='tran_sen_textarea'";
- //在非编辑状态下 不显示 编辑框
- if (_tran_show_textarea_esc_edit == false) {
- output += " style='display:none'";
- }
- output += ">";
- //只读权限不显示修改框
- if (power != "read") {
- //可写入模式
- if (readonly != 1) {
- //只读模式不显示修改框 只有power=write才考虑只读模式
- output += "<textarea id='ta_" + bId + "_" + senBegin + "_" + senEnd + "' ";
- output += " onkeyup=\"updateTranslationPreview('" + bId + "_" + senA + "',this)\" ";
- output += " onchange=\"tran_text_onchange('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" ";
- //output += " onchange=\"sen_save('"+bId+"','"+senBegin+"','"+senEnd+"',this.value)\" ";
- output += " onblur=\"tran_sent_div_blur('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" ";
- output +=
- " onfocus=\"tran_sent_div_onfocus('" + bId + "','" + senBegin + "','" + senEnd + "',this)\" >";
- senText = senText.replace(/\<br \/\>/g, "\n\n");
- output += term_std_str_to_edit(senText);
- output += "</textarea>";
- }
- }
- output += "</div>";
- output += '<div class="tran_sent_text_tool_bar">';
- //output += "<button onclick=\"tran_sen_save_click('"+bId+"','"+senBegin+"','"+senEnd+"',this)\">Save</button>";
- output += "<span></span>";
- output +=
- "<span onclick=\"show_tran_msg('" +
- bId +
- "','" +
- senBegin +
- "','" +
- senEnd +
- "')\"><span id='' class=\"word_msg\"></span></span>";
- output += "</div>";
- output += "</div>";
- output += "</div>";
- output += "</div>";
- }
- output += "</div>";
- return output;
- }
- function renderTranslateParBlockInnerPreview(strText) {}
- function updateTranslationPreview_a(blockId, text) {
- let out = "";
- let newText = text;
- newText = marked(newText);
- //newText = term_tran_edit_replace(newText);
- //newText = term_edit_to_std_str(newText);
- newText = term_std_str_to_tran(newText);
- out += newText;
- if (out == "") {
- out = "<span style='color:#ccbfbf;'>" + gLocal.gui.with_idea + "</span>";
- }
- $("#tran_pre_" + blockId).html(out);
- term_updata_translation();
- }
- function updateTranslationPreview(blockId, obj) {
- let out = "";
- let newText = obj.value;
- newText = marked(newText);
- let channal = $(obj).attr("channal");
- let lang = $(obj).attr("lang");
- newText = term_std_str_to_tran(newText, channal, getCookie("userid"), lang);
- out += newText;
- if (out == "") {
- out = "<span style='color:#ccbfbf;'>" + gLocal.gui.with_idea + "</span>";
- }
- $("#tran_pre_" + blockId).html(out);
- term_updata_translation();
- }
- function getSuperTranslateModifyString(inString, par_num, par_guid, language) {
- var curr_super_info = getPrevNextTrans_Guid("curr", par_guid);
- var arrString = translate_split(curr_super_info.senText, language).string;
- var output = "";
- var arrString_last = "";
- var sent_ID = "";
- var arr_sentA_ID = g_arr_Para_ID[par_num];
- var y = 0;
- for (y in arr_par_sent_num) {
- //得到本段句子外殻數0~par_num_last
- var arr_sentID = arr_par_sent_num[y].split("_");
- if (arr_sentID[1] == par_num) {
- var par_num_last = arr_sentID[2];
- }
- }
- if (par_num_last >= arrString.length - 1) {
- //外殻數大於等於切分結果,執行充填
- for (var x = 0; x < arrString.length; x++) {
- //整段渲染
- sent_ID = "sent_" + arr_sentA_ID[x];
- var superStringPosition_Start = 0;
- var superStringPosition_End = 0;
- var superString = translate_super_split(arrString[x], language).string;
- var language_type = translate_super_split(arrString[x], language).language_type;
- var output_super = "";
- for (var super_x = 0; super_x < superString.length; super_x++) {
- superStringPosition_End = superStringPosition_Start;
- superStringPosition_Start += superString[super_x].length;
- output_super +=
- "<span id='SBS_senA_" +
- par_guid +
- "_" +
- superStringPosition_End +
- "' class=\"tran_sen\" style='display:none'>";
- output_super += superStringPosition_End + "_" + superStringPosition_Start;
- output_super += "</span>";
- output_super +=
- "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
- output_super += superString[super_x];
- output_super += '<span class="tooltiptext tooltip-bottom">';
- output_super +=
- "<button onclick='super_trans_modify(up_sen," +
- superStringPosition_Start +
- "," +
- par_guid +
- "," +
- language +
- ")'>▲</button>";
- output_super +=
- "<button onclick='super_trans_modify(down_sen," +
- superStringPosition_End +
- "," +
- par_guid +
- "," +
- language +
- ")'>▼</button>";
- output_super += "</span></span>";
- }
- var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
- if (document.getElementById(sent_ID).innerHTML.length != 0) {
- if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
- document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
- } else {
- document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
- }
- }
- output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
- output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
- output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
- }
- } else if (par_num_last < arrString.length - 1) {
- //外殻數小於切分結果
- for (var x = 0; x < par_num_last; x++) {
- //除最後一句,其他充填
- //整段渲染
- sent_ID = "sent_" + arr_sentA_ID[x];
- var superStringPosition_Start = 0;
- var superStringPosition_End = 0;
- var superString = translate_super_split(arrString[x], language).string;
- var language_type = translate_super_split(arrString[x], language).language_type;
- var output_super = "";
- for (var super_x = 0; super_x < superString.length; super_x++) {
- superStringPosition_End = superStringPosition_Start;
- superStringPosition_Start += superString[super_x].length;
- output_super +=
- "<span id='SBS_senA_" +
- par_guid +
- "_" +
- superStringPosition_End +
- "' class=\"tran_sen\" style='display:none'>";
- output_super += superStringPosition_End + "_" + superStringPosition_Start;
- output_super += "</span>";
- output_super +=
- "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
- output_super += superString[super_x];
- output_super += '<span class="tooltiptext tooltip-bottom">';
- output_super +=
- "<button onclick='super_trans_modify(up_sen," +
- superStringPosition_Start +
- "," +
- par_guid +
- "," +
- language +
- ")'>▲</button>";
- output_super +=
- "<button onclick='super_trans_modify(down_sen," +
- superStringPosition_End +
- "," +
- par_guid +
- "," +
- language +
- ")'>▼</button>";
- output_super += "</span></span>";
- }
- output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
- output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
- output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
- var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
- if (document.getElementById(sent_ID).innerHTML.length != 0) {
- if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
- document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
- } else {
- document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
- }
- }
- }
- var output_super = "";
- for (var x = par_num_last; x < arrString.length - 1; x++) {
- //最後一句,合併所有譯文
- var superString = translate_super_split(arrString[x], language).string;
- var language_type = translate_super_split(arrString[x], language).language_type;
- for (var super_x = 0; super_x < superString.length; super_x++) {
- superStringPosition_End = superStringPosition_Start;
- superStringPosition_Start += superString[super_x].length;
- output_super +=
- "<span id='SBS_senA_" +
- par_guid +
- "_" +
- superStringPosition_End +
- "' class=\"tran_sen\" style='display:none'>";
- output_super += superStringPosition_End + "_" + superStringPosition_Start;
- output_super += "</span>";
- output_super +=
- "<span id='SBS_senText_" + par_guid + "_" + superStringPosition_End + '\' class="tooltip">';
- output_super += superString[super_x];
- output_super += '<span class="tooltiptext tooltip-bottom">';
- output_super +=
- "<button onclick='super_trans_modify(up_sen," +
- superStringPosition_Start +
- "," +
- par_guid +
- "," +
- language +
- ")'>▲</button>";
- output_super +=
- "<button onclick='super_trans_modify(down_sen," +
- superStringPosition_End +
- "," +
- par_guid +
- "," +
- language +
- ")'>▼</button>";
- output_super += "</span></span>";
- }
- output += output_super.replace(/SBS_/g, "PBP_"); //逐句譯id轉換為逐段id
- output = output.replace(/up_sen/g, "up_par"); //逐句譯id轉換為逐段id
- output = output.replace(/down_sen/g, "down_par"); //逐句譯id轉換為逐段id
- }
- sent_ID = "sent_" + arr_sentA_ID[par_num_last];
- var output_super_0 = "<div class=" + language_type + "_text>" + output_super + "</div>";
- if (document.getElementById(sent_ID).innerHTML.length != 0) {
- if (document.getElementById(sent_ID).innerHTML == gLocal.gui.sent_trans) {
- document.getElementById(sent_ID).innerHTML = output_super_0; //把逐句譯內容根據相應ID號寫入
- } else {
- document.getElementById(sent_ID).innerHTML += output_super_0; //把逐句譯內容根據相應ID號寫入
- }
- }
- }
- return output;
- }
- function super_trans_modify(updown, superStringPosition, par_guid, language) {
- //未完成
- var prev_super_info = getPrevNextTrans_Guid(prev, par_guid);
- var next_super_info = getPrevNextTrans_Guid(next, par_guid);
- var curr_super_info = getPrevNextTrans_Guid(curr, par_guid);
- var new_prev_super_info = new Object();
- var new_next_super_info = new Object();
- var new_curr_super_info = new Object();
- switch (updown) {
- case "up_par":
- new_prev_super_info.GUID = prev_super_info.GUID;
- new_prev_super_info.senText =
- prev_super_info.senText + curr_super_info.senText.replace(/#/g, "").slice(0, superStringPosition);
- var new_senText_array = translate_super_split(new_prev_super_info.senText, language);
- new_prev_super_info.senA = "0_";
- for (new_senText_array_i in new_senText_array) {
- new_prev_super_info.senA += new_senText_array[new_senText_array_i].length;
- new_prev_super_info.senA += "#" + new_senText_array[new_senText_array_i].length + "_";
- if (new_senText_array_i == new_senText_array.length - 1) {
- new_prev_super_info.senA += new_senText_array[new_senText_array_i].length;
- break;
- }
- }
- new_prev_super_info.senA = (new_prev_super_info.senA + "#").replace(/##/g, "");
- new_curr_super_info.GUID = curr_super_info.GUID;
- new_curr_super_info.senText = curr_super_info.senText.replace(/#/g, "").slice(superStringPosition);
- var new_senText_array = translate_super_split(new_curr_super_info.senText, language);
- new_curr_super_info.senA = "";
- for (new_senText_array_i in new_senText_array) {
- new_curr_super_info.senA += new_senText_array[new_senText_array_i].length;
- new_curr_super_info.senA += "#" + new_senText_array[new_senText_array_i].length + "_";
- if (new_senText_array_i == new_senText_array.length - 1) {
- new_curr_super_info.senA += new_senText_array[new_senText_array_i].length;
- break;
- }
- }
- new_curr_super_info.senA = (new_curr_super_info.senA + "#").replace(/##/g, "");
- break;
- case "down_par":
- if (par_num > max_par_num) {
- //无效通知
- }
- break;
- }
- }
- function getPrevNextTrans_Guid(direction, par_guid) {
- var allBlock = gXmlBookDataBody.getElementsByTagName("block"); //得到全局block
- var prev_super_info = new Object();
- var next_super_info = new Object();
- var curr_super_info = new Object();
- var super_arr_xmlParInfo = new Array();
- var super_arr_xmlParData = new Array();
- var super_arr_xmlParAllsen = new Array();
- var super_arr_xmlParAllloc = new Array();
- curr_super_info.GUID = par_guid;
- for (var super_iBlock = 0; super_iBlock < allBlock.length; super_iBlock++) {
- if (super_iBlock == "length") {
- break;
- }
- var elementBlock = allBlock[super_iBlock]; //得到其中一段的數據
- if (elementBlock.getElementsByTagName("sen").length != 0) {
- super_arr_xmlParInfo.push(elementBlock.getElementsByTagName("info")[0]);
- super_arr_xmlParData.push(elementBlock.getElementsByTagName("data")[0]);
- }
- }
- if (elementBlock.getElementsByTagName("sen").length != 0) {
- for (var super_iData in super_arr_xmlParData) {
- var super_xmlParAll_Sen = "";
- var super_xmlParAll_Loc = "";
- for (var super_iSen = 0; super_iSen < super_arr_xmlParData[super_iData].childNodes.length; super_iSen++) {
- var super_xmlParData_Detail = super_arr_xmlParData[super_iData].childNodes[super_iSen];
- super_xmlParAll_Sen += super_xmlParData_Detail.getElementsByTagName("text")[0].innerHTML + "#";
- super_xmlParAll_Loc += super_xmlParData_Detail.getElementsByTagName("a")[0].innerHTML + "#";
- }
- super_xmlParAll_Sen = (super_xmlParAll_Sen + "#").replace(/##/g, "");
- super_xmlParAll_Loc = (super_xmlParAll_Loc + "#").replace(/##/g, "");
- super_arr_xmlParAllsen.push(super_xmlParAll_Sen);
- super_arr_xmlParAllloc.push(super_xmlParAll_Loc);
- }
- for (var super_iBlock = 0; super_iBlock < super_arr_xmlParInfo.length; super_iBlock++) {
- if (super_iBlock == "length") {
- break;
- }
- var super_GUID = getNodeText(super_arr_xmlParInfo[super_iBlock], "id"); //得到guid
- prev_super_info.senText = "";
- prev_super_info.senA = "";
- curr_super_info.senText = super_arr_xmlParAllsen[super_iBlock];
- curr_super_info.senA = super_arr_xmlParAllloc[super_iBlock];
- next_super_info.senText = "";
- next_super_info.senA = "";
- if (super_GUID == par_guid && super_iBlock == 0) {
- prev_super_info.GUID = ""; //前一個為空
- next_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock + 1], "id"); //得到後一個guid
- next_super_info.senText = super_arr_xmlParAllsen[super_iBlock + 1];
- next_super_info.senA = super_arr_xmlParAllloc[super_iBlock + 1]; //根據譯文數組得到錨點
- break;
- } else if (super_GUID == par_guid && super_iBlock > 0 && super_iBlock < super_arr_xmlParAllsen.length - 1) {
- prev_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock - 1], "id"); //得到前一個guid
- next_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock + 1], "id"); //得到後一個guid
- prev_super_info.senText = super_arr_xmlParAllsen[super_iBlock - 1];
- prev_super_info.senA = super_arr_xmlParAllloc[super_iBlock - 1]; //根據譯文數組得到錨點
- next_super_info.senText = super_arr_xmlParAllsen[super_iBlock + 1];
- next_super_info.senA = super_arr_xmlParAllloc[super_iBlock + 1]; //根據譯文數組得到錨點
- break;
- } else if (super_GUID == par_guid && super_iBlock == super_arr_xmlParAllsen.length - 1) {
- prev_super_info.GUID = getNodeText(super_arr_xmlParInfo[super_iBlock - 1], "id"); //得到前一個guid
- next_super_info.GUID = "";
- prev_super_info.senText = super_arr_xmlParAllsen[super_iBlock - 1];
- prev_super_info.senA = super_arr_xmlParAllloc[super_iBlock - 1]; //根據譯文數組得到錨點
- break;
- }
- }
- } else {
- prev_super_info.GUID = "";
- prev_super_info.senText = "";
- prev_super_info.senA = "";
- curr_super_info.GUID = "";
- curr_super_info.senText = "";
- curr_super_info.senA = "";
- next_super_info.GUID = "";
- next_super_info.senText = "";
- next_super_info.senA = "";
- }
- switch (direction) {
- case "next":
- return next_super_info;
- break;
- case "curr":
- return curr_super_info;
- break;
- case "prev":
- return prev_super_info;
- break;
- }
- }
- function translate_split(inString, language) {
- var newString = "";
- var arrString = new Object();
- var language_type = "";
- if (
- language.toLowerCase() == "tw" ||
- language.toLowerCase() == "zh" ||
- language.toLowerCase() == "sc" ||
- language.toLowerCase() == "tc"
- ) {
- language_type = "ZH";
- } else {
- language_type = "EN";
- }
- arrString.language_type = language_type.toLowerCase();
- switch (language_type) {
- case "ZH":
- for (var i_cntransplit in cn_transplit) {
- newString = inString;
- eval("newString = newString.replace(" + cn_transplit[i_cntransplit] + ")");
- }
- /*newString = inString.replace(/。/g,"。#");
- newString = newString.replace(/;/g,";");
- newString = newString.replace(/ /g,"");
- newString = newString.replace(/;/g,";#");
- newString = newString.replace(/?/g,"?#");
- newString = newString.replace(/”“/g,"”#“");
- newString = newString.replace(/’‘/g,"’#‘");
- newString = newString.replace(/。#”/g,"。”#");
- newString = newString.replace(/?#”/g,"?”#");
- newString = newString.replace(/?“/g,"?#“");
- newString = newString.replace(/:“/g,":#“");
- newString = newString.replace(/:「/g,":#「");
- newString = newString.replace(/!#’/g,"!’#");
- newString = newString.replace(/。#’/g,"。’#");
- newString = newString.replace(/?#’/g,"?’#");
- newString = newString.replace(/?‘/g,"?#‘");
- newString = newString.replace(/:‘/g,":#‘");
- newString = newString.replace(/##/g,"#");
- */
- arrString.string = newString.split("#");
- break;
- case "EN":
- newString = inString;
- for (var i_entransplit in en_transplit) {
- newString = inString;
- eval("newString = newString.replace(" + en_transplit[i_entransplit] + ")");
- }
- /*newString = inString.replace(/\./g,"\.#");
- newString = newString.replace(/;/g,";");
- newString = newString.replace(/;/g,";#");
- newString = newString.replace(/\?/g,"?#");
- newString = newString.replace(/\"\"/g,"”#“");
- newString = newString.replace(/.\'\'/g,".”");
- newString = newString.replace(/.#\"/g,".”#");
- newString = newString.replace(/\?#\"/g,"?”#");
- newString = newString.replace(/\?“/g,"?#“");
- newString = newString.replace(/,\"/g,",#“");
- newString = newString.replace(/!#\'/g,"!’#");
- newString = newString.replace(/.#\'/g,".’#");
- newString = newString.replace(/?#’/g,"?’#");
- newString = newString.replace(/?‘/g,"?#‘");
- newString = newString.replace(/##/g,"#");
- */
- arrString.string = newString.split("#");
- break;
- }
- return arrString;
- // body...
- }
- function translate_super_split(inString) {
- var newString = inString;
- var arrString = new Object();
- var language_type = "";
- if (
- language.toLowerCase() == "tw" ||
- language.toLowerCase() == "zh" ||
- language.toLowerCase() == "sc" ||
- language.toLowerCase() == "tc"
- ) {
- language_type = "ZH";
- } else {
- language_type = "EN";
- }
- arrString.language_type = language_type.toLowerCase();
- switch (language_type) {
- case "ZH":
- newString = newString.replace(/,/g, ",#");
- newString = newString.replace(/!/g, "!#");
- newString = newString.replace(/!#”/g, "!”#");
- newString = newString.replace(/!#’/g, "!’#");
- arrString.string = newString.split("#");
- break;
- case "EN":
- newString = newString.replace(/,/g, ",#");
- newString = newString.replace(/!/g, "!#");
- arrString.string = newString.split("#");
- break;
- }
- return arrString;
- // body...
- }
- function renderNoteParBlockInner(elementBlock) {
- var output = "";
- xmlParInfo = elementBlock.getElementsByTagName("info")[0];
- book = getNodeText(xmlParInfo, "book");
- paragraph = getNodeText(xmlParInfo, "paragraph");
- bId = getNodeText(xmlParInfo, "id");
- type = getNodeText(xmlParInfo, "type");
- var allSen = elementBlock.getElementsByTagName("sen");
- output +=
- '<button type="button" class="edit_note_button imgbutton" onclick="editor_note_edit(\'' +
- bId +
- "')\"><svg class='icon' style='fill: var(--detail-color);'><use xlink:href='svg/icon.svg#ic_mode_edit'></use></svg></button>";
- for (iSen = 0; iSen < allSen.length; iSen++) {
- senText = getNodeText(allSen[iSen], "text");
- senA = getNodeText(allSen[iSen], "a");
- output += '<span id="note_sen_' + bId + "_" + iSen + '" class="note_sen">';
- output += senText;
- output += "</span>";
- }
- return output;
- }
- function renderHeadingBlockInner(elementBlock) {
- var output = "";
- xmlParInfo = elementBlock.getElementsByTagName("info")[0];
- book = getNodeText(xmlParInfo, "book");
- paragraph = getNodeText(xmlParInfo, "paragraph");
- bId = getNodeText(xmlParInfo, "id");
- type = getNodeText(xmlParInfo, "type");
- var headingData = elementBlock.getElementsByTagName("data")[0];
- headingText = getNodeText(headingData, "text");
- output += '<span id="id_heading_text_' + bId + '">' + headingText + "</span>";
- output +=
- '<button type="button" class="edit_tool imgbutton" onclick="editor_heading_edit(\'' +
- bId +
- "')\"><svg class='icon' style='fill: var(--detail-color);'><use xlink:href='svg/icon.svg#ic_mode_edit'></use></svg></button>";
- return output;
- }
- function updateWordParBlockInnerAll() {
- var xBlock = gXmlBookDataBody.getElementsByTagName("block");
- for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
- xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
- xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
- mId = getNodeText(xmlParInfo, "id");
- type = getNodeText(xmlParInfo, "type");
- if ((type = "wbw")) {
- updateWordParBlockInner(xBlock[iBlock]);
- }
- }
- }
- function updateWordParBlockInner(elementBlock) {
- var xmlParInfo = elementBlock.getElementsByTagName("info")[0];
- var blockId = getNodeText(xmlParInfo, "id");
- var wbwblock = document.getElementById("id_wbw_" + blockId);
- if (wbwblock) {
- wbwblock.innerHTML = renderWordParBlockInner(elementBlock);
- word_mouse_event();
- note_refresh_new();
- }
- }
- function renderNoteShell(elementBlock) {
- let output = "";
- let allWord = elementBlock.getElementsByTagName("word");
- for (iWord = 0; iWord < allWord.length; iWord++) {
- let wID = getNodeText(allWord[iWord], "id");
- output += '<div id="wn_' + wID + '">';
- output += '<div id="wnn_' + wID + '"></div>';
- output += '<div id="wnr_' + wID + '"></div>';
- output += '<div id="wnc_' + wID + '"></div>';
- output += "</div>";
- }
- return output;
- }
- //句子上面的工具条
- function render_sent_tool_bar(elementBlock, begin) {
- let output = "";
- let axmlParInfo = elementBlock.getElementsByTagName("info")[0];
- let abook = getNodeText(axmlParInfo, "book");
- let aparagraph = getNodeText(axmlParInfo, "paragraph");
- let xallWord = elementBlock.getElementsByTagName("word");
- let iBegin = -1;
- let iEnd = -1;
- let iWordId = 0;
- for (let i = 0; i < xallWord.length; i++) {
- let aID = getNodeText(xallWord[i], "id");
- let aEnter = getNodeText(xallWord[i], "enter");
- let arrId = aID.split("-");
- iWordId = parseInt(arrId[2]);
- if (iWordId > begin && iBegin < 0) {
- iBegin = iWordId;
- }
- if (iWordId > begin && aEnter == "1") {
- //句子末尾
- iEnd = iWordId;
- break;
- }
- }
- if (iEnd == -1) {
- iEnd = iWordId;
- }
- output += "<div class='sent_wbw_trans_bar'>";
- let sentIdString = abook + "-" + aparagraph + "-" + iBegin + "-" + iEnd;
- let sentIdStringLink = "{{" + sentIdString + "}}";
- let sentReaderLink = "";
- if (_display_sbs == 0) {
- //逐段模式
- sentReaderLink = "https://www.wikipali.org/app/reader/?view=para&book=" + abook + "¶=" + aparagraph;
- } else {
- //逐句模式
- sentReaderLink =
- "https://www.wikipali.org/app/reader/?view=sent&book=" +
- abook +
- "¶=" +
- aparagraph +
- "&begin=" +
- iBegin +
- "&end=" +
- iEnd;
- }
- output += "<span style='flex: 7;display: flex;'>";
- output += "<div style='background-color: silver;'>";
- //句子编号
- output += "<span style='font-size: large; font-weight: bolder;' title=" + gLocal.gui.text_num + ">";
- output += sentIdString;
- output += "</span>";
- //功能按钮
- //拷贝到剪贴板
- output +=
- "<button class='icon_btn' onclick=\"copy_to_clipboard('" +
- sentIdStringLink +
- "')\" title=" +
- gLocal.gui.copy_to_clipboard +
- ">";
- output +=
- '<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>';
- output += "</button>";
- //在阅读器中打开
- let reader_open_link = "";
- if (_display_sbs == 0) {
- //逐段模式
- reader_open_link = "../reader/?view=para&book=" + abook + "¶=" + aparagraph;
- } else {
- //逐句模式
- reader_open_link =
- "../reader/?view=sent&book=" + abook + "¶=" + aparagraph + "&begin=" + iBegin + "&end=" + iEnd;
- }
- output +=
- "<button class='icon_btn' onclick=\"window.open('" +
- reader_open_link +
- "')\" target='_blank' title='" +
- gLocal.gui.scan_in_reader +
- "'>";
- output +=
- '<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>';
- output += "</button>";
- //关系图
- output +=
- "<button class='icon_btn' title='" +
- gLocal.gui.relational_map +
- "' class='rel_map' onclick=\"sent_show_rel_map('" +
- abook +
- "','" +
- aparagraph +
- "','" +
- iBegin +
- "','" +
- iEnd +
- "')\">" +
- '<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>' +
- "</button>";
- //拷贝词意到剪贴板
- output +=
- "<button class='icon_btn' title='" +
- gLocal.gui.form_sent +
- "' class='rel_map' onclick=\"sent_copy_meaning('" +
- abook +
- "','" +
- aparagraph +
- "','" +
- iBegin +
- "','" +
- iEnd +
- "')\">" +
- '<svg style="fill: var(--link-color);" t="1611985739555" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6173" width="200" height="200"><path d="M423.198 640a83.84 83.84 0 0 1-64-28.8 259.84 259.84 0 0 1-26.88-308.48L441.118 128a261.12 261.12 0 1 1 448 272l-35.2 57.6a83.84 83.84 0 1 1-145.92-90.24l35.2-57.6a92.8 92.8 0 0 0-158.72-96.64l-107.52 176.64a92.8 92.8 0 0 0 9.6 109.44 83.84 83.84 0 0 1-64 139.52z" p-id="6174"></path><path d="M357.918 1024a261.12 261.12 0 0 1-222.72-397.44l31.36-50.56a83.84 83.84 0 1 1 144 87.68l-31.36 51.2a92.8 92.8 0 0 0 30.72 128 91.52 91.52 0 0 0 70.4 10.88 92.16 92.16 0 0 0 57.6-41.6l107.52-177.92a93.44 93.44 0 0 0-6.4-105.6 83.84 83.84 0 1 1 134.4-103.68 262.4 262.4 0 0 1 17.28 296.96L581.278 896a259.84 259.84 0 0 1-163.84 120.32 263.68 263.68 0 0 1-59.52 7.68z" p-id="6175"></path></svg>' +
- "</button>";
- //功能按钮结束
- output += "</div>";
- output += "<guide gid='sent_func' style='margin:unset;'></guide>";
- output += "</span>";
- output += "<span style='flex: 3;'><guide gid='sent_trans' style='margin:unset;'></guide></span>";
- output += "</div>";
- return output;
- }
- var arr_par_sent_num = new Array();
- var g_arr_Para_ID = new Array();
- function renderWordParBlockInner(elementBlock) {
- var output = "<div style='display:block;width:100%'>";
- var Note_Mark = 0;
- var sent_gramma_i = 0;
- var word_length_count = 0;
- var sent_num = 0;
- var arr_Para_ID = new Array();
- let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
- let book = getNodeText(xmlParInfo, "book");
- let paragraph = getNodeText(xmlParInfo, "paragraph");
- let par_num = paragraph - 1;
- let type = getNodeText(xmlParInfo, "type");
- let allWord = elementBlock.getElementsByTagName("word");
- output += "<div class='sent_wbw_trans'>";
- output += render_sent_tool_bar(elementBlock, 0);
- output += "<div class='sent_wbw'>";
- let sent_begin = 0;
- let wID;
- let word_id;
- for (let iWord = 0; iWord < allWord.length; iWord++) {
- wID = getNodeText(allWord[iWord], "id");
- let wPali = getNodeText(allWord[iWord], "pali");
- let wReal = getNodeText(allWord[iWord], "real");
- let wType = getNodeText(allWord[iWord], "type");
- let wGramma = getNodeText(allWord[iWord], "gramma");
- let wCase = getNodeText(allWord[iWord], "case");
- let wMean = getNodeText(allWord[iWord], "mean");
- let wParent = getNodeText(allWord[iWord], "parent");
- let wUn = getNodeText(allWord[iWord], "un");
- let wStyle = getNodeText(allWord[iWord], "style");
- let wEnter = getNodeText(allWord[iWord], "enter");
- if ((wType == "" || wType == "?") && wCase != "") {
- wType = wCase.split("#")[0];
- }
- word_id = parseInt(wID.split("-")[2]);
- if (sent_begin == 0) {
- sent_begin = word_id;
- }
- //渲染单词块
- //word div class
- let strMouseEvent = ' onmouseover="on_word_mouse_enter()" onmouseout="on_word_mouse_leave()"';
- if (wType == ".ctl." && wGramma == ".a.") {
- //output += "<div><a name='"+wPali+"'></a></div>";
- output +=
- '<div id="wb' +
- wID +
- "\" class='ctrl sent_gramma_" +
- (sent_gramma_i % 3) +
- "'> <a name='" +
- wPali +
- "'></a>";
- } else if (Note_Mark == 1) {
- output +=
- '<div id="wb' +
- wID +
- "\" class='word org_note sent_gramma_" +
- (sent_gramma_i % 3) +
- "'> <a name='" +
- wPali +
- "'></a>";
- } else {
- if (wReal == "") {
- output +=
- '<div id="wb' + wID + '" class="word_punc un_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //符號
- } else {
- if (wType == ".un.") {
- output +=
- '<div id="wb' + wID + '" class="word un_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //粘音詞
- } else if (wType == ".comp.") {
- output +=
- '<div id="wb' + wID + '" class="word comp_parent sent_gramma_' + (sent_gramma_i % 3) + '" >'; //複合詞
- } else {
- output += '<div id="wb' + wID + '" class="word sent_gramma_' + (sent_gramma_i % 3) + '" >'; //普通
- }
- }
- }
- //head div class
- output += " <div id='ws_" + wID + "' class='word_head_shell' >";
- if (wUn.length > 0) {
- output += " <div class='word_head un_pali' id=\"whead_" + wID + '">';
- } else {
- output += " <div class='word_head' id=\"whead_" + wID + '">';
- }
- output += renderWordHeadInner(allWord[iWord]);
- output += " </div>";
- output += " </div>";
- output += ' <div id="detail' + wID + '" class="wbody">';
- output += renderWordBodyInner(allWord[iWord]);
- output += " </div>";
- output += "</div>";
- //渲染单词块结束
- word_length_count += wPali.length;
- if (iWord >= 1) {
- var pre_pali_spell = getNodeText(allWord[iWord - 1], "pali");
- var pre_pali_type = getNodeText(allWord[iWord - 1], "type");
- var pre_pali_Gramma = getNodeText(allWord[iWord - 1], "gramma");
- var pre_pali_Case = getNodeText(allWord[iWord - 1], "case");
- if (pre_pali_type == "" && pre_pali_Case != "") {
- pre_pali_type = pre_pali_Case.split("#")[0];
- }
- if (pre_pali_Case != "" && pre_pali_Case.lastIndexOf("$") != -1) {
- var pre_case_array = pre_pali_Case.split("$");
- pre_pali_Case = pre_case_array[pre_case_array.length - 1];
- }
- }
- if (iWord + 2 <= allWord.length) {
- var next_pali_spell = getNodeText(allWord[iWord + 1], "pali");
- var next_pali_type = getNodeText(allWord[iWord + 1], "type");
- var next_pali_Gramma = getNodeText(allWord[iWord + 1], "gramma");
- var next_pali_Case = getNodeText(allWord[iWord + 1], "case");
- if (next_pali_type == "" && next_pali_Case != "") {
- next_pali_type = next_pali_Case.split("#")[0];
- }
- if (next_pali_Case != "" && next_pali_Case.lastIndexOf("$") != -1) {
- var next_case_array = next_pali_Case.split("$");
- next_pali_Case = next_case_array[next_case_array.length - 1];
- }
- }
- if (next_pali_spell == "(") {
- Note_Mark = 1;
- } else if (pre_pali_spell == ")" && Note_Mark == 1) {
- Note_Mark = 0;
- } else {
- }
- if (wEnter == 1) {
- //句子末尾
- var sent_ID = "sent_" + par_num + "_" + sent_num;
- if (_display_sbs == 1) {
- //逐句显示模式
- output += "</div>"; //逐句逐词译块结束
- //逐句翻译块开始
- output += "<div id='sent_div_" + wID + "' class='translate_sent'>";
- output += "<div class='translate_sent_head'>";
- output += "<div class='translate_sent_head_toolbar' style='display:none;'>";
- output += "<span></span>";
- output +=
- "<span onclick=\"show_tran_net('" +
- book +
- "','" +
- paragraph +
- "','" +
- sent_begin +
- "','" +
- word_id +
- "')\"><span id='' class=\"word_msg\">issue</span></span>";
- //
- output += "</div>";
- output += "<div class='translate_sent_head_content'>";
- //句子预览
- output += render_tran_sent_block(book, paragraph, sent_begin, word_id, 0, true);
- if (_my_channal != null) {
- for (const iterator of _my_channal) {
- if (iterator.status > 0) {
- output += render_tran_sent_block(book, paragraph, sent_begin, word_id, iterator.id, false);
- }
- }
- }
- //句子预览结束
- output += "</div>";
- output +=
- "<div class='trans_text_content' pcds='sent-net' book='" +
- book +
- "' para='" +
- paragraph +
- "' begin='" +
- sent_begin +
- "' end=''>";
- output += "</div>";
- output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
- output += "</div>";
- output += "</div>";
- output += "</div>";
- //逐句翻译块内容结束
- output += "<div class='translate_sent_foot'>";
- output += "</div>";
- output += "</div>";
- //逐句翻译块结束
- output += "</div>"; //逐句块结束
- sent_begin = word_id + 1;
- //下一个逐句块开始
- output += "<div class='sent_wbw_trans'>";
- //output += output += render_sent_tool_bar(elementBlock,word_id);
- let nextBegin = word_id + 1;
- let nextEnd = 0;
- for (let j = iWord + 1; j < allWord.length; j++) {
- let aID = getNodeText(allWord[j], "id");
- let aEnter = getNodeText(allWord[j], "enter");
- let arrId = aID.split("-");
- iWordId = parseInt(arrId[2]);
- if (aEnter == 1) {
- nextEnd = iWordId;
- break;
- }
- }
- if (nextEnd == 0) {
- nextEnd = iWordId;
- }
- output += "<div class='sent_wbw_trans_bar'>";
- let sentIdString = book + "-" + paragraph + "-" + nextBegin + "-" + nextEnd;
- let sentIdStringLink = "{{" + sentIdString + "}}";
- output +=
- "<span style='flex: 7;display: flex;'><div style='background-color: silver;'><span style='font-size: large; font-weight: bolder;' title=" +
- gLocal.gui.text_num +
- ">" +
- sentIdString +
- "</span><button class='icon_btn' onclick=\"copy_to_clipboard('" +
- sentIdStringLink +
- "')\" title=" +
- gLocal.gui.copy_to_clipboard +
- ">";
- output +=
- '<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>';
- output += "</button>";
- output +=
- "<button class='icon_btn' onclick=\"window.open('../reader/?view=sent&book=" +
- book +
- "¶=" +
- paragraph +
- "&begin=" +
- nextBegin +
- "&end=" +
- nextEnd +
- "')\" target='_blank' title='" +
- gLocal.gui.scan_in_reader +
- "'>";
- output +=
- '<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>';
- output += "</button>";
- output +=
- "<button class='icon_btn' title='" +
- gLocal.gui.relational_map +
- "' class='rel_map' onclick=\"sent_show_rel_map('" +
- book +
- "','" +
- paragraph +
- "','" +
- nextBegin +
- "','" +
- nextEnd +
- "')\">" +
- '<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>' +
- "</button>";
- //拷贝词意到剪贴板
- output +=
- "<button class='icon_btn' title='" +
- gLocal.gui.form_sent +
- "' class='rel_map' onclick=\"sent_copy_meaning('" +
- book +
- "','" +
- paragraph +
- "','" +
- nextBegin +
- "','" +
- nextEnd +
- "')\">" +
- '<svg style="fill: var(--link-color);" t="1611985739555" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6173" width="200" height="200"><path d="M423.198 640a83.84 83.84 0 0 1-64-28.8 259.84 259.84 0 0 1-26.88-308.48L441.118 128a261.12 261.12 0 1 1 448 272l-35.2 57.6a83.84 83.84 0 1 1-145.92-90.24l35.2-57.6a92.8 92.8 0 0 0-158.72-96.64l-107.52 176.64a92.8 92.8 0 0 0 9.6 109.44 83.84 83.84 0 0 1-64 139.52z" p-id="6174"></path><path d="M357.918 1024a261.12 261.12 0 0 1-222.72-397.44l31.36-50.56a83.84 83.84 0 1 1 144 87.68l-31.36 51.2a92.8 92.8 0 0 0 30.72 128 91.52 91.52 0 0 0 70.4 10.88 92.16 92.16 0 0 0 57.6-41.6l107.52-177.92a93.44 93.44 0 0 0-6.4-105.6 83.84 83.84 0 1 1 134.4-103.68 262.4 262.4 0 0 1 17.28 296.96L581.278 896a259.84 259.84 0 0 1-163.84 120.32 263.68 263.68 0 0 1-59.52 7.68z" p-id="6175"></path></svg>' +
- "</button>";
- output += "</div>";
- output += "<guide gid='sent_func' style='margin:unset;'></guide>";
- output += "</span>";
- output += "<span style='flex: 3;'><guide gid='sent_trans' style='margin:unset;'></guide></span>";
- output += "</div>";
- output += "<div class='sent_wbw'>";
- }
- sent_num += 1;
- word_length_count = 0;
- sent_gramma_i = 0;
- arr_Para_ID.push(wID);
- }
- } //循環結束
- output += "</div>";
- //逐句翻译块开始
- output += "<div id='sent_div_" + wID + "' class='translate_sent'>";
- output += "<div class='translate_sent_head'>";
- output += "<div class='translate_sent_head_toolbar'>";
- output += "<span></span>";
- output +=
- "<span onclick=\"show_tran_net('" +
- book +
- "','" +
- paragraph +
- "','" +
- sent_begin +
- "','" +
- word_id +
- "')\"><span id='' class=\"word_msg\">issue</span></span>";
- output += "</div>";
- output += "<div class='translate_sent_head_content'>";
- //逐句译文开始
- output += render_tran_sent_block(book, paragraph, sent_begin, word_id, 0, true);
- if (_my_channal != null) {
- for (const iterator of _my_channal) {
- if (iterator.status > 0) {
- output += render_tran_sent_block(book, paragraph, sent_begin, word_id, iterator.id, false);
- }
- }
- }
- output += "</div>";
- output += "<div id='sent_" + wID + "' class='translate_sent_content'>";
- output += "</div>";
- //逐句翻译块内容结束
- output += "<div class='translate_sent_foot'>";
- output += "</div>";
- output += "</div>";
- //逐句翻译块结束
- output += "</div>";
- var sent_ID = "sent_" + par_num + "_" + sent_num;
- arr_Para_ID.push(wID);
- arr_par_sent_num.push(sent_ID);
- g_arr_Para_ID[par_num] = arr_Para_ID;
- return output;
- }
- //根据relation 绘制关系图
- function sent_copy_meaning(book, para, begin, end) {
- let wordId = 0;
- let output = "";
- for (wordId = parseInt(begin); wordId <= parseInt(end); wordId++) {
- output += doc_word("#p" + book + "-" + para + "-" + wordId).val("mean");
- }
- copy_to_clipboard(output);
- }
- //根据relation 绘制关系图
- function sent_show_rel_map(book, para, begin, end) {
- let wordId = 0;
- let memind = "graph LR\n";
- let pali_text = "";
- for (wordId = parseInt(begin); wordId <= parseInt(end); wordId++) {
- let rel = doc_word("#p" + book + "-" + para + "-" + wordId).val("rela");
- let pali = doc_word("#p" + book + "-" + para + "-" + wordId).val("real");
- let type = doc_word("#p" + book + "-" + para + "-" + wordId).val("type");
- if (type != ".ctl.") {
- pali_text += pali + " ";
- }
- let wid = "p" + book + "-" + para + "-" + wordId;
- if (rel != "") {
- let relaData = JSON.parse(rel);
- for (const iterator of relaData) {
- let strRel = iterator.relation;
- let dest = iterator.dest_spell;
- let type = doc_word("#" + iterator.dest_id).val("case");
- if (type.indexOf(".v.") >= 0) {
- dest = iterator.dest_id + "[/" + dest + "/]";
- } else {
- dest = iterator.dest_id + "[" + dest + "]";
- }
- /*
- if (strRel.indexOf("SV") >= 0 || strRel.indexOf("-P") >= 0) {
- memind += wid + "(" + pali + ")" + " ==> |" + strRel + "|" + dest + "\n";
- } else if (strRel.indexOf("OV") >= 0 || strRel.indexOf("-S") >= 0) {
- memind += dest + " ==> |" + strRel + "|" + wid + "(" + pali + ")" + "\n";
- } else {
- }
- */
- memind += wid + "(" + pali + ")" + " -- " + strRel + " --> " + dest + "\n";
- }
- }
- }
- let graph = mermaid.render("graphDiv", memind);
- document.querySelector("#term_body_parent").innerHTML = '<div class="win_body_inner" id="term_body"></div>'; //清空之前的记录
- document.querySelector("#term_body").outerHTML =
- "<h3 style='padding: 0 1em;'>" + pali_text + "</h3>" + document.querySelector("#term_body").outerHTML;
- document.querySelector("#term_body").innerHTML = graph;
- document.querySelector("#term_win").style.display = "flex";
- document.querySelector(".win_body").style.display = "block";
- }
- //句子编辑块
- function render_tran_sent_block(book, para, begin, end, channal = 0, readonly = true) {
- let usent_count = _user_sent_buffer.getSentNum(book, para, begin, end);
- let netSent = doc_msg_get_trans(book, para, begin, end);
- let sender = "";
- let sChannalName = "";
- let sent_text = "";
- let sent_lang = "en";
- let objSent;
- let thischannal;
- let shell_class = "";
- if (channal == 0) {
- //百家言
- shell_class += " channel_0";
- if (netSent.length > 0) {
- sender = netSent[netSent.length - 1].sender;
- sent_text += netSent[netSent.length - 1].data.text;
- } else if (usent_count > 0) {
- sender = _user_sent_buffer.getSentText(book, para, begin, end)[0].nickname;
- sChannalName = "channal name";
- sent_text += _user_sent_buffer.getSentText(book, para, begin, end)[0].text;
- }
- } else {
- sender = "通道的名字";
- shell_class += " mychannel";
- objSent = _user_sent_buffer.getSentText(book, para, begin, end, channal);
- thischannal = channal_getById(channal);
- if (objSent == false) {
- objSent = new Object();
- objSent.text = "";
- objSent.language = thischannal.lang;
- objSent.id = "";
- objSent.tag = "[]";
- objSent.author = "{}";
- sent_text = "";
- } else {
- sent_text = objSent.text;
- }
- sent_lang = objSent.language;
- }
- let output = "";
- if (readonly == true) {
- shell_class += " readonly";
- }
- output += "<div class='trans_text_block " + shell_class + "' channel_id='" + channal + "'>";
- output += "<div class='trans_text_info' >";
- if (channal == 0) {
- output += "<span class='author'>" + sender + "</span>";
- } else {
- output += "<span style='width: 100%;display: contents;'>";
- output += "<span>";
- if (thischannal) {
- output += thischannal.name + "-<b>" + thischannal.lang + "<b>@";
- if (thischannal.username == getCookie("username")) {
- output += gLocal.gui.your;
- } else {
- output += thischannal.nickname;
- }
- } else {
- output += "未知的频道名";
- }
- output += "</span>";
- output +=
- "<span style='margin-left: auto;' class='send_status' id='send_" +
- book +
- "_" +
- para +
- "_" +
- begin +
- "_" +
- end +
- "_" +
- channal +
- "'></span>";
- }
- output += "</span><span></span>";
- output += "</div>";
- let id = "tran_pre_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal;
- output += "<div class='trans_text_content' tid = '" + id;
- if (channal == 0) {
- output += "' pcds='sent-net-all' ";
- } else {
- output += "' pcds='sent-net' ";
- }
- output +=
- " book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' channal='" + channal + "'>";
- if (readonly) {
- output += note_init(term_std_str_to_tran(sent_text, channal, getCookie("userid"), sent_lang));
- } else {
- output += "<span id='" + id + "' ";
- output += "onclick=\"sent_edit_click('";
- output += book + "','" + para + "','" + begin + "','" + end + "','" + channal + "',)\">";
- if (objSent.text == null || objSent.text == "") {
- output += "<span style='color:gray;'>";
- output += "<svg class='icon' style='fill: var(--detail-color);'>";
- output += "<use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_mode_edit'>";
- output += "</span>";
- } else {
- output += note_init(term_std_str_to_tran(objSent.text, channal, getCookie("userid"), sent_lang));
- }
- output += "</span>";
- }
- output += "</div>";
- //句子预览结束
- //编辑框开始
- if (readonly == false) {
- output += "<div style='display:none;'>";
- let id = book + "_" + para + "_" + begin + "_" + end + "_" + channal;
- output += "<textarea id='trans_sent_edit_" + id + "' ";
- output += " onkeyup = \"updateTranslationPreview('" + id + "',this)\" ";
- output +=
- " onchange=\"trans_text_save('" +
- book +
- "','" +
- para +
- "','" +
- begin +
- "','" +
- end +
- "','" +
- channal +
- "')\"";
- output += "class='trans_sent_edit' style='background-color: #f8f8fa;color: black;border-color: silver;' ";
- output += "sent_id='" + objSent.id + "' ";
- output += "book='" + book + "' para='" + para + "' begin='" + begin + "' end='" + end + "' ";
- output +=
- " channal='" +
- channal +
- "' author='" +
- objSent.author +
- "' lang='" +
- objSent.language +
- "' tag='" +
- objSent.tag +
- "' >";
- output += objSent.text;
- output += "</textarea>";
- output += "<div class='trans_text_info' style='justify-content: flex-end;'>";
- output += "<span></span>";
- output += "<button class='icon_btn' ";
- output +=
- "onclick=\"trans_text_save('" +
- book +
- "','" +
- para +
- "','" +
- begin +
- "','" +
- end +
- "','" +
- channal +
- "')\" ";
- output +=
- "title=" +
- gLocal.gui.draft +
- ">" +
- '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#ic_save"></use></svg>';
- output += "</button>";
- output += "<button class='icon_btn' ";
- output +=
- "onclick=\"trans_text_send('" +
- book +
- "','" +
- para +
- "','" +
- begin +
- "','" +
- end +
- "','" +
- channal +
- "')\"";
- output +=
- " title=" +
- gLocal.gui.send +
- " disabled>" +
- '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="svg/icon.svg#send_by_paper_plane"></use></svg>';
- output += "</button>";
- output += "</div>";
- output += "</div>";
- }
- if (readonly) {
- output += "<div class='trans_text_info'>" + "<span></span>" + "<span><span class='tools'>";
- output +=
- "<button class='icon_btn' title=" +
- gLocal.gui.accept_copy +
- ">" +
- "<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>" +
- "</button>";
- if (channal == 0) {
- //百家言 显示更多按钮
- output +=
- "<button class='icon_btn' onclick=\"show_tran_net('" +
- book +
- "','" +
- para +
- "','" +
- begin +
- "','" +
- end +
- "')\" title=" +
- gLocal.gui.message +
- ">" +
- '<svg class="icon" style="fill: var(--link-color); height: 2em; width: 2em;"><use xlink:href="plugin/system_message/icon.svg#icon_message"></use></svg>' +
- "</button>";
- }
- output += "</span><span>" + usent_count + "</span></span>";
- output += "</div>";
- }
- output += "</div>";
- return output;
- }
- function trans_text_save(book, para, begin, end, channal) {
- let textarea = $("#trans_sent_edit_" + book + "_" + para + "_" + begin + "_" + end + "_" + channal);
- if (textarea) {
- let objsent = new Object();
- objsent.id = textarea.attr("sent_id");
- objsent.book = book;
- objsent.paragraph = para;
- objsent.begin = begin;
- objsent.end = end;
- objsent.channal = channal;
- objsent.author = textarea.attr("author");
- objsent.lang = textarea.attr("lang");
- objsent.text = textarea.val();
- _user_sent_buffer.setSent(objsent);
- }
- }
- function sent_edit_click(book, para, begin, end, channal) {
- $(".trans_sent_edit").parent().hide(200);
- $(
- ".trans_sent_edit[book='" +
- book +
- "'][para='" +
- para +
- "'][begin='" +
- begin +
- "'][end='" +
- end +
- "'][channal='" +
- channal +
- "']"
- )
- .parent()
- .show();
- }
- function magic_sentence_cut() {
- var all_sent_array = document.getElementsByClassName("sent_wbw");
- for (i_magic = 0; i_magic < all_sent_array.length; i_magic++) {
- if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1").length != 0) {
- all_sent_array[i_magic].getElementsByClassName("word sent_gramma_1")[0].className += " sent_cut";
- }
- if (all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2").length != 0) {
- all_sent_array[i_magic].getElementsByClassName("word sent_gramma_2")[0].className += " sent_cut";
- }
- }
- }
- function updataWordHeadById(wordId) {
- var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
- var iIndex = getWordIndex(wordId);
- if (iIndex >= 0) {
- $("#whead_" + wordId).html(renderWordHeadInner(xAllWord[iIndex]));
- }
- }
- function updataWordHeadByIndex(wordIndex) {
- if (wordIndex > 0) {
- let xAllWord = gXmlBookDataBody.getElementsByTagName("word");
- let wordId = getNodeText(xAllWord[wordIndex], "id");
- let obj = document.getElementById("whead_" + wordId);
- if (obj) {
- obj.innerHTML = renderWordHeadInner(xAllWord[wordIndex]);
- }
- }
- }
- function updateWordBodyById(wordId) {
- var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
- var wordIndex = getWordIndex(wordId);
- var obj = document.getElementById("detail" + wordId);
- if (obj) {
- obj.innerHTML = renderWordBodyInner(xAllWord[wordIndex]);
- }
- }
- //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
- //返回 无
- function modifyWordDetailByWordIndex(wordIndex) {
- xAllWord = gXmlBookDataBody.getElementsByTagName("word");
- wordId = getNodeText(xAllWord[wordIndex], "id");
- try {
- var sDetail = "detail" + wordId;
- var cDetail = document.getElementById(sDetail);
- if (cDetail != null) {
- cDetail.innerHTML = renderWordDetailByElement(xAllWord[wordIndex]);
- }
- } catch (error) {
- debugOutput(error);
- }
- }
- function renderWordHeadInner(element) {
- var output = "";
- var wid = getNodeText(element, "id");
- var wpali = getNodeText(element, "pali");
- var sParent = getNodeText(element, "parent");
- var wId = getNodeText(element, "id");
- var wNote = getNodeText(element, "note");
- wStyle = "v_" + getNodeText(element, "style");
- if (wStyle == "v_bld") {
- if (wpali.indexOf("{") >= 0) {
- wpali = wpali.replace("{", "<span class='v_bld'>");
- wpali = wpali.replace("}", "</span>");
- wStyle = "";
- }
- }
- if (wNote.indexOf("{{") >= 0 && wNote.indexOf("}}") >= 0) {
- wStyle += " note_ref";
- }
- if (wNote.substring(0, 6) == "=term(") {
- wStyle += " term_word_head";
- } else {
- if (sParent.length > 0) {
- if (term_lookup_my(sParent) != false) {
- wStyle += " term_my";
- } else {
- if (term_lookup_all(sParent) != null) {
- wStyle += " term_other";
- }
- }
- }
- }
- var sign_count = 0;
- var letter_count = 0;
- for (i_sign in local_sign_str) {
- if (wpali.lastIndexOf(local_sign_str[i_sign].id) != -1) {
- sign_count += 1;
- } //如果是标点或数字
- else if (wpali.lastIndexOf(local_letter_str[i_sign].id) != -1) {
- letter_count += 1;
- } //如果有字母
- }
- if (sign_count != 0 && letter_count == 0) {
- output += "<a name='w" + wId + "'>";
- } else {
- output += "<a name='w" + wId + "' onclick='on_word_click(\"" + wId + "\")'>";
- }
- if (wpali) output += '<span id="whead1_' + wid + '" class="whead paliword1 ' + wStyle + '">';
- output += wpali;
- output += "</span>";
- output += "</a>";
- if (wNote.length > 0) {
- output += '<span id="wnote_root_' + wid + '"><wnh wid="' + wid + '">[1]</wnh></span>';
- } else {
- output += '<span id="wnote_root_' + wid + '"></span>';
- }
- var newMsg = msg_word_msg_num(wid);
- if (newMsg > 0) {
- output += "<span class='word_msg' onclick=\"word_msg_counter_click('" + wid + "')\">" + newMsg + "</span>";
- }
- output += '<span id="whead2_' + wid + '" class="whead paliword2 ' + wStyle + '">';
- output += "</span>";
- return output;
- }
- function renderWordBodyInner(element) {
- return renderWordDetailByElement(element);
- }
- //新的渲染单词块函数
- function renderWordDetailByElement_edit_a(xmlElement) {
- if (xmlElement == null) {
- return "";
- }
- var wordNode = xmlElement;
- var sPali = getNodeText(wordNode, "pali");
- var sId = getNodeText(wordNode, "id");
- var sReal = getNodeText(wordNode, "real");
- var sMean = getNodeText(wordNode, "mean");
- var sOrg = getNodeText(wordNode, "org");
- var sOm = getNodeText(wordNode, "om");
- var sCase = getNodeText(wordNode, "case");
- var sType = getNodeText(wordNode, "type");
- var sGramma = getNodeText(wordNode, "gramma");
- var sParent = getNodeText(wordNode, "parent");
- var sParentGrammar = getNodeText(wordNode, "pg");
- var sParent2 = getNodeText(wordNode, "parent2");
- var sNote = getNodeText(wordNode, "note");
- var sStatus = getNodeText(wordNode, "status");
- if (sStatus == "") {
- sStatus = 0;
- }
- var wordID = sId;
- if (sCase == "") {
- sCase = sType + "#" + sGramma;
- }
- var _txtOutDetail = "";
- var _bgColor = "";
- var status_bg_color = "status_bg_color_" + sStatus;
- var _caseColor = "";
- //标点符号
- if (sReal.length <= 1) {
- _txtOutDetail += "<div>";
- /*id begin*/
- _txtOutDetail += "<div class='ID'> </div>";
- /*mean begin*/
- _txtOutDetail += "<div class='mean'> </div>";
- /*org begin*/
- _txtOutDetail += "<div class='org'> </div>";
- /*org mean begin*/
- _txtOutDetail += "<div class='om'> </div>";
- /*case begin*/
- _txtOutDetail += "<div class='case'> </div>";
- _txtOutDetail += "</div>";
- return _txtOutDetail;
- }
- var strBookMarkColor = getNodeText(wordNode, "bmc");
- if (strBookMarkColor.length > 2) {
- var icolor = strBookMarkColor.substr(-1);
- _bgColor = " class='bookmarkcolor" + icolor + "' ";
- }
- // Auto Match Begin
- if (sCase == "?" && _bgColor == "") {
- _caseColor = " class='bookmarkcolorx' ";
- }
- if (g_useMode == "read" || g_useMode == "translate") {
- _bgColor = "";
- _caseColor = "";
- if (sOrg == "?") {
- sOrg = " ";
- }
- if (sMean == "?") {
- sMean = " ";
- }
- if (sCase == "?" || sCase == "?#?") {
- sCase = " ";
- }
- }
- //编辑模式开始
- {
- /*gramma*/
- /*find in dict*/
- var arrGramma = new Array();
- var thisWord = sReal;
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (thisWord == g_DictWordList[iDict].Pali) {
- if (
- (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
- (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
- ) {
- var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
- pushNewToList(arrGramma, arrCase);
- }
- }
- }
- if (sCase == "?" || sCase == "?#?") {
- if (arrGramma.length > 0) {
- setNodeText(xmlElement, "case", arrGramma[0]);
- sCase = arrGramma[0];
- } else {
- setNodeText(xmlElement, "case", "?#?");
- sCase = "?#?";
- }
- } else {
- if (sCase.indexOf("#") == -1) {
- sCase = "?#" + sCase;
- setNodeText(xmlElement, "case", "?#" + sCase);
- }
- }
- var currType = sCase.split("#")[0];
- var currGramma = sCase.split("#")[1];
- //end gramma
- if (getNodeText(wordNode, "lock") == "true") {
- _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
- } else {
- _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
- }
- //状态颜色
- _txtOutDetail += "<div class='" + status_bg_color + "'>";
- //书签颜色
- _txtOutDetail += "<div " + _bgColor + ">";
- /*id begin*/
- /*
- _txtOutDetail += "<p class='ID'>";
- _txtOutDetail += sId + " ";
- _txtOutDetail += "</p>";
- */
- /*id end*/
- /*meaning*/
- //格位公式开始
- //去除格位公式
- var currMeaning = removeFormula(sMean);
- //currMeaning = getLocalFormulaStr(currGramma,currMeaning);
- var orgMeaning = sMean;
- //切割过长意思
- if (sReal.length < 4) {
- currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, 24));
- } else {
- currMeaning = getLocalFormulaStr(currGramma, cutString(currMeaning, sReal.length * 6));
- }
- renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
- renderMeaning = renderMeaning.replace(/}/g, "</span>");
- renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
- renderMeaning = renderMeaning.replace(/\]/g, "</span>");
- //格位公式结束
- if (sMean.length == 0) {
- renderMeaning = "<span class='word_space_holder'>meaning</span>";
- }
- //渲染下拉菜单
- _txtOutDetail += "<div class='mean'>";
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<p class='case_dropbtn' >";
- _txtOutDetail += renderMeaning;
- _txtOutDetail += "</p>";
- _txtOutDetail += "<div id='mean_" + wordID + '\' class="case_dropdown-content">';
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- //render formula menu
- arrFormula = getFormulaList(currGramma);
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- newWord = removeFormula_B(orgMeaning);
- _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>["+gLocal.gui.none+"]</a>";
- _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>["+gLocal.gui.auto+"]</a>";
- for (var i in arrFormula) {
- newWord = removeFormula_B(orgMeaning);
- newWord = arrFormula[i].replace("~", newWord);
- newWord = newWord.replace(/{/g, "[");
- newWord = newWord.replace(/}/g, "]");
- _txtOutDetail +=
- "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
- }
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div> ";
- /*end of meaning*/
- /*org begin 拆分*/
- _txtOutDetail += "<div class='org' name='w_org'>";
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<p class='case_dropbtn' >";
- let currOrg;
- if (sOrg.length == 0) {
- currOrg = "<span class='word_space_holder'>parts</span>";
- } else {
- currOrg = sOrg;
- }
- _txtOutDetail += currOrg;
- _txtOutDetail += "</p>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- _txtOutDetail += "<div id='parts_" + sId + "'>Loading</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div> ";
- /*end of factors*/
- /*part meaning begin*/
- _txtOutDetail += "<div class='om' name='w_om'>";
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<p class='case_dropbtn' >";
- sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
- if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
- var currDefualtFM = "";
- var listFactorForFactorMean = sOrg.split("+");
- for (iFactor in listFactorForFactorMean) {
- currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
- }
- currDefualtFM = currDefualtFM.replace(/" "/g, " ");
- currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
- currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
- currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
- if (currDefualtFM.slice(-1, -2) == "+") {
- currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
- }
- currOM = "[a]" + currDefualtFM;
- setNodeText(wordNode, "om", currOM);
- } else {
- currOM = sOm;
- }
- if (currOM.length == 0) {
- currOM = "<span class='word_space_holder''>part mean</span>";
- }
- _txtOutDetail += currOM;
- _txtOutDetail += "</p>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- _txtOutDetail += "<div id='partmean_" + sId + "'></div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div> ";
- /*org meaning end*/
- /*begin gramma*/
- _txtOutDetail += "<div class='case'>";
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<p class='case_dropbtn' >";
- var sLocalCase = getLocalGrammaStr(sCase);
- var mArrGramma = sCase.split("#");
- if (mArrGramma.length >= 2) {
- mType = mArrGramma[0];
- mGramma = mArrGramma[1];
- mLocalType = sLocalCase.split("#")[0];
- mLocalGramma = sLocalCase.split("#")[1];
- } else {
- mType = "";
- mGramma = mArrGramma[0];
- mLocalType = "";
- mLocalGramma = sLocalCase.split("#")[0];
- }
- if (mType != "") {
- _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
- }
- _txtOutDetail += cutString(mLocalGramma, 30);
- if (mLocalType.length + mLocalGramma.length == 0) {
- _txtOutDetail += " ";
- }
- _txtOutDetail += "</p>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- _txtOutDetail += "<div id='gramma_" + sId + "'></div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- //连读词按钮
- if (mType == ".un." || mType == ".comp.") {
- nextElement = com_get_nextsibling(xmlElement);
- if (nextElement != null) {
- //下一个元素存在
- if (getNodeText(nextElement, "un") == sId) {
- //若有孩子則显示收起按鈕
- _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
- _txtOutDetail +=
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
- _txtOutDetail += "</button>";
- var parentElement = document.getElementById("wb" + sId);
- if (parentElement) {
- parentElement.classList.add("un_parent");
- }
- } else {
- //無kid展開按鈕
- _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
- _txtOutDetail +=
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
- _txtOutDetail += "</button> ";
- }
- } else {
- //下一个元素不存在
- _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
- _txtOutDetail +=
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
- _txtOutDetail += "</button> ";
- }
- }
- //连读词按钮 结束
- //爷爷和父亲的关系 如pp
- /*
- if(wordGranfatherGramma.length>0 && wordGranfatherGramma.length<6){
- _txtOutDetail += "<span class=\"tooltip\">«"+getLocalGrammaStr(wordGranfatherGramma)+"<span class=\"tooltiptext tooltip-bottom\">"+wordGranfather+"</span>"+"</span> ";
- }
- */
- _txtOutDetail += "</div> ";
- /*end of gramma*/
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- }
- return _txtOutDetail;
- }
- function renderWordDetailByElement(xmlElement) {
- return renderWordDetailByElement_edit_a(xmlElement);
- if (xmlElement == null) {
- return "";
- }
- wordNode = xmlElement;
- var sPali = getNodeText(wordNode, "pali");
- var sId = getNodeText(wordNode, "id");
- var sReal = getNodeText(wordNode, "real");
- var sMean = getNodeText(wordNode, "mean");
- var sOrg = getNodeText(wordNode, "org");
- var sOm = getNodeText(wordNode, "om");
- var sCase = getNodeText(wordNode, "case");
- var sType = getNodeText(wordNode, "type");
- var sGramma = getNodeText(wordNode, "gramma");
- var sParent = getNodeText(wordNode, "parent");
- var sNote = getNodeText(wordNode, "note");
- wordID = sId;
- if (sCase == "") {
- sCase = sType + "#" + sGramma;
- }
- var _txtOutDetail = "";
- var _bgColor = "";
- var _caseColor = "";
- //标点符号
- if (sReal.length <= 1) {
- _txtOutDetail += "<div>";
- /*id begin*/
- _txtOutDetail += "<div class='ID'> </div>";
- /*mean begin*/
- _txtOutDetail += "<div class='mean'> </div>";
- /*org begin*/
- _txtOutDetail += "<div class='org'> </div>";
- /*org mean begin*/
- _txtOutDetail += "<div class='om'> </div>";
- /*case begin*/
- _txtOutDetail += "<div class='case'> </div>";
- _txtOutDetail += "</div>";
- return _txtOutDetail;
- }
- if (sMean == "?") {
- _bgColor = " class='bookmarkcolorx' ";
- }
- strBookMarkColor = getNodeText(wordNode, "bmc");
- if (strBookMarkColor.length > 2) {
- var icolor = strBookMarkColor.substr(-1);
- _bgColor = " class='bookmarkcolor" + icolor + "' ";
- }
- // Auto Match Begin
- if (sCase == "?" && _bgColor == "") {
- _caseColor = " class='bookmarkcolorx' ";
- }
- if (g_useMode == "read" || g_useMode == "translate") {
- _bgColor = "";
- _caseColor = "";
- if (sOrg == "?") {
- sOrg = " ";
- }
- if (sMean == "?") {
- sMean = " ";
- }
- if (sCase == "?" || sCase == "?#?") {
- sCase = " ";
- }
- }
- if (g_useMode == "read") {
- _txtOutDetail += "<div " + _bgColor + ">";
- /*id begin*/
- _txtOutDetail += "<p class='ID'>";
- _txtOutDetail += sId + " ";
- _txtOutDetail += "</p>";
- /*id end*/
- /*meaning begin*/
- var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
- showMean = showMean.replace(/}/g, "</span>");
- showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
- showMean = showMean.replace(/\]/g, "</span>");
- _txtOutDetail += "<p class='mean'>";
- _txtOutDetail += showMean + " ";
- _txtOutDetail += "</p>";
- /*meaning end*/
- /*org begin*/
- _txtOutDetail += "<p class='org'>";
- _txtOutDetail += sOrg + " ";
- _txtOutDetail += "</p>";
- /*org end*/
- /*org meaning begin*/
- _txtOutDetail += "<p class='om'>";
- _txtOutDetail += sOm + " ";
- _txtOutDetail += "</p>";
- /*org meaning end*/
- /*grmma begin*/
- _txtOutDetail += "<p class='case'>";
- sCase = getLocalGrammaStr(sCase);
- var mGramma = sCase.split("#");
- if (mGramma.length >= 2) {
- mType = sCase.split("#")[0];
- mGramma = sCase.split("#")[1];
- } else {
- mType = "";
- mGramma = sCase.split("#")[0];
- }
- //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
- if (mType != "") {
- _txtOutDetail += "<span class='type'>" + mType + "</span>";
- }
- _txtOutDetail += mGramma;
- _txtOutDetail = _txtOutDetail + " " + "</p>";
- /*grmma end*/
- _txtOutDetail += "</div>";
- }
- //编辑模式开始
- if (g_useMode == "edit") {
- if (getNodeText(wordNode, "lock") == "true") {
- _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
- } else {
- _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
- }
- _txtOutDetail += "<div " + _bgColor + ">";
- /*id begin*/
- _txtOutDetail += "<p class='ID'>";
- _txtOutDetail += sId + " ";
- _txtOutDetail += "</p>";
- /*id end*/
- /*gramma*/
- /*find in dict*/
- var arrGramma = new Array();
- var thisWord = getNodeText(wordNode, "real");
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (thisWord == g_DictWordList[iDict].Pali) {
- if (
- (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
- (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
- ) {
- var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
- pushNewToList(arrGramma, arrCase);
- }
- }
- }
- if (sCase == "?" || sCase == "?#?") {
- if (arrGramma.length > 0) {
- setNodeText(xmlElement, "case", arrGramma[0]);
- sCase = arrGramma[0];
- } else {
- setNodeText(xmlElement, "case", "?#?");
- sCase = "?#?";
- }
- } else {
- if (sCase.indexOf("#") == -1) {
- sCase = "?#" + sCase;
- setNodeText(xmlElement, "case", "?#" + sCase);
- }
- }
- var currType = sCase.split("#")[0];
- var currGramma = sCase.split("#")[1];
- //end gramma
- /*meaning*/
- /*find in dict*/
- var arrMeaning = new Array();
- var currMeaning = "";
- var currGrammaMeaning = "";
- var wordParent = "";
- var wordGramma0 = "";
- //self meaning
- var thisWord = getNodeText(wordNode, "real");
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (
- thisWord == g_DictWordList[iDict].Pali &&
- g_DictWordList[iDict].Type != ".root." &&
- g_DictWordList[iDict].Type != ".suf." &&
- g_DictWordList[iDict].Type != ".prf."
- ) {
- if (
- wordParent == "" &&
- g_DictWordList[iDict].Parent.length > 0 &&
- g_DictWordList[iDict].Parent != thisWord
- ) {
- wordParent = g_DictWordList[iDict].Parent;
- wordGramma0 = g_DictWordList[iDict].Gramma;
- }
- var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
- if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
- if (currGrammaMeaning == "") {
- if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
- currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
- }
- }
- }
- var arrMean = g_DictWordList[iDict].Mean.split("$");
- for (var i = 0; i < arrMean.length; i++) {
- if (arrMean[i].length > 0 && arrMean[i] != "?") {
- //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
- if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
- arrMeaning.push(
- g_DictWordList[iDict].dictID +
- "$" +
- arrMeaning.length +
- "$$" +
- arrMean[i] +
- "$" +
- g_DictWordList[iDict].Language
- );
- }
- }
- }
- }
- }
- var wordGramma1 = "";
- //find in father
- if (wordParent != "") {
- //add parent infomation
- if (sParent == "" || sParent == " ") {
- setNodeText(wordNode, "parent", wordParent);
- sParent = wordParent;
- }
- thisWord = wordParent;
- wordParent = "";
- wordGramma1 = "";
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (
- thisWord == g_DictWordList[iDict].Pali &&
- g_DictWordList[iDict].Type != ".v." &&
- g_DictWordList[iDict].Type != ".n." &&
- g_DictWordList[iDict].Type != ".ti." &&
- g_DictWordList[iDict].Type != ".adj." &&
- g_DictWordList[iDict].Type != ".pron." &&
- g_DictWordList[iDict].Type != ".num."
- ) {
- if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
- if (wordParent == "") {
- wordParent = g_DictWordList[iDict].Parent;
- }
- if (wordGramma1 == "") {
- wordGramma1 = g_DictWordList[iDict].Gramma;
- }
- }
- var arrMean = g_DictWordList[iDict].Mean.split("$");
- for (var i = 0; i < arrMean.length; i++) {
- if (arrMean[i].length > 0 && arrMean[i] != "?") {
- //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
- if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
- arrMeaning.push(
- g_DictWordList[iDict].dictID +
- "$" +
- arrMeaning.length +
- "$*$" +
- getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
- "$" +
- g_DictWordList[iDict].Language
- );
- }
- }
- }
- }
- }
- }
- //爷爷跟父亲的关系 比如 pp
- wordGranfatherGramma = wordGramma1;
- wordGranfather = wordParent;
- //grandfather
- var wordGramma2 = "";
- if (wordParent != "") {
- thisWord = wordParent;
- wordParent = "";
- wordGramma2 = "";
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (
- thisWord == g_DictWordList[iDict].Pali &&
- g_DictWordList[iDict].Type != ".v." &&
- g_DictWordList[iDict].Type != ".n." &&
- g_DictWordList[iDict].Type != ".ti." &&
- g_DictWordList[iDict].Type != ".adj." &&
- g_DictWordList[iDict].Type != ".pron." &&
- g_DictWordList[iDict].Type != ".num."
- ) {
- if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
- if (wordParent == "") {
- wordParent = g_DictWordList[iDict].Parent;
- }
- if (wordGramma2 == "") {
- wordGramma2 = g_DictWordList[iDict].Gramma;
- }
- }
- var arrMean = g_DictWordList[iDict].Mean.split("$");
- for (var i = 0; i < arrMean.length; i++) {
- if (arrMean[i].length > 0 && arrMean[i] != "?") {
- //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
- if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
- arrMeaning.push(
- g_DictWordList[iDict].dictID +
- "$" +
- arrMeaning.length +
- "$**$" +
- getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
- "$" +
- g_DictWordList[iDict].Language
- );
- }
- }
- }
- }
- }
- }
- arrMeaning.sort(sortMeanByDictOrder);
- //arrMeaning.sort(sortMeanByLanguageOrder);
- newMeanList = removeSameWordInArray(arrMeaning);
- sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
- if (sMean == "?") {
- //自动匹配一个意思
- //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
- if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
- currMeaning = currGrammaMeaning;
- } else {
- if (newMeanList.length > 0) {
- currMeaning = newMeanList[0].word;
- } else {
- currMeaning = sMean;
- }
- }
- } else {
- currMeaning = removeFormula(sMean);
- currMeaning = getLocalFormulaStr(currGramma, currMeaning);
- }
- orgMeaning = removeFormula(currMeaning);
- if (sReal.length < 4) {
- currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
- } else {
- currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
- }
- setNodeText(wordNode, "mean", currMeaning);
- renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
- renderMeaning = renderMeaning.replace(/}/g, "</span>");
- renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
- renderMeaning = renderMeaning.replace(/\]/g, "</span>");
- //渲染下拉菜单
- _txtOutDetail += "<div class='mean'>";
- _txtOutDetail += render_word_mean_menu(wordNode);
- //render formula menu
- arrFormula = getFormulaList(currGramma);
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- newWord = removeFormula_B(orgMeaning);
- _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>["+gLocal.gui.none+"]</a>";
- _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>["+gLocal.gui.auto+"]</a>";
- for (var i in arrFormula) {
- newWord = removeFormula_B(orgMeaning);
- newWord = arrFormula[i].replace("~", newWord);
- newWord = newWord.replace(/{/g, "[");
- newWord = newWord.replace(/}/g, "]");
- _txtOutDetail +=
- "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
- }
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div> ";
- /*end of meaning*/
- /*org begin 拆分*/
- /*
- =======
- return renderWordDetailByElement_edit_a(xmlElement);
-
- if (xmlElement == null) {
- return "";
- }
- wordNode = xmlElement;
- var sPali = getNodeText(wordNode, "pali");
- var sId = getNodeText(wordNode, "id");
- var sReal = getNodeText(wordNode, "real");
- var sMean = getNodeText(wordNode, "mean");
- var sOrg = getNodeText(wordNode, "org");
- var sOm = getNodeText(wordNode, "om");
- var sCase = getNodeText(wordNode, "case");
- var sType = getNodeText(wordNode, "type");
- var sGramma = getNodeText(wordNode, "gramma");
- var sParent = getNodeText(wordNode, "parent");
- var sNote = getNodeText(wordNode, "note");
- wordID = sId;
-
- if (sCase == "") {
- sCase = sType + "#" + sGramma;
- }
-
- var _txtOutDetail = "";
- var _bgColor = "";
- var _caseColor = "";
- //标点符号
- if (sReal.length <= 1) {
- _txtOutDetail += "<div>";
- /*id begin*/
- _txtOutDetail += "<div class='ID'> </div>";
- /*mean begin*/
- _txtOutDetail += "<div class='mean'> </div>";
- /*org begin*/
- _txtOutDetail += "<div class='org'> </div>";
- /*org mean begin*/
- _txtOutDetail += "<div class='om'> </div>";
- /*case begin*/
- _txtOutDetail += "<div class='case'> </div>";
- _txtOutDetail += "</div>";
- return _txtOutDetail;
- }
- if (sMean == "?") {
- _bgColor = " class='bookmarkcolorx' ";
- }
- strBookMarkColor = getNodeText(wordNode, "bmc");
- if (strBookMarkColor.length > 2) {
- var icolor = strBookMarkColor.substr(-1);
- _bgColor = " class='bookmarkcolor" + icolor + "' ";
- }
- // Auto Match Begin
- if (sCase == "?" && _bgColor == "") {
- _caseColor = " class='bookmarkcolorx' ";
- }
- if (g_useMode == "read" || g_useMode == "translate") {
- _bgColor = "";
- _caseColor = "";
- if (sOrg == "?") {
- sOrg = " ";
- }
- if (sMean == "?") {
- sMean = " ";
- }
- if (sCase == "?" || sCase == "?#?") {
- sCase = " ";
- }
- }
- if (g_useMode == "read") {
- _txtOutDetail += "<div " + _bgColor + ">";
- /*id begin*/
- _txtOutDetail += "<p class='ID'>";
- _txtOutDetail += sId + " ";
- _txtOutDetail += "</p>";
- /*id end*/
- /*meaning begin*/
- var showMean = sMean.replace(/{/g, "<span class='grm_add_mean'>");
- showMean = showMean.replace(/}/g, "</span>");
- showMean = showMean.replace(/\[/g, "<span class='grm_add_mean_user'>");
- showMean = showMean.replace(/\]/g, "</span>");
- _txtOutDetail += "<p class='mean'>";
- _txtOutDetail += showMean + " ";
- _txtOutDetail += "</p>";
- /*meaning end*/
- /*org begin*/
- _txtOutDetail += "<p class='org'>";
- _txtOutDetail += sOrg + " ";
- _txtOutDetail += "</p>";
- /*org end*/
- /*org meaning begin*/
- _txtOutDetail += "<p class='om'>";
- _txtOutDetail += sOm + " ";
- _txtOutDetail += "</p>";
- /*org meaning end*/
- /*grmma begin*/
- _txtOutDetail += "<p class='case'>";
- sCase = getLocalGrammaStr(sCase);
- var mGramma = sCase.split("#");
- if (mGramma.length >= 2) {
- mType = sCase.split("#")[0];
- mGramma = sCase.split("#")[1];
- } else {
- mType = "";
- mGramma = sCase.split("#")[0];
- }
- //_txtOutDetail += ("<span class='type'>"+mType+"</span> "+mGramma);
- if (mType != "") {
- _txtOutDetail += "<span class='type'>" + mType + "</span>";
- }
- _txtOutDetail += mGramma;
- _txtOutDetail = _txtOutDetail + " " + "</p>";
- /*grmma end*/
- _txtOutDetail += "</div>";
- }
- //编辑模式开始
- if (g_useMode == "edit") {
- if (getNodeText(wordNode, "lock") == "true") {
- _bgColor += " style='box-shadow: 0 3px 0 0 #FF0000'";
- } else {
- _bgColor += " class='bookmarkcolor0' style='box-shadow: 0 0 0 0'";
- }
- _txtOutDetail += "<div " + _bgColor + ">";
- /*id begin*/
- _txtOutDetail += "<p class='ID'>";
- _txtOutDetail += sId + " ";
- _txtOutDetail += "</p>";
- /*id end*/
- /*gramma*/
- /*find in dict*/
- var arrGramma = new Array();
- var thisWord = getNodeText(wordNode, "real");
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (thisWord == g_DictWordList[iDict].Pali) {
- if (
- (g_DictWordList[iDict].Type != "" && g_DictWordList[iDict].Type != "?") ||
- (g_DictWordList[iDict].Gramma != "" && g_DictWordList[iDict].Gramma != "?")
- ) {
- var arrCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
- pushNewToList(arrGramma, arrCase);
- }
- }
- }
- if (sCase == "?" || sCase == "?#?") {
- if (arrGramma.length > 0) {
- setNodeText(xmlElement, "case", arrGramma[0]);
- sCase = arrGramma[0];
- } else {
- setNodeText(xmlElement, "case", "?#?");
- sCase = "?#?";
- }
- } else {
- if (sCase.indexOf("#") == -1) {
- sCase = "?#" + sCase;
- setNodeText(xmlElement, "case", "?#" + sCase);
- }
- }
- var currType = sCase.split("#")[0];
- var currGramma = sCase.split("#")[1];
- //end gramma
- /*meaning*/
- /*find in dict*/
- var arrMeaning = new Array();
- var currMeaning = "";
- var currGrammaMeaning = "";
- var wordParent = "";
- var wordGramma0 = "";
- //self meaning
- var thisWord = getNodeText(wordNode, "real");
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (
- thisWord == g_DictWordList[iDict].Pali &&
- g_DictWordList[iDict].Type != ".root." &&
- g_DictWordList[iDict].Type != ".suf." &&
- g_DictWordList[iDict].Type != ".prf."
- ) {
- if (
- wordParent == "" &&
- g_DictWordList[iDict].Parent.length > 0 &&
- g_DictWordList[iDict].Parent != thisWord
- ) {
- wordParent = g_DictWordList[iDict].Parent;
- wordGramma0 = g_DictWordList[iDict].Gramma;
- }
- var tempCase = g_DictWordList[iDict].Type + "#" + g_DictWordList[iDict].Gramma;
- if (sCase == tempCase && g_DictWordList[iDict].Mean.length > 0) {
- if (currGrammaMeaning == "") {
- if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
- currGrammaMeaning = g_DictWordList[iDict].Mean.split("$")[0];
- }
- }
- }
- var arrMean = g_DictWordList[iDict].Mean.split("$");
- for (var i = 0; i < arrMean.length; i++) {
- if (arrMean[i].length > 0 && arrMean[i] != "?") {
- //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+arrMeaning.length+'$$'+arrMean[i]);
- if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
- arrMeaning.push(
- g_DictWordList[iDict].dictID +
- "$" +
- arrMeaning.length +
- "$$" +
- arrMean[i] +
- "$" +
- g_DictWordList[iDict].Language
- );
- }
- }
- }
- }
- }
- var wordGramma1 = "";
- //find in father
- if (wordParent != "") {
- //add parent infomation
- if (sParent == "" || sParent == " ") {
- setNodeText(wordNode, "parent", wordParent);
- sParent = wordParent;
- }
- thisWord = wordParent;
- wordParent = "";
- wordGramma1 = "";
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (
- thisWord == g_DictWordList[iDict].Pali &&
- g_DictWordList[iDict].Type != ".v." &&
- g_DictWordList[iDict].Type != ".n." &&
- g_DictWordList[iDict].Type != ".ti." &&
- g_DictWordList[iDict].Type != ".adj." &&
- g_DictWordList[iDict].Type != ".pron." &&
- g_DictWordList[iDict].Type != ".num."
- ) {
- if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
- if (wordParent == "") {
- wordParent = g_DictWordList[iDict].Parent;
- }
- if (wordGramma1 == "") {
- wordGramma1 = g_DictWordList[iDict].Gramma;
- }
- }
- var arrMean = g_DictWordList[iDict].Mean.split("$");
- for (var i = 0; i < arrMean.length; i++) {
- if (arrMean[i].length > 0 && arrMean[i] != "?") {
- //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"*$"+getLocalParentFormulaStr(wordGramma0,arrMean[i]));
- if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
- arrMeaning.push(
- g_DictWordList[iDict].dictID +
- "$" +
- arrMeaning.length +
- "$*$" +
- getLocalParentFormulaStr(wordGramma0, arrMean[i]) +
- "$" +
- g_DictWordList[iDict].Language
- );
- }
- }
- }
- }
- }
- }
- //爷爷跟父亲的关系 比如 pp
- wordGranfatherGramma = wordGramma1;
- wordGranfather = wordParent;
- //grandfather
- var wordGramma2 = "";
- if (wordParent != "") {
- thisWord = wordParent;
- wordParent = "";
- wordGramma2 = "";
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (
- thisWord == g_DictWordList[iDict].Pali &&
- g_DictWordList[iDict].Type != ".v." &&
- g_DictWordList[iDict].Type != ".n." &&
- g_DictWordList[iDict].Type != ".ti." &&
- g_DictWordList[iDict].Type != ".adj." &&
- g_DictWordList[iDict].Type != ".pron." &&
- g_DictWordList[iDict].Type != ".num."
- ) {
- if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
- if (wordParent == "") {
- wordParent = g_DictWordList[iDict].Parent;
- }
- if (wordGramma2 == "") {
- wordGramma2 = g_DictWordList[iDict].Gramma;
- }
- }
- var arrMean = g_DictWordList[iDict].Mean.split("$");
- for (var i = 0; i < arrMean.length; i++) {
- if (arrMean[i].length > 0 && arrMean[i] != "?") {
- //pushNewToList(arrMeaning,g_DictWordList[iDict].dictID+'$'+"**"+getLocalParentFormulaStr(wordGramma1,arrMean[i]));
- if (dict_language_enable.indexOf(g_DictWordList[iDict].Language) >= 0) {
- arrMeaning.push(
- g_DictWordList[iDict].dictID +
- "$" +
- arrMeaning.length +
- "$**$" +
- getLocalParentFormulaStr(wordGramma1, arrMean[i]) +
- "$" +
- g_DictWordList[iDict].Language
- );
- }
- }
- }
- }
- }
- }
- arrMeaning.sort(sortMeanByDictOrder);
- //arrMeaning.sort(sortMeanByLanguageOrder);
- newMeanList = removeSameWordInArray(arrMeaning);
- sMean = sMean.replace("_un_auto_mean_", getLocalGrammaStr("_un_auto_mean_"));
- if (sMean == "?") {
- //自动匹配一个意思
- //currGrammaMeaning是与语法信息最匹配的一个意思 如果使用这个 与语言排序冲突
- if (currGrammaMeaning.length > 0 && currGrammaMeaning != "?") {
- currMeaning = currGrammaMeaning;
- } else {
- if (newMeanList.length > 0) {
- currMeaning = newMeanList[0].word;
- } else {
- currMeaning = sMean;
- }
- }
- } else {
- currMeaning = removeFormula(sMean);
- currMeaning = getLocalFormulaStr(currGramma, currMeaning);
- }
- orgMeaning = removeFormula(currMeaning);
- if (sReal.length < 4) {
- currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, 24));
- } else {
- currMeaning = getLocalFormulaStr(currGramma, cutString(orgMeaning, sReal.length * 6));
- }
- setNodeText(wordNode, "mean", currMeaning);
- renderMeaning = currMeaning.replace(/{/g, "<span class='grm_add_mean'>");
- renderMeaning = renderMeaning.replace(/}/g, "</span>");
- renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
- renderMeaning = renderMeaning.replace(/\]/g, "</span>");
- //渲染下拉菜单
- _txtOutDetail += "<div class='mean'>";
- _txtOutDetail += render_word_mean_menu(wordNode);
- //render formula menu
- arrFormula = getFormulaList(currGramma);
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<svg class='edit_icon';'><use xlink:href='svg/icon.svg#ic_more'></use></svg>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- newWord = removeFormula_B(orgMeaning);
- _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","[]' + newWord + "\")'>["+gLocal.gui.none+"]</a>";
- _txtOutDetail += "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>["+gLocal.gui.auto+"]</a>";
- for (var i in arrFormula) {
- newWord = removeFormula_B(orgMeaning);
- newWord = arrFormula[i].replace("~", newWord);
- newWord = newWord.replace(/{/g, "[");
- newWord = newWord.replace(/}/g, "]");
- _txtOutDetail +=
- "<a onclick='fieldListChanged(\"" + wordID + '","mean","' + newWord + "\")'>" + arrFormula[i] + "</a>";
- }
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div> ";
- /*end of meaning*/
- /*org begin 拆分*/
- /*
- >>>>>>> bc16896ae743d21de32c24d5ffe63b6be00a315c
- _txtOutDetail += "<p class='org' name='w_org'>";
- _txtOutDetail += sOrg + " ";
- _txtOutDetail += "</p> ";
- */
- /*find in dict*/
- var currOrg = "";
- var wordParent = "";
- var arrOrg = new Array();
- var thisWord = getNodeText(wordNode, "real");
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (thisWord == g_DictWordList[iDict].Pali) {
- if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
- wordParent = g_DictWordList[iDict].Parent;
- }
- var currOrg = g_DictWordList[iDict].Factors;
- if (currOrg.length > 0 && currOrg != "?") {
- pushNewToList(arrOrg, currOrg);
- //arrOrg.push(currOrg);
- }
- }
- }
- //father
- if (wordParent != "") {
- thisWord = wordParent;
- wordParent = "";
- wordGramma1 = "";
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (thisWord == g_DictWordList[iDict].Pali) {
- if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
- if (wordParent == "") {
- wordParent = g_DictWordList[iDict].Parent;
- }
- }
- var currOrg = g_DictWordList[iDict].Factors;
- if (currOrg.length > 0 && currOrg != "?") {
- pushNewToList(arrOrg, currOrg);
- //arrOrg.push(currOrg);
- }
- }
- }
- }
- //grandfather
- if (wordParent != "") {
- thisWord = wordParent;
- wordParent = "";
- wordGramma2 = "";
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (thisWord == g_DictWordList[iDict].Pali) {
- if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
- if (wordParent == "") {
- wordParent = g_DictWordList[iDict].Parent;
- }
- }
- var currOrg = g_DictWordList[iDict].Factors;
- if (currOrg.length > 0 && currOrg != "?") {
- pushNewToList(arrOrg, currOrg);
- //arrOrg.push(currOrg);
- }
- }
- }
- }
- _txtOutDetail += "<div class='org' name='w_org'>";
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<p class='case_dropbtn' >";
- if (sOrg == "?") {
- if (arrOrg.length > 0) {
- currOrg = arrOrg[0];
- } else {
- currOrg = sOrg;
- }
- setNodeText(wordNode, "org", currOrg);
- } else {
- currOrg = sOrg;
- }
- _txtOutDetail += currOrg;
- if (arrOrg.length > 0) {
- _txtOutDetail += "<svg class='edit_icon'>";
- _txtOutDetail += "<use xlink:href='svg/icon.svg#ic_down'></use>";
- _txtOutDetail += "</svg>";
- }
- _txtOutDetail += "</p>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- _txtOutDetail +=
- "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
- wordID +
- '","org","")\'>' +
- gLocal.gui.empty1 +
- "</button>";
- _txtOutDetail +=
- "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='show_word_map(\"" +
- wordID +
- "\")'>" +
- gLocal.gui.wordmap +
- "</button>";
- //新加 base 信息 vn
- _txtOutDetail += '<div class="case_dropdown-org">';
- _txtOutDetail += '<div class="case_dropdown-first">';
- _txtOutDetail += "<a style='z-index:250; position:absolute; margin-right:2em;'>";
- _txtOutDetail += sParent + "</a>";
- _txtOutDetail += "<span style='z-index:220' class='case_dropdown-title'>";
- _txtOutDetail += gLocal.gui.more + "»</span>";
- _txtOutDetail += "</div>";
- for (i in arrOrg) {
- _txtOutDetail +=
- "<a onclick='fieldListChanged(\"" + wordID + '","org","' + arrOrg[i] + "\")'>" + arrOrg[i] + "</a>";
- }
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div> ";
- /*end of factors*/
- /*part meaning begin*/
- listFactorForFactorMean = currOrg.split("+");
- currDefualtFM = "";
- for (iFactor in listFactorForFactorMean) {
- currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+"; //拆分元素加号分隔
- }
- currDefualtFM = currDefualtFM.replace(/" "/g, " ");
- currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
- currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
- currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1); //去掉尾部的加号 kosalla
- if (currDefualtFM.slice(-1, -2) == "+") {
- currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
- }
- /*find in dict*/
- var currOM = "";
- var wordParent = "";
- var arrOM = new Array();
- var thisWord = getNodeText(wordNode, "real");
- for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
- if (thisWord == g_DictWordList[iDict].Pali) {
- if (g_DictWordList[iDict].Parent.length > 0 && g_DictWordList[iDict].Parent != thisWord) {
- wordParent = g_DictWordList[iDict].Parent;
- }
- var currOM = g_DictWordList[iDict].FactorMean;
- if (currOM.length > 0 && currOM != "?") {
- pushNewToList(arrOM, currOM);
- //arrOM.push(currOM);
- }
- }
- }
- /*
- //father
- if(wordParent!=""){
- thisWord=wordParent;
- wordParent="";
- for(iDict=0;iDict<g_DictWordList.length;iDict++){
- if(thisWord==g_DictWordList[iDict].Pali){
- if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
- if(wordParent==""){
- wordParent=g_DictWordList[iDict].Parent;
- }
- }
- var currOM=g_DictWordList[iDict].FactorMean;
- if(currOM.length>0 && currOM!="?"){
- pushNewToList(arrOM,currOM);
- }
- }
- }
- }
- //grandfather
- if(wordParent!=""){
- thisWord=wordParent;
- wordParent="";
- wordGramma2="";
- for(iDict=0;iDict<g_DictWordList.length;iDict++){
- if(thisWord==g_DictWordList[iDict].Pali){
- if(g_DictWordList[iDict].Parent.length>0 && g_DictWordList[iDict].Parent!=thisWord){
- if(wordParent==""){
- wordParent=g_DictWordList[iDict].Parent;
- }
- }
- var currOM=g_DictWordList[iDict].FactorMean;
- if(currOM.length>0 && currOM!="?"){
- pushNewToList(arrOM,currOM);
- }
- }
- }
- }
- */
- _txtOutDetail += "<div class='om' name='w_om'>";
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<p class='case_dropbtn' >";
- sOm = sOm.replace("_un_auto_factormean_", getLocalGrammaStr("_un_auto_factormean_"));
- if (sOm == "?" || sOm.substring(0, 3) == "[a]") {
- if (arrOM.length > 0) {
- currOM = arrOM[0];
- } else {
- currOM = "[a]" + currDefualtFM;
- }
- setNodeText(wordNode, "om", currOM);
- } else {
- currOM = sOm;
- }
- _txtOutDetail += currOM;
- if (arrOM.length > 0) {
- _txtOutDetail += " ▾";
- }
- _txtOutDetail += "</p>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- _txtOutDetail +=
- "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
- wordID +
- '","om","")\'>' +
- gLocal.gui.empty1 +
- "</button>";
- _txtOutDetail +=
- "<a onclick='fieldListChanged(\"" +
- wordID +
- '","om","[a]' +
- currDefualtFM +
- "\")'>[" +
- gLocal.gui.auto +
- "]" +
- currDefualtFM +
- "</a>";
- for (i in arrOM) {
- _txtOutDetail +=
- "<a onclick='fieldListChanged(\"" + wordID + '","om","' + arrOM[i] + "\")'>" + arrOM[i] + "</a>";
- }
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div> ";
- /*org meaning end*/
- /*begin gramma*/
- _txtOutDetail += "<div class='case'>";
- _txtOutDetail += '<div class="case_dropdown">';
- _txtOutDetail += "<p class='case_dropbtn' >";
- sLocalCase = getLocalGrammaStr(sCase);
- var mArrGramma = sCase.split("#");
- if (mArrGramma.length >= 2) {
- mType = mArrGramma[0];
- mGramma = mArrGramma[1];
- mLocalType = sLocalCase.split("#")[0];
- mLocalGramma = sLocalCase.split("#")[1];
- } else {
- mType = "";
- mGramma = mArrGramma[0];
- mLocalType = "";
- mLocalGramma = sLocalCase.split("#")[0];
- }
- if (mType != "") {
- _txtOutDetail += "<span class='cell'>" + mLocalType + "</span>";
- }
- _txtOutDetail += cutString(mLocalGramma, 30);
- _txtOutDetail += "</p>";
- _txtOutDetail += '<div class="case_dropdown-content">';
- for (i in arrGramma) {
- _txtOutDetail +=
- "<a onclick='fieldListChanged(\"" +
- wordID +
- '","case","' +
- arrGramma[i] +
- "\")'>" +
- cutString(getLocalGrammaStr(arrGramma[i]), 30) +
- "</a>";
- }
- _txtOutDetail += "</div>";
- _txtOutDetail += "</div>";
- //连读词按钮
- if (mType == ".un." || mType == ".comp.") {
- nextElement = com_get_nextsibling(xmlElement);
- if (nextElement != null) {
- //下一个元素存在
- if (getNodeText(nextElement, "un") == sId) {
- //若有孩子則显示收起按鈕
- _txtOutDetail += "<button class='in_word_button' onclick='edit_un_remove(\"" + wordID + "\")'>";
- _txtOutDetail +=
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_join "></use></svg>';
- _txtOutDetail += "</button>";
- var parentElement = document.getElementById("wb" + sId);
- if (parentElement) {
- parentElement.classList.add("un_parent");
- }
- } else {
- //無kid展開按鈕
- _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
- _txtOutDetail +=
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
- _txtOutDetail += "</button> ";
- }
- } else {
- //下一个元素不存在
- _txtOutDetail += "<button class='in_word_button' onclick='edit_un_split(\"" + wordID + "\")'>";
- _txtOutDetail +=
- '<svg class="icon" ><use xlink="http://www.w3.org/1999/xlink" href="svg/icon.svg#ic_split "></use></svg>';
- _txtOutDetail += "</button> ";
- }
- }
- //连读词按钮 结束
- //爷爷和父亲的关系 如pp
- if (wordGranfatherGramma.length > 0 && wordGranfatherGramma.length < 6) {
- _txtOutDetail +=
- '<span class="tooltip">«' +
- getLocalGrammaStr(wordGranfatherGramma) +
- '<span class="tooltiptext tooltip-bottom">' +
- wordGranfather +
- "</span>" +
- "</span> ";
- }
- _txtOutDetail += "</div> ";
- /*end of gramma*/
- //Auto Match Finished
- _txtOutDetail += "</div>";
- }
- return _txtOutDetail;
- }
- function renderWordNoteDivByParaNo(book, paragraph) {}
- /*
- paragraph word note
- */
- function renderWordNoteDivByElement(elementBlock) {
- let output = "";
- let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
- let book = getNodeText(xmlParInfo, "book");
- let paragraph = getNodeText(xmlParInfo, "paragraph");
- let bId = getNodeText(xmlParInfo, "id");
- let type = getNodeText(xmlParInfo, "type");
- let allWord = elementBlock.getElementsByTagName("word");
- let iNoteCounter = 0;
- for (iWord = 0; iWord < allWord.length; iWord++) {
- let oneNote = "";
- let pali = getNodeText(allWord[iWord], "pali");
- let sNote = getNodeText(allWord[iWord], "note");
- if (sNote != "") {
- oneNote += note_init(sNote);
- }
- let sRela = getNodeText(allWord[iWord], "rela");
- if (sRela != "") {
- oneNote += "<div>" + renderWordRelation(allWord[iWord]) + "</div>";
- }
- id = getNodeText(allWord[iWord], "id");
- if (oneNote == "") {
- //有内容
- $("#wnote_root_" + id).html("");
- } else {
- $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
- output += "<div>";
- output += "<wnc wid='" + id + "'></wnc>";
- output += "<strong>" + pali + ":</strong>";
- output += oneNote;
- output += "</div>";
- }
- }
- return output;
- }
- function refreshWordNoteDiv(elementBlock) {
- let html = renderWordNoteDivByElement(elementBlock);
- let xmlParInfo = elementBlock.getElementsByTagName("info")[0];
- let book = getNodeText(xmlParInfo, "book");
- let paragraph = parseInt(getNodeText(xmlParInfo, "paragraph"));
- let noteid = "wnote_" + book + "_" + (paragraph - 1);
- try {
- if (html == "") {
- $("#" + noteid).hide();
- } else {
- $("#" + noteid).html(html);
- $("#" + noteid).show();
- }
- } catch (e) {
- console.error(e.message + noteid);
- }
- }
- function refreshWordNote(elementBlock) {
- var output = "";
- xmlParInfo = elementBlock.getElementsByTagName("info")[0];
- book = getNodeText(xmlParInfo, "book");
- paragraph = getNodeText(xmlParInfo, "paragraph");
- bId = getNodeText(xmlParInfo, "id");
- type = getNodeText(xmlParInfo, "type");
- var allWord = elementBlock.getElementsByTagName("word");
- var iNoteCounter = 0;
- for (iWord = 0; iWord < allWord.length; iWord++) {
- pali = getNodeText(allWord[iWord], "pali");
- wnote = note_init(getNodeText(allWord[iWord], "note"));
- id = getNodeText(allWord[iWord], "id");
- var note = wnote;
- if (note.length > 0 && note != "?") {
- iNoteCounter++;
- if (wnote.substring(0, 6) == "=term(") {
- var termId = wnote.slice(6, -1);
- //alert(arrTerm.length);
- if (arrTerm[note]) {
- note = "<term guid='" + termId + "' pos='wbw'>" + arrTerm[termId].note + "</term>";
- } else {
- note = "<term guid='" + termId + "' pos='wbw'></term>";
- }
- }
- output += '<p><a href="#word_note_root_' + id + '" name="word_note_' + id + '">[' + iNoteCounter + "]</a>";
- if (note.match("{") && note.match("}")) {
- note = note.replace("{", "<strong>");
- note = note.replace("}", "</strong>");
- if (note.length > 100) {
- shortNote = note.substring(0, 99);
- otherNode = note.substring(100);
- output +=
- shortNote +
- '<span class="full_note_handle">...<span class="full_note">' +
- otherNode +
- "</span></span>";
- } else {
- output += note;
- }
- } else {
- if (note.length > 100) {
- shortNote = note.substring(0, 99);
- otherNode = note.substring(100);
- output +=
- shortNote +
- '<span class="full_note_handle">...<span class="full_note">' +
- otherNode +
- "</span></span>";
- } else {
- output += "<strong>" + pali + ":</strong>" + note;
- }
- }
- output += "</p>";
- if (termId) {
- document.getElementById("wnote_root_" + id).innerHTML =
- "<a onclick=\"term_show_win('" +
- termId +
- '\')" name="word_note_root_' +
- id +
- '">[' +
- iNoteCounter +
- "]</a>";
- } else {
- document.getElementById("wnote_root_" + id).innerHTML =
- '<a href="#word_note_' + id + '" name="word_note_root_' + id + '">[' + iNoteCounter + "]</a>";
- }
- } else {
- noteRootObj = document.getElementById("wnote_root_" + id);
- if (noteRootObj) {
- document.getElementById("wnote_root_" + id).innerHTML = "";
- }
- }
- }
- if (output == "") {
- document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "none";
- } else {
- document.getElementById("wnote_" + book + "_" + (paragraph - 1)).style.display = "block";
- }
- document.getElementById("wnote_" + book + "_" + (paragraph - 1)).innerHTML = output;
- }
- function updateWordNote(element) {
- let paliword = getNodeText(element, "real");
- let wnote = getNodeText(element, "note");
- wnote = note_init(wnote);
- let id = getNodeText(element, "id");
- if (wnote == "") {
- $("#wnote_root_" + id).html("");
- $("#wnn_" + id).html("");
- } else {
- $("#wnote_root_" + id).html("<wnh wid='" + id + "'></wnh>");
- let output = "";
- output += "<wnc wid='" + id + "'></wnc>";
- let head = "";
- let content = "";
- if (wnote.match("{") && wnote.match("}")) {
- wnote = wnote.replace("{", "<strong>");
- wnote = wnote.replace("}", "</strong>");
- } else {
- output += "<strong>" + paliword + ":</strong>";
- }
- output += wnote;
- $("#wnn_" + id).html(output);
- }
- }
- function updateWordCommentary(element) {}
- //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
- //返回 无
- function updataWordBodyByElement(element) {
- try {
- var sId = getNodeText(wordNode, "id");
- var sDetail = "detail" + sId;
- var cDetail = document.getElementById(sDetail);
- if (cDetail != null) {
- cDetail.innerHTML = renderWordDetailByElement(element);
- }
- } catch (error) {
- var_dump(error);
- }
- }
- //根据xmlDocument 对象中的单词序号修改单词块的显示(不含Pali)
- //返回 无
- function modifyWordDetailByWordId(wordId) {
- try {
- var sDetail = "detail" + wordId;
- var cDetail = document.getElementById(sDetail);
- if (cDetail != null) {
- cDetail.innerHTML = renderWordDetailById(wordId);
- }
- } catch (error) {
- var_dump(error);
- }
- }
- //根据xmlDocument 对象中的单词GUID返回单词块字符串(不含Pali)
- //返回 字符串
- function renderWordDetailById(wordID) {
- var mXML = gXmlBookDataBody.getElementsByTagName("word");
- var wordIndex = getWordIndex(wordID);
- return renderWordDetailByElement(mXML[wordIndex]);
- }
- function reloadPar(parIndex) {
- bookId = gArrayDocParagraph[parIndex].book;
- parNo = gArrayDocParagraph[parIndex].paragraph;
- var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
- if (htmlBlock.style.display != "none") {
- return false;
- }
- allBlock = gXmlBookDataBody.getElementsByTagName("block");
- for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
- xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
- xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
- currBookId = getNodeText(xmlParInfo, "book");
- currParNo = getNodeText(xmlParInfo, "paragraph");
- if (bookId == currBookId && currParNo == parNo) {
- insertBlockToHtml(allBlock[iBlock]);
- }
- }
- return true;
- }
- function removePar(parIndex) {
- bookId = gArrayDocParagraph[parIndex].book;
- parNo = gArrayDocParagraph[parIndex].paragraph;
- if (gCurrModifyWindowParNo == parIndex) {
- //关闭单词修改窗口
- closeModifyWindow();
- }
- var htmlBlock = document.getElementById("par_" + bookId + "_" + (parNo - 1));
- if (htmlBlock) {
- htmlBlock.style.display = "none";
- document.getElementById("heading_" + bookId + "_" + (parNo - 1)).innerHTML = "";
- document.getElementById("wblock_" + bookId + "_" + (parNo - 1)).innerHTML = "";
- document.getElementById("tran_" + bookId + "_" + (parNo - 1)).innerHTML = "";
- document.getElementById("wnote_" + bookId + "_" + (parNo - 1)).innerHTML = "";
- document.getElementById("note_" + bookId + "_" + (parNo - 1)).innerHTML = "";
- }
- }
- function setView(topParIndex) {
- var parInOnePage = 3;
- gCurrTopParagraph = topParIndex;
- gVisibleParBegin = topParIndex - parInOnePage;
- gVisibleParEnd = parInOnePage * 2;
- if (gVisibleParBegin < 0) {
- gVisibleParBegin = 0;
- }
- if (gVisibleParEnd >= gArrayDocParagraph.length) {
- gVisibleParEnd = gArrayDocParagraph.length - 1;
- }
- }
- function isParInView(parIndex) {
- if (parIndex >= gVisibleParBegin && parIndex <= gVisibleParEnd) {
- return true;
- } else {
- return false;
- }
- }
- function refresh_Dispaly_Cap() {
- var new_par_length = gPalitext_length / gtext_max_length;
- for (refresh_i in allTextLen_array) {
- gNewArrayDocParagraph.push(allTextLen_array[refresh_i].length / gtext_max_length);
- }
- }
- function prev_page() {
- //向上翻页
- gVisibleParBeginOld = gVisibleParBegin;
- gVisibleParEndOld = gVisibleParEnd;
- if (g_allparlen_array[gVisibleParEnd - 1] - g_allparlen_array[gVisibleParBegin - 1] <= gDisplayCapacity) {
- gVisibleParBegin -= 1;
- } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin - 1] > gDisplayCapacity) {
- gVisibleParBegin -= 1;
- gVisibleParEnd -= 1;
- }
- if (gVisibleParBegin < 0) {
- //如果到顶,则恢复原始值
- gVisibleParBegin = 0;
- //gVisibleParEnd=gDisplayCapacity;
- if (gVisibleParEnd >= gArrayDocParagraph.length) {
- //如果到底,则锁死最大值
- gVisibleParEnd = gArrayDocParagraph.length - 1;
- }
- }
- updataView();
- }
- function next_page() {
- //向下翻页
- gVisibleParBeginOld = gVisibleParBegin;
- gVisibleParEndOld = gVisibleParEnd;
- if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] <= gDisplayCapacity) {
- gVisibleParEnd += 1;
- } else if (g_allparlen_array[gVisibleParEnd + 1] - g_allparlen_array[gVisibleParBegin + 1] > gDisplayCapacity) {
- gVisibleParBegin += 1;
- gVisibleParEnd += 1;
- }
- if (gVisibleParEnd >= gArrayDocParagraph.length) {
- //如果到底
- gVisibleParEnd = gArrayDocParagraph.length - 1;
- //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
- if (gVisibleParBegin < 0) {
- gVisibleParBegin = 0;
- }
- }
- updataView();
- }
- function setNewView(newBegin, newEnd) {
- gVisibleParBeginOld = gVisibleParBegin;
- gVisibleParEndOld = gVisibleParEnd;
- gVisibleParBegin = newBegin;
- gVisibleParEnd = newEnd;
- if (gVisibleParBegin < 0) {
- gVisibleParBegin = 0;
- //gVisibleParEnd=gDisplayCapacity;
- if (gVisibleParEnd >= gArrayDocParagraph.length) {
- gVisibleParEnd = gArrayDocParagraph.length - 1;
- }
- }
- if (gVisibleParEnd >= gArrayDocParagraph.length) {
- gVisibleParEnd = gArrayDocParagraph.length - 1;
- //gVisibleParBegin=gVisibleParEnd-gDisplayCapacity;
- if (gVisibleParBegin < 0) {
- gVisibleParBegin = 0;
- }
- }
- updataView();
- }
- function updataView() {
- var topNewDivArray = Array(); //在顶端新加入的块列表
- for (var iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
- if (isParInView(iPar)) {
- isLoadNew = reloadPar(iPar);
- if (isLoadNew) {
- if (iPar < gVisibleParBeginOld) {
- topNewDivArray.push(iPar);
- }
- }
- } else {
- removePar(iPar);
- }
- }
- word_mouse_event();
- //console.log("updataview");
- console.log(topNewDivArray.toString());
- }
- function render_word_mean_menu2(spell) {
- var wReal = spell;
- var output = "<div>";
- for (var iDict = 0; iDict < mDict[spell].length; iDict++) {
- output += "<div>";
- output += "<span>dict_name</span>";
- var meanGroup = partList2[i].mean.split("$");
- for (var iMean = 0; iMean < meanGroup.length; iMean++) {
- output +=
- "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
- wId +
- '","mean","' +
- meanGroup[iMean] +
- "\")'>" +
- meanGroup[iMean] +
- "</span>";
- }
- output += "</div>";
- }
- output += "</div>";
- return;
- var sWord = new Array(wReal);
- sWord = sWord.concat(render_get_word_parent_list(wReal));
- for (var iWord in sWord) {
- output += '<div class="case_dropdown-first">';
- output +=
- '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
- sWord[iWord] +
- "\")'>";
- output += sWord[iWord] + "</a>";
- output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
- output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
- output += '</span><div class="case_dropdown-detail">';
- var partList = render_get_word_mean_list(sWord[iWord]);
- var L_width_mean = 0;
- var partList2 = repeat_combine(partList);
- //计算字符长度并控制
- for (var i in partList2) {
- var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
- if (L_width_mean < L_width / 1.7) {
- L_width_mean = L_width / 1.7;
- }
- }
- for (var i in partList2) {
- var meanGroup = partList2[i].mean.split("$");
- var htmlMean = "";
- output += "<a style='display:flex; flex-wrap: wrap;'>";
- output +=
- "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
- //output += "<a ><div id='div_dictname_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_dictname+"em; display:flex'>"
- output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
- output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
- output += getLocalDictname(partList2[i].dict) + "</span>";
- output += "</div>";
- output +=
- "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
- //output += "<div id='div_type_"+wId+"_"+iWord+"_"+i+"' style='width: "+L_width_type+"em; display:flex'>"
- output +=
- "<span id='span_type_" +
- wId +
- "_" +
- iWord +
- "_" +
- i +
- "' style='height: 1.5em;' class='wm_wordtype'>" +
- getLocalGrammaStr(partList2[i].type) +
- "</span>";
- for (var iMean in meanGroup) {
- if (meanGroup[iMean] != "") {
- htmlMean +=
- "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
- wId +
- '","mean","' +
- meanGroup[iMean] +
- "\")'>" +
- meanGroup[iMean] +
- "</span>";
- }
- }
- output += "</div><div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
- output += "</a>";
- }
- output += "</div></div>";
- }
- output += "</div></div></div>";
- return output;
- }
- function render_word_mean_menu(xElement) {
- var wMean = getNodeText(xElement, "mean");
- var wReal = getNodeText(xElement, "real");
- var wId = getNodeText(xElement, "id");
- var renderMeaning = wMean.replace(/{/g, "<span class='grm_add_mean'>");
- renderMeaning = renderMeaning.replace(/}/g, "</span>");
- renderMeaning = renderMeaning.replace(/\[/g, "<span class='grm_add_mean_user'>");
- renderMeaning = renderMeaning.replace(/\]/g, "</span>");
- var output = "";
- output += '<div class="case_dropdown">';
- output += "<p class='case_dropbtn' >";
- output += renderMeaning;
- output += "</p>";
- output += '<div class="case_dropdown-content">';
- output +=
- "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" +
- wId +
- '","mean","")\'>' +
- gLocal.gui.empty1 +
- '</button><div class="case_dropdown-org">';
- var sWord = new Array(wReal);
- sWord = sWord.concat(render_get_word_parent_list(wReal));
- for (var iWord in sWord) {
- output += '<div class="case_dropdown-first">';
- output +=
- '<a style="z-index:250; position:absolute; margin-right:2em;" onclick=\'dict_search("' +
- sWord[iWord] +
- "\")'>";
- output += sWord[iWord] + "</a>";
- output += '<span style="z-index:220" class="case_dropdown-title" onclick="submenu_show_detail(this)">';
- output += '<svg class="icon" style="fill:var(--main-color)"><use xlink:href="svg/icon.svg#ic_add"></use></svg>';
- output += "</span>";
- output += '<div class="case_dropdown-detail">';
- var partList = render_get_word_mean_list(sWord[iWord]);
- var L_width_mean = 0;
- var partList2 = repeat_combine(partList);
- for (var i in partList2) {
- var L_width = getLocalDictname(partList2[i].mean).replace(/[\u0391-\uFFE5]/g, "aa").length;
- if (L_width_mean < L_width / 1.7) {
- L_width_mean = L_width / 1.7;
- }
- }
- for (var i in partList2) {
- var meanGroup = partList2[i].mean.split("$");
- var htmlMean = "";
- output += "<a style='display:flex; flex-wrap: wrap;'>";
- output +=
- "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>";
- output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "'";
- output += "style='height: 1.5em;' class='wm_dictname' >"; //onclick='fieldListChanged1(\""+wId+"\",\"mean\",\""+partList2[i].mean+"\")'
- output += getLocalDictname(partList2[i].dict) + "</span>";
- output += "</div>";
- output +=
- "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>";
- output +=
- "<span id='span_type_" + wId + "_" + iWord + "_" + i + "' style='height: 1.5em;' class='wm_wordtype'>";
- if (partList2[i].type == ".n:base.") {
- output += getLocalGrammaStr(partList2[i].gramma);
- } else {
- output += getLocalGrammaStr(partList2[i].type);
- }
- output += "</span>";
- for (var iMean in meanGroup) {
- if (meanGroup[iMean] != "") {
- htmlMean +=
- "<span class='wm_one_mean' onclick='fieldListChanged(\"" +
- wId +
- '","mean","' +
- meanGroup[iMean] +
- "\")'>" +
- meanGroup[iMean] +
- "</span>";
- }
- }
- output += "</div>";
- output += "<div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
- output += "</a>";
- }
- output += "</div></div>";
- }
- output += "</div></div></div>";
- return output;
- }
- function render_get_word_mean_list(sWord) {
- var wReal = sWord;
- var output = Array();
- for (var x in g_DictWordList) {
- if (g_DictWordList[x].Pali == wReal || g_DictWordList[x].Real == wReal) {
- if (dict_language_enable.indexOf(g_DictWordList[x].Language) >= 0) {
- if (
- g_DictWordList[x].Mean != "" &&
- g_DictWordList[x].Type != ".part." &&
- g_DictWordList[x].Type != ".root." &&
- g_DictWordList[x].Type != ".suf." &&
- g_DictWordList[x].Type != ".pfx."
- ) {
- var newPart = Object();
- newPart.dict = g_DictWordList[x].dictname;
- newPart.mean = g_DictWordList[x].Mean;
- newPart.type = g_DictWordList[x].Type;
- var bIsExist = false;
- for (var iBuffer in output) {
- if (
- output[iBuffer].dict == newPart.dict &&
- output[iBuffer].type == newPart.type &&
- output[iBuffer].mean == newPart.mean
- ) {
- bIsExist = true;
- break;
- }
- if (newPart.dict == "wbw") {
- if (output[iBuffer].dict == newPart.dict && output[iBuffer].type == newPart.type) {
- output[iBuffer].mean += "$" + newPart.mean;
- bIsExist = true;
- break;
- }
- }
- }
- if (!bIsExist) {
- output.push(newPart);
- }
- }
- }
- }
- }
- return output;
- }
- function render_get_word_parent_list(sWord) {
- var wReal = sWord;
- var output = Array();
- for (var x in g_DictWordList) {
- if (g_DictWordList[x].Pali == wReal) {
- {
- if (g_DictWordList[x].Parent != "" && g_DictWordList[x].Parent != sWord) {
- var newPart = g_DictWordList[x].Parent;
- var bIsExist = false;
- for (var iBuffer in output) {
- if (output[iBuffer] == newPart) {
- bIsExist = true;
- break;
- }
- }
- if (!bIsExist) {
- output.push(newPart);
- }
- }
- }
- }
- }
- return output;
- }
- function repeat_combine(list) {
- var list_new = new Array();
- for (var repeat_combine_i = 0; repeat_combine_i < list.length; repeat_combine_i++) {
- var repeat_string = new Object();
- var repeat_combine_j = 0;
- repeat_string.dict = list[repeat_combine_i].dict;
- repeat_string.type = list[repeat_combine_i].type;
- repeat_string.mean = list[repeat_combine_i].mean;
- for (repeat_combine_j = repeat_combine_i + 1; repeat_combine_j < list.length; repeat_combine_j++) {
- if (
- list[repeat_combine_j].dict == list[repeat_combine_i].dict &&
- list[repeat_combine_j].type == list[repeat_combine_i].type
- ) {
- repeat_string.mean = repeat_string.mean + "$" + list[repeat_combine_j].mean;
- repeat_string.mean = repeat_string.mean.replace(/\$\$/g, "$");
- repeat_string.mean = repeat_string.mean.replace(/\$ /g, "$");
- repeat_string.mean = repeat_string.mean.replace(/ \$/g, "$");
- repeat_combine_i = repeat_combine_j;
- }
- }
- repeat_string.mean = "#" + repeat_string.mean + "#";
- repeat_string.mean = repeat_string.mean.replace(/ #/g, "");
- repeat_string.mean = repeat_string.mean.replace(/# /g, "");
- repeat_string.mean = repeat_string.mean.replace(/\$#/g, "");
- repeat_string.mean = repeat_string.mean.replace(/#\$/g, "");
- repeat_string.mean = repeat_string.mean.replace(/ /g, "");
- repeat_string.mean = repeat_string.mean.replace(/#/g, "");
- list_new.push(repeat_string);
- }
- return list_new;
- }
- function show_pop_note(wordid) {
- let html = $("wnc[wid='" + wordid + "']")
- .parent()
- .html();
- $("#word_note_pop_content").html(
- html
- /*note_init(doc_word("#" + wordid).val("note"))*/
- );
- $("#word_note_pop").show("500");
- }
- function refreshNoteNumber() {
- $("wnh").each(function (index, element) {
- let id = $(this).attr("wid");
- //$(this).html("<a href='#word_note_"+id+"' name=\"word_note_root_"+id+"\">"+(index+1)+"</a>");
- $(this).html("<span onclick=\"show_pop_note('" + id + "')\">" + (index + 1) + "</span>");
- });
- $("wnc").each(function (index, element) {
- let id = $(this).attr("wid");
- $(this).html("<a href='#word_note_root_" + id + "' name=\"word_note_" + id + '">[' + (index + 1) + "]</a>");
- });
- note_refresh_new();
- }
|