2
0

editor.js 178 KB

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