editor.js 173 KB

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