editor.js 172 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357
  1. var g_DictWordList = new Array();
  2. var g_DocWordMean = new Array();
  3. var g_dictList = new Array();
  4. var g_DictWordNew = new Object();
  5. var g_DictWordUpdataIndex = 0;//正在更新的记录在内存字典表中的索引号
  6. var g_InlineDictWordList = new Array;
  7. var g_CurrDictBuffer = null;
  8. var g_key_match_str = "";
  9. var myFormula = Array();//用户词典里的格位公式
  10. var g_DictCount = 0;
  11. var g_currEditWord = -1; //当前正在编辑词的id
  12. var g_eCurrWord = null; //当前正在编辑词的element对象
  13. var g_currBookMarkColor = "0";
  14. var g_dictFindParentLevel = 0;
  15. var g_dictFindAllDone = false;
  16. var g_currAutoMatchDictType = "user";
  17. var g_caseSelect = new Array("", "", "", "");
  18. var gEditorTranslateEditBlockId = -1;
  19. var gEditorNoteEditBlockId = -1
  20. var gEditorHeadingEditBlockId = -1
  21. var gEditorNewHeadingBookId = ""
  22. var gEditorNewHeadingPar = ""
  23. var g_fileid = 0;
  24. var g_docid = "";
  25. var g_op = "";
  26. var g_book = "";
  27. var g_para = "";
  28. var g_channal = "";
  29. var gCurrModifyWindowParNo = -1;
  30. var gUserSetup;
  31. var mDictQueue = Array();
  32. var gNaviCurrPanalId = "";
  33. function setNaviVisibility(strObjId = "") {
  34. var objNave = document.getElementById('leftmenuinner');
  35. var objblack = document.getElementById('BV');
  36. if (strObjId == "") {
  37. objblack.style.display = "none";
  38. objNave.className = "viewswitch_off";
  39. }
  40. else {
  41. $("#" + strObjId).show();
  42. $("#" + strObjId).siblings().hide();
  43. if (strObjId == gNaviCurrPanalId) {
  44. if (objNave.className == 'viewswitch_off') {
  45. objblack.style.display = "block";
  46. objNave.className = "viewswitch_on";
  47. }
  48. else {
  49. objblack.style.display = "none";
  50. objNave.className = "viewswitch_off";
  51. }
  52. }
  53. else {
  54. objblack.style.display = "block";
  55. objNave.className = "viewswitch_on";
  56. }
  57. }
  58. gNaviCurrPanalId = strObjId;
  59. }
  60. //选项卡函数
  61. function select_modyfy_type(itemname, idname) {
  62. document.getElementById("modify_detaile").style.display = "none";
  63. document.getElementById("modify_bookmark").style.display = "none";
  64. document.getElementById("modify_note").style.display = "none";
  65. document.getElementById("modify_spell").style.display = "none";
  66. document.getElementById("modify_apply").style.display = "block";
  67. document.getElementById("detail_li").className = "common-tab_li";
  68. document.getElementById("mark_li").className = "common-tab_li";
  69. document.getElementById("note_li").className = "common-tab_li";
  70. document.getElementById("spell_li").className = "common-tab_li";
  71. document.getElementById(itemname).style.display = "block";
  72. document.getElementById(idname).className = " common-tab_li_act";
  73. }
  74. function menuSelected(obj) {
  75. var objMenuItems = document.getElementsByClassName("menu");
  76. for (var i = 0; i < objMenuItems.length; i++) {
  77. objMenuItems[i].style.display = "none";
  78. }
  79. var objThisItem = document.getElementById(obj.value);
  80. objThisItem.style.display = "block";
  81. }
  82. function menuSelected_2(obj, id_name, class_Name) {
  83. var objMenuItems = document.getElementsByClassName(class_Name);
  84. var id_array = new Array()
  85. for (var i = 0; i < objMenuItems.length; i++) {
  86. if (objMenuItems[i].id.split("_")[0] == obj.id.split("_")[0]) {
  87. objMenuItems[i].style.display = "none";
  88. id_array.push(objMenuItems[i].id)
  89. }
  90. }
  91. var objThisItem = document.getElementById(obj.id);
  92. objThisItem.style.display = "block";
  93. for (menu_selected_i in id_array) {
  94. document.getElementById(id_array[menu_selected_i] + '_li').className = "common-tab_li";
  95. }
  96. //document.getElementById('content_menu_li').className = " common-tab_li";
  97. //document.getElementById('bookmark_menu_li').className = " common-tab_li";
  98. refreshBookMark()
  99. //document.getElementById('project_menu_li').className = " common-tab_li";
  100. //document.getElementById('dictionary_menu_li').className = " common-tab_li";
  101. //document.getElementById('layout_menu_li').className = " common-tab_li";
  102. //document.getElementById('plugin_menu_li').className = " common-tab_li";
  103. document.getElementById(id_name).className = " common-tab_li_act";
  104. }
  105. var editor_xmlhttp;
  106. var currMatchingDictNum = 0; //当前正在查询的字典索引
  107. function editor_getDictFileList() {
  108. if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
  109. editor_xmlhttp = new XMLHttpRequest();
  110. }
  111. else {// code for IE6, IE5
  112. editor_xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  113. }
  114. var d = new Date();
  115. editor_xmlhttp.onreadystatechange = editor_serverResponse;
  116. editor_xmlhttp.open("GET", "dict_get_list.php?t=" + d.getTime(), true);
  117. editor_xmlhttp.send();
  118. }
  119. function editor_serverResponse() {
  120. if (editor_xmlhttp.readyState == 4)// 4 = "loaded"
  121. {
  122. if (editor_xmlhttp.status == 200) {// 200 = "OK"
  123. var DictFileList = new Array;
  124. eval(editor_xmlhttp.responseText);
  125. for (x in local_dict_list) {
  126. g_dictList.push(local_dict_list[x]);
  127. }
  128. var fileList = "";
  129. for (x in local_dict_list) {
  130. if (local_dict_list[x].used) {
  131. fileList = fileList + "<p><input id='id_dict_file_list_" + x + "' type='checkbox' style='width: 20px; height: 20px' checked onclick='dict_active(this," + x + ")'/>" + local_dict_list[x].filename + "<span id='dict_result_" + x + "'></span></p>";
  132. }
  133. else {
  134. fileList = fileList + "<p><input id='id_dict_file_list_" + x + "' type='checkbox' style='width: 20px; height: 20px' onclick='dict_active(this," + x + ")'/>" + local_dict_list[x].filename + "<span id='dict_result_" + x + "'></span></p>";
  135. }
  136. }
  137. document.getElementById('basic_dict_list').innerHTML = fileList;
  138. }
  139. else {
  140. document.getElementById('basic_dict_list') = "Problem retrieving data:" + xmlhttp.statusText;
  141. }
  142. }
  143. }
  144. function dict_active(obj, dictIndex) {
  145. if (this.checked) {
  146. g_dictList[dictIndex].used = true;
  147. }
  148. else {
  149. g_dictList[dictIndex].used = false;
  150. }
  151. }
  152. function editor_windowsInit() {
  153. $("see").click(function () {
  154. var to = $(this).attr("to");
  155. var link;
  156. if (to) {
  157. link = to;
  158. }
  159. else {
  160. link = $(this).text();
  161. }
  162. alert(link);
  163. dict_search(link);
  164. });
  165. var strSertch = location.search;
  166. if (strSertch.length > 0) {
  167. strSertch = strSertch.substr(1);
  168. let sertchList = strSertch.split('&');
  169. for (const param of sertchList) {
  170. let item = param.split('=');
  171. switch (item[0]) {
  172. case "filename":
  173. g_filename = item[1];
  174. break;
  175. case "fileid":
  176. g_docid = item[1];
  177. break;
  178. case "doc_id":
  179. g_docid = item[1];
  180. break;
  181. case "op":
  182. g_op = item[1];
  183. break;
  184. case "book":
  185. g_book = item[1];
  186. break;
  187. case "para":
  188. g_para = item[1];
  189. break;
  190. case "channal":
  191. g_channal = item[1];
  192. break;
  193. }
  194. }
  195. }
  196. checkCookie();
  197. setUseMode("Edit");
  198. editor_getDictFileList();
  199. document.getElementById('id_info_window_select').value = "view_dict_curr";
  200. windowsSelected(document.getElementById('id_info_window_select'));
  201. document.getElementById('id_info_panal').style.height = "0px";
  202. palicannon_init();
  203. //载入我的术语词典
  204. term_get_my();
  205. //载入全部术语词头
  206. term_get_all_pali();
  207. //载入格位公式
  208. load_my_formula();
  209. switch (g_op) {
  210. case "new":
  211. document.getElementById("wizard_div").style.display = "flex";
  212. document.getElementById('id_editor_menu_select').value = "menu_pali_cannon"
  213. menuSelected(document.getElementById('id_editor_menu_select'))
  214. createXmlDoc()
  215. var_dump(gLocal.gui.newproject);
  216. break;
  217. case "open":
  218. if (g_docid.length > 0) {
  219. editor_openProject(g_docid, "pcs");
  220. }
  221. else {
  222. alert(gLocal.gui.nofilename);
  223. }
  224. break;
  225. case "opendb":
  226. if (g_docid.length > 0) {
  227. editor_openProject(g_docid, "db");
  228. }
  229. else {
  230. alert("no doc id");
  231. }
  232. break;
  233. case "openchannal":
  234. editor_openChannal(g_book, g_para, g_channal);
  235. break;
  236. case "import":
  237. if (g_filename.length > 0) {
  238. editor_importOldVer(g_filename)
  239. g_filename = g_filename.substring(0, g_filename.length - 4) + ".pcs"
  240. }
  241. else {
  242. alert(gLocal.gui.nofilename);
  243. }
  244. break;
  245. case "loadlist":
  246. editor_show_right_tool_bar(true);
  247. //get_pc_res_download_list_from_cookie();
  248. get_pc_res_download_list_from_string(gDownloadListString);
  249. createXmlDoc();
  250. pc_loadStream(0);
  251. break;
  252. default:
  253. break;
  254. }
  255. ntf_init();
  256. }
  257. var g_dict_search_one_pass_done = null;
  258. var g_dict_search_one_dict_done = null;
  259. var g_dict_search_all_done = null;
  260. function editor_dict_all_done() {
  261. document.getElementById('editor_doc_notify').innerHTML = gLocal.gui.all_done;
  262. var t = setTimeout("document.getElementById('editor_doc_notify').innerHTML=''", 5000);
  263. }
  264. function editor_dict_one_dict_done(dictIndex) {
  265. document.getElementById('editor_doc_notify').innerHTML = gLocal.gui.round_1 + (g_dictFindParentLevel + 1) + gLocal.gui.round_2 + "【" + g_dictList[dictIndex].name + "】" + gLocal.gui.done;
  266. if (dictIndex + 1 < g_dictList.length - 1) {
  267. document.getElementById('editor_doc_notify').innerHTML += "【" + g_dictList[dictIndex + 1].name + "】" + gLocal.gui.checking;
  268. }
  269. }
  270. function menu_dict_match() {
  271. g_dict_search_one_pass_done = null;
  272. g_dict_search_one_dict_done = null;
  273. g_dict_search_all_done = null;
  274. currMatchingDictNum = 0;
  275. g_dictFindParentLevel = 0;
  276. g_dictFindAllDone = false;
  277. g_dict_search_one_dict_done = editor_dict_one_dict_done;
  278. g_dict_search_all_done = editor_dict_all_done;
  279. dict_refresh_word_download_list();
  280. var arrBuffer = dict_get_search_list();
  281. g_CurrDictBuffer = JSON.stringify(arrBuffer);
  282. dict_mark_word_list_done();
  283. document.getElementById('id_dict_match_inner').innerHTML += "finding parent level " + g_dictFindParentLevel + " buffer:" + arrBuffer.length + "<br>";
  284. editor_dict_match();
  285. }
  286. function editor_dict_match() {
  287. if (currMatchingDictNum < g_dictList.length) {
  288. if (g_dictList[currMatchingDictNum].used) {
  289. editor_loadDictFromDB(g_filename, g_dictList[currMatchingDictNum]);
  290. }
  291. else {
  292. currMatchingDictNum++;
  293. editor_dict_match();
  294. }
  295. if (g_dictFindAllDone) {
  296. dictMatchXMLDoc();
  297. }
  298. }
  299. else {
  300. if (g_dictFindParentLevel < 3) {
  301. if (g_dict_search_one_pass_done) {
  302. g_dict_search_one_pass_done(g_dictFindParentLevel);
  303. }
  304. currMatchingDictNum = 0;
  305. g_dictFindParentLevel++;
  306. var arrBuffer = dict_get_search_list();
  307. g_CurrDictBuffer = JSON.stringify(arrBuffer);
  308. dict_mark_word_list_done();
  309. document.getElementById('id_dict_match_inner').innerHTML += "finding parent level " + g_dictFindParentLevel + " buffer:" + arrBuffer.length + "<br>";
  310. editor_dict_match();
  311. }
  312. else {
  313. document.getElementById('id_dict_match_inner').innerHTML += "Max Parent Level " + g_dictFindParentLevel + " Stop!<br>";
  314. if (g_dict_search_all_done) {
  315. g_dict_search_all_done();
  316. }
  317. dict_mark_word_list_done();
  318. dictMatchXMLDoc();
  319. }
  320. }
  321. }
  322. function dict_push_word_to_download_list(word, level) {
  323. for (var i in g_InlineDictWordList) {
  324. if (g_InlineDictWordList[i].word == word) {
  325. return;
  326. }
  327. }
  328. var newWord = new Object();
  329. newWord.word = word;
  330. newWord.done = false;
  331. newWord.level = level;
  332. g_InlineDictWordList.push(newWord);
  333. }
  334. function dict_get_search_list() {
  335. var output = new Array()
  336. for (var i in g_InlineDictWordList) {
  337. if (g_InlineDictWordList[i].done == false) {
  338. output.push(g_InlineDictWordList[i]);
  339. }
  340. }
  341. return (output);
  342. }
  343. function dict_mark_word_list_done() {
  344. for (var i in g_InlineDictWordList) {
  345. g_InlineDictWordList[i].done = true;
  346. }
  347. }
  348. function dict_refresh_word_download_list() {
  349. var xDict = gXmlBookDataBody.getElementsByTagName("word");
  350. for (var iword = 0; iword < xDict.length; iword++) {
  351. var pali = com_getPaliReal(getNodeText(xDict[iword], "real"));
  352. var part = getNodeText(xDict[iword], "org");
  353. var type = getNodeText(xDict[iword], "case").split("#");
  354. if (pali != "") {
  355. dict_push_word_to_download_list(pali, 0);
  356. }
  357. if (part != "") {
  358. var level = 1;
  359. if (type == ".un.") {
  360. level = 0;
  361. }
  362. var arrPart = part.split("+");
  363. for (var ipart in arrPart) {
  364. var onePart = com_getPaliReal(arrPart[ipart]);
  365. if (onePart != "") {
  366. dict_push_word_to_download_list(onePart, level);
  367. }
  368. }
  369. }
  370. }
  371. for (var i in g_DictWordList) {
  372. var pali = com_getPaliReal(g_DictWordList[i].Pali);
  373. var wparent = com_getPaliReal(g_DictWordList[i].Parent);
  374. var part = g_DictWordList[i].Factors;
  375. var type = g_DictWordList[i].Type;
  376. var level = 1;
  377. if (type == ".un.") {
  378. level = 0;
  379. }
  380. if (wparent != "") {
  381. dict_push_word_to_download_list(wparent, level);
  382. }
  383. if (part != "") {
  384. var arrPart = part.split("+");
  385. for (var ipart in arrPart) {
  386. var onePart = com_getPaliReal(arrPart[ipart]);
  387. if (onePart != "") {
  388. dict_push_word_to_download_list(onePart, level);
  389. }
  390. }
  391. }
  392. }
  393. }
  394. function dict_inid_ild_word_list() {
  395. g_InlineDictWordList = new Array();
  396. for (var i in g_DictWordList) {
  397. var pali = g_DictWordList[i].Pali;
  398. var wparent = g_DictWordList[i].Parent;
  399. var part = g_DictWordList[i].Factors;
  400. var type = g_DictWordList[i].Type;
  401. var level = 1;
  402. dict_push_word_to_download_list(g_DictWordList[i].Pali, 0);
  403. }
  404. dict_mark_word_list_done();
  405. }
  406. function getAllWordList() {
  407. var output = new Array();
  408. if (g_dictFindParentLevel == 0) {
  409. var xDict = gXmlBookDataBody.getElementsByTagName("word");
  410. for (iword = 0; iword < xDict.length; iword++) {
  411. pali = getNodeText(xDict[iword], "real");
  412. if (isPaliWord(pali)) {
  413. output.push(pali);
  414. }
  415. }
  416. }
  417. else {
  418. var currLevel = g_dictFindParentLevel - 1;
  419. for (i = 0; i < g_DictWordList.length; i++) {
  420. if (g_DictWordList[i].ParentLevel == currLevel) {
  421. if (g_DictWordList[i].Parent.length > 0 && g_DictWordList[i].Parent != g_DictWordList[i].Pali) {
  422. var arrList = g_DictWordList[i].Parent.split("$");
  423. var paliInParent = false;
  424. for (x = 0; x < arrList.length; x++) {
  425. if (arrList[x] == g_DictWordList[i].Pali) {
  426. paliInParent = true;
  427. }
  428. }
  429. if (paliInParent == false) {
  430. output.push(g_DictWordList[i].Parent);
  431. }
  432. }
  433. if (g_DictWordList[i].Factors.length > 0) {
  434. arrList = g_DictWordList[i].Factors.split("+");
  435. for (x = 0; x < arrList.length; x++) {
  436. if (arrList[x] != g_DictWordList[i].Pali) {
  437. output.push(arrList[x]);
  438. }
  439. }
  440. }
  441. }
  442. }
  443. }
  444. if (output.length > 0) {
  445. return output.join("$");
  446. }
  447. else {
  448. return null;
  449. }
  450. }
  451. var editor_DictXmlHttp = null;
  452. function editor_loadDictFromDB(strFileName, dictName) {
  453. var xmlText = "";
  454. if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc.
  455. editor_DictXmlHttp = new XMLHttpRequest();
  456. }
  457. else if (window.ActiveXObject) {// code for IE6, IE5
  458. editor_DictXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  459. }
  460. if (editor_DictXmlHttp != null) {
  461. var d = new Date();
  462. var strLink = "dict_find.php?mode=xml&filename=" + strFileName + "&type=" + dictName.type + "&dict=" + dictName.filename;
  463. editor_DictXmlHttp.onreadystatechange = editor_dict_serverResponse;
  464. //var wordList=getAllWordList();
  465. var wordList = g_CurrDictBuffer;
  466. if (wordList != null) {
  467. document.getElementById('id_dict_msg').innerHTML = "开始匹配字典" + dictName.name;
  468. editor_DictXmlHttp.open("POST", "dict_find2.php", true);
  469. //editor_DictXmlHttp.send(dictName.type+"$"+dictName.filename+"$"+g_dictFindParentLevel+"$"+wordList);
  470. editor_DictXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  471. editor_DictXmlHttp.send("type=" + dictName.type + "&filename=" + dictName.filename + "&level=" + g_dictFindParentLevel + "&data=" + wordList);
  472. }
  473. else {
  474. g_dictFindAllDone = true;
  475. document.getElementById('id_dict_match_inner').innerHTML += "all done!";
  476. if (g_dict_search_all_done) {
  477. g_dict_search_all_done();
  478. }
  479. }
  480. }
  481. else {
  482. alert("Your browser does not support XMLHTTP.");
  483. }
  484. }
  485. function editor_dict_serverResponse() {
  486. if (editor_DictXmlHttp.readyState == 4)// 4 = "loaded"
  487. {
  488. document.getElementById('id_dict_msg').innerHTML = "已经获取字典数据";
  489. if (editor_DictXmlHttp.status == 200) {// 200 = "OK"
  490. var xmlText = editor_DictXmlHttp.responseText;
  491. if (window.DOMParser) {
  492. parser = new DOMParser();
  493. xmlDict = parser.parseFromString(xmlText, "text/xml");
  494. }
  495. else // Internet Explorer
  496. {
  497. xmlDict = new ActiveXObject("Microsoft.XMLDOM");
  498. xmlDict.async = "false";
  499. xmlDict.loadXML(xmlText);
  500. }
  501. if (xmlDict == null) {
  502. alert("error:can not load dict.");
  503. return;
  504. }
  505. document.getElementById('dict_result_' + currMatchingDictNum).innerHTML = " : " + g_dictFindParentLevel + "-" + xmlDict.getElementsByTagName("word").length;
  506. dictDataParse(xmlDict, currMatchingDictNum);
  507. editor_addDictDataToXmlDoc(xmlDict);
  508. }
  509. else {
  510. document.getElementById('id_dict_match_inner').innerHTML = "Problem retrieving data:" + editor_DictXmlHttp.statusText;
  511. }
  512. if (g_dict_search_one_dict_done) {
  513. g_dict_search_one_dict_done(currMatchingDictNum);
  514. }
  515. currMatchingDictNum++;
  516. editor_dict_match();
  517. }
  518. }
  519. //添加字典数据到内联字典
  520. function editor_addDictDataToXmlDoc(xmlDictData) {
  521. var xDict = xmlDictData.getElementsByTagName("word");
  522. for (iword = 0; iword < xDict.length; iword++) {
  523. gXmlBookDataInlineDict.appendChild(xDict[iword].cloneNode(true));
  524. }
  525. }
  526. /*解析字典数据*/
  527. function dictDataParse(xmlDictData, dictID) {
  528. document.getElementById('id_dict_msg').innerHTML = "正在解析字典数据";
  529. var xDict = xmlDictData.getElementsByTagName("word");
  530. var tOut = "";
  531. var sDictPali = "";
  532. var sDictId = "";
  533. var sDictOrg = "";
  534. var sDictMean = "";
  535. var sDictCase = "";
  536. for (iword = 0; iword < xDict.length; iword++) {
  537. var objDictItem = new Object();/*一个字典元素*/
  538. objDictItem.Id = getNodeText(xDict[iword], "id");
  539. objDictItem.Guid = getNodeText(xDict[iword], "guid");
  540. objDictItem.Pali = getNodeText(xDict[iword], "pali");
  541. objDictItem.Mean = getNodeText(xDict[iword], "mean");
  542. objDictItem.Type = getNodeText(xDict[iword], "type");
  543. objDictItem.Gramma = getNodeText(xDict[iword], "gramma");
  544. objDictItem.Parent = getNodeText(xDict[iword], "parent");
  545. objDictItem.Factors = getNodeText(xDict[iword], "factors");
  546. objDictItem.PartId = getNodeText(xDict[iword], "part_id");
  547. objDictItem.FactorMean = getNodeText(xDict[iword], "factormean");
  548. objDictItem.Note = getNodeText(xDict[iword], "note");
  549. objDictItem.Confer = getNodeText(xDict[iword], "confer");
  550. objDictItem.Status = getNodeText(xDict[iword], "status");
  551. objDictItem.Enable = getNodeText(xDict[iword], "enable");
  552. objDictItem.Language = getNodeText(xDict[iword], "language");
  553. objDictItem.dictname = getNodeText(xDict[iword], "dict_name");
  554. //objDictItem.dictname=g_dictList[dictID].name;
  555. objDictItem.dictType = g_dictList[dictID].type;
  556. objDictItem.fileName = g_dictList[dictID].filename;
  557. objDictItem.dictID = dictID;
  558. objDictItem.ParentLevel = g_dictFindParentLevel;
  559. //插入数据到内联字典索引表
  560. var level = 1;
  561. if (objDictItem.Type == ".un.") {
  562. level = 0;
  563. }
  564. if (objDictItem.Parent != "") {
  565. dict_push_word_to_download_list(objDictItem.Parent, level);
  566. }
  567. if (objDictItem.Factors != "") {
  568. var arrPart = objDictItem.Factors.split("+");
  569. for (var ipart in arrPart) {
  570. dict_push_word_to_download_list(arrPart[ipart], level);
  571. }
  572. }
  573. if (objDictItem.Case != "?" || objDictItem.Org != "?" || objDictItem.Mean != "?") {
  574. pushNewDictItem(g_DictWordList, objDictItem);
  575. }
  576. }
  577. //dict end
  578. }
  579. function pushNewDictItem(inArray, objNew) {
  580. //var isExist=false;
  581. for (indexList in inArray) {
  582. if (inArray[indexList].Id == objNew.Id && inArray[indexList].dictID == objNew.dictID) {
  583. return;
  584. }
  585. }
  586. inArray.push(objNew);
  587. }
  588. function dictShowAsTable() {
  589. var outData = "<table>";
  590. for (var i = 0; i < g_DictWordList.length; i++) {
  591. outData += "<tr class='dict_row" + g_DictWordList[i].ParentLevel + "'>";
  592. outData = outData + "<td>" + g_DictWordList[i].dictname + "</td>";
  593. outData = outData + "<td>" + g_DictWordList[i].Pali + "</td>";
  594. outData = outData + "<td>" + g_DictWordList[i].Type + "</td>";
  595. outData = outData + "<td>" + g_DictWordList[i].Gramma + "</td>";
  596. outData = outData + "<td>" + g_DictWordList[i].Parent + "</td>";
  597. outData = outData + "<td>" + g_DictWordList[i].Mean + "</td>";
  598. outData = outData + "<td>" + g_DictWordList[i].Factors + "</td>";
  599. outData = outData + "</tr>";
  600. }
  601. outData += "</table>";
  602. return outData;
  603. }
  604. var g_CurrActiveRecorder = "new";
  605. function setCurrActiveRecorder(recorderName) {
  606. g_CurrActiveRecorder = recorderName;
  607. }
  608. function updataCurrActiveRecorder(filder, value) {
  609. if (filder == "all") {
  610. }
  611. else {
  612. document.getElementById(filder + "_" + g_CurrActiveRecorder).value = value;
  613. mean_change(g_CurrActiveRecorder);
  614. }
  615. }
  616. function addToCurrActiveRecorder(filder, value) {
  617. if (filder == "all") {
  618. }
  619. else {
  620. meanString = document.getElementById(filder + "_" + g_CurrActiveRecorder).value;
  621. meanList = meanString.split("$");
  622. for (i in meanList) {
  623. if (meanList[i] == value) {
  624. return;
  625. }
  626. }
  627. document.getElementById(filder + "_" + g_CurrActiveRecorder).value += "$" + value;
  628. mean_change(g_CurrActiveRecorder);
  629. }
  630. }
  631. function updataFactorMeanPrev(id, strNew) {
  632. //if(strNew!=null){
  633. //document.getElementById("id_factormean_prev_"+id).value=strNew;
  634. //}
  635. }
  636. function factorMeanItemChange(id, iPos, count, obj) {
  637. //alert(id+":"+iPos+":"+newMean);
  638. newMean = obj.value
  639. var factorMeanPrevString = document.getElementById("id_factormean_prev_" + id).value;
  640. currFactorMeanPrevList = factorMeanPrevString.split("+");
  641. currFactorMeanPrevList[iPos] = newMean;
  642. document.getElementById("id_factormean_prev_" + id).value = currFactorMeanPrevList.join("+");
  643. }
  644. function makeFactorBlock(factorStr, id) {
  645. var output = "";
  646. var factorList = factorStr.split("+");
  647. var defualtFactorMeanList = new Array;
  648. for (iFactor in factorList) {
  649. arrFM = findAllMeanInDict(factorList[iFactor], 10);
  650. if (arrFM.length == 0) {
  651. arrFM[0] = "unkow";
  652. }
  653. output += "<select onclick=\"factorMeanItemChange('" + id + "','" + iFactor + "','" + factorList.length + "',this)\">";
  654. defualtFactorMeanList.push(arrFM[0]);
  655. for (iFM in arrFM) {
  656. output += "<option value='" + arrFM[iFM] + "' >" + arrFM[iFM] + "</option>";
  657. }
  658. output += "</select>";
  659. if (iFactor < factorList.length - 1) {
  660. output += "+";
  661. }
  662. }
  663. //updataFactorMeanPrev(id,defualtFactorMeanList.join("+"));
  664. g_FactorMean = defualtFactorMeanList.join("+");
  665. return (output);
  666. }
  667. function factor_change(id) {
  668. var factorString = document.getElementById("id_dict_user_factors_" + id).value;
  669. document.getElementById("id_factor_block_" + id).innerHTML = makeFactorBlock(factorString, id);
  670. }
  671. function makeMeanBlock(meanStr, id) {
  672. var output = "";
  673. var meanList = meanStr.split("$");
  674. for (i in meanList) {
  675. output += "<div class=\"mean_cell\">";
  676. output += "<div class=\"button_shell\">";
  677. output += "<p class=\"mean_button\" onclick=\"meanBlockMove('" + id + "'," + i + "," + (i - 1) + ")\">«</p>";
  678. output += "</div>";
  679. output += "<p class=\"mean_inner\" onclick=\"meanBlockMove('" + id + "'," + i + "," + 0 + ")\">" + meanList[i] + "</p>";
  680. output += "<div class=\"button_shell\">";
  681. output += "<p class=\"mean_button\" onclick=\"meanBlockDelete('" + id + "'," + i + ")\">x</p>";
  682. output += "</div>";
  683. output += "</div>";
  684. }
  685. return (output);
  686. }
  687. function mean_change(id) {
  688. var meanString = document.getElementById("id_dict_user_mean_" + id).value;
  689. document.getElementById("id_mean_block_" + id).innerHTML = makeMeanBlock(meanString, id);
  690. }
  691. function meanBlockDelete(id, indexDelete) {
  692. var meanString = document.getElementById("id_dict_user_mean_" + id).value;
  693. var meanBlock = "";
  694. var meanList = meanString.split("$");
  695. meanList.splice(indexDelete, 1);
  696. var newString = meanList.join("$");
  697. document.getElementById("id_dict_user_mean_" + id).value = newString;
  698. mean_change(id);
  699. }
  700. function meanBlockMove(id, moveFrom, moveTo) {
  701. var meanString = document.getElementById("id_dict_user_mean_" + id).value;
  702. var meanBlock = "";
  703. var meanList = meanString.split("$");
  704. if (moveTo < 0) {
  705. moveTo = 0;
  706. }
  707. if (moveFrom == moveTo) {
  708. return;
  709. }
  710. var temp = meanList[moveTo];
  711. meanList[moveTo] = meanList[moveFrom];
  712. for (i = moveFrom - 1; i > moveTo; i--) {
  713. meanList[i + 1] = meanList[i];
  714. }
  715. meanList[moveTo + 1] = temp;
  716. var newString = meanList.join("$");
  717. /*
  718. for(x in meanList){
  719. newString+=meanList[x]+"$";
  720. }
  721. */
  722. document.getElementById("id_dict_user_mean_" + id).value = newString;
  723. mean_change(id);
  724. }
  725. function addAutoMeanToFactorMean(id) {
  726. document.getElementById("id_dict_user_fm_" + id).value = document.getElementById("id_factormean_prev_" + id).value;
  727. }
  728. //show current selected word in the word window to modify
  729. var g_WordTableCurrWord = "";
  730. function dictCurrWordShowAsTable(inCurrWord) {
  731. g_WordTableCurrWord = inCurrWord;
  732. g_CurrActiveRecorder = "new";
  733. var outData = "";
  734. var listParent = new Array();
  735. var listFactors = new Array();
  736. var listChildren = new Array();
  737. outData += "<p class='word_parent'>" + gLocal.gui.parent + ":";
  738. for (var i = 0; i < g_DictWordList.length; i++) {
  739. if (g_DictWordList[i].Pali == inCurrWord) {
  740. if (g_DictWordList[i].Parent.length > 0) {
  741. var find = false;
  742. for (x in listParent) {
  743. if (listParent[x] == g_DictWordList[i].Parent) {
  744. find = true;
  745. break;
  746. }
  747. }
  748. if (!find) {
  749. listParent.push(g_DictWordList[i].Parent);
  750. }
  751. }
  752. if (g_DictWordList[i].Factors.length > 0) {
  753. arrFactors = g_DictWordList[i].Factors.split("+");
  754. for (iFactors in arrFactors) {
  755. var find = false;
  756. for (x in listFactors) {
  757. if (listFactors[x] == arrFactors[iFactors]) {
  758. find = true;
  759. break;
  760. }
  761. }
  762. if (!find) {
  763. listFactors.push(arrFactors[iFactors]);
  764. }
  765. }
  766. }
  767. }
  768. }
  769. for (x in listParent) {
  770. outData += "<a onclick=\"showCurrWordTable('" + listParent[x] + "')\">" + listParent[x] + "</a> "
  771. }
  772. for (x in listFactors) {
  773. outData += "[<a onclick=\"showCurrWordTable('" + listFactors[x] + "')\">" + listFactors[x] + "</a>] "
  774. }
  775. outData += "</p>";
  776. outData = outData + "<p class=\"word_current\">└" + inCurrWord + "</p>";
  777. outData += "<p class='word_child'>└" + gLocal.gui.children + ": ";
  778. for (var i = 0; i < g_DictWordList.length; i++) {
  779. if (g_DictWordList[i].Parent == inCurrWord) {
  780. if (g_DictWordList[i].Pali.length > 0) {
  781. var find = false;
  782. for (x in listChildren) {
  783. if (listChildren[x] == g_DictWordList[i].Pali) {
  784. find = true;
  785. break;
  786. }
  787. }
  788. if (!find) {
  789. listChildren.push(g_DictWordList[i].Pali);
  790. }
  791. }
  792. }
  793. }
  794. for (x in listChildren) {
  795. outData += "<a onclick=\"showCurrWordTable('" + listChildren[x] + "')\">" + listChildren[x] + "</a> "
  796. }
  797. outData += "</p>";
  798. //get new recorder filder
  799. var newRecorder = new Object();
  800. newRecorder.Type = "";
  801. newRecorder.Gramma = "";
  802. newRecorder.Parent = "";
  803. newRecorder.Mean = "";
  804. newRecorder.Note = "";
  805. newRecorder.Factors = "";
  806. newRecorder.FactorMean = "";
  807. newRecorder.Confer = "";
  808. newRecorder.Status = "";
  809. newRecorder.Lock = "";
  810. newRecorder.Tag = "";
  811. var newMeanList = new Array();
  812. for (var i = 0; i < g_DictWordList.length; i++) {
  813. if (g_DictWordList[i].Pali == inCurrWord) {
  814. if (newRecorder.Type == "" && g_DictWordList[i].Type.length > 0) {
  815. newRecorder.Type = g_DictWordList[i].Type
  816. }
  817. if (newRecorder.Gramma == "" && g_DictWordList[i].Gramma.length > 0) {
  818. newRecorder.Gramma = g_DictWordList[i].Gramma;
  819. }
  820. if (newRecorder.Parent == "" && g_DictWordList[i].Parent.length > 0) {
  821. newRecorder.Parent = g_DictWordList[i].Parent;
  822. }
  823. if (g_DictWordList[i].Mean.length > 0) {
  824. otherMean = g_DictWordList[i].Mean.split("$");
  825. for (iMean in otherMean) {
  826. pushNewToList(newMeanList, otherMean[iMean]);
  827. }
  828. newRecorder.Mean = newMeanList.join("$");
  829. }
  830. if (newRecorder.Factors == "" && g_DictWordList[i].Factors.length > 0) {
  831. newRecorder.Factors = g_DictWordList[i].Factors;
  832. }
  833. if (newRecorder.FactorMean == "" && g_DictWordList[i].FactorMean.length > 0) {
  834. newRecorder.FactorMean = g_DictWordList[i].FactorMean;
  835. }
  836. if (newRecorder.Note == "" && g_DictWordList[i].Note) {
  837. if (g_DictWordList[i].Note.length > 0) {
  838. newRecorder.Note = g_DictWordList[i].Note;
  839. }
  840. }
  841. }
  842. }
  843. newMeanBlock = makeMeanBlock(newRecorder.Mean, "new");
  844. newFactorBlock = makeFactorBlock(newRecorder.Factors, "new");
  845. newFactorMeanPrevString = g_FactorMean;
  846. outData += "<div class=\"word_edit\">"
  847. outData += " <div class=\"word_edit_head\">"
  848. outData += "<input type=\"input\" id=\"id_dict_user_id_new\" hidden value=\"0\" >"
  849. outData += "<input type=\"input\" id=\"id_dict_user_pali_new\" hidden value=\"" + inCurrWord + "\" >"
  850. outData += " <button type=\"button\" onclick=\"editor_UserDictUpdata('new',this)\">" + gLocal.gui.newword + "</button>"
  851. outData += " " + gLocal.gui.wordtype + ":"
  852. outData += " <select name=\"type\" id=\"id_dict_user_type_new\" onchange=\"typeChange(this)\">";
  853. for (x in gLocal.type_str) {
  854. if (gLocal.type_str[x].id == newRecorder.Type) {
  855. outData = outData + "<option value=\"" + gLocal.type_str[x].id + "\" selected>" + gLocal.type_str[x].value + "</option>";
  856. }
  857. else {
  858. outData = outData + "<option value=\"" + gLocal.type_str[x].id + "\">" + gLocal.type_str[x].value + "</option>";
  859. }
  860. }
  861. outData = outData + " </select>";
  862. outData += " " + gLocal.gui.gramma + ":<input type=\"input\" id=\"id_dict_user_gramma_new\" size=\"12\" value=\"" + newRecorder.Gramma + "\" />"
  863. outData += " " + gLocal.gui.parent + ":<input type=\"input\" id=\"id_dict_user_parent_new\" size=\"12\" value=\"" + newRecorder.Parent + "\" />"
  864. outData += " " + gLocal.gui.part + ":<input type=\"input\" id=\"id_dict_user_factors_new\" size=\"" + inCurrWord.length * 1.2 + "\" value=\"" + newRecorder.Factors + "\" onkeyup=\"factor_change('new')\" />"
  865. outData += " " + gLocal.gui.partmeaning + ":" + newFactorBlock
  866. outData += "<button type=\"button\" onclick=\"addAutoMeanToFactorMean('new')\" >▶</button>"
  867. outData += " <input type=\"input\" id=\"id_dict_user_fm_new\" size=\"" + inCurrWord.length + "\" value=\"" + newRecorder.FactorMean + "\" />"
  868. outData += " </div>"
  869. outData += " <div class=\"word_edit_mean\">"
  870. outData += " " + gLocal.gui.meaning + ":<input type=\"input\" size='50' id=\"id_dict_user_mean_new\" value=\"" + newRecorder.Mean + "\" onkeyup=\"mean_change('new')\"/><div class='mean_block' id='id_mean_block_new'>" + newMeanBlock + "</div>"
  871. outData += " </div>"
  872. outData += "<input type='text' id='id_factormean_prev_new' value='" + newFactorMeanPrevString + "' hidden />"
  873. outData += " <div class=\"word_edit_note\">"
  874. outData += gLocal.gui.note + ":<br /><textarea id=\"id_dict_user_note_new\" rows='3' cols='100'>" + newRecorder.Note + "</textarea>"
  875. outData += " </div>"
  876. outData += "</div>"
  877. //draw new
  878. /*
  879. outData=outData+"<h3>New:</h3>";
  880. outData+="<table>";
  881. outData+="<tr class='dict_row_new'><td></td><td>Type</td><td>Parent</td><td>Meaning</td></tr>";
  882. outData+="<tr class='dict_row_new'><td><input type='radio' name='dictupdata' checked onclick=\"setCurrActiveRecorder('new')\" /></td>"+
  883. "<td><input type=\"input\" id=\"id_dict_user_id_new\" hidden value=\"0\" >"+
  884. "<input type=\"input\" id=\"id_dict_user_pali_new\" hidden value=\""+inCurrWord+"\" >"+
  885. " <select name=\"type\" id=\"id_dict_user_type_new\" onchange=\"typeChange(this)\">";
  886. for (x in gLocal.type_str){
  887. if(gLocal.type_str[x].id==newRecorder.Type){
  888. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\" selected>"+gLocal.type_str[x].value+"</option>";
  889. }
  890. else{
  891. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\">"+gLocal.type_str[x].value+"</option>";
  892. }
  893. }
  894. outData=outData+" </select>";
  895. outData=outData+"</td>";
  896. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_parent_new\" size=\"12\" value=\""+newRecorder.Parent+"\" /></td>";
  897. outData=outData+"<td><input type=\"input\" size='50' id=\"id_dict_user_mean_new\" value=\""+newRecorder.Mean+"\" onkeyup=\"mean_change('new')\"/><div class='mean_block' id='id_mean_block_new'>"+newMeanBlock+"</div></td>";
  898. outData+="</tr>";
  899. outData+="<tr class='dict_row_new'><td></td><td>Gramma</td><td>Parts</td><td>Parts Meaning</td></tr>";
  900. outData+="<tr class='dict_row_new'><td><button type=\"button\" onclick=\"editor_UserDictUpdata('new',this)\">Submit</button></td>";
  901. outData+="<td><input type=\"input\" id=\"id_dict_user_gramma_new\" size=\"12\" value=\""+newRecorder.Gramma+"\" /></td>";
  902. outData+="<td><input type=\"input\" id=\"id_dict_user_factors_new\" size=\""+inCurrWord.length*1.2+"\" value=\""+newRecorder.Factors+"\" onkeyup=\"factor_change('new')\" />";
  903. outData+="<br /><input type='text' id='id_factormean_prev_new' value='"+newFactorMeanPrevString+"' hidden />";
  904. outData+="<div class='factor' id='id_factor_block_new'>"+newFactorBlock+"</div>";
  905. outData+="<button type=\"button\" onclick=\"addAutoMeanToFactorMean('new')\" >▶</button></td>";
  906. outData+="<td><input type=\"input\" id=\"id_dict_user_fm_new\" size=\""+inCurrWord.length*1.5+"\" value=\""+newRecorder.FactorMean+"\" /></td></tr>";
  907. outData+="<tr class='dict_row_new'><td>Note</td>";
  908. outData+="<td colspan=3><textarea id=\"id_dict_user_note_new\" rows='3' cols='100'>"+newRecorder.Note+"</textarea></td></tr>"
  909. outData+="</table>";
  910. */
  911. // end of New
  912. outData += "<h3>" + gLocal.gui.userdict + "</h3>";
  913. outData += "<table>";
  914. outData = outData + "<tr><th></th><th>" + gLocal.gui.dictsouce + "</th> <th>" + gLocal.gui.wordtype + "</th> <th>" + gLocal.gui.gramma + "</th> <th>" + gLocal.gui.parent + "</th> <th>" + gLocal.gui.meaning + "</th> <th>" + gLocal.gui.part + "</th> <th>" + gLocal.gui.partmeaning + "</th> <th></th> </tr>";
  915. for (var i = 0; i < g_DictWordList.length; i++) {
  916. if (g_DictWordList[i].Pali == inCurrWord) {
  917. if (g_DictWordList[i].dictname == "用户字典") {
  918. outData += "<tr class='dict_row" + g_DictWordList[i].ParentLevel + "'>";
  919. outData += "<td><input type=radio name='dictupdata' onclick=\"setCurrActiveRecorder('" + i + "')\" /></td>";
  920. outData = outData + "<td>" + g_DictWordList[i].dictname + "</td>";
  921. outData = outData + "<td><input type=\"input\" id=\"id_dict_user_id_" + i + "\" hidden value=\"" + g_DictWordList[i].Id + "\" >";
  922. outData = outData + "<input type=\"input\" id=\"id_dict_user_pali_" + i + "\" hidden value=\"" + g_DictWordList[i].Pali + "\" >";
  923. outData = outData + " <select name=\"type\" id=\"id_dict_user_type_" + i + "\" onchange=\"typeChange(this)\">";
  924. for (x in gLocal.type_str) {
  925. if (gLocal.type_str[x].id == g_DictWordList[i].Type) {
  926. outData = outData + "<option value=\"" + gLocal.type_str[x].id + "\" selected>" + gLocal.type_str[x].value + "</option>";
  927. }
  928. else {
  929. outData = outData + "<option value=\"" + gLocal.type_str[x].id + "\">" + gLocal.type_str[x].value + "</option>";
  930. }
  931. }
  932. outData = outData + " </select>";
  933. outData = outData + "</td>";
  934. outData = outData + "<td><input type=\"input\" id=\"id_dict_user_gramma_" + i + "\" size=\"12\" value=\"" + g_DictWordList[i].Gramma + "\" /></td>";
  935. outData = outData + "<td><input type=\"input\" id=\"id_dict_user_parent_" + i + "\" size=\"12\" value=\"" + g_DictWordList[i].Parent + "\" />";
  936. outData = outData + "<button type='button' onclick=\"showCurrWordTable('" + g_DictWordList[i].Parent + "')\">»</button></td>";
  937. outData = outData + "<td><input type=\"input\" size='50' id=\"id_dict_user_mean_" + i + "\" value=\"" + g_DictWordList[i].Mean + "\" onkeyup='mean_change(" + i + ")' /><div class='mean_block' id='id_mean_block_" + i + "'></div></td>";
  938. outData = outData + "<td><input type=\"input\" id=\"id_dict_user_factors_" + i + "\" size=\"15\" value=\"" + g_DictWordList[i].Factors + "\" /></td>";
  939. outData = outData + "<td><input type=\"input\" id=\"id_dict_user_fm_" + i + "\" size=\"15\" value=\"" + g_DictWordList[i].FactorMean + "\" /></td>";
  940. outData = outData + "<td><button type=\"button\" onclick=\"editor_UserDictUpdata('" + i + "',this)\">Updata</button></td>";
  941. outData = outData + "</tr>";
  942. outData += "<tr ><td>Note</td>";
  943. outData += "<td colspan=3><textarea id=\"id_dict_user_note_" + i + "\" rows='3' cols='100'>" + g_DictWordList[i].Note + "</textarea></td></tr>"
  944. }
  945. }
  946. }
  947. /*
  948. for(var i=0;i<g_DictWordList.length;i++){
  949. if(g_DictWordList[i].Pali==inCurrWord){
  950. if(g_DictWordList[i].dictname=="用户字典"){
  951. outData+="<tr ><td></td><td>Type</td><td>Parent</td><td>Meaning</td></tr>";
  952. outData+="<tr ><td><input type='radio' name='dictupdata' checked onclick=\"setCurrActiveRecorder('new')\" /></td>"+
  953. "<td><input type=\"input\" id=\"id_dict_user_id_new"+i+"\" hidden value=\"0\" >"+
  954. "<input type=\"input\" id=\"id_dict_user_pali_"+i+"\" hidden value=\""+inCurrWord+"\" >"+
  955. " <select name=\"type\" id=\"id_dict_user_type_"+i+"\" onchange=\"typeChange(this)\">";
  956. for (x in gLocal.type_str){
  957. if(gLocal.type_str[x].id==g_DictWordList[i].Type){
  958. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\" selected>"+gLocal.type_str[x].value+"</option>";
  959. }
  960. else{
  961. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\">"+gLocal.type_str[x].value+"</option>";
  962. }
  963. }
  964. outData=outData+" </select>";
  965. outData=outData+"</td>";
  966. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_parent_"+i+"\" size=\"12\" value=\""+g_DictWordList[i].Parent+"\" /></td>";
  967. outData=outData+"<td><input type=\"input\" size='50' id=\"id_dict_user_mean_"+i+"\" value=\""+g_DictWordList[i].Mean+"\" onkeyup=\"mean_change('new')\"/><div class='mean_block' id='id_mean_block_new'>"+newMeanBlock+"</div></td>";
  968. outData+="</tr>";
  969. outData+="<tr ><td></td><td>Gramma</td><td>Parts</td><td>Parts Meaning</td></tr>";
  970. outData+="<tr ><td><button type=\"button\" onclick=\"editor_UserDictUpdata('"+i+"',this)\">Submit</button></td>";
  971. outData+="<td><input type=\"input\" id=\"id_dict_user_gramma_"+i+"\" size=\"12\" value=\""+g_DictWordList[i].Gramma+"\" /></td>";
  972. outData+="<td><input type=\"input\" id=\"id_dict_user_factors_"+i+"\" size=\""+inCurrWord.length*1.2+"\" value=\""+g_DictWordList[i].Factors+"\" onkeyup=\"factor_change('new')\" />";
  973. outData+="<br /><input type='text' id='id_factormean_prev_"+i+"' value='"+newFactorMeanPrevString+"' hidden />";
  974. outData+="<div class='factor' id='id_factor_block_"+i+"'>"+newFactorBlock+"</div>";
  975. outData+="<button type=\"button\" onclick=\"addAutoMeanToFactorMean('"+i+"')\" >▲</button></td>";
  976. outData+="<td><input type=\"input\" id=\"id_dict_user_fm_"+i+"\" size=\""+inCurrWord.length*1.5+"\" value=\""+g_DictWordList[i].FactorMean+"\" /></td></tr>";
  977. outData+="<tr ><td>Note</td>";
  978. outData+="<td colspan=3><textarea id=\"id_dict_user_note_"+i+"\" rows='3' cols='100'>"+g_DictWordList[i].Note+"</textarea></td></tr>"
  979. }
  980. }
  981. }
  982. */
  983. outData = outData + "</table>";
  984. outData += "<h3>" + gLocal.gui.otherdict + "</h3>";
  985. outData += "<table>";
  986. outData = outData + "<tr><th></th><th>" + gLocal.gui.dictsouce + "</th> <th>" + gLocal.gui.wordtype + "</th> <th>" + gLocal.gui.gramma + "</th> <th>" + gLocal.gui.parent + "</th> <th>" + gLocal.gui.meaning + "</th> <th>" + gLocal.gui.part + "</th> <th>" + gLocal.gui.partmeaning + "</th> <th></th> </tr>";
  987. for (var i = 0; i < g_DictWordList.length; i++) {
  988. if (g_DictWordList[i].Pali == inCurrWord) {
  989. if (g_DictWordList[i].dictname == "用户字典") {
  990. }
  991. else {
  992. outData += "<tr class='dict_row" + g_DictWordList[i].ParentLevel + "'>";
  993. outData += "<td><button type=\"button\" >▲</button></td>";
  994. outData = outData + "<td>" + g_DictWordList[i].dictname + "</td>";
  995. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_type','" + g_DictWordList[i].Type + "')\" >▲</button><span id=\"id_dict_user_gramma_" + i + "\">" + g_DictWordList[i].Type + "</span></td>";
  996. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_gramma','" + g_DictWordList[i].Gramma + "')\">▲</button>" + g_DictWordList[i].Gramma + "</td>";
  997. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_parent','" + g_DictWordList[i].Parent + "')\">▲</button>" + g_DictWordList[i].Parent;
  998. outData = outData + "<button type='button' onclick=\"showCurrWordTable('" + g_DictWordList[i].Parent + "')\">»</button></td>";
  999. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_mean','" + g_DictWordList[i].Mean + "')\">▲</button>" + g_DictWordList[i].Mean + "<br />" + makeMeanLink(g_DictWordList[i].Mean) + "</td>";
  1000. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_factors','" + g_DictWordList[i].Factors + "')\">▲</button>" + g_DictWordList[i].Factors + "</td>";
  1001. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_fm','" + g_DictWordList[i].FactorMean + "')\">▲</button>" + g_DictWordList[i].FactorMean + "</td>";
  1002. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('all','" + g_DictWordList[i].Type + "')\">▲</button></td>";
  1003. outData = outData + "</tr>";
  1004. }
  1005. }
  1006. }
  1007. outData += "</table>";
  1008. //children
  1009. for (x in listChildren) {
  1010. wordChildren = listChildren[x]
  1011. outData += "<h4>" + wordChildren + "</h4> ";
  1012. outData += "<table>";
  1013. outData = outData + "<tr><th></th><th>" + gLocal.gui.dictsouce + "</th> <th>" + gLocal.gui.wordtype + "</th> <th>" + gLocal.gui.gramma + "</th> <th>" + gLocal.gui.parent + "</th> <th>" + gLocal.gui.meaning + "</th> <th>" + gLocal.gui.part + "</th> <th>" + gLocal.gui.partmeaning + "</th> <th></th> </tr>";
  1014. for (var i = 0; i < g_DictWordList.length; i++) {
  1015. if (g_DictWordList[i].Pali == wordChildren) {
  1016. {
  1017. outData += "<tr class='dict_row" + g_DictWordList[i].ParentLevel + "'>";
  1018. outData += "<td><button type=\"button\" >▲</button></td>";
  1019. outData = outData + "<td>" + g_DictWordList[i].dictname + "</td>";
  1020. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_type','" + g_DictWordList[i].Type + "')\" >▲</button><span id=\"id_dict_user_gramma_" + i + "\">" + g_DictWordList[i].Type + "</span></td>";
  1021. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_gramma','" + g_DictWordList[i].Gramma + "')\">▲</button>" + g_DictWordList[i].Gramma + "</td>";
  1022. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_parent','" + g_DictWordList[i].Parent + "')\">▲</button>" + g_DictWordList[i].Parent;
  1023. outData = outData + "<button type='button' onclick=\"showCurrWordTable('" + g_DictWordList[i].Parent + "')\">»</button></td>";
  1024. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_mean','" + g_DictWordList[i].Mean + "')\">▲</button>" + g_DictWordList[i].Mean + "<br />" + makeMeanLink(g_DictWordList[i].Mean) + "</td>";
  1025. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_factors','" + g_DictWordList[i].Factors + "')\">▲</button>" + g_DictWordList[i].Factors + "</td>";
  1026. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_fm','" + g_DictWordList[i].FactorMean + "')\">▲</button>" + g_DictWordList[i].FactorMean + "</td>";
  1027. outData = outData + "<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('all','" + g_DictWordList[i].Type + "')\">▲</button></td>";
  1028. outData = outData + "</tr>";
  1029. }
  1030. }
  1031. }
  1032. outData += "</table>";
  1033. }
  1034. return outData;
  1035. }
  1036. function makeMeanLink(inStr) {
  1037. var arrList = inStr.split("$");
  1038. var output = "";
  1039. for (i in arrList) {
  1040. output += "<a onclick=\"addToCurrActiveRecorder('id_dict_user_mean','" + arrList[i] + "')\">" + arrList[i] + "</a> "
  1041. }
  1042. return (output);
  1043. }
  1044. function showCurrWordTable(currWord) {
  1045. document.getElementById('id_dict_curr_word_inner').innerHTML = dictCurrWordShowAsTable(currWord);
  1046. }
  1047. //匹配字典数据到文档
  1048. function dictMatchXMLDoc() {
  1049. document.getElementById('id_dict_msg').innerHTML = gLocal.gui.dict_match;
  1050. var docWordCounter = 0;
  1051. var matchedCounter = 0;
  1052. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1053. for (var iword = 0; iword < xDocWords.length; iword++) {
  1054. var sPaliWord = getNodeText(xDocWords[iword], "real");
  1055. var sFactorsWord = getNodeText(xDocWords[iword], "org");
  1056. var sMeanWord = getNodeText(xDocWords[iword], "mean");
  1057. var sTypeWord = getNodeText(xDocWords[iword], "case");
  1058. if (isPaliWord(sPaliWord)) {
  1059. docWordCounter++;
  1060. /*将这个词与字典匹配,*/
  1061. var iDict = 0;
  1062. //if(sMeanWord=="?"){
  1063. var thisWord = sPaliWord
  1064. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  1065. if (thisWord == g_DictWordList[iDict].Pali && g_DictWordList[iDict].ParentLevel == 0) {
  1066. if (sMeanWord == "?") {
  1067. setNodeText(xDocWords[iword], "bmc", "bmca");
  1068. }
  1069. modifyWordDetailByWordIndex(iword);
  1070. matchedCounter++;
  1071. break;
  1072. }
  1073. }
  1074. //}
  1075. /*
  1076. else{
  1077. if(isPaliWord(sPaliWord)){
  1078. matchedCounter++;
  1079. }
  1080. }*/
  1081. }
  1082. }
  1083. var progress = matchedCounter * 100 / docWordCounter;
  1084. document.getElementById('id_dict_msg').innerHTML = gLocal.gui.match_end + Math.round(progress) + "%";
  1085. }
  1086. function dictGetFirstMean(strMean) {
  1087. var arrMean = strMean.split("$");
  1088. if (arrMean.length > 0) {
  1089. for (var i = 0; i < arrMean.length; i++) {
  1090. if (arrMean[i].length > 0) {
  1091. return (arrMean[i]);
  1092. }
  1093. else {
  1094. return "";
  1095. }
  1096. }
  1097. return "";
  1098. }
  1099. else {
  1100. return "";
  1101. }
  1102. }
  1103. //test word is pali word or not
  1104. function isPaliWord(inWord) {
  1105. if (inWord.length < 2) {
  1106. return false;
  1107. }
  1108. if (inWord.match(/[x]/)) {
  1109. return false;
  1110. }
  1111. if (inWord.match(/[q]/)) {
  1112. return false;
  1113. }
  1114. if (inWord.match(/[w]/)) {
  1115. return false;
  1116. }
  1117. if (inWord.match(/[a-y]/)) {
  1118. return true;
  1119. }
  1120. else {
  1121. return false;
  1122. }
  1123. }
  1124. function submenu_show_detail(obj) {
  1125. eParent = obj.parentNode;
  1126. //var y = obj.getElementsByTagName("svg");
  1127. var x = eParent.getElementsByTagName("div");
  1128. var o = obj.getElementsByTagName("svg");
  1129. if (x[0].style.maxHeight == "200em") {
  1130. x[0].style.maxHeight = "0px";
  1131. x[0].style.padding = "0px";
  1132. x[0].style.opacity = "0";
  1133. o[0].style.transform = "rotate(0deg)";
  1134. }
  1135. else {
  1136. x[0].style.maxHeight = "200em";
  1137. x[0].style.padding = "10px";
  1138. x[0].style.opacity = "1";
  1139. o[0].style.transform = "rotate(45deg)";
  1140. }
  1141. }
  1142. function getAutoMaxWidth() {
  1143. var Width = $('#').width
  1144. }
  1145. //在导航窗口中显示与此词匹配的字典中的词
  1146. function showMatchedWordsInNavi(wordId) {
  1147. //var matchedCounter=0;
  1148. /*
  1149. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1150. for(var iWord=0;iWord<xDocWords.length;iWord++){
  1151. if(getNodeText(xDocWords[iWord],"id")==wordId){
  1152. wIndex=iWord;
  1153. }
  1154. }
  1155. var sPaliWord = getNodeText(xDocWords[wIndex],"real");
  1156. showWordInNavi(sPaliWord);
  1157. */
  1158. }
  1159. //在导航窗口中显示与此词匹配的字典中的词
  1160. function showWordInNavi(inWord) {
  1161. var matchedCounter = 0;
  1162. var outText = "";
  1163. var sLastDict = "";
  1164. var sPaliWord = inWord;
  1165. outText = outText + "<h3>" + sPaliWord + "</h3>";
  1166. /*将这个词与字典匹配,*/
  1167. var iDict = 0;
  1168. var thisWord = sPaliWord;
  1169. for (iDict = 0; iDict < g_DictWordList.length; iDict++) {
  1170. if (thisWord == g_DictWordList[iDict].Pali) {
  1171. if (g_DictWordList[iDict].dictname != sLastDict) {
  1172. outText = outText + "<dict><span>" + g_DictWordList[iDict].dictname + "<span></dict>";
  1173. sLastDict = g_DictWordList[iDict].dictname;
  1174. }
  1175. outText = outText + "<input type='input' id=\"id_dict_word_list_" + iDict + "\" size='5' value='" + g_DictWordList[iDict].Type + "' />";
  1176. outText = outText + "<input type='input' size='15' value='" + g_DictWordList[iDict].Gramma + "' /><br />";
  1177. outText = outText + "<input type='input' size='20' value='" + g_DictWordList[iDict].Parent + "' /> <button type='button' onclick=\"showWordInNavi('" + g_DictWordList[iDict].Parent + "')\">»</button><br />";
  1178. outText = outText + "<textarea name=\"dict_mean\" rows=\"3\" col=\"25\" style=\"width:20em;\">" + g_DictWordList[iDict].Mean + "</textarea>"
  1179. outText = outText + "<input type='input' size='20' value='" + g_DictWordList[iDict].Factors + "' /><br />";
  1180. outText = outText + "<input type='input' size='20' value='" + g_DictWordList[iDict].FactorMean + "' /><br />";
  1181. outText = outText + "<button type='button' onclick=\"updataDict('" + iDict + "','userdict')\">Modify</button><br />";
  1182. /*
  1183. outText=outText+"<mean onclick=\"updataWordFromDict(this,'mean')\">"+g_DictWordList[iDict].Mean+"</mean>";
  1184. outText=outText+"<org onclick=\"updataWordFromDict(this,'org')\">"+g_DictWordList[iDict].Factors+"</org>";
  1185. outText=outText+"<om onclick=\"updataWordFromDict(this,'om')\">"+g_DictWordList[iDict].FactorMean+"</om>";
  1186. outText=outText+"<case onclick=\"updataWordFromDict(this,'case')\">"+g_DictWordList[iDict].Type+"#"+g_DictWordList[iDict].Gramma+"</case>";
  1187. */
  1188. matchedCounter++;
  1189. }
  1190. }
  1191. document.getElementById("id_dict_matched").innerHTML = outText;
  1192. document.getElementById('id_dict_curr_word_inner').innerHTML = dictCurrWordShowAsTable(inWord);
  1193. }
  1194. function updataWordFromDict(obj, field) {
  1195. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1196. var strValue = obj.innerHTML;
  1197. var applayTo = document.getElementById("id_dict_applay_to").value;
  1198. var strCurrPali = getNodeText(xDocWords[g_currEditWord], "pali");
  1199. switch (applayTo) {
  1200. case "current":
  1201. setNodeText(xDocWords[g_currEditWord], field, strValue);
  1202. modifyWordDetailByWordIndex(g_currEditWord);
  1203. break;
  1204. case "sys":
  1205. for (i = 0; i < xDocWords.length; i++) {
  1206. var strPali = getNodeText(xDocWords[i], "pali");
  1207. if (strCurrPali == strPali) {
  1208. var isAuto = getNodeText(xDocWords[i], "bmc");
  1209. if (isAuto == "bmca") {
  1210. setNodeText(xDocWords[g_currEditWord], field, strValue);
  1211. modifyWordDetailByWordIndex(i);
  1212. }
  1213. }
  1214. }
  1215. break;
  1216. case "all":
  1217. for (i = 0; i < xDocWords.length; i++) {
  1218. var strPali = getNodeText(xDocWords[i], "pali");
  1219. if (strCurrPali == strPali) {
  1220. setNodeText(xDocWords[g_currEditWord], field, strValue);
  1221. modifyWordDetailByWordIndex(i);
  1222. }
  1223. }
  1224. break;
  1225. }
  1226. }
  1227. function setBookMarkColor(obj, strColor) {
  1228. var items = obj.parentNode.getElementsByTagName("li");
  1229. for (var i = 0; i < items.length; i++) {
  1230. items[i].style.outline = "0px solid";
  1231. }
  1232. if (g_currBookMarkColor == strColor || strColor == "bmc0") {
  1233. g_currBookMarkColor = "bmc0"
  1234. }
  1235. else {
  1236. obj.style.outline = "0.2em solid";
  1237. g_currBookMarkColor = strColor;
  1238. }
  1239. //apply_button_lock();
  1240. }
  1241. function getBookMarkColor(idColor) {
  1242. var items = document.getElementById("id_book_mark_color_select").getElementsByTagName("li");
  1243. for (var i = 0; i < items.length; i++) {
  1244. items[i].style.outline = "0px solid";
  1245. }
  1246. if (document.getElementById("id_" + idColor)) {
  1247. document.getElementById("id_" + idColor).style.outline = "0.2em solid";
  1248. }
  1249. }
  1250. function match_key(obj) {
  1251. g_key_match_str = obj.value;
  1252. for (unicode_key_i in local_code_str) {
  1253. g_key_match_str = g_key_match_str.replace(/\+/g, "");
  1254. g_key_match_str = g_key_match_str.replace(/\[/g, "");
  1255. g_key_match_str = g_key_match_str.replace(/\]/g, "");
  1256. }
  1257. }
  1258. function unicode_key(obj) {
  1259. var strNew = obj.value;
  1260. var key_match_str = strNew;
  1261. var replace_judge = 0;
  1262. key_match_str = key_match_str.replace(/\+/g, "");
  1263. key_match_str = key_match_str.replace(/\[/g, "");
  1264. key_match_str = key_match_str.replace(/\]/g, "");
  1265. for (unicode_key_i in local_code_str) {
  1266. if (strNew.lastIndexOf(local_code_str[unicode_key_i].id) != -1) {
  1267. replace_judge = 1;
  1268. break;
  1269. }
  1270. }
  1271. if (key_match_str != g_key_match_str && replace_judge == 1 && document.getElementById("input_smart_switch").checked) {
  1272. for (unicode_key_i in local_code_str) {
  1273. strNew = strNew.replace(local_code_str[unicode_key_i].id, local_code_str[unicode_key_i].value);
  1274. }
  1275. obj.value = strNew;
  1276. }
  1277. }
  1278. function input_key(obj) {
  1279. var strNew = obj.value;
  1280. for (input_key_i in local_codestr_sinhala) {
  1281. strNew = strNew.replace(local_codestr_sinhala[input_key_i].id, local_codestr_sinhala[input_key_i].value);
  1282. }
  1283. for (input_key_i in local_codestr_sinhala) {
  1284. strNew = strNew.replace(local_codestr_sinhala[input_key_i].id, local_codestr_sinhala[input_key_i].value);
  1285. }
  1286. obj.value = strNew;
  1287. }
  1288. function getPaliReal(inStr) {
  1289. var paliletter = "abcdefghijklmnoprstuvyāīūṅñṭḍṇḷṃ";
  1290. var output = "";
  1291. inStr = inStr.toLowerCase();
  1292. inStr = inStr.replace(/ṁ/g, "ṃ");
  1293. inStr = inStr.replace(/ŋ/g, "ṃ");
  1294. for (x in inStr) {
  1295. if (paliletter.indexOf(inStr[x]) != -1) {
  1296. output += inStr[x];
  1297. }
  1298. }
  1299. return (output);
  1300. }
  1301. function menu_file_convert() {
  1302. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1303. var outText = "";
  1304. var sLastDict = "";
  1305. for (var iword = 0; iword < xDocWords.length; iword++) {
  1306. var sPaliWord = getNodeText(xDocWords[iword], "pali");
  1307. var sPaliMean = getNodeText(xDocWords[iword], "mean");
  1308. /*var thisWord = sPaliWord.toLowerCase();
  1309. thisWord = thisWord.replace(/-/g,"");
  1310. thisWord = thisWord.replace(/'/g,"");
  1311. thisWord = thisWord.replace(/’/g,"");*/
  1312. setNodeText(xDocWords[iword], "real", getPaliReal(sPaliWord));
  1313. setNodeText(xDocWords[iword], "om", sPaliMean);
  1314. }
  1315. alert("convert " + xDocWords.length + "words.");
  1316. }
  1317. function editor_save() {
  1318. $.post("dom_http.php",
  1319. {
  1320. fileid: g_docid,
  1321. xmldata: com_xmlToString(gXmlBookData)
  1322. },
  1323. function (data, status) {
  1324. ntf_show("Data: " + data + "\nStatus: " + status);
  1325. });
  1326. }
  1327. /*Parse csv data and fill this document*/
  1328. function csvDataParse(xmlCSVData) {
  1329. document.getElementById('id_csv_msg_inner').innerHTML = "Parseing CSV Data";
  1330. var xCSV = xmlCSVData.getElementsByTagName("word");
  1331. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1332. for (iword = 0; iword < xCSV.length; iword++) {
  1333. setNodeText(xDocWords[iword], "pali", getNodeText(xCSV[iword], "pali"));
  1334. setNodeText(xDocWords[iword], "real", getNodeText(xCSV[iword], "real"));
  1335. setNodeText(xDocWords[iword], "id", getNodeText(xCSV[iword], "id"));
  1336. setNodeText(xDocWords[iword], "mean", getNodeText(xCSV[iword], "mean"));
  1337. setNodeText(xDocWords[iword], "org", getNodeText(xCSV[iword], "org"));
  1338. setNodeText(xDocWords[iword], "om", getNodeText(xCSV[iword], "om"));
  1339. setNodeText(xDocWords[iword], "case", getNodeText(xCSV[iword], "case"));
  1340. setNodeText(xDocWords[iword], "bmc", getNodeText(xCSV[iword], "bmc"));
  1341. setNodeText(xDocWords[iword], "bmt", getNodeText(xCSV[iword], "bmt"));
  1342. setNodeText(xDocWords[iword], "note", getNodeText(xCSV[iword], "note"));
  1343. setNodeText(xDocWords[iword], "lock", getNodeText(xCSV[iword], "lock"));
  1344. modifyWordDetailByWordIndex(iword);
  1345. }
  1346. document.getElementById('id_csv_msg_inner').innerHTML = "Updata Document Data OK!";
  1347. }
  1348. //import csv end
  1349. //export cav begin
  1350. function menu_file_export_ild() {
  1351. xmlHttp = null;
  1352. var_dump(gLocal.gui.loading);
  1353. if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc.
  1354. xmlHttp = new XMLHttpRequest();
  1355. var_dump("test XMLHttpRequest<br/>");
  1356. }
  1357. else if (window.ActiveXObject) {// code for IE6, IE5
  1358. xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  1359. var_dump("testing Microsoft.XMLHTTP<br/>");
  1360. }
  1361. if (xmlHttp != null) {
  1362. var_dump(gLocal.gui.ok);
  1363. xmlHttp.open("POST", "export_ild.php", false);
  1364. var sendHead = "filename=" + g_filename + "#";
  1365. var dictDataString = "<dict>";
  1366. for (iDict in g_DictWordList) {
  1367. dictDataString += "<word>";
  1368. dictDataString += "<recorderId>" + g_DictWordList[iDict].Id + "</recorderId>";
  1369. dictDataString += "<pali>" + g_DictWordList[iDict].Pali + "</pali>";
  1370. dictDataString += "<mean>" + g_DictWordList[iDict].Mean + "</mean>";
  1371. dictDataString += "<type>" + g_DictWordList[iDict].Type + "</type>";
  1372. dictDataString += "<gramma>" + g_DictWordList[iDict].Gramma + "</gramma>";
  1373. dictDataString += "<parent>" + g_DictWordList[iDict].Parent + "</parent>";
  1374. dictDataString += "<factors>" + g_DictWordList[iDict].Factors + "</factors>";
  1375. dictDataString += "<factorMean>" + g_DictWordList[iDict].FactorMean + "</factorMean>";
  1376. dictDataString += "<note>" + g_DictWordList[iDict].Note + "</note>";
  1377. dictDataString += "<confer>" + g_DictWordList[iDict].Confer + "</confer>";
  1378. dictDataString += "<status>" + g_DictWordList[iDict].Status + "</status>";
  1379. dictDataString += "<delete>" + g_DictWordList[iDict].Delete + "</delete>";
  1380. dictDataString += "<dictname>" + g_DictWordList[iDict].dictname + "</dictname>";
  1381. dictDataString += "<dictType>" + g_DictWordList[iDict].dictType + "</dictType>";
  1382. dictDataString += "<fileName>" + g_DictWordList[iDict].fileName + "</fileName>";
  1383. dictDataString += "<parentLevel>" + g_DictWordList[iDict].ParentLevel + "</parentLevel>";
  1384. dictDataString += "</word>";
  1385. }
  1386. dictDataString += "</dict>";
  1387. xmlHttp.send(sendHead + dictDataString);
  1388. var_dump(xmlHttp.responseText);
  1389. }
  1390. else {
  1391. alert("Your browser does not support XMLHTTP.");
  1392. }
  1393. }
  1394. function menu_file_tools_empty(opt) {
  1395. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1396. if (opt == 'all') {
  1397. for (var iword = 0; iword < xDocWords.length; iword++) {
  1398. setNodeText(xDocWords[iword], "mean", "?");
  1399. setNodeText(xDocWords[iword], "org", "?");
  1400. setNodeText(xDocWords[iword], "om", "?");
  1401. setNodeText(xDocWords[iword], "case", "?");
  1402. setNodeText(xDocWords[iword], "bmc", "");
  1403. setNodeText(xDocWords[iword], "bmt", "");
  1404. setNodeText(xDocWords[iword], "note", "");
  1405. setNodeText(xDocWords[iword], "lock", "FALSE");
  1406. modifyWordDetailByWordIndex(iword);
  1407. }
  1408. }
  1409. else if (opt == 'mean') {
  1410. for (var iword = 0; iword < xDocWords.length; iword++) {
  1411. setNodeText(xDocWords[iword], "mean", "[]");
  1412. //setNodeText(xDocWords[iword],"org","?");
  1413. setNodeText(xDocWords[iword], "om", "");
  1414. //setNodeText(xDocWords[iword],"case","?");
  1415. //setNodeText(xDocWords[iword],"bmc","");
  1416. //setNodeText(xDocWords[iword],"bmt","");
  1417. //setNodeText(xDocWords[iword],"note","");
  1418. //setNodeText(xDocWords[iword],"lock","FALSE");
  1419. modifyWordDetailByWordIndex(iword);
  1420. }
  1421. }
  1422. else if (opt == 'case') {
  1423. for (var iword = 0; iword < xDocWords.length; iword++) {
  1424. //setNodeText(xDocWords[iword],"mean","[]");
  1425. //setNodeText(xDocWords[iword],"org","?");
  1426. //setNodeText(xDocWords[iword],"om","");
  1427. setNodeText(xDocWords[iword], "case", "?#?");
  1428. //setNodeText(xDocWords[iword],"bmc","");
  1429. //setNodeText(xDocWords[iword],"bmt","");
  1430. //setNodeText(xDocWords[iword],"note","");
  1431. //setNodeText(xDocWords[iword],"lock","FALSE");
  1432. modifyWordDetailByWordIndex(iword);
  1433. }
  1434. }
  1435. else if (opt == 'bookmark') {
  1436. for (var iword = 0; iword < xDocWords.length; iword++) {
  1437. //setNodeText(xDocWords[iword],"mean","[]");
  1438. //setNodeText(xDocWords[iword],"org","?");
  1439. //setNodeText(xDocWords[iword],"om","");
  1440. //setNodeText(xDocWords[iword],"case","?#?");
  1441. setNodeText(xDocWords[iword], "bmc", "");
  1442. setNodeText(xDocWords[iword], "bmt", "");
  1443. //setNodeText(xDocWords[iword],"note","");
  1444. //setNodeText(xDocWords[iword],"lock","FALSE");
  1445. modifyWordDetailByWordIndex(iword);
  1446. }
  1447. }
  1448. else if (opt == 'note') {
  1449. for (var iword = 0; iword < xDocWords.length; iword++) {
  1450. //setNodeText(xDocWords[iword],"mean","[]");
  1451. //setNodeText(xDocWords[iword],"org","?");
  1452. //setNodeText(xDocWords[iword],"om","");
  1453. //setNodeText(xDocWords[iword],"case","?#?");
  1454. //setNodeText(xDocWords[iword],"bmc","");
  1455. //setNodeText(xDocWords[iword],"bmt","");
  1456. setNodeText(xDocWords[iword], "note", "");
  1457. //setNodeText(xDocWords[iword],"lock","FALSE");
  1458. modifyWordDetailByWordIndex(iword);
  1459. }
  1460. }
  1461. }
  1462. function menu_file_tools_GUID() {
  1463. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1464. for (var iword = 0; iword < xDocWords.length; iword++) {
  1465. setNodeText(xDocWords[iword], "id", com_guid());
  1466. modifyWordDetailByWordIndex(iword);
  1467. }
  1468. var_dump("reset id finished!");
  1469. }
  1470. function showDebugPanal() {
  1471. var w = window.innerWidth
  1472. || document.documentElement.clientWidth
  1473. || document.body.clientWidth;
  1474. var h = window.innerHeight
  1475. || document.documentElement.clientHeight
  1476. || document.body.clientHeight;
  1477. }
  1478. function show_popup(strMsg) {
  1479. var p = window.createPopup()
  1480. var pbody = p.document.body
  1481. pbody.style.backgroundColor = "red"
  1482. pbody.style.border = "solid black 1px"
  1483. pbody.innerHTML = strMsg + "<br />外面点击,即可关闭它!"
  1484. p.show(150, 150, 200, 50, document.body)
  1485. }
  1486. //Info_Panal顯示 begin
  1487. function setInfoPanalVisibility() {
  1488. if (document.getElementById("id_info_panal").style.height == "0px") {
  1489. setInfoPanalSize('half');
  1490. }
  1491. else {
  1492. setInfoPanalSize('hidden');
  1493. }
  1494. }
  1495. //Info_Panal顯示尺寸
  1496. function setInfoPanalSize(inSize) {
  1497. var h = window.innerHeight
  1498. || document.documentElement.clientHeight
  1499. || document.body.clientHeight;
  1500. var objInfoPanal = document.getElementById("id_info_panal");
  1501. //show_popup(w);
  1502. //alert(objInfoPanal.style.right);
  1503. switch (inSize) {
  1504. case "hidden"://min
  1505. objInfoPanal.style.height = 0 + "px";
  1506. //setTimeout("hiddenPanal()",400);
  1507. break;
  1508. case "min"://min
  1509. objInfoPanal.style.height = (30) + "px";
  1510. break;
  1511. case "half"://half
  1512. objInfoPanal.style.height = h / 2 + "px";
  1513. break;
  1514. case "0.6"://2/3
  1515. objInfoPanal.style.height = (h * 0.6) + "px";
  1516. break;
  1517. case "max"://max
  1518. objInfoPanal.style.height = (h) + "px";
  1519. break;
  1520. }
  1521. }
  1522. function hiddenPanal() {
  1523. document.getElementById("id_info_panal").style.display = "none";
  1524. }
  1525. //Info_Panal顯示 end
  1526. function windowsSelected(obj) {
  1527. document.getElementById('word_table').style.display = "none";
  1528. document.getElementById('id_dict_match_result').style.display = "none";
  1529. document.getElementById('id_dict_curr_word').style.display = "none";
  1530. document.getElementById('id_debug').style.display = "none";
  1531. switch (obj.value) {
  1532. case "view_vocabulary":
  1533. document.getElementById('word_table').style.display = "block";
  1534. break;
  1535. case "view_dict_all":
  1536. document.getElementById('id_dict_match_result').style.display = "block";
  1537. break;
  1538. case "view_dict_curr":
  1539. document.getElementById('id_dict_curr_word').style.display = "block";
  1540. break;
  1541. case "view_debug":
  1542. document.getElementById('id_debug').style.display = "block";
  1543. break;
  1544. }
  1545. }
  1546. function userDictUpdata() {
  1547. }
  1548. var editor_DictUpdataXmlHttp = null;
  1549. function editor_UserDictUpdata(recorderName, thisObj) {
  1550. thisObj.disabled = true;
  1551. var xmlText = "";
  1552. if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc.
  1553. editor_DictUpdataXmlHttp = new XMLHttpRequest();
  1554. }
  1555. else if (window.ActiveXObject) {// code for IE6, IE5
  1556. editor_DictUpdataXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  1557. }
  1558. if (editor_DictUpdataXmlHttp != null) {
  1559. var queryString = "<wordlist>";
  1560. queryString += "<word>";
  1561. var d_id = document.getElementById('id_dict_user_id_' + recorderName).value;
  1562. var d_pali = document.getElementById('id_dict_user_pali_' + recorderName).value;
  1563. var d_type = document.getElementById('id_dict_user_type_' + recorderName).value;
  1564. var d_gramma = document.getElementById('id_dict_user_gramma_' + recorderName).value;
  1565. var d_parent = document.getElementById('id_dict_user_parent_' + recorderName).value;
  1566. var d_mean = document.getElementById('id_dict_user_mean_' + recorderName).value;
  1567. var d_note = document.getElementById('id_dict_user_note_' + recorderName).value;
  1568. var d_factors = document.getElementById('id_dict_user_factors_' + recorderName).value;
  1569. var d_fm = document.getElementById('id_dict_user_fm_' + recorderName).value;
  1570. var d_confer = "";
  1571. var d_status = "";
  1572. var d_delete = "";
  1573. var d_tag = "";
  1574. var d_language = language_translation;
  1575. queryString += "<id>" + d_id + "</id>";
  1576. queryString += "<pali>" + d_pali + "</pali>";
  1577. queryString += "<type>" + d_type + "</type>";
  1578. queryString += "<gramma>" + d_gramma + "</gramma>";
  1579. queryString += "<parent>" + d_parent + "</parent>";
  1580. queryString += "<mean>" + d_mean + "</mean>";
  1581. queryString += "<note>" + d_note + "</note>";
  1582. queryString += "<factors>" + d_factors + "</factors>";
  1583. queryString += "<fm>" + d_fm + "</fm>";
  1584. queryString += "<confer>" + d_confer + "</confer>";
  1585. queryString += "<status>" + d_status + "</status>";
  1586. queryString += "<enable>TRUE</enable>";
  1587. queryString += "<language>" + d_language + "</language>";
  1588. queryString += "</word>";
  1589. queryString += "</wordlist>";
  1590. editor_DictUpdataXmlHttp.onreadystatechange = editor_UserDictUpdata_serverResponse;
  1591. debugOutput("updata user dict start.", 0);
  1592. editor_DictUpdataXmlHttp.open("POST", "dict_updata_user.php", true);
  1593. editor_DictUpdataXmlHttp.send(queryString);
  1594. var i = recorderName;
  1595. g_DictWordUpdataIndex = i;
  1596. g_DictWordNew.Id = d_id;
  1597. g_DictWordNew.Pali = d_pali;
  1598. g_DictWordNew.Mean = d_mean;
  1599. g_DictWordNew.Type = d_type;
  1600. g_DictWordNew.Gramma = d_gramma;
  1601. g_DictWordNew.Parent = d_parent;
  1602. g_DictWordNew.Factors = d_factors;
  1603. g_DictWordNew.FactorMean = d_fm;
  1604. g_DictWordNew.Note = d_note;
  1605. g_DictWordNew.Confer = d_confer;
  1606. g_DictWordNew.Status = d_status;
  1607. g_DictWordNew.Delete = d_delete;
  1608. g_DictWordNew.dictname = "用户字典";
  1609. g_DictWordNew.dictType = "user";
  1610. g_DictWordNew.fileName = "user_default";
  1611. g_DictWordNew.ParentLevel = 0;
  1612. }
  1613. else {
  1614. alert("Your browser does not support XMLHTTP.");
  1615. }
  1616. }
  1617. function editor_UserDictUpdata_serverResponse() {
  1618. if (editor_DictUpdataXmlHttp.readyState == 4)// 4 = "loaded"
  1619. {
  1620. debugOutput("server response.", 0);
  1621. if (editor_DictUpdataXmlHttp.status == 200) {// 200 = "OK"
  1622. var serverText = editor_DictUpdataXmlHttp.responseText;
  1623. debugOutput(serverText, 0);
  1624. obj = JSON.parse(serverText);
  1625. if (obj.msg[0].server_return == -1) {
  1626. alert(obj.msg[0].server_error);
  1627. }
  1628. else {
  1629. var_dump(gLocal.gui.userdict + obj.msg[0].server_op + " " + gLocal.gui.ok);
  1630. switch (obj.msg[0].server_op) {
  1631. case "insert":
  1632. g_DictWordNew.Id = obj.msg[0].server_return;
  1633. g_DictWordNew.dictID = 1;/*temp code*/
  1634. var inDict = false;
  1635. for (iFindNew in g_DictWordList) {
  1636. if (g_DictWordList[iFindNew].Id == g_DictWordNew.Id && g_DictWordList[iFindNew].fileName == "user_default") {
  1637. inDict = true;
  1638. break;
  1639. }
  1640. }
  1641. //if recorder in list don't add to list
  1642. if (!inDict) {
  1643. g_DictWordList.unshift(g_DictWordNew);
  1644. editor_insertNewWordToInlineDict(g_DictWordNew);
  1645. }
  1646. break;
  1647. case "update":
  1648. g_DictWordList[g_DictWordUpdataIndex] = g_DictWordNew;
  1649. editor_updataInlineDict(g_DictWordUpdataIndex, g_DictWordNew)
  1650. break;
  1651. }
  1652. }
  1653. showCurrWordTable(g_WordTableCurrWord);
  1654. modifyWordDetailByWordId(g_currEditWord);
  1655. }
  1656. else {
  1657. debugOutput(xmlhttp.statusText, 0);
  1658. }
  1659. }
  1660. }
  1661. function editor_insertNewWordToInlineDict(newWord) {
  1662. var xAllWord = gXmlBookDataInlineDict.getElementsByTagName("word");
  1663. var newElement = gXmlBookData.createElement("word");
  1664. setNodeText(newElement, "id", newWord.Id.toString());
  1665. setNodeText(newElement, "guid", newWord.Guid);
  1666. setNodeText(newElement, "pali", newWord.Pali);
  1667. setNodeText(newElement, "mean", newWord.Mean);
  1668. setNodeText(newElement, "type", newWord.Type);
  1669. setNodeText(newElement, "gramma", newWord.Gramma);
  1670. setNodeText(newElement, "parent", newWord.Parent);
  1671. setNodeText(newElement, "parentid", newWord.ParentId);
  1672. setNodeText(newElement, "factors", newWord.Factors);
  1673. setNodeText(newElement, "factorMean", newWord.FactorMean);
  1674. setNodeText(newElement, "partid", newWord.PartId);
  1675. setNodeText(newElement, "note", newWord.Note);
  1676. setNodeText(newElement, "confer", newWord.Confer);
  1677. setNodeText(newElement, "status", newWord.Status);
  1678. setNodeText(newElement, "enable", newWord.Enable);
  1679. setNodeText(newElement, "dictname", newWord.dictname);
  1680. setNodeText(newElement, "dictType", newWord.dictType);
  1681. setNodeText(newElement, "fileName", newWord.fileName);
  1682. setNodeText(newElement, "parentLevel", newWord.ParentLevel.toString());
  1683. if (xAllWord.length > 0) {
  1684. gXmlBookDataInlineDict.insertBefore(newElement, xAllWord[0]);
  1685. }
  1686. else {
  1687. gXmlBookDataInlineDict.insertBefore(newElement, null);
  1688. }
  1689. }
  1690. function editor_updataInlineDict(iword, newWord) {
  1691. var xILD = gXmlBookDataInlineDict.getElementsByTagName("word")
  1692. if (xILD == null) {
  1693. return;
  1694. }
  1695. setNodeText(xILD[iword], "id", newWord.Id);
  1696. setNodeText(xILD[iword], "pali", newWord.Pali);
  1697. setNodeText(xILD[iword], "mean", newWord.Mean);
  1698. setNodeText(xILD[iword], "type", newWord.Type);
  1699. setNodeText(xILD[iword], "gramma", newWord.Gramma);
  1700. setNodeText(xILD[iword], "parent", newWord.Parent);
  1701. setNodeText(xILD[iword], "factors", newWord.Factors);
  1702. setNodeText(xILD[iword], "factorMean", newWord.FactorMean);
  1703. setNodeText(xILD[iword], "note", newWord.Note);
  1704. setNodeText(xILD[iword], "confer", newWord.Confer);
  1705. setNodeText(xILD[iword], "status", newWord.Status);
  1706. setNodeText(xILD[iword], "delete", newWord.Delete);
  1707. setNodeText(xILD[iword], "dictname", newWord.dictname);
  1708. setNodeText(xILD[iword], "dictType", newWord.dictType);
  1709. setNodeText(xILD[iword], "fileName", newWord.fileName);
  1710. setNodeText(xILD[iword], "parentLevel", newWord.ParentLevel);
  1711. }
  1712. /*
  1713. 上传到我的字典
  1714. */
  1715. function upload_to_my_dict(wordIdFrom = -1, wordIdTo = -1) {
  1716. let queryString = "<wordlist>";
  1717. let x = gXmlBookDataBody.getElementsByTagName("word");
  1718. let iCount = 0;
  1719. let wordNode;
  1720. let d_pali;
  1721. let d_guid;
  1722. let d_mean;
  1723. let d_parent;
  1724. let d_parent_id;
  1725. let d_parentmean;
  1726. let d_factors;
  1727. let d_fm;
  1728. let d_part_id;
  1729. let d_case;
  1730. let d_note;
  1731. let formula;
  1732. for (let wordID = wordIdFrom; wordID <= wordIdTo; wordID++) {
  1733. if (wordIdFrom == -1) {
  1734. d_pali = doc_word("#" + g_currEditWord).val("real");
  1735. d_guid = "";
  1736. d_mean = $("#input_meaning").val();
  1737. d_parent = $("#id_text_parent").val();
  1738. d_parent_id = "";
  1739. d_parent = com_getPaliReal(d_parent);
  1740. d_parentmean = removeFormulaB(d_mean, '[', ']');
  1741. d_parentmean = removeFormulaB(d_parentmean, '{', '}');
  1742. //if(d_parentmean.substr())
  1743. d_factors = $("#input_org").val();
  1744. d_fm = $("#input_om").val();//g_arrPartMean.join("+");
  1745. d_part_id = "";
  1746. d_case = $("#input_case").val();
  1747. d_note = $("#id_text_note").val();
  1748. }
  1749. else {
  1750. wordNode = x[wordID];
  1751. d_pali = getNodeText(wordNode, "real");
  1752. d_guid = getNodeText(wordNode, "guid");
  1753. d_mean = getNodeText(wordNode, "mean");
  1754. d_parent = getNodeText(wordNode, "parent");
  1755. d_parent_id = getNodeText(wordNode, "parent_id");
  1756. d_parent = com_getPaliReal(d_parent);
  1757. d_parentmean = removeFormulaB(d_mean, '[', ']');
  1758. d_parentmean = removeFormulaB(d_parentmean, '{', '}');
  1759. d_factors = getNodeText(wordNode, "org");
  1760. d_fm = getNodeText(wordNode, "om");
  1761. d_part_id = getNodeText(wordNode, "part_id");
  1762. d_case = getNodeText(wordNode, "case");
  1763. d_note = getNodeText(wordNode, "note");
  1764. }
  1765. var iPos = d_case.indexOf("#");
  1766. if (iPos >= 0) {
  1767. var d_type = d_case.substring(0, iPos);
  1768. if (iPos < d_case.length - 1) {
  1769. var d_gramma = d_case.substring(iPos + 1);
  1770. }
  1771. else {
  1772. var d_gramma = "";
  1773. }
  1774. }
  1775. else {
  1776. var d_type = "";
  1777. var d_gramma = d_case;
  1778. }
  1779. formula = getFormulaFromMeaning(d_mean, "[", "]");
  1780. let d_language = get_string_lang(d_mean);
  1781. if (d_mean == "?") {
  1782. d_mean = "";
  1783. }
  1784. if (d_factors == "?") {
  1785. d_factors = "";
  1786. }
  1787. if (d_fm == "?" || d_fm == "[a]?") {
  1788. d_fm = "";
  1789. }
  1790. if ((d_type == ".un." || d_type == ".comp.") && (d_mean == "" && d_factors == "" && d_fm == "")) {
  1791. }
  1792. else if (d_pali.length > 0 && !(d_mean == "" && d_factors == "" && d_fm == "" && d_case == "")) {
  1793. //parent gramma infomation
  1794. switch (d_type) {
  1795. case ".n.":
  1796. d_parentType = ".n:base.";
  1797. d_parentGramma = d_gramma.split("$")[0];
  1798. if (d_parentGramma == ".m." || d_parentGramma == ".f." || d_parentGramma == ".nt.") {
  1799. d_parentGramma = d_parentGramma;
  1800. }
  1801. else {
  1802. d_parentGramma = "";
  1803. }
  1804. break;
  1805. case ".adj.":
  1806. d_parentType = ".ti:base.";
  1807. d_parentGramma = ".adj.";
  1808. break;
  1809. case ".ti.":
  1810. d_parentType = ".ti:base.";
  1811. d_parentGramma = "";
  1812. break;
  1813. case ".pron.":
  1814. d_parentType = ".pron:base.";
  1815. d_parentGramma = "";
  1816. break;
  1817. case ".num.":
  1818. d_parentType = ".num:base.";
  1819. d_parentGramma = "";
  1820. break;
  1821. case ".v.":
  1822. d_parentType = ".v:base.";
  1823. d_parentGramma = "";
  1824. break;
  1825. case ".v:ind.":
  1826. d_parentType = ".v:base.";
  1827. d_parentGramma = "";
  1828. break;
  1829. case ".ind.":
  1830. d_parentType = ".ind.";
  1831. d_parentGramma = "";
  1832. break;
  1833. default:
  1834. d_parentType = "";
  1835. d_parentGramma = "";
  1836. break;
  1837. }
  1838. let d_confer = "";
  1839. let d_status = "512";
  1840. let d_enable = "TRUE";
  1841. queryString += "<word>";
  1842. queryString += "<pali>" + d_pali + "</pali>";
  1843. queryString += "<guid>" + d_guid + "</guid>";
  1844. queryString += "<type>" + d_type + "</type>";
  1845. queryString += "<gramma>" + d_gramma + "</gramma>";
  1846. queryString += "<parent>" + d_parent + "</parent>";
  1847. queryString += "<parent_id>" + d_parent_id + "</parent_id>";
  1848. queryString += "<mean>" + d_mean + "</mean>";
  1849. queryString += "<note>" + d_note + "</note>";
  1850. queryString += "<factors>" + d_factors + "</factors>";
  1851. queryString += "<fm>" + d_fm + "</fm>";
  1852. queryString += "<part_id>" + d_part_id + "</part_id>";
  1853. queryString += "<confer>" + d_confer + "</confer>";
  1854. queryString += "<status>" + d_status + "</status>";
  1855. queryString += "<enable>" + d_enable + "</enable>";
  1856. queryString += "<language>" + d_language + "</language>";
  1857. queryString += "</word>";
  1858. iCount++;
  1859. //formula
  1860. if (formula != "~") {
  1861. queryString += "<word>";
  1862. queryString += "<pali>_formula_</pali>";
  1863. queryString += "<guid></guid>";
  1864. queryString += "<type>" + d_type + "</type>";
  1865. queryString += "<gramma>" + d_gramma + "</gramma>";
  1866. queryString += "<parent></parent>";
  1867. queryString += "<parent_id></parent_id>";
  1868. queryString += "<mean>" + formula + "</mean>";
  1869. queryString += "<note></note>";
  1870. queryString += "<factors></factors>";
  1871. queryString += "<fm></fm>";
  1872. queryString += "<part_id></part_id>";
  1873. queryString += "<confer></confer>";
  1874. queryString += "<status>" + d_status + "</status>";
  1875. queryString += "<enable>" + d_enable + "</enable>";
  1876. queryString += "<language>" + d_language + "</language>";
  1877. queryString += "</word>";
  1878. iCount++;
  1879. }
  1880. //parent recorder
  1881. if (d_parent.length > 0) {
  1882. queryString += "<word>";
  1883. queryString += "<pali>" + d_parent + "</pali>";
  1884. queryString += "<guid></guid>";
  1885. queryString += "<type>" + d_parentType + "</type>";
  1886. queryString += "<gramma>" + d_parentGramma + "</gramma>";
  1887. queryString += "<parent></parent>";
  1888. queryString += "<parent_id></parent_id>";
  1889. queryString += "<mean>" + d_parentmean + "</mean>";
  1890. queryString += "<note></note>";
  1891. let fc = d_factors.split("+");
  1892. if (fc.length > 0 && (fc[fc.length - 1].slice(0, 1) == "[" && fc[fc.length - 1].slice(-1) == "]")) {
  1893. fc.pop();
  1894. }
  1895. queryString += "<factors>" + fc.join("+") + "</factors>";
  1896. let fm = d_fm.split("+");
  1897. fm.length = fc.length;
  1898. queryString += "<fm>" + fm.join("+") + "</fm>";
  1899. queryString += "<part_id></part_id>";
  1900. queryString += "<confer></confer>";
  1901. queryString += "<status>512</status>";
  1902. queryString += "<enable>TRUE</enable>";
  1903. queryString += "<language>" + d_language + "</language>";
  1904. queryString += "</word>";
  1905. iCount++;
  1906. }
  1907. //part recorder
  1908. if (d_fm.slice(0, 3) != "[a]") {
  1909. let arrPart = d_factors.split('+');
  1910. let arrPartMean = d_fm.split('+');
  1911. if (arrPart.length > 0 && arrPart.length == arrPartMean.length) {
  1912. for (iPart in arrPart) {
  1913. if (arrPartMean[iPart] != "" && arrPartMean[iPart] != "?")
  1914. arrPart[iPart] = arrPart[iPart].replace("(", "");
  1915. arrPart[iPart] = arrPart[iPart].replace(")", "");
  1916. queryString += "<word>";
  1917. queryString += "<guid></guid>";
  1918. queryString += "<pali>" + arrPart[iPart] + "</pali>";
  1919. queryString += "<type>.part.</type>";
  1920. queryString += "<gramma></gramma>";
  1921. queryString += "<parent></parent>";
  1922. queryString += "<parent_id></parent_id>";
  1923. queryString += "<mean>" + arrPartMean[iPart] + "</mean>";
  1924. queryString += "<note></note>";
  1925. queryString += "<factors></factors>";
  1926. queryString += "<fm></fm>";
  1927. queryString += "<part_id></part_id>";
  1928. queryString += "<confer></confer>";
  1929. queryString += "<status>512</status>";
  1930. queryString += "<enable>TRUE</enable>";
  1931. queryString += "<language>" + d_language + "</language>";
  1932. queryString += "</word>";
  1933. iCount++
  1934. }
  1935. }
  1936. }
  1937. }
  1938. }
  1939. queryString += "</wordlist>";
  1940. if (iCount == 0) {
  1941. ntf_show("no word update");
  1942. }
  1943. else {
  1944. $.post("dict_updata_wbw.php",
  1945. queryString,
  1946. function (data, status) {
  1947. ntf_show("Data: " + data + "\nStatus: " + status);
  1948. });
  1949. }
  1950. }
  1951. // word by word dict updata
  1952. var editor_wbwUpdataXmlHttp = null;
  1953. function editor_WbwUpdata(wordIdFrom, wordIdTo) {
  1954. var xmlText = "";
  1955. if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc.
  1956. editor_wbwUpdataXmlHttp = new XMLHttpRequest();
  1957. }
  1958. else if (window.ActiveXObject) {// code for IE6, IE5
  1959. editor_wbwUpdataXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  1960. }
  1961. if (editor_wbwUpdataXmlHttp != null) {
  1962. let queryString = "<wordlist>";
  1963. let x = gXmlBookDataBody.getElementsByTagName("word");
  1964. let iCount = 0;
  1965. let d_language = language_translation;
  1966. for (let wordID = wordIdFrom; wordID <= wordIdTo; wordID++) {
  1967. let wordNode = x[wordID];
  1968. let d_pali = getNodeText(wordNode, "real");
  1969. let d_guid = getNodeText(wordNode, "guid");
  1970. let d_mean = getNodeText(wordNode, "mean");
  1971. let d_parent = getNodeText(wordNode, "parent");
  1972. let d_parent_id = getNodeText(wordNode, "parent_id");
  1973. d_parent = com_getPaliReal(d_parent);
  1974. let d_parentmean = removeFormulaB(d_mean, '[', ']');
  1975. d_parentmean = removeFormulaB(d_parentmean, '{', '}');
  1976. let formula = getFormulaFromMeaning(d_mean);
  1977. let d_factors = getNodeText(wordNode, "org");
  1978. let d_fm = getNodeText(wordNode, "om");
  1979. let d_part_id = getNodeText(wordNode, "part_id");
  1980. let d_case = getNodeText(wordNode, "case");
  1981. let d_note = getNodeText(wordNode, "note");
  1982. if (d_pali.length > 0 && !(d_mean == "?" && d_factors == "?" && d_fm == "?" && d_case == "?")) {
  1983. let iPos = d_case.indexOf("#");
  1984. if (iPos >= 0) {
  1985. let d_type = d_case.substring(0, iPos);
  1986. if (iPos < d_case.length - 1) {
  1987. let d_gramma = d_case.substring(iPos + 1);
  1988. }
  1989. else {
  1990. let d_gramma = "";
  1991. }
  1992. }
  1993. else {
  1994. let d_type = "";
  1995. let d_gramma = d_case;
  1996. }
  1997. //parent gramma infomation
  1998. switch (d_type) {
  1999. case ".n.":
  2000. d_parentType = ".n:base.";
  2001. d_parentGramma = d_gramma.split("$")[0];
  2002. if (d_parentGramma == ".m." || d_parentGramma == ".f." || d_parentGramma == ".nt.") {
  2003. d_parentGramma = d_parentGramma;
  2004. }
  2005. else {
  2006. d_parentGramma = "";
  2007. }
  2008. break;
  2009. case ".adj.":
  2010. d_parentType = ".adj:base.";
  2011. d_parentGramma = "";
  2012. break;
  2013. case ".ti.":
  2014. d_parentType = ".ti:base.";
  2015. d_parentGramma = "";
  2016. break;
  2017. case ".pron.":
  2018. d_parentType = ".pron:base.";
  2019. d_parentGramma = "";
  2020. break;
  2021. case ".num.":
  2022. d_parentType = ".num:base.";
  2023. d_parentGramma = "";
  2024. break;
  2025. case ".v.":
  2026. d_parentType = ".v:base.";
  2027. d_parentGramma = "";
  2028. break;
  2029. case ".ind.":
  2030. d_parentType = ".ind.";
  2031. d_parentGramma = "";
  2032. break;
  2033. default:
  2034. d_parentType = "";
  2035. d_parentGramma = "";
  2036. break;
  2037. }
  2038. let d_confer = "";
  2039. let d_status = "512";
  2040. let d_enable = "TRUE";
  2041. queryString += "<word>";
  2042. queryString += "<pali>" + d_pali + "</pali>";
  2043. queryString += "<guid>" + d_guid + "</guid>";
  2044. queryString += "<type>" + d_type + "</type>";
  2045. queryString += "<gramma>" + d_gramma + "</gramma>";
  2046. queryString += "<parent>" + d_parent + "</parent>";
  2047. queryString += "<parent_id>" + d_parent_id + "</parent_id>";
  2048. queryString += "<mean>" + d_mean + "</mean>";
  2049. queryString += "<note>" + d_note + "</note>";
  2050. queryString += "<factors>" + d_factors + "</factors>";
  2051. queryString += "<fm>" + d_fm + "</fm>";
  2052. queryString += "<part_id>" + d_part_id + "</part_id>";
  2053. queryString += "<confer>" + d_confer + "</confer>";
  2054. queryString += "<status>" + d_status + "</status>";
  2055. queryString += "<enable>" + d_enable + "</enable>";
  2056. queryString += "<language>" + d_language + "</language>";
  2057. queryString += "</word>";
  2058. iCount++;
  2059. //formula
  2060. queryString += "<word>";
  2061. queryString += "<pali>_formula_</pali>";
  2062. queryString += "<guid></guid>";
  2063. queryString += "<type>" + d_type + "</type>";
  2064. queryString += "<gramma>" + d_gramma + "</gramma>";
  2065. queryString += "<parent></parent>";
  2066. queryString += "<parent_id></parent_id>";
  2067. queryString += "<mean>" + formula + "</mean>";
  2068. queryString += "<note></note>";
  2069. queryString += "<factors></factors>";
  2070. queryString += "<fm></fm>";
  2071. queryString += "<part_id></part_id>";
  2072. queryString += "<confer></confer>";
  2073. queryString += "<status>" + d_status + "</status>";
  2074. queryString += "<enable>" + d_enable + "</enable>";
  2075. queryString += "<language>" + d_language + "</language>";
  2076. queryString += "</word>";
  2077. iCount++;
  2078. //parent recorder
  2079. if (d_parent.length > 0) {
  2080. queryString += "<word>";
  2081. queryString += "<pali>" + d_parent + "</pali>";
  2082. queryString += "<guid></guid>";
  2083. queryString += "<type>" + d_parentType + "</type>";
  2084. queryString += "<gramma>" + d_parentGramma + "</gramma>";
  2085. queryString += "<parent></parent>";
  2086. queryString += "<parent_id></parent_id>";
  2087. queryString += "<mean>" + d_parentmean + "</mean>";
  2088. queryString += "<note></note>";
  2089. queryString += "<factors></factors>";
  2090. queryString += "<fm></fm>";
  2091. queryString += "<part_id></part_id>";
  2092. queryString += "<confer></confer>";
  2093. queryString += "<status>512</status>";
  2094. queryString += "<enable>TRUE</enable>";
  2095. queryString += "<language>" + d_language + "</language>";
  2096. queryString += "</word>";
  2097. iCount++;
  2098. }
  2099. //part recorder
  2100. arrPart = d_factors.split('+');
  2101. arrPartMean = d_fm.split('+');
  2102. if (arrPart.length > 0 && arrPart.length == arrPartMean.length) {
  2103. for (iPart in arrPart) {
  2104. if (arrPartMean[iPart] != "?" && arrPartMean[iPart] != "" && arrPartMean[iPart] != "") {
  2105. arrPart[iPart] = arrPart[iPart].replace("(", "");
  2106. arrPart[iPart] = arrPart[iPart].replace(")", "");
  2107. queryString += "<word>";
  2108. queryString += "<guid></guid>";
  2109. queryString += "<pali>" + arrPart[iPart] + "</pali>";
  2110. queryString += "<type>.part.</type>";
  2111. queryString += "<gramma></gramma>";
  2112. queryString += "<parent></parent>";
  2113. queryString += "<parent_id></parent_id>";
  2114. queryString += "<mean>" + arrPartMean[iPart] + "</mean>";
  2115. queryString += "<note></note>";
  2116. queryString += "<factors></factors>";
  2117. queryString += "<fm></fm>";
  2118. queryString += "<part_id></part_id>";
  2119. queryString += "<confer></confer>";
  2120. queryString += "<status>512</status>";
  2121. queryString += "<enable>TRUE</enable>";
  2122. queryString += "<language>" + d_language + "</language>";
  2123. queryString += "</word>";
  2124. iCount++
  2125. }
  2126. }
  2127. }
  2128. }
  2129. }
  2130. queryString += "</wordlist>";
  2131. if (iCount > 0) {
  2132. editor_wbwUpdataXmlHttp.onreadystatechange = editor_wbwDictUpdata_serverResponse;
  2133. console.log("updata user dict start.", 0);
  2134. editor_wbwUpdataXmlHttp.open("POST", "dict_updata_wbw.php", true);
  2135. editor_wbwUpdataXmlHttp.send(queryString);
  2136. }
  2137. else {
  2138. console.log("no user dicttionary data need updata.", 0);
  2139. }
  2140. }
  2141. else {
  2142. alert("Your browser does not support XMLHTTP.");
  2143. }
  2144. }
  2145. function editor_wbwDictUpdata_serverResponse() {
  2146. if (editor_wbwUpdataXmlHttp.readyState == 4)// 4 = "loaded"
  2147. {
  2148. debugOutput("server response.", 0);
  2149. if (editor_wbwUpdataXmlHttp.status == 200) {// 200 = "OK"
  2150. let serverText = editor_wbwUpdataXmlHttp.responseText;
  2151. var_dump(serverText);
  2152. debugOutput(serverText, 0);
  2153. }
  2154. else {
  2155. debugOutput(xmlhttp.statusText, 0);
  2156. }
  2157. }
  2158. }
  2159. function uploadAllWordData() {
  2160. let x = gXmlBookDataBody.getElementsByTagName("word");
  2161. if (x.length > 0) {
  2162. editor_WbwUpdata(0, x.length - 1);
  2163. }
  2164. else {
  2165. }
  2166. }
  2167. function renderCaseSelect(type, case1, case2, case3, unique_id, padding_width) {
  2168. eCaseTable = document.getElementById("input_select_case");
  2169. eCaseItems = eCaseTable.getElementsByTagName("span");
  2170. if (type) {
  2171. strTypeSelect = "<div id=\"id_case_dropdown_0_" + unique_id + "\" class=\"case_dropdown gramma_selector\" style='min-width: unset;padding-right: " + padding_width + "em;'>";
  2172. strTypeSelect += "<p class=\"case_dropbtn cell\" style='line-height: 1.2em;'>" + getLocalGrammaStr(type) + "</p>";
  2173. }
  2174. else {
  2175. strTypeSelect = "<div id=\"id_case_dropdown_0_" + unique_id + "\" class=\"case_dropdown gramma_selector\" style='min-width: unset;padding-right: " + padding_width + "em;'>";
  2176. strTypeSelect += "<p class=\"case_dropbtn cell\" style='line-height: 1.2em;'>?</p>";
  2177. }
  2178. strTypeSelect += "<div class=\"case_dropdown-content\">";
  2179. for (iType = 0; iType < gLocal.type_str.length; iType++) {
  2180. strTypeSelect += "<a onclick=\"caseChanged(0,'" + gLocal.type_str[iType].id + "')\">" + gLocal.type_str[iType].value + "</a>"
  2181. }
  2182. strTypeSelect += "</div>";
  2183. strTypeSelect += "</div>";
  2184. eCaseItems[0].innerHTML = strTypeSelect;
  2185. for (iType = 0; iType < gramma_str.length; iType++) {
  2186. if (gramma_str[iType].id == type) {
  2187. var strTypeSelect = "";
  2188. gramma = gramma_str[iType].a;
  2189. if (gramma.length > 0) {
  2190. items = gramma.split("$");
  2191. if (case1 == "") {
  2192. case1 = items[0];
  2193. g_caseSelect[1] = case1;
  2194. }
  2195. strTypeSelect = "<div id=\"id_case_dropdown_1_" + unique_id + "\" class=\"case_dropdown gramma_selector\" style='min-width: unset;padding-right: " + padding_width + "em;'><p class=\"case_dropbtn\" style='line-height: 1.2em;'>" + getLocalGrammaStr(case1) + "</p>";
  2196. strTypeSelect += "<div class=\"case_dropdown-content\">";
  2197. for (iItem = 0; iItem < items.length; iItem++) {
  2198. strTypeSelect += "<a onclick=\"caseChanged(1,'" + items[iItem] + "')\">" + getLocalGrammaStr(items[iItem]) + "</a>"
  2199. }
  2200. strTypeSelect += "</div>";
  2201. strTypeSelect += "</div>";
  2202. }
  2203. else {
  2204. g_caseSelect[1] = "";
  2205. }
  2206. eCaseItems[1].innerHTML = strTypeSelect;
  2207. strTypeSelect = "";
  2208. gramma = gramma_str[iType].b;
  2209. if (gramma.length > 0) {
  2210. items = gramma.split("$");
  2211. if (case2 == "") {
  2212. case2 = items[0];
  2213. g_caseSelect[2] = case2;
  2214. }
  2215. strTypeSelect = "<div id=\"id_case_dropdown_2_" + unique_id + "\" class=\"case_dropdown gramma_selector\" style='min-width: unset;padding-right: " + padding_width + "em;'><p class=\"case_dropbtn\" style='line-height: 1.2em;'>" + getLocalGrammaStr(case2) + "</p>";
  2216. strTypeSelect += "<div class=\"case_dropdown-content\">";
  2217. for (iItem = 0; iItem < items.length; iItem++) {
  2218. strTypeSelect += "<a onclick=\"caseChanged(2,'" + items[iItem] + "')\">" + getLocalGrammaStr(items[iItem]) + "</a>"
  2219. }
  2220. strTypeSelect += "</div>";
  2221. strTypeSelect += "</div>";
  2222. }
  2223. else {
  2224. g_caseSelect[2] = "";
  2225. }
  2226. eCaseItems[2].innerHTML = strTypeSelect;
  2227. strTypeSelect = "";
  2228. gramma = gramma_str[iType].c;
  2229. if (gramma.length > 0) {
  2230. items = gramma.split("$");
  2231. if (case3 == "") {
  2232. case3 = items[0];
  2233. g_caseSelect[3] = case3;
  2234. }
  2235. strTypeSelect = "<div id=\"id_case_dropdown_3_" + unique_id + "\" class=\"case_dropdown gramma_selector\" style='min-width: unset;padding-right: " + padding_width + "em;'><p class=\"case_dropbtn\" style='line-height: 1.2em;'>" + getLocalGrammaStr(case3) + "</p>";
  2236. strTypeSelect += "<div class=\"case_dropdown-content\">";
  2237. for (iItem = 0; iItem < items.length; iItem++) {
  2238. strTypeSelect += "<a onclick=\"caseChanged(3,'" + items[iItem] + "')\">" + getLocalGrammaStr(items[iItem]) + "</a>"
  2239. }
  2240. strTypeSelect += "</div>";
  2241. strTypeSelect += "</div>";
  2242. }
  2243. else {
  2244. g_caseSelect[3] = "";
  2245. }
  2246. eCaseItems[3].innerHTML = strTypeSelect;
  2247. }
  2248. }
  2249. }
  2250. function refreshCaseSelect() {
  2251. renderCaseSelect(g_caseSelect[0], g_caseSelect[1], g_caseSelect[2], g_caseSelect[3], "wbw", 1);
  2252. var newCaseString = g_caseSelect[0] + "#";
  2253. if (g_caseSelect[1].length > 0) {
  2254. newCaseString += g_caseSelect[1];
  2255. }
  2256. if (g_caseSelect[2].length > 0) {
  2257. newCaseString += "$" + g_caseSelect[2];
  2258. }
  2259. if (g_caseSelect[3].length > 0) {
  2260. newCaseString += "$" + g_caseSelect[3];
  2261. }
  2262. document.getElementById("input_case").value = newCaseString;
  2263. rela_refresh(g_currEditWord);
  2264. }
  2265. function caseChanged(index, newValue) {
  2266. g_caseSelect[index] = newValue;
  2267. refreshCaseSelect();
  2268. refreshPartMeaningSelect();
  2269. }
  2270. function removeFormula_B(inStr) {
  2271. pos = 0;
  2272. copy = true;
  2273. var output = "";
  2274. for (i = 0; i < inStr.length; i++) {
  2275. if (inStr[i] == "{" || inStr[i] == "[") {
  2276. copy = false;
  2277. }
  2278. if (copy) {
  2279. output += inStr[i];
  2280. }
  2281. if (inStr[i] == "}" || inStr[i] == "]") {
  2282. copy = true;
  2283. }
  2284. }
  2285. return output;
  2286. }
  2287. function removeFormula(inStr) {
  2288. if (inStr.indexOf("[") >= 0) {
  2289. return (inStr);
  2290. }
  2291. pos = 0;
  2292. copy = true;
  2293. var output = "";
  2294. for (i = 0; i < inStr.length; i++) {
  2295. if (inStr[i] == "{") {
  2296. copy = false;
  2297. }
  2298. if (copy) {
  2299. output += inStr[i];
  2300. }
  2301. if (inStr[i] == "}") {
  2302. copy = true;
  2303. }
  2304. }
  2305. return output;
  2306. }
  2307. //移除字符串中的格位公式
  2308. //input:[zzz]xxx[yyy]
  2309. //output:xxx
  2310. function removeFormulaB(inStr, sBegin, sEnd) {
  2311. pos = 0;
  2312. copy = true;
  2313. var output = "";
  2314. for (i = 0; i < inStr.length; i++) {
  2315. if (inStr[i] == sBegin) {
  2316. copy = false;
  2317. }
  2318. if (copy) {
  2319. output += inStr[i];
  2320. }
  2321. if (inStr[i] == sEnd) {
  2322. copy = true;
  2323. }
  2324. }
  2325. return output;
  2326. }
  2327. function getFormulaFromMeaning(inStr, sBegin, sEnd) {
  2328. let pos = 0;
  2329. let fromulaBegin = false;
  2330. let meaningBegin = false;
  2331. let output = "";
  2332. let meaningExisted = false;
  2333. for (i = 0; i < inStr.length; i++) {
  2334. if (inStr[i] == sBegin) {
  2335. fromulaBegin = true;
  2336. meaningBegin = false;
  2337. }
  2338. else if (inStr[i] == sEnd) {
  2339. fromulaBegin = false;
  2340. meaningBegin = true;
  2341. output += inStr[i];
  2342. }
  2343. else {
  2344. if (!fromulaBegin) {
  2345. meaningBegin = true;
  2346. }
  2347. }
  2348. if (meaningBegin && !meaningExisted) {
  2349. output += "~";
  2350. meaningExisted = true;
  2351. }
  2352. if (fromulaBegin) {
  2353. output += inStr[i];
  2354. }
  2355. }
  2356. return output;
  2357. }
  2358. //关闭单词修改窗口
  2359. function closeModifyWindow() {
  2360. var eWin = document.getElementById("modifywin");
  2361. if (eWin) {
  2362. eWin.style.display = "none";
  2363. document.getElementById("modifyDiv").appendChild(eWin);
  2364. gCurrModifyWindowParNo = -1;
  2365. }
  2366. else {
  2367. }
  2368. if (_display_sbs == 1) {
  2369. $("#ws_" + g_currEditWord).removeClass("wbw_selected")
  2370. }
  2371. }
  2372. //取消对单个词的修改
  2373. function modifyCancel() {
  2374. //关闭单词修改窗口
  2375. closeModifyWindow();
  2376. //??????
  2377. getStyleClass("debug_info").style.display = "none";
  2378. document.getElementById("debug").style.display = "-webkit-flex";
  2379. document.getElementById("debug").style.display = "-moz-flex";
  2380. document.getElementById("debug").style.display = "-webkit-flex";
  2381. }
  2382. //获取某词的段落索引
  2383. function getParIndexByWordId(wordId) {
  2384. //遍历所有块,找到这个单词
  2385. var bookId = "";
  2386. var parNo = "";
  2387. var allBlock = gXmlBookDataBody.getElementsByTagName("block")
  2388. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  2389. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  2390. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  2391. type = getNodeText(xmlParInfo, "type");
  2392. if (type == "wbw") {
  2393. words = xmlParData.getElementsByTagName("word");
  2394. for (var iWord = 0; iWord < words.length; iWord++) {
  2395. wId = getNodeText(words[iWord], "id");
  2396. if (wId == wordId) {
  2397. bookId = getNodeText(xmlParInfo, "book");
  2398. parNo = getNodeText(xmlParInfo, "paragraph");
  2399. break;
  2400. }
  2401. }
  2402. }
  2403. }
  2404. if (bookId == "" || parNo == "") {
  2405. return (false);
  2406. }
  2407. else {
  2408. for (var iPar = 0; iPar < gArrayDocParagraph.length; iPar++) {
  2409. currBookId = gArrayDocParagraph[iPar].book
  2410. currParNo = gArrayDocParagraph[iPar].paragraph
  2411. if (currBookId == bookId && currParNo == parNo) {
  2412. return (iPar);
  2413. }
  2414. }
  2415. }
  2416. return (false);
  2417. }
  2418. var mouse_action_edit = true;
  2419. var mouse_action_lookup = true;
  2420. var mouse_action_translate = false;
  2421. function lock_key(obj, key, check_id, svg_id) {
  2422. var lock_key_str = ""
  2423. switch (key) {
  2424. case "off":
  2425. lock_key_str += "<input id='" + check_id + "' type=\"checkbox\" style=\"display:none; \" />";
  2426. lock_key_str += "<svg class=\"icon\" onclick=lock_key('" + obj + "','on','" + check_id + "','" + svg_id + "')>";
  2427. lock_key_str += "<use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_" + svg_id + "_off\">";
  2428. lock_key_str += "</use></svg>";
  2429. document.getElementById(obj).innerHTML = lock_key_str;
  2430. break;
  2431. case "on":
  2432. lock_key_str += "<input id='" + check_id + "' type=\"checkbox\" style=\"display:none; \" checked/>";
  2433. lock_key_str += "<svg class=\"icon\" onclick=lock_key('" + obj + "','off','" + check_id + "','" + svg_id + "')>";
  2434. lock_key_str += "<use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_" + svg_id + "_on \">";
  2435. lock_key_str += "</use></svg>";
  2436. document.getElementById(obj).innerHTML = lock_key_str;
  2437. break;
  2438. }
  2439. }
  2440. function set_word_click_action(obj, item) {
  2441. switch (item) {
  2442. case "normal":
  2443. if (document.getElementById(obj).checked == true) {
  2444. document.getElementById(obj).checked = false;
  2445. document.getElementById("icon_" + obj + "_on").style.display = "none";
  2446. document.getElementById("icon_" + obj + "_off").style.display = "block";
  2447. }
  2448. else {
  2449. document.getElementById(obj).checked = true;
  2450. document.getElementById("icon_" + obj + "_on").style.display = "block";
  2451. document.getElementById("icon_" + obj + "_off").style.display = "none";
  2452. }
  2453. break;
  2454. case "edit":
  2455. if (document.getElementById(obj).checked == true) {
  2456. document.getElementById(obj).checked = false;
  2457. document.getElementById("icon_" + obj + "_on").style.display = "none";
  2458. document.getElementById("icon_" + obj + "_off").style.display = "block";
  2459. mouse_action_edit = document.getElementById(obj).checked;
  2460. }
  2461. else {
  2462. document.getElementById(obj).checked = true;
  2463. document.getElementById("icon_" + obj + "_on").style.display = "block";
  2464. document.getElementById("icon_" + obj + "_off").style.display = "none";
  2465. document.getElementById("icon_Trans_as_on").style.display = "none";
  2466. document.getElementById("icon_Trans_as_off").style.display = "block";
  2467. document.getElementById("Trans_as").checked = false;
  2468. mouse_action_translate = false;
  2469. mouse_action_edit = document.getElementById(obj).checked;
  2470. }
  2471. break;
  2472. case "lookup":
  2473. if (document.getElementById(obj).checked == true) {
  2474. document.getElementById(obj).checked = false;
  2475. document.getElementById("icon_" + obj + "_on").style.display = "none";
  2476. document.getElementById("icon_" + obj + "_off").style.display = "block";
  2477. mouse_action_lookup = document.getElementById(obj).checked;
  2478. }
  2479. else {
  2480. document.getElementById(obj).checked = true;
  2481. document.getElementById("icon_" + obj + "_on").style.display = "block";
  2482. document.getElementById("icon_" + obj + "_off").style.display = "none";
  2483. document.getElementById("icon_Trans_as_on").style.display = "none";
  2484. document.getElementById("icon_Trans_as_off").style.display = "block";
  2485. document.getElementById("Trans_as").checked = false;
  2486. mouse_action_translate = false;
  2487. mouse_action_lookup = document.getElementById(obj).checked;
  2488. }
  2489. break;
  2490. case "translate":
  2491. if (document.getElementById(obj).checked == true) {
  2492. document.getElementById(obj).checked = false;
  2493. document.getElementById("icon_" + obj + "_on").style.display = "none";
  2494. document.getElementById("icon_" + obj + "_off").style.display = "block";
  2495. mouse_action_translate = document.getElementById(obj).checked;
  2496. }
  2497. else {
  2498. document.getElementById(obj).checked = true;
  2499. document.getElementById("icon_" + obj + "_on").style.display = "block";
  2500. document.getElementById("icon_" + obj + "_off").style.display = "none";
  2501. document.getElementById("icon_Look_Up_on").style.display = "none";
  2502. document.getElementById("icon_Look_Up_off").style.display = "block";
  2503. document.getElementById("icon_Edit_Dialog_on").style.display = "none";
  2504. document.getElementById("icon_Edit_Dialog_off").style.display = "block";
  2505. document.getElementById("Edit_Dialog").checked = false;
  2506. document.getElementById("Look_Up").checked = false;
  2507. mouse_action_edit = false;
  2508. mouse_action_lookup = false;
  2509. mouse_action_translate = document.getElementById(obj).checked;
  2510. }
  2511. break;
  2512. }
  2513. }
  2514. //鼠标点击词头
  2515. function on_word_click(sWordId) {
  2516. closeModifyWindow();
  2517. g_currEditWord = sWordId;
  2518. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  2519. var wid = getWordIndex(sWordId);
  2520. g_eCurrWord = xAllWord[wid];
  2521. var sReal = getNodeText(xAllWord[wid], "real");
  2522. var sParent = getNodeText(xAllWord[wid], "parent");
  2523. var sMeaning = getNodeText(xAllWord[wid], "mean");
  2524. //显示修改单个词的窗口
  2525. if (mouse_action_edit) {
  2526. showModifyWin(sWordId)
  2527. }
  2528. //word Message
  2529. msg_show_content(1, sWordId);
  2530. msg_show_content_panal();
  2531. //术语
  2532. note_lookup(sParent, "term_dict");
  2533. //参考字典
  2534. if (mouse_action_lookup) {
  2535. dict_search(sReal);
  2536. }
  2537. //添加词到翻译框
  2538. //if(mouse_action_translate){
  2539. // add_word_to_tran_win(sMeaning);
  2540. //}
  2541. }
  2542. function note_apply(guid) {
  2543. }
  2544. /*
  2545. function apply_button_lock(){
  2546. if($("#input_lock")[0].checked){// || g_currBookMarkColor!="bmc0"
  2547. $("#apply_to_down")[0].disabled=true;
  2548. $("#apply_to_up")[0].disabled=true;
  2549. $("#apply_to_all")[0].disabled=true;
  2550. }
  2551. else{
  2552. $("#apply_to_down")[0].disabled=false;
  2553. $("#apply_to_up")[0].disabled=false;
  2554. $("#apply_to_all")[0].disabled=false;
  2555. }
  2556. }
  2557. */
  2558. function mdf_win_data_change(key, value) {
  2559. $("#" + key).val(value);
  2560. }
  2561. function mdf_win_part_change(strPart) {
  2562. $("#input_org").val(strPart);
  2563. input_org_change();
  2564. }
  2565. function mdf_win_case_change(strCase) {
  2566. let aCase = strCase.split("#");
  2567. let type = "";
  2568. let gramma = "";
  2569. if (aCase[0]) {
  2570. type = aCase[0];
  2571. }
  2572. if (aCase[0]) {
  2573. type = aCase[0];
  2574. }
  2575. if (aCase[1]) {
  2576. gramma = aCase[1];
  2577. }
  2578. $("#input_case").val(strCase);
  2579. let arrGramma = gramma.split("$");
  2580. g_caseSelect[0] = type;
  2581. if (arrGramma[0]) {
  2582. g_caseSelect[1] = arrGramma[0];
  2583. }
  2584. else {
  2585. g_caseSelect[1] = "";
  2586. }
  2587. if (arrGramma[1]) {
  2588. g_caseSelect[2] = arrGramma[1];
  2589. }
  2590. else {
  2591. g_caseSelect[2] = "";
  2592. }
  2593. if (arrGramma[2]) {
  2594. g_caseSelect[3] = arrGramma[2];
  2595. }
  2596. else {
  2597. g_caseSelect[3] = "";
  2598. }
  2599. refreshCaseSelect();
  2600. }
  2601. //显示修改单个词的窗口
  2602. function showModifyWin(sWordId) {
  2603. //获取当前编辑的单词所在的段的索引号
  2604. gCurrModifyWindowParNo = getParIndexByWordId(sWordId);
  2605. let xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  2606. let wid = getWordIndex(sWordId);
  2607. let tWin = "";
  2608. let tApply = "";
  2609. let eWord = document.getElementById("wb" + sWordId);
  2610. let eWin = document.getElementById("modifywin");
  2611. let eWordInfo = document.getElementById("modify_detaile");
  2612. let eApply = document.getElementById("modify_apply");
  2613. let sReal = getNodeText(xAllWord[wid], "real");
  2614. let sParent = getNodeText(xAllWord[wid], "parent");
  2615. let sMeaning = getNodeText(xAllWord[wid], "mean");
  2616. let sOrg = getNodeText(xAllWord[wid], "org");
  2617. let sOm = getNodeText(xAllWord[wid], "om");
  2618. let sCase = getNodeText(xAllWord[wid], "case");
  2619. let sParentGrammar = getNodeText(xAllWord[wid], "pg");
  2620. let sParent2 = getNodeText(xAllWord[wid], "parent2");
  2621. //showCurrWordTable(sReal);
  2622. if (g_useMode == "edit") {
  2623. $("#input_meaning").val(sMeaning);
  2624. $("#input_org").val(sOrg);
  2625. $("#input_om").val(sOm);
  2626. $("#input_case").val(sCase);
  2627. if (sParentGrammar != "" || sParent2 != "") {
  2628. document.getElementById("edit_detail_prt_prt").style.display = "block";
  2629. document.getElementById("svg_parent2").style.transform = "rotate(90deg)";
  2630. }
  2631. else {
  2632. document.getElementById("edit_detail_prt_prt").style.display = "none";
  2633. document.getElementById("svg_parent2").style.transform = "rotate(0deg)";
  2634. }
  2635. document.getElementById("parent_grammar").innerHTML = sParentGrammar;
  2636. $("#id_text_prt_prt").val(sParent2);
  2637. //右侧修改菜单
  2638. $("#word_mdf_mean_dropdown").html(render_word_menu_mean(g_currEditWord, 1));
  2639. $("#word_mdf_parts_dropdown").html(render_word_menu_parts(sWordId, 1));
  2640. $("#word_mdf_case_dropdown").html(render_word_menu_gramma(sWordId, 1));
  2641. $("#word_mdf_parent_dropdown").html(render_word_menu_parent(sWordId));
  2642. let typeAndGramma = sCase.split("#");
  2643. if (typeAndGramma.length > 1) {
  2644. sType = typeAndGramma[0];
  2645. sGramma = typeAndGramma[1];
  2646. }
  2647. else {
  2648. sType = "";
  2649. sGramma = typeAndGramma[0];
  2650. }
  2651. g_caseSelect[0] = sType;
  2652. aGramma = sGramma.split("$");
  2653. lenGramma = aGramma.length;
  2654. if (lenGramma > 3) {
  2655. lenGramma = 3;
  2656. }
  2657. for (iGramma = 0; iGramma < lenGramma; iGramma++) {
  2658. g_caseSelect[iGramma + 1] = aGramma[iGramma];
  2659. }
  2660. //刷新type and gramma 下拉菜单选项
  2661. refreshCaseSelect();
  2662. //刷新part meaning 下拉菜单选项
  2663. g_currPartMeaning = "";
  2664. g_initPartMeaning = true;
  2665. refreshPartMeaningSelect();
  2666. if (sOrg != "?" && sOrg != "") {
  2667. input_org_change(document.getElementById("input_org"));
  2668. }
  2669. tApply += "<div class=\"modifybutton\">";
  2670. tApply += "<p style='display: flex' >"//onclick=apply_button_lock()
  2671. if (getNodeText(xAllWord[wid], "lock") == "true") {
  2672. tApply += "<span class='apply_to' id='edit_lock' align=\"left\">";
  2673. tApply += "<input type=\"checkbox\" style=\" display:none;\" align=\"left\" id='input_lock' checked />"
  2674. tApply += "<svg class=\"icon\" onclick=lock_key('edit_lock','off','input_lock','lock')><use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_lock_on \"></use></svg>";
  2675. tApply += "</span>"
  2676. }
  2677. else {
  2678. tApply += "<span class='apply_to' id='edit_lock' align=\"left\">";
  2679. tApply += "<input type=\"checkbox\" style=\" display:none;\" align=\"left\" id='input_lock' />";
  2680. tApply += "<svg class=\"icon\" onclick=lock_key('edit_lock','on','input_lock','lock')><use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_lock_off\"></use></svg>";
  2681. tApply += "</span>";
  2682. }
  2683. //tApply += "<button onclick=\"upload_to_my_dict()\">上传到我的字典</button>";
  2684. let allword = doc_word();
  2685. let sameCount = 0;
  2686. for (let i = 0; i < allword.length; i++) {
  2687. if (sReal == getNodeText(allword[i], "real") || (sParent != "" && sParent == getNodeText(allword[i], "parent"))) {
  2688. sameCount++;
  2689. }
  2690. }
  2691. if (sameCount > 1) {
  2692. tApply += "<span>";
  2693. }
  2694. else {
  2695. tApply += "<span style='display:none'>";
  2696. }
  2697. tApply += "<input id='checkbox_apply_same' type=\"checkbox\" style=\" width:14px; height:14px; margin-left:10px;\" align=\"left\"/>" + gLocal.gui.applyto + "&nbsp;<span id='same_word_count' >" + (sameCount + 1) + "&nbsp;" + gLocal.gui.same_word + "</span>";
  2698. tApply += "</span>";
  2699. tApply += "<span class='apply_to' id='upload_lock' align=\"left\">";
  2700. tApply += "<input type=\"checkbox\" style=\"display:none; width:14px; height:14px; margin-left:10px;\" align=\"left\" id='input_to_db' />";
  2701. //tApply += "<svg class=\"icon\" onclick=lock_key('upload_lock','on','input_to_db','cloud')><use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_cloud_off\"></span>";
  2702. tApply += "</span>";
  2703. tApply += "</p>";
  2704. tApply += "</div>";
  2705. tApply += "<div class=\"modifycancel\" align=\"right\">";
  2706. /*
  2707. tApply += "<span class='apply_to'>"
  2708. tApply+= "<svg class=\"icon\"><use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_format_paint\">";
  2709. tApply += "</span>";
  2710. tApply+= "<button class='apply_to' id='apply_to_down' onclick=\"modifyApply('" + sWordId + "','down')\" title='向下填充'>";
  2711. tApply+= "<svg style='transform: rotate(180deg)' class=\"icon\"><use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_file_upload\">";
  2712. tApply+= "</button>";
  2713. tApply+= "<button class=' apply_to' id='apply_to_up' onclick=\"modifyApply('" + sWordId + "','up')\" title='向上填充'>";
  2714. tApply+= "<svg class=\"icon\"><use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_file_upload\">";
  2715. tApply+= "</button>";
  2716. tApply+= "<button class=' apply_to' id='apply_to_all' onclick=\"modifyApply('" + sWordId + "','all')\" title='更新全部'>";
  2717. tApply+= "<svg class=\"icon\"><use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_format_line_spacing\">";
  2718. tApply+= "</button>";
  2719. */
  2720. tApply += "<button class=' apply_to' id='apply_to_this' onclick=\"modifyApply('" + sWordId + "',true)\" title='Save and Favorite'>";
  2721. tApply += gLocal.gui.to_user_dictionary;
  2722. tApply += "</button>";
  2723. tApply += "<button class=' apply_to' id='apply_to_this' onclick=\"modifyApply('" + sWordId + "',false)\" title='Save Draft'>";
  2724. tApply += gLocal.gui.save;
  2725. tApply += "</button>";
  2726. tApply += "<button class=' apply_to' onclick=\"modifyCancel()\">";
  2727. tApply += gLocal.gui.cancel;
  2728. tApply += "</button>";
  2729. tApply += "</div>";
  2730. eApply.innerHTML = tApply;
  2731. document.getElementById("id_text_bookmark").value = getNodeText(xAllWord[wid], "bmt");
  2732. document.getElementById("id_text_note").value = getNodeText(xAllWord[wid], "note");
  2733. document.getElementById("id_text_id").innerHTML = get_book_name_by_id(getNodeText(xAllWord[wid], "id"));
  2734. document.getElementById("id_text_pali").value = getNodeText(xAllWord[wid], "pali");
  2735. document.getElementById("id_text_real").value = getNodeText(xAllWord[wid], "real");
  2736. document.getElementById("id_text_parent").value = getNodeText(xAllWord[wid], "parent");
  2737. $("#id_relation_text").val(getNodeText(xAllWord[wid], "rela"));
  2738. rela_refresh(sWordId);
  2739. if (getNodeText(xAllWord[wid], "bmc") == "") {
  2740. g_currBookMarkColor = "bmc0";
  2741. }
  2742. else {
  2743. g_currBookMarkColor = getNodeText(xAllWord[wid], "bmc");
  2744. }
  2745. getBookMarkColor(g_currBookMarkColor);
  2746. //显示编辑窗口
  2747. eWin.style.display = "block";
  2748. if (_display_sbs == 1) {
  2749. $("#modifywin").addClass("left_edit_frame");
  2750. //根据偏移量设置窗口位置
  2751. if ($(".sent_wbw").outerWidth() + $("#left_tool_bar").outerWidth() - $("#wb" + sWordId).offset().left - $("#modifywin").outerWidth() > 0) {
  2752. //$("#modifywin").removeClass("right_edit_frame")
  2753. $("#modifywin").css("margin-left", "0");
  2754. //$("#modifywin").style();
  2755. //$("#modifywin").css("margin-left", "8px");
  2756. //$("#modifywin::after").css("left", "0");
  2757. //$("#modifywin::after").style.left = "0";, "": "" }
  2758. } else {
  2759. let margin_change = $(".sent_wbw").outerWidth() + $("#left_tool_bar").outerWidth() - $("#wb" + sWordId).offset().left - $("#modifywin").outerWidth();
  2760. //$("#modifywin").removeClass("left_edit_frame")
  2761. //$("#modifywin").addClass("right_edit_frame")
  2762. $("#modifywin").css("margin-left", margin_change + "px");
  2763. //$("#modifywin::after").css("right", "0");
  2764. //$("#modifywin::after").style.right = "0";
  2765. }
  2766. $("#ws_" + sWordId).addClass("wbw_selected")
  2767. }
  2768. var sDetail = "detail" + sWordId;
  2769. var eDetail = document.getElementById(sDetail);
  2770. eWord.insertBefore(eWin, eDetail);
  2771. document.getElementById("dict_ref_search_input").value = sReal;
  2772. //editor_refresh_inline_dict(sReal);
  2773. }
  2774. }
  2775. function get_book_name_by_id(bookid) {
  2776. var book_id = bookid.split("-")[0];
  2777. var book_id2 = bookid.slice(book_id.length);
  2778. for (i_bookname in local_palicannon_index) {
  2779. if (book_id == local_palicannon_index[i_bookname].id) {
  2780. book_id2 = local_palicannon_index[i_bookname].title + book_id2;
  2781. }
  2782. }
  2783. return (book_id2);
  2784. }
  2785. function add_word_to_tran_win(sMeaning) {
  2786. var tranObj = document.getElementById("id_text_edit_form");
  2787. if (tranObj && tranObj.style.display != "none") {
  2788. var textObj = document.getElementById("id_text_edit_area");
  2789. if (textObj) {
  2790. textObj.value += sMeaning;
  2791. }
  2792. }
  2793. }
  2794. //编辑窗口拆分改变
  2795. var g_arrPartMean = null;
  2796. var g_initPartMeaning = true;
  2797. var mDict = new Array();
  2798. function input_org_change() {
  2799. g_arrPartMean = null;
  2800. g_initPartMeaning = true;
  2801. var arrPart = $("#input_org").val().split("+");
  2802. var arrNewPart = new Array();
  2803. var i;
  2804. for (i in arrPart) {
  2805. if (!mDict[arrPart[i]]) {
  2806. arrNewPart.push(arrPart[i]);
  2807. }
  2808. }
  2809. if (arrNewPart.length > 0) {
  2810. //如果有内存字典里面没有的单词,查询
  2811. $.get("dict_find_one.php",
  2812. {
  2813. word: arrNewPart.join(),
  2814. type: "part"
  2815. },
  2816. function (data, status) {
  2817. try {
  2818. var worddata = JSON.parse(data);
  2819. }
  2820. catch (e) {
  2821. console.error(e.error);
  2822. }
  2823. if (worddata.length > 0) {
  2824. var spell = new Array();
  2825. for (var i in worddata) {
  2826. if (mDict[worddata[i].pali]) {
  2827. spell[worddata[i].pali] = 1;
  2828. }
  2829. else {
  2830. spell[worddata[i].pali] = 0;
  2831. }
  2832. }
  2833. for (var word in spell) {
  2834. if (spell[word] == 0) {
  2835. mDict[word] = new Array();
  2836. }
  2837. }
  2838. for (var i in worddata) {
  2839. if (spell[worddata[i].pali] == 0) {
  2840. mDict[worddata[i].pali].push(worddata[i]);
  2841. }
  2842. }
  2843. }
  2844. else {
  2845. }
  2846. refreshPartMeaningSelect();
  2847. });
  2848. }
  2849. else {
  2850. refreshPartMeaningSelect();
  2851. }
  2852. }
  2853. const db_name = "../../tmp/user/wbw.db3";
  2854. function load_my_formula() {
  2855. //如果有内存字典里面没有的单词,查询
  2856. console.log("load_my_formula - dict_find_one.php");
  2857. $.get("dict_find_one.php",
  2858. {
  2859. word: "_formula_",
  2860. dict_name: db_name,
  2861. deep: 1
  2862. },
  2863. function (data, status) {
  2864. try {
  2865. myFormula = JSON.parse(data);
  2866. }
  2867. catch (e) {
  2868. console.error(e.error);
  2869. }
  2870. });
  2871. }
  2872. function part_mean_ok() {
  2873. var part_mean_ok_str = g_arrPartMean.join("+");
  2874. part_mean_ok_str = "#" + part_mean_ok_str + "#"
  2875. part_mean_ok_str = part_mean_ok_str.replace(/\+ /g, "+");
  2876. part_mean_ok_str = part_mean_ok_str.replace(/ \+/g, "+");
  2877. part_mean_ok_str = part_mean_ok_str.replace(/\# /g, "");
  2878. part_mean_ok_str = part_mean_ok_str.replace(/ \#/g, "");
  2879. part_mean_ok_str = part_mean_ok_str.replace(/\#/g, "");
  2880. document.getElementById("input_om").value = part_mean_ok_str;//.slice(0,-1);
  2881. }
  2882. /*
  2883. 编辑窗口中拆分下拉菜单改变
  2884. */
  2885. function meaningPartChange(index, newValue) {
  2886. g_initPartMeaning = false;
  2887. g_arrPartMean[index] = newValue;
  2888. part_mean_ok()
  2889. refreshPartMeaningSelect();
  2890. }
  2891. function input_org_switch(id_1, id_2) {
  2892. document.getElementById(id_1).style.display = "none";
  2893. document.getElementById(id_2).style.display = "inline-flex";
  2894. document.getElementById(id_2).focus();
  2895. refreshPartMeaningSelect();
  2896. }
  2897. function refreshPartMeaningSelect() {
  2898. var part = document.getElementById("input_org").value;
  2899. var arrPart = new Array;
  2900. if (part == "" || part.lastIndexOf("+") == -1) {
  2901. arrPart.push(part);
  2902. }
  2903. else {
  2904. arrPart = part.split("+");
  2905. }
  2906. if (g_initPartMeaning) {
  2907. g_arrPartMean = part.split("+");
  2908. }
  2909. var output = "";
  2910. //output="<span style='width:90%' onclick=\"input_org_switch('input_org_select','input_om')\"></span><br/>"
  2911. for (iPart in arrPart) {
  2912. output += getMeaningMenuList(iPart, arrPart[iPart])
  2913. if (arrPart.length == 1) {
  2914. break;
  2915. }
  2916. else if (iPart < arrPart.length - 1) {
  2917. output += "+";
  2918. }
  2919. }
  2920. output += "<div>";
  2921. output += "<button style='margin-left:auto; padding: 1px 6px;' onclick=\"copy_part_mean_to_mean()\">";
  2922. output += "<svg class=\"icon\"><use xlink=\"http://www.w3.org/1999/xlink\" href=\"svg/icon.svg#ic_vertical_align_top\">";
  2923. output += "</button>";
  2924. output += "<button style='margin-left:auto; padding: 1px 6px;' onclick=\"input_org_switch('input_org_select','input_om')\">";
  2925. output += "<svg class='icon'><use xlink='http://www.w3.org/1999/xlink' href='svg/icon.svg#ic_mode_edit'>";
  2926. output += "</button>";
  2927. output += "</div>";
  2928. document.getElementById("input_org_select").innerHTML = output;
  2929. //增加拆分意思所见即所得
  2930. var part_mean_display_str = document.getElementById("input_om").value;
  2931. var part_mean_display_array = new Array;
  2932. if (part_mean_display_str.lastIndexOf("+") != -1) {
  2933. part_mean_display_array = part_mean_display_str.split("+");
  2934. }
  2935. else {
  2936. part_mean_display_array.push(part_mean_display_str);
  2937. }
  2938. if (part_mean_display_array.length <= arrPart.length) {
  2939. for (i_display in part_mean_display_array) {
  2940. document.getElementById("org_part_mean_" + i_display).innerHTML = part_mean_display_array[i_display];
  2941. }
  2942. if (part_mean_display_array.length < arrPart.length) {
  2943. for (i_display = part_mean_display_array.length; i_display < arrPart.length; i_display++) {
  2944. document.getElementById("org_part_mean_" + i_display).innerHTML = "↓↓";
  2945. }
  2946. }
  2947. }
  2948. else {
  2949. for (i_display in arrPart) {
  2950. if (i_display == arrPart.length - 1) {
  2951. var part_mean_display_str_last = ""
  2952. for (j_display = i_display; j_display < part_mean_display_array.length; j_display++) {
  2953. part_mean_display_str_last += part_mean_display_array[j_display];
  2954. }
  2955. document.getElementById("org_part_mean_" + i_display).innerHTML = part_mean_display_str_last;
  2956. }
  2957. else {
  2958. document.getElementById("org_part_mean_" + i_display).innerHTML = part_mean_display_array[i_display];
  2959. }
  2960. }
  2961. }
  2962. }
  2963. //编辑窗口拆分意思复制到整体意思
  2964. function copy_part_mean_to_mean() {
  2965. $("#input_meaning").val(removeFormulaB(g_arrPartMean.join(""), "[", "]"));
  2966. }
  2967. //编辑窗口拆分意思下拉菜单
  2968. function getMeaningMenuList(index, word) {
  2969. var currMeaningList0 = getWordMeaningList(word);
  2970. var currMeaningList = new Array;
  2971. var part_mean_display_str = document.getElementById("input_om").value;
  2972. var part_mean_display_array = new Array;
  2973. if (part_mean_display_str.lastIndexOf("+") != -1) {
  2974. part_mean_display_array = part_mean_display_str.split("+");
  2975. }
  2976. else {
  2977. part_mean_display_array.push(part_mean_display_str);
  2978. }
  2979. if (part_mean_display_array.length - 1 >= index) {
  2980. currMeaningList.push(part_mean_display_array[index]);
  2981. }
  2982. else {
  2983. currMeaningList.push("↓↓");
  2984. }
  2985. for (MeaningList_i in currMeaningList0) {
  2986. currMeaningList.push(currMeaningList0[MeaningList_i]);
  2987. }
  2988. var output = "";
  2989. output += "<div class=\"case_dropdown\" style='display:inline-block;'>";
  2990. output += "<p id='org_part_mean_" + index + "' class='case_dropbtn' >";
  2991. if (g_initPartMeaning) {
  2992. output += currMeaningList[0];
  2993. g_arrPartMean[index] = currMeaningList[0];
  2994. }
  2995. else {
  2996. output += g_arrPartMean[index];
  2997. }
  2998. output += "</p>";
  2999. output += "<div class=\"case_dropdown-content\" id='part_mean_menu_" + index + "'>";
  3000. //直列菜单
  3001. for (i in currMeaningList) {
  3002. output += "<a onclick='meaningPartChange(" + index + ",\"" + currMeaningList[i] + "\")'>" + currMeaningList[i] + "</a>";
  3003. }
  3004. //带字典名的菜单
  3005. /*
  3006. if(mDict[word]){
  3007. for(var j=0;j<mDict[word].length;j++){
  3008. //
  3009. output += "<div class='om_menu'>";
  3010. var dictName = mDict[word][j].dict_name;
  3011. if(dictName==""){
  3012. dictName="未知";
  3013. }
  3014. output += "<span>"+dictName+"</span>";
  3015. var currOM=mDict[word][j].mean.split("$");
  3016. for(var iMean in currOM){
  3017. if(currOM[iMean].length>0 && currOM[iMean]!="?"){
  3018. output +="<a onclick='meaningPartChange("+index+",\""+currOM[iMean]+"\")'>"+currOM[iMean]+"</a>";
  3019. }
  3020. }
  3021. output +="</div>";
  3022. }
  3023. }
  3024. else{
  3025. output += "未知";
  3026. }
  3027. */
  3028. output += "</div>";
  3029. output += "</div>";
  3030. return (output);
  3031. }
  3032. function getWordMeaningList(word) {
  3033. var currOM = "";
  3034. var arrOM = new Array();
  3035. var thisWord = word;
  3036. //新的方法 内存字典用索引数组
  3037. if (mDict[word]) {
  3038. for (var j = 0; j < mDict[word].length; j++) {
  3039. if (mDict[word][j].mean) {
  3040. var currOM = mDict[word][j].mean.split("$");
  3041. for (iMean in currOM) {
  3042. if (currOM[iMean].length > 0 && currOM[iMean] != "?") {
  3043. pushNewToList(arrOM, currOM[iMean]);
  3044. }
  3045. }
  3046. }
  3047. }
  3048. }
  3049. if (arrOM.length == 0) {
  3050. arrOM.push("?");
  3051. }
  3052. return (arrOM);
  3053. }
  3054. function edit_un_remove(parentId) {
  3055. edit_un_RemoveHtmlNode(parentId);
  3056. var xWord = gXmlBookDataBody.getElementsByTagName("word");
  3057. var count = 0;
  3058. for (iWord = xWord.length - 1; iWord >= 0; iWord--) {
  3059. if (getNodeText(xWord[iWord], "un") == parentId) {
  3060. xWord[iWord].parentNode.removeChild(xWord[iWord]);
  3061. count++;
  3062. }
  3063. }
  3064. var parentElement = document.getElementById('wb' + parentId);
  3065. if (parentElement) {
  3066. parentElement.classList.remove("un_parent");
  3067. parentElement.classList.remove("comp_parent");
  3068. }
  3069. user_wbw_push_word(parentId);
  3070. user_wbw_commit();
  3071. com_XmlAllWordRefresh();
  3072. modifyWordDetailByWordId(parentId);
  3073. var_dump(gLocal.gui.removeword + ": " + count);
  3074. }
  3075. function edit_un_RemoveHtmlNode(parentId) {
  3076. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  3077. for (wordIndex = 0; wordIndex < xAllWord.length; wordIndex++) {
  3078. if (getNodeText(xAllWord[wordIndex], "un") == parentId) {
  3079. var childId = getNodeText(xAllWord[wordIndex], "id");
  3080. var element = document.getElementById("wb" + childId);
  3081. element.parentNode.removeChild(element);
  3082. }
  3083. }
  3084. }
  3085. /*
  3086. 拆连读词
  3087. */
  3088. function edit_un_split(parentId) {
  3089. var xBlock = gXmlBookDataBody.getElementsByTagName("block");
  3090. var iWordCount = 0;
  3091. for (iBlock = 0; iBlock < xBlock.length; iBlock++) {
  3092. var xData = xBlock[iBlock].getElementsByTagName("data")[0]
  3093. xWord = xData.getElementsByTagName("word");
  3094. for (iWord = 0; iWord < xWord.length; iWord++) {
  3095. if (getNodeText(xWord[iWord], "id") == parentId) {
  3096. mType = getNodeText(xWord[iWord], "case").split("#")[0];
  3097. if (mType == ".un." || mType == ".comp.") {
  3098. nextElement = com_get_nextsibling(xWord[iWord]);
  3099. if (nextElement != null) {//下一个元素存在
  3100. if (getNodeText(nextElement, "un") == parentId) {//若有孩子則不进行任何处理,直接返回
  3101. return;
  3102. }
  3103. }
  3104. }
  3105. else {//若不是连读词則不进行任何处理,直接返回
  3106. return;
  3107. }
  3108. if (getNodeText(xWord[iWord], "mean") == "?") {
  3109. setNodeText(xWord[iWord], "mean", "_un_auto_mean_");
  3110. }
  3111. if (getNodeText(xWord[iWord], "om") == "?") {
  3112. setNodeText(xWord[iWord], "om", "_un_auto_factormean_");
  3113. }
  3114. var parentElement = document.getElementById('wb' + parentId);
  3115. if (parentElement) {
  3116. if (mType == ".un.") {
  3117. parentElement.classList.add("un_parent");
  3118. }
  3119. else {
  3120. parentElement.classList.add("comp_parent");
  3121. }
  3122. }
  3123. var nextWordNodeId = getNodeText(xWord[iWord + 1], "id")
  3124. if (mType == ".un.") {
  3125. var org = "[+" + getNodeText(xWord[iWord], "org") + "+]";
  3126. }
  3127. else {
  3128. var org = getNodeText(xWord[iWord], "org").replace(/\+/g, "+-+");
  3129. }
  3130. var sSubPali = org.split("+");
  3131. var orgReal = org.replace(/n\+/g, "ṃ+");//智能識別結尾為n的拆分
  3132. orgReal = orgReal.replace(/ñ\+/g, "ṃ+");//智能識別結尾為n的拆分
  3133. orgReal = orgReal.replace(/m\+/g, "ṃ+");//智能識別結尾為n的拆分
  3134. orgReal = orgReal.replace(/d\+/g, "ṃ+");//智能識別結尾為n的拆分
  3135. var sSubReal = orgReal.split("+");
  3136. for (iNewWord = 0; iNewWord < sSubPali.length; iNewWord++) {
  3137. var newNode = gXmlBookData.createElement("word");
  3138. setNodeText(newNode, "pali", sSubPali[iNewWord]);
  3139. var newGUID = parentId + "-" + iNewWord;
  3140. setNodeText(newNode, "id", newGUID);
  3141. setNodeText(newNode, "un", parentId);
  3142. let newPali = sSubReal[iNewWord].toLowerCase();
  3143. if (sSubPali[iNewWord] == "[") {
  3144. setNodeText(newNode, "real", "");
  3145. setNodeText(newNode, "case", ".un:begin.");
  3146. }
  3147. else if (sSubPali[iNewWord] == "]") {
  3148. setNodeText(newNode, "real", "");
  3149. setNodeText(newNode, "case", ".un:end.");
  3150. }
  3151. else {
  3152. setNodeText(newNode, "real", newPali);//real转换为小写
  3153. setNodeText(newNode, "case", "?");
  3154. }
  3155. let newMeaning = findFirstMeanInDict(newPali);
  3156. let newParts = findFirstPartInDict(newPali);
  3157. let newPartMean = findFirstPartMeanInDict(newPali);
  3158. let newCase = findFirstCaseInDict(newPali);
  3159. setNodeText(newNode, "mean", newMeaning);
  3160. setNodeText(newNode, "org", newParts);
  3161. setNodeText(newNode, "om", newPartMean);
  3162. setNodeText(newNode, "case", newCase);
  3163. if (iWord == xWord.length - 1) {
  3164. xData.insertBefore(newNode, null);
  3165. edit_un_AddNewHtmlNode(nextWordNodeId, sSubPali[iNewWord], newGUID, iWordCount + iNewWord + 1);
  3166. }
  3167. else {
  3168. xData.insertBefore(newNode, xWord[iWord + iNewWord + 1]);
  3169. edit_un_AddNewHtmlNode(nextWordNodeId, sSubPali[iNewWord], newGUID, iWordCount + iNewWord + 1);
  3170. }
  3171. }
  3172. modifyWordDetailByWordId(parentId);
  3173. word_mouse_event();//添加鼠标事件,每次都执行效率低以后需要修改
  3174. var_dump(gLocal.gui.unsplit + " " + gLocal.gui.ok);
  3175. user_wbw_push_word(parentId);
  3176. user_wbw_commit();
  3177. return;
  3178. }
  3179. iWordCount++;
  3180. }
  3181. }
  3182. }
  3183. function edit_un_AddNewHtmlNode(nextNodeId, strInsert, guid, id) {
  3184. var xWord = gXmlBookDataBody.getElementsByTagName("word");
  3185. var iWordIndex = getWordIndex(guid);
  3186. var parentId = guid.split("_")[0];
  3187. var parentElement = document.getElementById("wb" + parentId);
  3188. var element = document.getElementById("wb" + nextNodeId);
  3189. var divWord = document.createElement("div");
  3190. var typ = document.createAttribute("class");
  3191. if (strInsert.length <= 1) {
  3192. typ.nodeValue = "word_punc";
  3193. }
  3194. else {
  3195. typ.nodeValue = "word";
  3196. }
  3197. divWord.attributes.setNamedItem(typ);
  3198. var typId = document.createAttribute("id");
  3199. typId.nodeValue = "wb" + guid;
  3200. divWord.attributes.setNamedItem(typId);
  3201. var txtOut = "";
  3202. /*word block begin*/
  3203. //add more class string for union word
  3204. sUnParent = getNodeText(xWord[iWordIndex], "un");
  3205. sWordCase = getNodeText(xWord[iWordIndex], "case");
  3206. txtUnClass = "";
  3207. if (sUnParent.length > 0) {
  3208. switch (sWordCase) {
  3209. case ".un:begin.":
  3210. txtUnClass = " un_begin";
  3211. break;
  3212. case ".un:begin.":
  3213. txtUnClass = " un_end";
  3214. break;
  3215. default:
  3216. txtUnClass = " un_pali";
  3217. break;
  3218. }
  3219. }
  3220. //word head being
  3221. /*长度为1的为标点符号*/
  3222. if (strInsert.length <= 1) {
  3223. txtOut = txtOut + "<p class='pali " + txtUnClass + "' name='wPali'>";
  3224. txtOut = txtOut + "<span class='paliword' name=\"spali\">" + strInsert + "</span>";
  3225. txtOut = txtOut + "<span class='paliword2' name=\"spali\"></span>";
  3226. txtOut = txtOut + "</p>\n";
  3227. }
  3228. else {
  3229. txtOut = txtOut + "<p class='pali " + txtUnClass + "' name='wPali'>";
  3230. txtOut = txtOut + "<a name='w" + guid + "' title=\"\" onclick='on_word_click(\"" + guid + "\")'>";
  3231. txtOut = txtOut + "<span class='paliword' name=\"spali\">" + strInsert + "</span>";
  3232. txtOut = txtOut + "<span class='paliword2' name=\"spali\"></span>";
  3233. txtOut = txtOut + "</a>";
  3234. txtOut = txtOut + "</p>\n";
  3235. }
  3236. //word head end
  3237. /*Detail being*/
  3238. txtOut = txtOut + "<div id='detail" + guid + "'>";
  3239. txtOut = txtOut + renderWordDetailById(guid);
  3240. txtOut = txtOut + "</div>";
  3241. //detail end
  3242. //word block end
  3243. divWord.innerHTML = txtOut;
  3244. //如果下一个词不存在。
  3245. if (element) {
  3246. element.parentNode.insertBefore(divWord, element);
  3247. }
  3248. else {
  3249. parentElement.parentNode.appendChild(divWord);
  3250. }
  3251. }
  3252. function file_export_html_validate_form(thisform) {
  3253. with (thisform) {
  3254. var tocstring = document.getElementById("content").innerHTML;
  3255. var suttastring = document.getElementById("sutta_text").innerHTML;
  3256. txt_toc.value = tocstring.replace(/onclick/g, "");
  3257. txt_sutta.value = suttastring.replace(/onclick/g, "");
  3258. return true;
  3259. }
  3260. }
  3261. function show_case_input(obj) {
  3262. if (obj.checked) {
  3263. document.getElementById("input_case").style.display = "block";
  3264. }
  3265. else {
  3266. document.getElementById("input_case").style.display = "none";
  3267. }
  3268. }
  3269. function edit_tran_save() {
  3270. let eBlock;
  3271. switch (gTextEditMediaType) {
  3272. case "translate":
  3273. newText = document.getElementById("id_text_edit_area").value;
  3274. newText = newText.replace(/\n\n/g, "<br />");
  3275. newText = term_edit_to_std_str(newText);
  3276. setTranText(gEditorTranslateEditBlockId, newText);
  3277. eBlock = document.getElementById("id_tran_" + gEditorTranslateEditBlockId);
  3278. if (eBlock) {
  3279. eBlock.innerHTML = renderTranslateParBlockInnerById(gEditorTranslateEditBlockId);
  3280. term_updata_translation();
  3281. }
  3282. break;
  3283. case "note":
  3284. setNoteText(gEditorNoteEditBlockId, document.getElementById("id_text_edit_area").value);
  3285. newText = document.getElementById("id_text_edit_area").value;
  3286. newText = newText.replace(/\n/g, "<br />");
  3287. eBlock = document.getElementById("note_sen_" + gEditorNoteEditBlockId + "_0");
  3288. if (eBlock) {
  3289. eBlock.innerHTML = newText;
  3290. }
  3291. break;
  3292. case "heading":
  3293. var newHeadingInfo = new Object();
  3294. newHeadingInfo.level = document.getElementById("id_heading_edit_level").value
  3295. newHeadingInfo.language = document.getElementById("id_text_edit_language").value
  3296. newHeadingInfo.author = document.getElementById("id_text_edit_author").value
  3297. newHeadingInfo.text = document.getElementById("id_text_edit_area").value
  3298. setHeadingInfo(gEditorHeadingEditBlockId, newHeadingInfo);
  3299. newText = document.getElementById("id_text_edit_area").value;
  3300. newText = newText.replace(/\n/g, "<br />");
  3301. eBlock = document.getElementById("id_heading_text_" + gEditorHeadingEditBlockId);
  3302. if (eBlock) {
  3303. eBlock.innerHTML = newText;
  3304. }
  3305. updataToc()
  3306. break;
  3307. case "new_heading":
  3308. var newHeadingInfo = new Object();
  3309. newHeadingInfo.book = gEditorNewHeadingBookId;
  3310. newHeadingInfo.paragraph = gEditorNewHeadingPar;
  3311. newHeadingInfo.level = document.getElementById("id_heading_edit_level").value
  3312. newHeadingInfo.language = document.getElementById("id_text_edit_language").value
  3313. newHeadingInfo.author = document.getElementById("id_text_edit_author").value
  3314. newHeadingInfo.text = document.getElementById("id_text_edit_area").value
  3315. newHeadBlock(newHeadingInfo)
  3316. updataToc()
  3317. break;
  3318. }
  3319. document.getElementById("id_text_edit_form").style.display = "none";
  3320. Dragging(getDraggingDialog).disable()
  3321. }
  3322. function edit_tran_cancal() {
  3323. document.getElementById("id_text_edit_form").style.display = "none";
  3324. Dragging(getDraggingDialog).disable()
  3325. }
  3326. function edit_tran_delete() {
  3327. switch (gTextEditMediaType) {
  3328. case "heading":
  3329. xBlock = gXmlBookDataBody.getElementsByTagName("block");
  3330. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  3331. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  3332. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  3333. mId = getNodeText(xmlParInfo, "id")
  3334. type = getNodeText(xmlParInfo, "type")
  3335. if (mId == gEditorHeadingEditBlockId) {
  3336. gXmlBookDataBody.removeChild(xBlock[iBlock]);
  3337. return
  3338. }
  3339. }
  3340. htmlNode = document.getElementById("id_heading_" + gEditorHeadingEditBlockId);
  3341. if (htmlNode) {
  3342. htmlNode.parentNode.removeChild(htmlNode);
  3343. }
  3344. updataToc()
  3345. break;
  3346. }
  3347. document.getElementById("id_text_edit_form").style.display = "none";
  3348. }
  3349. function editor_translate_edit(id) {
  3350. gTextEditMediaType = "translate";
  3351. gEditorTranslateEditBlockId = id;
  3352. var headingObj = getTranslateText(id);
  3353. document.getElementById("id_text_edit_language").value = headingObj.language;
  3354. document.getElementById("id_text_edit_author").value = headingObj.author;
  3355. document.getElementById("id_text_edit_area").value = term_std_str_to_edit(headingObj.text);
  3356. //document.getElementById("id_heading_edit_level").style.display="none";
  3357. document.getElementById("id_text_edit_delete").style.display = "none";
  3358. document.getElementById("id_text_edit_form").style.display = "block";
  3359. Dragging(getDraggingDialog).enable();
  3360. }
  3361. function editor_note_edit(id) {
  3362. gTextEditMediaType = "note";
  3363. gEditorNoteEditBlockId = id;
  3364. var tranText = getNoteText(id);
  3365. document.getElementById("id_text_edit_area").value = tranText;
  3366. document.getElementById("id_heading_edit_level").style.display = "none";
  3367. document.getElementById("id_text_edit_delete").style.display = "none";
  3368. document.getElementById("id_text_edit_form").style.display = "block";
  3369. }
  3370. function getNoteText(id) {
  3371. xBlock = gXmlBookDataBody.getElementsByTagName("block");
  3372. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  3373. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  3374. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  3375. mId = getNodeText(xmlParInfo, "id");
  3376. type = getNodeText(xmlParInfo, "type");
  3377. if (mId == id) {
  3378. xmlParDataSen = xmlParData.getElementsByTagName("sen");
  3379. var currText = "";
  3380. for (iSen = 0; iSen < xmlParDataSen.length; iSen++) {
  3381. currText += getNodeText(xmlParDataSen[iSen], "text");
  3382. }
  3383. return (currText);
  3384. }
  3385. }
  3386. return ("");
  3387. }
  3388. function editor_heading_add_new(inBook, inPar) {
  3389. document.getElementById("id_text_edit_caption_text").innerHTML = gLocal.gui.newheading;
  3390. gTextEditMediaType = "new_heading";
  3391. gEditorHeadingEditBlockId = -1;
  3392. gEditorNewHeadingBookId = inBook;
  3393. gEditorNewHeadingPar = inPar;
  3394. document.getElementById("id_heading_edit_level").value = "1";
  3395. document.getElementById("id_text_edit_language").value = "pali";
  3396. document.getElementById("id_text_edit_author").value = config_user_name;
  3397. document.getElementById("id_text_edit_area").value = "";
  3398. document.getElementById("id_heading_edit_level").style.display = "flex";
  3399. document.getElementById("id_text_edit_delete").style.display = "none";
  3400. document.getElementById("id_text_edit_form").style.display = "block";
  3401. }
  3402. function editor_heading_edit(id) {
  3403. document.getElementById("id_text_edit_caption_text").innerHTML = "Heading";
  3404. gTextEditMediaType = "heading";
  3405. gEditorHeadingEditBlockId = id;
  3406. var headingObj = getHeadingText(id);
  3407. document.getElementById("id_heading_edit_level").value = headingObj.level;
  3408. document.getElementById("id_text_edit_language").value = headingObj.language;
  3409. document.getElementById("id_text_edit_author").value = headingObj.author;
  3410. document.getElementById("id_text_edit_area").value = headingObj.text;
  3411. document.getElementById("id_heading_edit_level").style.display = "flex";
  3412. document.getElementById("id_text_edit_delete").style.display = "inline";
  3413. document.getElementById("id_text_edit_form").style.display = "block";
  3414. }
  3415. function getHeadingText(id) {
  3416. xBlock = gXmlBookDataBody.getElementsByTagName("block");
  3417. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  3418. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  3419. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  3420. mId = getNodeText(xmlParInfo, "id")
  3421. type = getNodeText(xmlParInfo, "type")
  3422. if (mId == id) {
  3423. var obj = new Object();
  3424. obj.text = getNodeText(xmlParData, "text");
  3425. obj.level = getNodeText(xmlParInfo, "level");
  3426. obj.language = getNodeText(xmlParInfo, "language");
  3427. obj.author = getNodeText(xmlParInfo, "author");
  3428. return (obj);
  3429. }
  3430. }
  3431. return (null);
  3432. }
  3433. function setHeadingInfo(id, objValue) {
  3434. xBlock = gXmlBookDataBody.getElementsByTagName("block");
  3435. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  3436. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  3437. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  3438. blockId = getNodeText(xmlParInfo, "id")
  3439. if (blockId == id) {
  3440. newText = objValue.text.replace(/\n/g, "<br />");
  3441. setNodeText(xmlParData, "text", newText);
  3442. setNodeText(xmlParInfo, "level", objValue.level);
  3443. setNodeText(xmlParInfo, "author", objValue.author);
  3444. setNodeText(xmlParInfo, "language", objValue.language);
  3445. return;
  3446. }
  3447. }
  3448. }
  3449. function editor_openChannal(book, para, channal) {
  3450. $.post(
  3451. "../doc/load_channal_para.php",
  3452. {
  3453. book: book,
  3454. para: para,
  3455. channal: channal,
  3456. },
  3457. function (data) {
  3458. editor_parse_doc_xml(data);
  3459. }
  3460. );
  3461. }
  3462. //open project begin
  3463. var editor_openProjectXmlHttp = null;
  3464. function editor_openProject(strFileId, filetype) {
  3465. if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc.
  3466. editor_openProjectXmlHttp = new XMLHttpRequest();
  3467. }
  3468. else if (window.ActiveXObject) {// code for IE6, IE5
  3469. editor_openProjectXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  3470. }
  3471. if (editor_openProjectXmlHttp != null) {
  3472. var d = new Date();
  3473. var strLink = "";
  3474. if (filetype == "db") {
  3475. strLink = "project_load_db.php?id=" + strFileId;
  3476. }
  3477. else {
  3478. strLink = "project_load.php?id=" + strFileId;
  3479. }
  3480. editor_openProjectXmlHttp.onreadystatechange = editor_open_project_serverResponse;
  3481. editor_openProjectXmlHttp.open("GET", strLink, true);
  3482. editor_openProjectXmlHttp.send(null);
  3483. }
  3484. else {
  3485. alert("Your browser does not support XMLHTTP.");
  3486. }
  3487. }
  3488. function editor_parse_doc_xml(xmlText) {
  3489. if (window.DOMParser) {
  3490. parser = new DOMParser();
  3491. gXmlBookData = parser.parseFromString(xmlText, "text/xml");
  3492. }
  3493. else { // Internet Explorer
  3494. gXmlBookData = new ActiveXObject("Microsoft.XMLDOM");
  3495. gXmlBookData.async = "false";
  3496. gXmlBookData.loadXML(xmlText);
  3497. }
  3498. if (gXmlBookData == null) {
  3499. alert("error:can not load Project. xml obj is null.");
  3500. return;
  3501. }
  3502. projectDataParse(gXmlBookData);
  3503. doc_file_info_get();
  3504. doc_info_change("accese_time", "");
  3505. //消息系统初始化
  3506. let msg_id = doc_head("msg_db_max_id");
  3507. if (msg_id != "" && !isNaN(msg_id)) {
  3508. msg_init(msg_id);
  3509. }
  3510. else {
  3511. msg_init(1);
  3512. }
  3513. updataDocParagraphList();
  3514. updataToc();
  3515. //渲染数据块
  3516. blockShow(0);
  3517. refreshResource()
  3518. editro_layout_loadStyle();
  3519. }
  3520. function editor_open_project_serverResponse() {
  3521. // 4 = "loaded"
  3522. if (editor_openProjectXmlHttp.readyState == 4) {
  3523. if (editor_openProjectXmlHttp.status == 200) {
  3524. // 200 = "OK"
  3525. var xmlText = editor_openProjectXmlHttp.responseText;
  3526. editor_parse_doc_xml(xmlText);
  3527. }
  3528. else {
  3529. $('#sutta_text').html("Problem retrieving data:" + editor_openProjectXmlHttp.statusText);
  3530. }
  3531. }
  3532. }
  3533. //数据块显示
  3534. function blockShow(id) {
  3535. xmlBlock = gXmlBookDataBody.getElementsByTagName("block")
  3536. if (id < xmlBlock.length) {
  3537. insertBlockToHtml(xmlBlock[id]);
  3538. t = setTimeout("blockShow(" + (id + 1) + ")", 1)
  3539. progress = id / xmlBlock.length//计算比例
  3540. strProgress = (progress * 100).toFixed(0) + "%"//计算百分比,保留1位小数
  3541. document.getElementById("load_progress_num").innerHTML = strProgress;//显示计算结果
  3542. loading.setAttribute("stroke-dashoffset", (255 - progress * 140) + "%");
  3543. }
  3544. else {
  3545. //文档载入完毕
  3546. strProgress = "OK";
  3547. loading.setAttribute("stroke-dashoffset", "0%");
  3548. document.getElementById("load_progress_num").innerHTML = strProgress;
  3549. setTimeout("hiddenProgressDiv()", 1000);
  3550. term_array_updata();
  3551. //单词块响应鼠标消息
  3552. word_mouse_event();
  3553. //刷新译文中的术语
  3554. term_updata_translation();
  3555. //自动将逐词译段落切分为句子
  3556. layout_wbw_auto_cut();
  3557. }
  3558. }
  3559. function word_mouse_event() {
  3560. $(".word").mouseenter(on_word_mouse_enter);
  3561. $(".word").mouseleave(on_word_mouse_leave);
  3562. }
  3563. var _curr_mouse_enter_wordid = "";
  3564. //单词快鼠标退出
  3565. function on_word_mouse_leave() {
  3566. $("#mean_" + _curr_mouse_enter_wordid).html("loading");
  3567. $("#parts_" + _curr_mouse_enter_wordid).html("loading");
  3568. $("#partmean_" + _curr_mouse_enter_wordid).html("loading");
  3569. $("#gramma_" + _curr_mouse_enter_wordid).html("loading");
  3570. relation_link_hide();
  3571. if (gRelationSelectWordBegin) {
  3572. //$(this).css(gCurrWordDivBorder);
  3573. $(this).css("border", "none");
  3574. }
  3575. gCurrMoseEnterWordId = "";
  3576. }
  3577. //单词块鼠标进入事件
  3578. var gCurrLookupWord = "";
  3579. //save the broder style when mouse leave recover
  3580. var gCurrWordDivBorder = "none";
  3581. var gWordHeadBarVisible = false;
  3582. var gCurrMoseEnterWordId = "";
  3583. function on_word_mouse_enter() {
  3584. var wordid = $(this).attr("id");
  3585. if (gCurrMoseEnterWordId == wordid) {
  3586. return;
  3587. }
  3588. gCurrMoseEnterWordId = wordid;
  3589. //remove the 'wb' in string head
  3590. _curr_mouse_enter_wordid = wordid.substr(2);
  3591. relation_link_show(_curr_mouse_enter_wordid);
  3592. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  3593. var iIndex = getWordIndex(_curr_mouse_enter_wordid);
  3594. if (iIndex >= 0) {
  3595. var paliword = getNodeText(xAllWord[iIndex], "real");
  3596. //如果内存里有这个词,渲染单词下拉菜单
  3597. if (mDict[paliword]) {
  3598. render_word_menu(_curr_mouse_enter_wordid);
  3599. }
  3600. else {
  3601. //如果内存里没有这个词,查字典
  3602. if (!mDictQueue[paliword]) {
  3603. if (gCurrLookupWord != paliword) {
  3604. mDictQueue[paliword] = 1;
  3605. gCurrLookupWord = paliword;
  3606. $.get("dict_find_one.php",
  3607. {
  3608. word: paliword
  3609. },
  3610. on_dict_lookup
  3611. );
  3612. }
  3613. }
  3614. }
  3615. }
  3616. //如果显示relation
  3617. if (gRelationSelectWordBegin) {
  3618. gCurrWordDivBorder = $(this).css("border");
  3619. $(this).css("border", "1px solid #65c5bd");
  3620. let eHeadBar = document.getElementById("word_tool_bar");
  3621. if (eHeadBar) {
  3622. eHeadBar.style.display = "block";
  3623. }
  3624. let eWord = document.getElementById("ws_" + _curr_mouse_enter_wordid);
  3625. let eWordHead = document.getElementById("whead_" + _curr_mouse_enter_wordid);
  3626. eWord.insertBefore(eHeadBar, eWordHead);
  3627. gWordHeadBarVisible = true;
  3628. }
  3629. }
  3630. //解析字典数据
  3631. function inline_dict_parse(data) {
  3632. if (data == "") {
  3633. return;
  3634. }
  3635. try {
  3636. var worddata = JSON.parse(data);
  3637. }
  3638. catch (e) {
  3639. console.error(e + " data:" + data);
  3640. return;
  3641. }
  3642. if (worddata.length > 0) {
  3643. //如果有数据 解析查询数据
  3644. let spell = new Array();
  3645. for (let i in worddata) {
  3646. if (mDict[worddata[i].pali]) {
  3647. spell[worddata[i].pali] = 1;
  3648. }
  3649. else {
  3650. spell[worddata[i].pali] = 0;
  3651. }
  3652. }
  3653. for (let word in spell) {
  3654. if (spell[word] == 0) {
  3655. mDict[word] = new Array();
  3656. }
  3657. }
  3658. for (let i in worddata) {
  3659. if (spell[worddata[i].pali] == 0) {
  3660. mDict[worddata[i].pali].push(worddata[i]);
  3661. mDictQueue[worddata[i].pali] = 0;
  3662. }
  3663. }
  3664. let type = new Array();
  3665. if (mDict[gCurrLookupWord]) {
  3666. for (let i in mDict[gCurrLookupWord]) {
  3667. type[mDict[gCurrLookupWord][i].type] = 1;
  3668. }
  3669. if (type.length == 1 && type[".comp."]) {
  3670. inline_dict_auto_case(gCurrLookupWord);
  3671. }
  3672. }
  3673. else {
  3674. //如果没有查到数据 添加自动格位
  3675. mDict[gCurrLookupWord] = new Array();
  3676. inline_dict_auto_case(gCurrLookupWord);
  3677. }
  3678. }
  3679. else {
  3680. //如果没有查到数据 添加自动格位
  3681. mDict[gCurrLookupWord] = new Array();
  3682. inline_dict_auto_case(gCurrLookupWord);
  3683. }
  3684. }
  3685. //添加自动格位数据到内存字典
  3686. function inline_dict_auto_case(paliword) {
  3687. for (let i in gCaseTable) {
  3688. if (gCaseTable[i].type != ".v.") {
  3689. let sEnd2 = gCurrLookupWord.slice(0 - gCaseTable[i].end2.length);
  3690. if (sEnd2 == gCaseTable[i].end2) {
  3691. let wordParent = gCurrLookupWord.slice(0, 0 - gCaseTable[i].end2.length) + gCaseTable[i].end1;
  3692. let newWord = new Object();
  3693. newWord.pali = gCurrLookupWord;
  3694. newWord.type = gCaseTable[i].type;
  3695. newWord.gramma = gCaseTable[i].gramma;
  3696. newWord.parent = wordParent;
  3697. newWord.mean = "";
  3698. newWord.note = "";
  3699. newWord.parts = wordParent + "+[" + gCaseTable[i].end2 + "]";
  3700. newWord.partmean = "";
  3701. newWord.confidence = gCaseTable[i].confidence;
  3702. mDict[paliword].push(newWord);
  3703. }
  3704. }
  3705. }
  3706. }
  3707. function getAutoEnding(pali, base) {
  3708. let ending = Array();
  3709. for (let i in gCaseTable) {
  3710. if (gCaseTable[i].type != ".v.") {
  3711. let sEnd2 = pali.slice(0 - gCaseTable[i].end2.length);
  3712. if (sEnd2 == gCaseTable[i].end2) {
  3713. let wordParent = pali.slice(0, 0 - gCaseTable[i].end2.length) + gCaseTable[i].end1;
  3714. if (base == wordParent) {
  3715. ending[gCaseTable[i].end2] = 1;
  3716. }
  3717. }
  3718. }
  3719. }
  3720. return (ending);
  3721. }
  3722. //查字典结果
  3723. function on_dict_lookup(data, status) {
  3724. //解析查询数据
  3725. inline_dict_parse(data);
  3726. render_word_menu(_curr_mouse_enter_wordid);
  3727. }
  3728. function render_word_menu(id) {
  3729. $("#word_mean").html(render_word_menu_mean(id));
  3730. $("#word_parts").html(render_word_menu_parts(id));
  3731. $("#word_partmean").html(render_word_menu_partmean(id));
  3732. $("#word_gramma").html(render_word_menu_gramma(id));
  3733. show_word_menu_mean(id);
  3734. show_word_menu_parts(id)
  3735. show_word_menu_partmean(id)
  3736. show_word_menu_gramma(id)
  3737. }
  3738. //根据单词长度排序 短词优先
  3739. function sortWordLen(a, b) {
  3740. return (a.length - b.length);
  3741. }
  3742. //渲染单词意思下拉菜单
  3743. function render_word_menu_mean(id, target = 0) {
  3744. var output = "";
  3745. var word_real = doc_word("#" + id).val("real");
  3746. var word_parent = doc_word("#" + id).val("parent");
  3747. var arrParent = new Array();
  3748. //检索语基
  3749. if (word_parent.length > 0) {
  3750. //arrParent[word_parent]=1;
  3751. }
  3752. if (mDict[word_real]) {
  3753. for (var i in mDict[word_real]) {
  3754. if (mDict[word_real][i].parent && mDict[word_real][i].parent.length > 0) {
  3755. if (word_parent != mDict[word_real][i].parent && word_real != mDict[word_real][i].parent) {
  3756. arrParent[mDict[word_real][i].parent] = 1;
  3757. }
  3758. }
  3759. }
  3760. }
  3761. var sWord = new Array();
  3762. for (var sParent in arrParent) {
  3763. sWord.push(sParent);
  3764. }
  3765. //按照base长度升序
  3766. sWord.sort(sortWordLen);
  3767. if (word_parent.length > 0) {
  3768. sWord.unshift(word_parent);
  3769. }
  3770. sWord.unshift(word_real);
  3771. output += "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" + id + "\",\"mean\",\"\")'>" + gLocal.gui.empty1 + "</button>";
  3772. output += "<div class=\"case_dropdown-org\">";
  3773. for (var iWord in sWord) {
  3774. var pali = sWord[iWord];
  3775. //该词字典数量
  3776. var dict_count = 0;
  3777. if (mDict[pali]) {
  3778. for (iCount in mDict[pali]) {
  3779. if (mDict[pali][iCount].mean && mDict[pali][iCount].mean.length > 0) {
  3780. dict_count++;
  3781. }
  3782. }
  3783. }
  3784. if (pali == word_parent) {
  3785. output += "<div class=\"case_dropdown-base\">";
  3786. }
  3787. else {
  3788. output += "<div class=\"case_dropdown-first\">";
  3789. }
  3790. output += "<a style=\"z-index:250; position:absolute; margin-right:2em;\" onclick='dict_search(\"" + pali + "\")'>";
  3791. if (pali == word_parent) {
  3792. output += "<b>·" + pali + "·</b>";
  3793. }
  3794. else {
  3795. output += pali;
  3796. }
  3797. output += "-" + dict_count + "</a>"
  3798. output += "<span style=\"z-index:220\" class=\"case_dropdown-title\" onclick=\"submenu_show_detail(this)\">";
  3799. output += "<svg class=\"icon\" style=\"fill:var(--main-color)\"><use xlink:href=\"svg/icon.svg#ic_add\"></use></svg>";
  3800. output += "</span>";
  3801. output += "<div class=\"case_dropdown-detail\" style='display:block;'>";
  3802. var currWordMean = new Array();
  3803. if (mDict[pali]) {
  3804. for (var i in mDict[pali]) {
  3805. var objMean = new Object();
  3806. objMean.type = "";
  3807. objMean.gramma = "";
  3808. objMean.dict_name = "";
  3809. objMean.mean = "";
  3810. if (mDict[pali][i].type) {
  3811. objMean.type = mDict[pali][i].type;
  3812. }
  3813. if (mDict[pali][i].gramma) {
  3814. objMean.gramma = mDict[pali][i].gramma;
  3815. }
  3816. if (mDict[pali][i].dict_name) {
  3817. objMean.dict_name = mDict[pali][i].dict_name;
  3818. }
  3819. if (mDict[pali][i].mean) {
  3820. objMean.mean = mDict[pali][i].mean;
  3821. }
  3822. if (objMean.mean.length > 0) {
  3823. _mean_push(currWordMean, objMean);
  3824. }
  3825. }
  3826. }
  3827. for (var i in currWordMean) {
  3828. var htmlMean = "";
  3829. var wId = id;
  3830. output += "<a style='display:flex; flex-wrap: wrap;'>";
  3831. output += "<div id='div_dictname_" + wId + "_" + iWord + "_" + i + "' style='margin-right: auto; display:flex;'>"
  3832. output += "<span id='span_dictname_" + wId + "_" + iWord + "_" + i + "' style='height: 1.5em;' class='wm_dictname' >";
  3833. output += getLocalDictname(currWordMean[i].dict_name) + "</span>"
  3834. output += "</div>"
  3835. output += "<div id='div_type_" + wId + "_" + iWord + "_" + i + "' style='margin-left: 0.4em; display:flex'>"
  3836. output += "<span id='span_type_" + wId + "_" + iWord + "_" + i + "' style='height: 1.5em;' class='wm_wordtype'>" + getLocalGrammaStr(currWordMean[i].type) + "</span>"
  3837. for (var iMean in currWordMean[i].mean) {
  3838. if (currWordMean[i].mean[iMean] != "") {
  3839. if (target == 0) {
  3840. htmlMean += "<span class='wm_one_mean' onclick='fieldListChanged(\"" + wId + "\",\"mean\",\"" + currWordMean[i].mean[iMean] + "\" ";
  3841. //parent 与意思联动
  3842. if (iWord > 0) {
  3843. htmlMean += ",\"" + pali + "\"";
  3844. }
  3845. htmlMean += " )'>" + currWordMean[i].mean[iMean] + "</span>";
  3846. }
  3847. else {
  3848. htmlMean += "<span class='wm_one_mean' onclick='_win_mean_change(\"" + currWordMean[i].mean[iMean] + "\" )'>" + currWordMean[i].mean[iMean] + "</span>";
  3849. }
  3850. }
  3851. }
  3852. output += "</div>";
  3853. output += "<div style='width:15em; display:flex; flex-wrap: wrap;'>" + htmlMean + "</div>";
  3854. output += "</a>";
  3855. }
  3856. output += "</div></div>";
  3857. }
  3858. output += "</div>";
  3859. return (output);
  3860. }
  3861. function _win_mean_change(newmean) {
  3862. $("#input_meaning").val(newmean);
  3863. }
  3864. function _mean_push(arr, obj) {
  3865. var arrMean = obj.mean.split("$");
  3866. var strIndex = obj.dict_name + "-" + obj.type + "-" + obj.gramma;
  3867. if (arr[strIndex] == null) {
  3868. arr[strIndex] = new Object();
  3869. arr[strIndex].dict_name = obj.dict_name;
  3870. arr[strIndex].type = obj.type
  3871. arr[strIndex].gramma = obj.gramma;
  3872. arr[strIndex].mean = new Array();
  3873. }
  3874. for (var i = 0; i < arrMean.length; i++) {
  3875. var found = false;
  3876. for (var j = 0; j < arr[strIndex].mean.length; j++) {
  3877. if (arr[strIndex].mean[j] == arrMean[i]) {
  3878. found = true;
  3879. break;
  3880. }
  3881. }
  3882. if (!found) {
  3883. arr[strIndex].mean.push(arrMean[i]);
  3884. }
  3885. }
  3886. }
  3887. function show_word_menu_mean(id) {
  3888. var word_menu_div = document.getElementById("mean_" + id);
  3889. if (word_menu_div) {
  3890. var menu_div = document.getElementById("word_mean");
  3891. if (menu_div) {
  3892. $("#mean_" + id).html($("#word_mean").html());
  3893. }
  3894. }
  3895. }
  3896. /*
  3897. 渲染单词拆分下拉菜单
  3898. id 单词id
  3899. target 默认渲染目标
  3900. 0:主编辑窗口下拉菜
  3901. 1:编辑窗口下拉菜单
  3902. 返回值 无
  3903. */
  3904. function render_word_menu_parts(id, target = 0) {
  3905. let output = "";
  3906. let wordID = id;
  3907. output += "<div>";
  3908. output += "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" + wordID + "\",\"org\",\"\")'>" + gLocal.gui.empty1 + "</button>"
  3909. output += "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='show_word_map(\"" + wordID + "\")'>" + gLocal.gui.wordmap + "</button>";
  3910. output += "</div>";
  3911. let pali = doc_word("#" + id).val("real");
  3912. let wParent = doc_word("#" + id).val("parent");
  3913. let wParts = doc_word("#" + id).val("org");
  3914. let arrParts = new Array();
  3915. let arrParent = new Array();
  3916. if (wParent != "") {
  3917. arrParts[wParent] = 1;
  3918. }
  3919. if (target == 1) {
  3920. arrParts[pali] = 1;
  3921. }
  3922. if (mDict[pali]) {
  3923. for (let iWord in mDict[pali]) {
  3924. if (mDict[pali][iWord].parts && mDict[pali][iWord].parts != "") {
  3925. arrParts[mDict[pali][iWord].parts] = 1;
  3926. }
  3927. if (mDict[pali][iWord].parent && mDict[pali][iWord].parent != "") {
  3928. arrParent[mDict[pali][iWord].parent] = 1;
  3929. }
  3930. }
  3931. }
  3932. //加入base拆分
  3933. if (mDict[wParent]) {
  3934. let ending = getAutoEnding(pali, wParent);
  3935. for (let iWord in mDict[wParent]) {
  3936. if (mDict[wParent][iWord].parts && mDict[wParent][iWord].parts != "") {
  3937. arrParts[mDict[wParent][iWord].parts] = 1;
  3938. {
  3939. for (let end in ending) {
  3940. arrParts[mDict[wParent][iWord].parts + "+[" + end + "]"] = 1;
  3941. }
  3942. }
  3943. }
  3944. }
  3945. }
  3946. output += "<div>";
  3947. let outputPart = "";
  3948. for (let sPart in arrParts) {
  3949. if (wParts == sPart) {
  3950. outputPart = "<b>" + sPart + "</b>";
  3951. }
  3952. else {
  3953. outputPart = sPart;
  3954. }
  3955. if (target == 0) {
  3956. output += "<a onclick='fieldListChanged(\"" + wordID + "\",\"org\",\"" + sPart + "\")'>" + outputPart + "</a>";
  3957. }
  3958. else {
  3959. output += "<a onclick='mdf_win_part_change(\"" + sPart + "\")'>" + outputPart + "</a>";
  3960. }
  3961. }
  3962. output += "</div>";
  3963. //base parts 信息
  3964. for (let sParent in arrParent) {
  3965. if (mDict[sParent]) {
  3966. let arrParts = new Array();
  3967. for (let iWord in mDict[sParent]) {
  3968. if (mDict[sParent][iWord].parts && mDict[sParent][iWord].parts != "") {
  3969. arrParts[mDict[sParent][iWord].parts] = 1;
  3970. }
  3971. }
  3972. if (arrParts.length > 0) {
  3973. output += "<div class=\"case_dropdown-org\">";
  3974. output += "<div class=\"case_dropdown-first\">";
  3975. output += "<a style='z-index:250; position:absolute; margin-right:2em;'>";
  3976. output += sParent + "</a>";
  3977. output += "<span style='z-index:220' class='case_dropdown-title'>";
  3978. output += gLocal.gui.more + "»</span>";
  3979. output += "</div>";
  3980. output += "<div>";
  3981. for (let sPart in arrParts) {
  3982. output += "<a onclick='fieldListChanged(\"" + wordID + "\",\"org\",\"" + sPart + "\")'>" + sPart + "</a>";
  3983. }
  3984. output += "</div>";
  3985. output += "</div>";
  3986. }
  3987. }
  3988. }
  3989. return (output);
  3990. }
  3991. function show_word_menu_parts(id) {
  3992. var word_parts_div = document.getElementById("parts_" + id);
  3993. if (word_parts_div) {
  3994. var parts_div = document.getElementById("word_parts");
  3995. if (parts_div) {
  3996. //word_menu_div.appendChild(menu_div);
  3997. $("#parts_" + id).html($("#word_parts").html());
  3998. }
  3999. }
  4000. }
  4001. //渲染单词拆分意思下拉菜单
  4002. function render_word_menu_partmean(id) {
  4003. var wordID = id;
  4004. var sHtml = "";
  4005. var pali = doc_word("#" + id).val("real");
  4006. var sOrg = doc_word("#" + id).val("org");
  4007. var listFactorForFactorMean = sOrg.split("+");
  4008. var currDefualtFM = "";
  4009. for (iFactor in listFactorForFactorMean) {
  4010. currDefualtFM += findFirstMeanInDict(listFactorForFactorMean[iFactor]) + "+";//拆分元素加号分隔
  4011. }
  4012. currDefualtFM = currDefualtFM.replace(/" "/g, " ");
  4013. currDefualtFM = currDefualtFM.replace(/"+ "/g, "+");
  4014. currDefualtFM = currDefualtFM.replace(/" +"/g, "+");
  4015. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);//去掉尾部的加号 kosalla
  4016. if (currDefualtFM.slice(-1, -2) == "+") {
  4017. currDefualtFM = currDefualtFM.substring(0, currDefualtFM.length - 1);
  4018. }
  4019. sHtml += "<button style='font-size:100%;display:inline-flex; padding:0.1em 0.5em' onclick='fieldListChanged(\"" + wordID + "\",\"om\",\"\")'>" + gLocal.gui.empty1 + "</button>";
  4020. sHtml += "<a onclick='fieldListChanged(\"" + wordID + "\",\"om\",\"[a]" + currDefualtFM + "\")'>[" + gLocal.gui.auto + "]" + currDefualtFM + "</a>";
  4021. var arrPartMean = new Array();
  4022. if (mDict[pali]) {
  4023. for (var i in mDict[pali]) {
  4024. if (mDict[pali][i].partmean && mDict[pali][i].partmean.length > 0) {
  4025. arrPartMean[mDict[pali][i].partmean] = 1;
  4026. }
  4027. }
  4028. }
  4029. for (var sPM in arrPartMean) {
  4030. sHtml += "<a onclick='fieldListChanged(\"" + wordID + "\",\"om\",\"" + sPM + "\")'>" + sPM + "</a>";
  4031. }
  4032. return (sHtml);
  4033. }
  4034. /*
  4035. 渲染单词语基下拉菜单
  4036. id 单词id
  4037. return 无
  4038. */
  4039. function render_word_menu_parent(id) {
  4040. let output = "";
  4041. let word_real = doc_word("#" + id).val("real");
  4042. let word_parent = doc_word("#" + id).val("parent");
  4043. let arrParent = new Array();
  4044. //检索语基
  4045. if (word_parent != "") {
  4046. arrParent[word_parent] = 1;
  4047. }
  4048. if (mDict[word_real]) {
  4049. for (let i in mDict[word_real]) {
  4050. if (mDict[word_real][i].parent &&
  4051. mDict[word_real][i].parent.length > 0) {
  4052. arrParent[mDict[word_real][i].parent] = 1;
  4053. }
  4054. }
  4055. }
  4056. let sWord = new Array();
  4057. for (let sParent in arrParent) {
  4058. sWord.push(sParent);
  4059. }
  4060. //按照base长度升序
  4061. sWord.sort(sortWordLen);
  4062. if (!str_in_array(word_real, sWord)) {
  4063. sWord.push(word_real);
  4064. }
  4065. for (var iWord in sWord) {
  4066. var pali = sWord[iWord];
  4067. output += "<a onclick=\"mdf_win_data_change('id_text_parent','" + pali + "')\">";
  4068. if (word_parent == pali) {
  4069. output += "<b>" + pali + "</b>";
  4070. }
  4071. else {
  4072. output += pali;
  4073. }
  4074. output += "</a>";
  4075. }
  4076. return (output);
  4077. }
  4078. function show_word_menu_partmean(id) {
  4079. var word_partmean_div = document.getElementById("partmean_" + id);
  4080. if (word_partmean_div) {
  4081. var partmean_div = document.getElementById("word_partmean");
  4082. if (partmean_div) {
  4083. //word_menu_div.appendChild(menu_div);
  4084. $("#partmean_" + id).html($("#word_partmean").html());
  4085. }
  4086. }
  4087. }
  4088. //语法按照信心指数排序
  4089. function sortWordConfidence(a, b) {
  4090. return (b - a);
  4091. }
  4092. /*渲染语法菜单
  4093. //@param
  4094. target
  4095. 0:主窗口
  4096. 1:编辑窗口
  4097. */
  4098. function render_word_menu_gramma(id, target = 0) {
  4099. var wordID = id;
  4100. var sHtml = "";
  4101. var pali = doc_word("#" + id).val("real");
  4102. var arrGramma = new Array();
  4103. if (mDict[pali]) {
  4104. for (var i in mDict[pali]) {
  4105. var type = mDict[pali][i].type;
  4106. var gramma = mDict[pali][i].gramma;
  4107. if ((type && type.length > 0) || (gramma && gramma.length > 0)) {
  4108. var sCase = type + "#" + gramma;
  4109. if (arrGramma[sCase]) {
  4110. if (mDict[pali][i].confidence > arrGramma[sCase]) {
  4111. arrGramma[sCase] = mDict[pali][i].confidence;
  4112. }
  4113. }
  4114. else {
  4115. arrGramma[sCase] = 1;
  4116. }
  4117. }
  4118. }
  4119. }
  4120. arrGramma.sort(sortWordConfidence);
  4121. for (var sGramma in arrGramma) {
  4122. var sLocalCase = getLocalGrammaStr(sGramma);
  4123. if (target == 0) {
  4124. sHtml += "<a onclick='fieldListChanged(\"" + wordID + "\",\"case\",\"" + sGramma + "\")'>" + cutString(sLocalCase, 30) + "</a>";
  4125. }
  4126. else {
  4127. sHtml += "<a onclick='mdf_win_case_change(\"" + sGramma + "\")'>" + cutString(sLocalCase, 30) + "</a>";
  4128. }
  4129. }
  4130. return (sHtml);
  4131. }
  4132. function show_word_menu_gramma(id) {
  4133. var gramma_div = document.getElementById("gramma_" + id);
  4134. if (gramma_div) {
  4135. var word_gramma_div = document.getElementById("word_gramma");
  4136. if (word_gramma_div) {
  4137. //word_menu_div.appendChild(menu_div);
  4138. $("#gramma_" + id).html($("#word_gramma").html());
  4139. }
  4140. }
  4141. }
  4142. function hiddenProgressDiv() {
  4143. document.getElementById("loading_bar").style.animation = "opacityGo 1s both";
  4144. }
  4145. function editor_project_updataProjectInfo() {
  4146. var strInfo = "";
  4147. var iInlineDictCount = gXmlBookDataInlineDict.getElementsByTagName("word").length;
  4148. var iWordCount = gXmlBookDataBody.getElementsByTagName("word").length;
  4149. strInfo += gLocal.gui.wordnum + iWordCount + "<br />";
  4150. strInfo += gLocal.gui.para + ":" + gArrayDocParagraph.length + "<br />";
  4151. strInfo += gLocal.gui.innerdict + ":" + iInlineDictCount + "<br />";
  4152. strInfo += gLocal.gui.vocabulary + CountVocabulary() + "<br />";
  4153. document.getElementById("id_editor_project_infomation").innerHTML = strInfo;
  4154. document.getElementById("doc_info_title").value = getNodeText(gXmlBookDataHead, "doc_title");
  4155. document.getElementById("editor_doc_title").innerHTML = getNodeText(gXmlBookDataHead, "doc_title");
  4156. document.getElementById("file_title").innerHTML = getNodeText(gXmlBookDataHead, "doc_title");
  4157. }
  4158. //import old ver file
  4159. var editor_importOldVerXmlHttp = null;
  4160. function editor_importOldVer(strFileName) {
  4161. if (window.XMLHttpRequest) {// code for IE7, Firefox, Opera, etc.
  4162. editor_importOldVerXmlHttp = new XMLHttpRequest();
  4163. }
  4164. else if (window.ActiveXObject) {// code for IE6, IE5
  4165. editor_importOldVerXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  4166. }
  4167. if (editor_importOldVerXmlHttp != null) {
  4168. var d = new Date();
  4169. var strLink = "";
  4170. strLink = "com_fileopen.php?filename=" + strFileName;
  4171. if (strLink.length > 0) {
  4172. editor_importOldVerXmlHttp.onreadystatechange = editor_import_old_ver_serverResponse;
  4173. editor_importOldVerXmlHttp.open("GET", strLink, true);
  4174. editor_importOldVerXmlHttp.send(null);
  4175. //document.getElementById('sutta_text').innerHTML="Importing..."+strFileName;
  4176. }
  4177. else {
  4178. //document.getElementById('sutta_text').innerHTML="无法识别的文件类型";
  4179. }
  4180. }
  4181. else {
  4182. alert("Your browser does not support XMLHTTP.");
  4183. }
  4184. }
  4185. function editor_import_old_ver_serverResponse() {
  4186. // 4 = "loaded"
  4187. if (editor_importOldVerXmlHttp.readyState == 4) {
  4188. document.getElementById('sutta_text').innerHTML = "<div class=\"sutta_top_blank\"></div>";
  4189. if (editor_importOldVerXmlHttp.status == 200) {// 200 = "OK"
  4190. var xmlText = editor_importOldVerXmlHttp.responseText;
  4191. if (window.DOMParser) {
  4192. parser = new DOMParser();
  4193. gXmlOldVerData = parser.parseFromString(xmlText, "text/xml");
  4194. }
  4195. else { // Internet Explorer
  4196. gXmlOldVerData = new ActiveXObject("Microsoft.XMLDOM");
  4197. gXmlOldVerData.async = "false";
  4198. gXmlOldVerData.loadXML(xmlText);
  4199. }
  4200. if (gXmlOldVerData == null) {
  4201. alert("error:can not load. xml obj is null.");
  4202. return;
  4203. }
  4204. oldVerDataParse(gXmlOldVerData);
  4205. }
  4206. else {
  4207. document.getElementById('sutta_text').innerHTML = "Problem retrieving data:" + editor_openProjectXmlHttp.statusText;
  4208. }
  4209. }
  4210. }
  4211. //在段落前设置或取消分页
  4212. function editor_page_break(obj, book, par) {
  4213. if (obj.checked) {
  4214. document.getElementById("par_" + book + "_" + par).style.pageBreakBefore = "always"
  4215. }
  4216. else {
  4217. document.getElementById("par_" + book + "_" + par).style.pageBreakBefore = "auto"
  4218. }
  4219. }
  4220. function editor_heading_change(obj, book, par) {
  4221. document.getElementById("content").innerHTML = "";
  4222. allBlock = gXmlBookDataBody.getElementsByTagName("block")
  4223. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  4224. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  4225. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  4226. bookId = getNodeText(xmlParInfo, "book")
  4227. paragraph = getNodeText(xmlParInfo, "paragraph")
  4228. type = getNodeText(xmlParInfo, "type")
  4229. if (bookId == book && paragraph == par && type == "heading") {
  4230. setNodeText(xmlParInfo, "level", obj.value)
  4231. }
  4232. }
  4233. updataHeadingBlockInHtml(book, par)
  4234. updataToc();
  4235. }
  4236. function editor_par_show(obj, book, par) {
  4237. parId = "par_" + book + "_" + (par - 1);
  4238. if (obj.checked) {
  4239. document.getElementById(parId).style.display = "block";
  4240. }
  4241. else {
  4242. document.getElementById(parId).style.display = "none";
  4243. }
  4244. var rootIndex = -1
  4245. var rootLevel = -1
  4246. allBlock = gXmlBookDataBody.getElementsByTagName("block")
  4247. for (var iBlock = 0; iBlock < allBlock.length; iBlock++) {
  4248. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  4249. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  4250. bookId = getNodeText(xmlParInfo, "book")
  4251. paragraph = getNodeText(xmlParInfo, "paragraph")
  4252. type = getNodeText(xmlParInfo, "type")
  4253. if (bookId == book && paragraph == par && type == "heading") {
  4254. rootIndex = iBlock;
  4255. rootLevel = getNodeText(xmlParInfo, "level")
  4256. break;
  4257. }
  4258. }
  4259. var opBegin = false;
  4260. for (var iBlock = rootIndex + 1; iBlock < allBlock.length; iBlock++) {
  4261. xmlParInfo = allBlock[iBlock].getElementsByTagName("info")[0];
  4262. xmlParData = allBlock[iBlock].getElementsByTagName("data")[0];
  4263. bookId = getNodeText(xmlParInfo, "book")
  4264. paragraph = getNodeText(xmlParInfo, "paragraph")
  4265. type = getNodeText(xmlParInfo, "type")
  4266. if (type == "heading") {
  4267. currLevel = getNodeText(xmlParInfo, "level")
  4268. if (currLevel == 0 || currLevel > rootLevel) {
  4269. opBegin = true;
  4270. parId = "par_" + bookId + "_" + (paragraph - 1);
  4271. if (obj.checked) {
  4272. document.getElementById(parId).style.display = "block";
  4273. }
  4274. else {
  4275. document.getElementById(parId).style.display = "none";
  4276. }
  4277. }
  4278. else {
  4279. if (opBegin) {
  4280. break;
  4281. }
  4282. }
  4283. }
  4284. }
  4285. }
  4286. function editor_right_tool_bar_slide_toggle() {
  4287. if (document.getElementById("right_tool_bar").style.left == "100%") {
  4288. document.getElementById("right_tool_bar").style.display = "block";
  4289. document.getElementById("right_tool_bar").style.left = "calc(100% - 28vw)";
  4290. document.getElementById("right_tool_bar").style.width = "28vw";
  4291. }
  4292. else {
  4293. document.getElementById("right_tool_bar").style.left = "100%";
  4294. }
  4295. }
  4296. function right_panal_slide_toggle(idPanal) {
  4297. if ($("#" + idPanal).hasClass("act")) {
  4298. document.getElementById("right_tool_bar").style.display = "block";
  4299. document.getElementById("right_tool_bar").style.left = "calc(100% - 28vw)";
  4300. document.getElementById("right_tool_bar").style.width = "28vw";
  4301. }
  4302. else {
  4303. document.getElementById("right_tool_bar").style.left = "100%";
  4304. }
  4305. }
  4306. function editor_show_right_tool_bar(visible) {
  4307. if (visible) {
  4308. document.getElementById("right_tool_bar").style.display = "block";
  4309. document.getElementById("right_tool_bar").style.left = "calc(100% - 28vw)";
  4310. document.getElementById("right_tool_bar").style.width = "28vw";
  4311. }
  4312. else {
  4313. document.getElementById("right_tool_bar").style.left = "100%";
  4314. }
  4315. }
  4316. function editor_goto_link(bookId, parNo, strLink = "") {
  4317. parIndex = getParIndex(bookId, parNo);
  4318. scrollEventLock = true;
  4319. setNewView(parIndex - 3, parIndex + 6);
  4320. scrollEventLock = false;
  4321. if (strLink == "") {
  4322. window.location.assign("#par_begin_" + bookId + "_" + (parNo - 1));
  4323. }
  4324. else {
  4325. window.location.assign("#" + strLink);
  4326. }
  4327. }
  4328. function get_language_order(strLanguage) {
  4329. for (iLan in dict_language_order) {
  4330. if (dict_language_order[iLan] == strLanguage) {
  4331. return (iLan);
  4332. }
  4333. }
  4334. return (1000);
  4335. }
  4336. function removeAllInlinDictItem() {
  4337. var count;
  4338. var xAllWord = gXmlBookDataInlineDict.getElementsByTagName("word");
  4339. count = xAllWord.length;
  4340. while (xAllWord.length) {
  4341. gXmlBookDataInlineDict.removeChild(xAllWord[0]);
  4342. }
  4343. g_DictWordList = new Array();
  4344. return (count);
  4345. }
  4346. function editor_refresh_inline_dict(word) {
  4347. currMatchingDictNum = 0;
  4348. g_dictFindParentLevel = 0;
  4349. g_dictFindAllDone = false;
  4350. g_dict_search_one_dict_done = editor_dict_one_dict_done;
  4351. g_dict_search_all_done = editor_dict_all_done;
  4352. g_dict_search_one_pass_done = null;
  4353. dict_mark_word_list_done();
  4354. dict_push_word_to_download_list(word, 0);
  4355. var arrBuffer = dict_get_search_list();
  4356. if (arrBuffer.length > 0) {
  4357. g_CurrDictBuffer = JSON.stringify(arrBuffer);
  4358. dict_mark_word_list_done();
  4359. editor_dict_match();
  4360. }
  4361. else {
  4362. document.getElementById('editor_doc_notify').innerHTML = "no new part";
  4363. }
  4364. }
  4365. function win_close(id) {
  4366. document.getElementById(id).style.display = "none";
  4367. }
  4368. //利用下拉菜单修改单词信息
  4369. function fieldListChanged(inWordId, inField, inChangeTo, sParent = null) {
  4370. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  4371. var wordIndex = getWordIndex(inWordId);
  4372. let arr_id_word = inWordId.split("-");
  4373. let book = arr_id_word[0].slice(1);
  4374. let paragraph = arr_id_word[1];
  4375. setNodeText(xAllWord[wordIndex], "status", "7");
  4376. setNodeAttr(xAllWord[wordIndex], inField, "status", "7");
  4377. if (inField == "om") {/*拆分意思去掉开头的[a]*/
  4378. inChangeTo = inChangeTo.replace("[a]", "");
  4379. }
  4380. setNodeText(xAllWord[wordIndex], inField, inChangeTo);
  4381. if (sParent) {
  4382. setNodeText(xAllWord[wordIndex], "parent", sParent);
  4383. }
  4384. //提交用户逐词解析数据库
  4385. user_wbw_push_word(inWordId);
  4386. user_wbw_commit();
  4387. //准备消息数据
  4388. let d = new Date();
  4389. let msg_doc_id;
  4390. if (doc_info.sendmsg) {
  4391. if (doc_info.parent_id != "") {
  4392. msg_doc_id = doc_info.parent_id;
  4393. }
  4394. else {
  4395. msg_doc_id = doc_info.doc_id;
  4396. }
  4397. let msg_data = new Object();
  4398. msg_data.id = inWordId;
  4399. msg_data[inField] = inChangeTo;
  4400. msg_data.status = 7;
  4401. msg_push(1, JSON.stringify(msg_data), msg_doc_id, d.getTime(), book, paragraph);
  4402. }
  4403. modifyWordDetailByWordIndex(wordIndex);
  4404. //modify other same word with auto-mark
  4405. var word = getNodeText(xAllWord[wordIndex], "real");
  4406. for (var i = wordIndex + 1; i < xAllWord.length; i++) {
  4407. let status = getNodeText(xAllWord[i], "status");
  4408. if (status != 7) {
  4409. if (getNodeText(xAllWord[i], "real") == word) {
  4410. setNodeText(xAllWord[i], inField, inChangeTo);
  4411. if (sParent) {
  4412. setNodeText(xAllWord[i], "parent", sParent);
  4413. }
  4414. setNodeText(xAllWord[i], "status", "5");
  4415. //准备消息数据
  4416. if (doc_info.sendmsg) {
  4417. let wordid = getNodeText(xAllWord[i], "id");
  4418. let msg_data = new Object();
  4419. msg_data.id = wordid;
  4420. msg_data[inField] = inChangeTo;
  4421. msg_data.status = 5;
  4422. msg_push(1, JSON.stringify(msg_data), msg_doc_id, d.getTime(), book, paragraph);
  4423. }
  4424. modifyWordDetailByWordIndex(i);
  4425. }
  4426. }
  4427. }
  4428. }
  4429. function editor_word_status_by_id(id, newStatus = null) {
  4430. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  4431. return (editor_word_status(xAllWord[getWordIndex(wordId)]), newStatus);
  4432. }
  4433. function editor_word_status(wElement, newStatus = null) {
  4434. if (newStatus == null) {
  4435. var wStatus = getNodeText(wElement, "status");
  4436. if (wStatus == "") {
  4437. var oldVerStauts = getNodeText(wElement, "bmc");
  4438. if (oldVerStauts == "") {
  4439. setNodeText(wElement, "status", "1");//未处理
  4440. return (1);
  4441. }
  4442. else if (oldVerStauts == "bmca") {
  4443. setNodeText(wElement, "status", "3");//自己机器自动
  4444. return (3);
  4445. }
  4446. else {
  4447. setNodeText(wElement, "status", "7");//人工
  4448. return (7);
  4449. }
  4450. }
  4451. else {
  4452. return (wStatus);
  4453. }
  4454. }
  4455. else {
  4456. setNodeText(wElement, "status", newStatus.toString());
  4457. }
  4458. }
  4459. //载入用户设置
  4460. function editor_setup_load() {
  4461. $.post("user_setup.php",
  4462. {
  4463. op: "load"
  4464. },
  4465. function (data, status) {
  4466. if (data.length > 0) {
  4467. gUserSetup = JSON.parse(data);
  4468. }
  4469. });
  4470. }
  4471. //修改用户设置
  4472. function editor_setup_save(key, value) {
  4473. $.post("user_setup.php",
  4474. {
  4475. op: "save",
  4476. key: key,
  4477. value: value
  4478. },
  4479. function (data, status) {
  4480. if (data.length > 0) {
  4481. gUserSetup = JSON.parse(data);
  4482. }
  4483. });
  4484. }
  4485. function tran_sen_save_click(blockid, senBegin, senEnd, obj) {
  4486. let textareaid = "ta_" + blockid + "_" + senBegin + "_" + senEnd;
  4487. let newText = $("#" + textareaid).val();
  4488. tran_sen_save(blockid, senBegin, senEnd, newText);
  4489. }
  4490. function tran_sen_save(blockid, senBegin, senEnd, input) {
  4491. if (input.length > 0) {
  4492. //input=input.replace(/\n\n/g,"<br />");
  4493. }
  4494. input = term_edit_to_std_str(input);
  4495. setTranText(blockid, senEnd, input);
  4496. doc_tran("#" + blockid).text(senBegin, senEnd, "status", 7);
  4497. }
  4498. function tran_text_onchange(blockid, senBegin, senEnd, obj) {
  4499. let newText = obj.value;
  4500. tran_sen_save(blockid, senBegin, senEnd, newText);
  4501. //保存到数据库
  4502. sen_save(blockid, senBegin, senEnd, newText);
  4503. }
  4504. /*
  4505. 句子失去焦点
  4506. 退出编辑状态
  4507. */
  4508. function tran_sent_div_blur(blockId, senBegin, senEnd, obj) {
  4509. obj.style.height = "28px";
  4510. }
  4511. function tran_sent_div_onfocus(blockId, senBegin, senEnd, obj) {
  4512. obj.style.height = "100px";
  4513. }
  4514. //鼠标移到逐句翻译上 编辑状态
  4515. function tran_sent_div_mouseenter(blockId, wordSn) {
  4516. /*
  4517. $("#tran_sent_text_div_"+blockId+"_"+wordSn).show();
  4518. if(_tran_show_preview_on_edit==true){
  4519. $("#tran_pre_"+blockId+"_"+wordSn).show();
  4520. }
  4521. else{
  4522. $("#tran_pre_"+blockId+"_"+wordSn).hide();
  4523. }
  4524. */
  4525. }
  4526. function set_tran_show_mode(set, obj) {
  4527. if (set == 1) {
  4528. _tran_show_preview_on_edit = obj.checked;
  4529. } else if (set == 2) {
  4530. _tran_show_textarea_esc_edit = obj.checked;
  4531. if (obj.checked) {
  4532. $(".tran_sen_textarea").show();
  4533. } else {
  4534. $(".tran_sen_textarea").hide();
  4535. }
  4536. }
  4537. }
  4538. //按自动查词典按钮
  4539. var _para_list = new Array();
  4540. function menu_dict_match1() {
  4541. var book;
  4542. var para = new Array();
  4543. xBlock = gXmlBookDataBody.getElementsByTagName("block");
  4544. for (var iBlock = 0; iBlock < xBlock.length; iBlock++) {
  4545. xmlParInfo = xBlock[iBlock].getElementsByTagName("info")[0];
  4546. xmlParData = xBlock[iBlock].getElementsByTagName("data")[0];
  4547. book = getNodeText(xmlParInfo, "book")
  4548. paragraph = getNodeText(xmlParInfo, "paragraph");
  4549. para[book + "-" + paragraph] = { "book": book, "para": paragraph };
  4550. }
  4551. _para_list = new Array;
  4552. for (var i in para) {
  4553. _para_list.push(para[i]);
  4554. }
  4555. if (_para_list.length > 0) {
  4556. auto_match_wbw(0);
  4557. }
  4558. }
  4559. //自动查词典
  4560. function auto_match_wbw(para_index) {
  4561. $.get("dict_find_auto.php",
  4562. {
  4563. book: _para_list[para_index].book,
  4564. para: _para_list[para_index].para
  4565. },
  4566. function (data, status) {
  4567. if (data.length > 0) {
  4568. var dict_data = new Array();
  4569. try {
  4570. dict_data = JSON.parse(data);
  4571. }
  4572. catch (error) {
  4573. ntf_show("Error:" + error + "<br>" + data);
  4574. }
  4575. var counter = 0;
  4576. var xAllWord = gXmlBookDataBody.getElementsByTagName("word");
  4577. for (var x = 0; x < xAllWord.length; x++) {
  4578. let wordStatus = getNodeText(xAllWord[x], "status");
  4579. if (parseInt(wordStatus) > 3) {
  4580. //忽略已经被用户修改的词
  4581. continue;
  4582. }
  4583. let wid = getNodeText(xAllWord[x], "id");
  4584. let aid = wid.split("-");
  4585. let book = aid[0].substr(1);
  4586. let para = aid[1];
  4587. let num = aid[2];
  4588. for (var i = 0; i < dict_data.length; i++) {
  4589. if (dict_data[i].book == book && dict_data[i].paragraph == para && dict_data[i].num == num) {
  4590. if (dict_data[i].type) {
  4591. setNodeText(xAllWord[x], "type", dict_data[i].type);
  4592. }
  4593. if (dict_data[i].gramma) {
  4594. setNodeText(xAllWord[x], "gramma", dict_data[i].gramma);
  4595. }
  4596. setNodeText(xAllWord[x], "case", dict_data[i].type + "#" + dict_data[i].gramma);
  4597. if (dict_data[i].mean) {
  4598. setNodeText(xAllWord[x], "mean", dict_data[i].mean);
  4599. }
  4600. if (dict_data[i].parent) {
  4601. setNodeText(xAllWord[x], "parent", dict_data[i].parent);
  4602. }
  4603. if (dict_data[i].parts) {
  4604. setNodeText(xAllWord[x], "org", dict_data[i].parts);
  4605. }
  4606. if (dict_data[i].partmean) {
  4607. setNodeText(xAllWord[x], "om", dict_data[i].partmean);
  4608. }
  4609. setNodeText(xAllWord[x], "status", "3");
  4610. counter++;
  4611. modifyWordDetailByWordId(wid);
  4612. user_wbw_push_word(wid);
  4613. break;
  4614. }
  4615. }
  4616. }
  4617. user_wbw_commit();
  4618. }
  4619. //计算查字典的进度
  4620. var precent = para_index * 100 / (_para_list.length - 1);
  4621. ntf_show(gLocal.gui.auto_fill + _para_list[para_index].book + "-" + _para_list[para_index].para + "-" + precent.toFixed(1) + "%" + gLocal.gui.finished);
  4622. para_index++;
  4623. if (para_index < _para_list.length) {
  4624. auto_match_wbw(para_index);
  4625. }
  4626. });
  4627. }
  4628. //旧版本的xml解析
  4629. function oldVerDataParse(oldXmlData) {
  4630. createXmlDoc();
  4631. newBlockString = "<root><block><info></info><data></data></block></root>"
  4632. if (window.DOMParser) {
  4633. parser = new DOMParser();
  4634. newXmlBlock = parser.parseFromString(newBlockString, "text/xml");
  4635. }
  4636. else { // Internet Explorer
  4637. newXmlBlock = new ActiveXObject("Microsoft.XMLDOM");
  4638. newXmlBlock.async = "false";
  4639. newXmlBlock.loadXML(newBlockString);
  4640. }
  4641. if (newXmlBlock == null) {
  4642. alert("error:can not load book index.");
  4643. return;
  4644. }
  4645. var titleBlockInfo = new Array()
  4646. var titleInfo = new Object;
  4647. titleInfo.language = "pali";
  4648. titleInfo.author = "author";
  4649. titleBlockInfo.push(titleInfo);
  4650. var titleInfo = new Object;
  4651. titleInfo.language = "en";
  4652. titleInfo.author = "author";
  4653. titleBlockInfo.push(titleInfo);
  4654. var titleInfo = new Object;
  4655. titleInfo.language = "zh";
  4656. titleInfo.author = "author";
  4657. titleBlockInfo.push(titleInfo);
  4658. var iPara = 1
  4659. var BookId = com_guid();
  4660. var x = gXmlOldVerData.getElementsByTagName("sutta");
  4661. for (var i = 0; i < x.length; i++) {
  4662. //title begin
  4663. xTitle = x[i].getElementsByTagName("title");
  4664. /*if title node is */
  4665. if (xTitle.length > 0) {
  4666. /*text of title*/
  4667. var xTitleText = xTitle[0].getElementsByTagName("text");
  4668. if (xTitleText.length > 0) {
  4669. for (var iTitleText = 0; iTitleText < xTitleText.length; iTitleText++) {
  4670. cloneBlock = newXmlBlock.cloneNode(true)
  4671. newBlock = cloneBlock.getElementsByTagName("block")[0]
  4672. xmlNewInfo = newBlock.getElementsByTagName("info")[0];
  4673. xmlNewData = newBlock.getElementsByTagName("data")[0];
  4674. var titleLangauge = "en";
  4675. var titleAuthor = "unkow";
  4676. var xTitleTextInfo = xTitleText[iTitleText].getElementsByTagName("info");
  4677. if (xTitleTextInfo.length > 0) {
  4678. titleLangauge = getNodeText(xTitleTextInfo[0], "language");
  4679. titleAuthor = getNodeText(xTitleTextInfo[0], "tranAuthor");
  4680. }
  4681. var strTitle = getNodeText(xTitleText[iTitleText], "data");
  4682. setNodeText(xmlNewInfo, "type", "heading");
  4683. setNodeText(xmlNewInfo, "paragraph", iPara.toString());
  4684. setNodeText(xmlNewInfo, "book", BookId);
  4685. setNodeText(xmlNewInfo, "author", "kosalla");
  4686. setNodeText(xmlNewInfo, "language", titleLangauge);
  4687. setNodeText(xmlNewInfo, "edition", '0');
  4688. setNodeText(xmlNewInfo, "subedition", '0');
  4689. setNodeText(xmlNewInfo, "level", '1');
  4690. setNodeText(xmlNewInfo, "id", com_guid());
  4691. setNodeText(xmlNewData, "text", strTitle);
  4692. gXmlBookDataBody.appendChild(newBlock);
  4693. }
  4694. }
  4695. /*end of text of title*/
  4696. }
  4697. //end of title
  4698. xParagraph = x[i].getElementsByTagName("paragraph");
  4699. for (var j = 0; j < xParagraph.length; j++) {
  4700. //toc begin
  4701. if (j > 0) {
  4702. for (var iTran = 0; iTran < titleBlockInfo.length; iTran++) {
  4703. cloneBlock = newXmlBlock.cloneNode(true)
  4704. newBlock = cloneBlock.getElementsByTagName("block")[0]
  4705. xmlNewInfo = newBlock.getElementsByTagName("info")[0];
  4706. xmlNewData = newBlock.getElementsByTagName("data")[0];
  4707. titleLangauge = titleBlockInfo[iTran].language;
  4708. titleAuthor = titleBlockInfo[iTran].author;
  4709. var strTitle = "new title";
  4710. setNodeText(xmlNewInfo, "type", "heading");
  4711. setNodeText(xmlNewInfo, "paragraph", iPara.toString());
  4712. setNodeText(xmlNewInfo, "book", BookId);
  4713. setNodeText(xmlNewInfo, "author", titleAuthor);
  4714. setNodeText(xmlNewInfo, "language", titleLangauge);
  4715. setNodeText(xmlNewInfo, "edition", '0');
  4716. setNodeText(xmlNewInfo, "subedition", '0');
  4717. setNodeText(xmlNewInfo, "level", '0');
  4718. setNodeText(xmlNewInfo, "id", com_guid());
  4719. setNodeText(xmlNewData, "text", strTitle);
  4720. gXmlBookDataBody.appendChild(newBlock);
  4721. }
  4722. }
  4723. //toc end
  4724. //word by word paragraph begin
  4725. xPali = xParagraph[j].getElementsByTagName("palipar");
  4726. if (xPali.length > 0) {
  4727. cloneBlock = newXmlBlock.cloneNode(true)
  4728. newBlock = cloneBlock.getElementsByTagName("block")[0]
  4729. xmlNewInfo = newBlock.getElementsByTagName("info")[0];
  4730. xmlNewData = newBlock.getElementsByTagName("data")[0];
  4731. setNodeText(xmlNewInfo, "type", "wbw");
  4732. setNodeText(xmlNewInfo, "paragraph", iPara.toString());
  4733. setNodeText(xmlNewInfo, "book", BookId);
  4734. setNodeText(xmlNewInfo, "author", "kosalla");
  4735. setNodeText(xmlNewInfo, "edition", '0');
  4736. setNodeText(xmlNewInfo, "subedition", '0');
  4737. setNodeText(xmlNewInfo, "id", com_guid());
  4738. xWord = xPali[0].getElementsByTagName("word");//如果只有一个palipar
  4739. /*遍历此段落中所有单词*/
  4740. var iSen = 0;
  4741. var strTranWords = "";
  4742. for (k = 0; k < xWord.length; k++) {
  4743. newWord = xWord[k].cloneNode(true);
  4744. xmlNewData.appendChild(newWord);
  4745. }
  4746. gXmlBookDataBody.appendChild(newBlock);
  4747. }
  4748. //word by word paragraph begin
  4749. /*翻译块开始*/
  4750. xTran = xParagraph[j].getElementsByTagName("translate");
  4751. if (xTran.length > 0) {
  4752. /*text of translate*/
  4753. var xTranText = xTran[0].getElementsByTagName("text");
  4754. if (xTranText.length > 0) {
  4755. for (iTranText = 0; iTranText < xTranText.length; iTranText++) {
  4756. cloneBlock = newXmlBlock.cloneNode(true)
  4757. newBlock = cloneBlock.getElementsByTagName("block")[0]
  4758. xmlNewInfo = newBlock.getElementsByTagName("info")[0];
  4759. xmlNewData = newBlock.getElementsByTagName("data")[0];
  4760. var tranLangauge = "";
  4761. var tranAuthor = "";
  4762. var xTranTextInfo = xTranText[iTranText].getElementsByTagName("info");
  4763. if (xTranTextInfo.length > 0) {
  4764. tranLangauge = getNodeText(xTranTextInfo[0], "language");
  4765. tranAuthor = getNodeText(xTranTextInfo[0], "author");
  4766. }
  4767. var strTran = getNodeText(xTranText[iTranText], "data");
  4768. setNodeText(xmlNewInfo, "type", "translate");
  4769. setNodeText(xmlNewInfo, "paragraph", iPara.toString());
  4770. setNodeText(xmlNewInfo, "book", BookId);
  4771. setNodeText(xmlNewInfo, "author", tranAuthor);
  4772. setNodeText(xmlNewInfo, "language", tranLangauge);
  4773. setNodeText(xmlNewInfo, "edition", '0');
  4774. setNodeText(xmlNewInfo, "subedition", '0');
  4775. setNodeText(xmlNewInfo, "id", com_guid());
  4776. newSen = newXmlBlock.createElement("sen");
  4777. setNodeText(newSen, "a", "");
  4778. setNodeText(newSen, "text", strTran);
  4779. xmlNewData.appendChild(newSen);
  4780. gXmlBookDataBody.appendChild(newBlock);
  4781. }
  4782. }
  4783. /*end of text of translate*/
  4784. }
  4785. /*翻译块结束*/
  4786. /*文件内note块开始*/
  4787. xTran = xParagraph[j].getElementsByTagName("comm");
  4788. if (xTran.length > 0) {
  4789. /*text of translate*/
  4790. var xTranText = xTran[0].getElementsByTagName("text");
  4791. if (xTranText.length > 0) {
  4792. for (iTranText = 0; iTranText < xTranText.length; iTranText++) {
  4793. cloneBlock = newXmlBlock.cloneNode(true)
  4794. newBlock = cloneBlock.getElementsByTagName("block")[0]
  4795. xmlNewInfo = newBlock.getElementsByTagName("info")[0];
  4796. xmlNewData = newBlock.getElementsByTagName("data")[0];
  4797. var tranLangauge = "";
  4798. var tranAuthor = "";
  4799. var xTranTextInfo = xTranText[iTranText].getElementsByTagName("info");
  4800. if (xTranTextInfo.length > 0) {
  4801. tranLangauge = getNodeText(xTranTextInfo[0], "language");
  4802. tranAuthor = getNodeText(xTranTextInfo[0], "author");
  4803. }
  4804. var strNote = getNodeText(xTranText[iTranText], "data");
  4805. setNodeText(xmlNewInfo, "type", "note");
  4806. setNodeText(xmlNewInfo, "paragraph", iPara.toString());
  4807. setNodeText(xmlNewInfo, "book", BookId);
  4808. setNodeText(xmlNewInfo, "author", tranAuthor);
  4809. setNodeText(xmlNewInfo, "language", titleLangauge);
  4810. setNodeText(xmlNewInfo, "edition", '0');
  4811. setNodeText(xmlNewInfo, "subedition", '0');
  4812. setNodeText(xmlNewInfo, "id", com_guid());
  4813. newSen = newXmlBlock.createElement("sen");
  4814. setNodeText(newSen, "a", "");
  4815. setNodeText(newSen, "text", strNote);
  4816. xmlNewData.appendChild(newSen);
  4817. gXmlBookDataBody.appendChild(newBlock);
  4818. }
  4819. }
  4820. /*end of text of translate*/
  4821. }
  4822. /*文件内翻译块结束*/
  4823. iPara++
  4824. }
  4825. }
  4826. projectDataParse(gXmlBookData)
  4827. updataToc()
  4828. refreshResource()
  4829. }
  4830. function add_part(part) {
  4831. $("#input_org").val(part);
  4832. }