editor.js 172 KB

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