editor.js 170 KB

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