editor.js 178 KB

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