dictionary.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948
  1. var g_findWord=""; // word for find
  2. var g_findMode=""; // 1.parent 2.children 3.self
  3. var g_currShowDeep=0;
  4. var g_DictWordList= new Array();
  5. var g_DocWordMean= new Array();
  6. var g_dictList = new Array();
  7. var g_DictWordNew = new Object();
  8. var g_DictWordUpdataIndex=0;//正在更新的记录在内存字典表中的索引号
  9. var g_DictCount=0;
  10. var g_currEditWord=-1;
  11. var g_currBookMarkColor="0";
  12. var g_dictFindParentLevel=0;
  13. var g_dictFindAllDone=false;
  14. function setNaviVisibility(){
  15. var objNave = document.getElementById('leftmenuinner');
  16. var objMainView = document.getElementById("body_mainview");
  17. if(objNave.style.display=="none"){
  18. objNave.style.display="block";
  19. getStyleClass('mainview').style.margin = "0px 0px 0px 30em";
  20. }
  21. else{
  22. objNave.style.display="none";
  23. getStyleClass('mainview').style.margin = "0px";
  24. }
  25. }
  26. function menuSelected(obj){
  27. var objMenuItems=document.getElementsByClassName("menu");
  28. for (var i=0;i<objMenuItems.length;i++){
  29. objMenuItems[i].style.display="none";
  30. }
  31. var objThisItem = document.getElementById(obj.value);
  32. objThisItem.style.display="block";
  33. }
  34. function menu_file_print_printpreview(isPrev){
  35. printpreview(true);
  36. }
  37. function printpreview(isPrev){
  38. var objNave = document.getElementById('leftmenuinner');
  39. if(isPrev){
  40. setNaviVisibility();
  41. document.getElementById("toolbar").style.display="none";
  42. document.getElementById("word_table").style.display="none";
  43. }
  44. else{
  45. setNaviVisibility();
  46. document.getElementById("toolbar").style.display="block";
  47. document.getElementById("word_table").style.display="block";
  48. }
  49. }
  50. function menu_view_script_sinhala(){
  51. var xmlHttp=null;
  52. var xmlText="";
  53. var xmlScript=null;
  54. if(window.XMLHttpRequest)
  55. {// code for IE7, Firefox, Opera, etc.
  56. xmlHttp=new XMLHttpRequest();
  57. }
  58. else if(window.ActiveXObject)
  59. {// code for IE6, IE5
  60. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  61. }
  62. if (xmlHttp!=null)
  63. {
  64. var d=new Date();
  65. var strLink = "./spt_get.php";
  66. xmlHttp.open("GET", strLink, false);
  67. xmlHttp.send(null);
  68. xmlText=xmlHttp.responseText;
  69. //xmlDict=xmlHttp.responseXML;
  70. }
  71. else
  72. {
  73. alert("Your browser does not support XMLHTTP.");
  74. }
  75. if (window.DOMParser)
  76. {
  77. parser=new DOMParser();
  78. xmlScript=parser.parseFromString(xmlText,"text/xml");
  79. }
  80. else // Internet Explorer
  81. {
  82. xmlScript=new ActiveXObject("Microsoft.XMLDOM");
  83. xmlScript.async="false";
  84. xmlScript.loadXML(xmlText);
  85. }
  86. var xScriptWord = xmlScript.getElementsByTagName("word");
  87. var xPaliWords = document.getElementsByClassName("paliword");
  88. var arrPaliWords="";
  89. for(k=0;k<xPaliWords.length;k++){
  90. arrPaliWords = arrPaliWords + "$" + xPaliWords[k].innerHTML;
  91. }
  92. arrPaliWords = arrPaliWords.toLowerCase();
  93. for(i=0;i<xScriptWord.length;i++){
  94. var src = getNodeText(xScriptWord[i],"src");
  95. var dest = getNodeText(xScriptWord[i],"dest");
  96. var strReplace = "arrPaliWords = arrPaliWords.replace(/"+src+"/g, dest);";
  97. eval("arrPaliWords = arrPaliWords.replace(/"+src+"/g, dest);");
  98. //arrPaliWords = arrPaliWords.replace(src, dest);
  99. }
  100. var arrDestWords = arrPaliWords.split("$");
  101. for(k=0;k<xPaliWords.length;k++){
  102. xPaliWords[k].innerHTML = arrDestWords[k+1];
  103. }
  104. document.getElementById("scriptinner").innerHTML=arrPaliWords;
  105. if (xmlScript == null){
  106. alert("error:can not load dict.");
  107. return;
  108. }
  109. }
  110. var dict_xmlhttp;
  111. var arrDictFileList;
  112. var currMatchingDictNum=0;
  113. function dict_getDictFileList()
  114. {
  115. if (window.XMLHttpRequest)
  116. {// code for IE7+, Firefox, Chrome, Opera, Safari
  117. dict_xmlhttp=new XMLHttpRequest();
  118. }
  119. else
  120. {// code for IE6, IE5
  121. dict_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  122. }
  123. var d=new Date();
  124. dict_xmlhttp.onreadystatechange=dict_serverResponse;
  125. dict_xmlhttp.open("GET","./dict_get_list.php?t="+d.getTime(),true);
  126. dict_xmlhttp.send();
  127. }
  128. function dict_serverResponse()
  129. {
  130. if (dict_xmlhttp.readyState==4)// 4 = "loaded"
  131. {
  132. if (dict_xmlhttp.status==200)
  133. {// 200 = "OK"
  134. //arrDictFileList = dict_xmlhttp.responseText.split(",");
  135. var DictFileList = new Array;
  136. eval(dict_xmlhttp.responseText);
  137. for (x in arrDictFileList)
  138. {
  139. g_dictList[x]=arrDictFileList[x];
  140. }
  141. var fileList="";
  142. for (x in arrDictFileList)
  143. {
  144. if(arrDictFileList[x].used){
  145. fileList = fileList + "<p><input id='id_dict_file_list_"+x+"' type='checkbox' style='width: 20px; height: 20px' checked />"+arrDictFileList[x].filename+"</p>";
  146. }
  147. else{
  148. fileList = fileList + "<p><input id='id_dict_file_list_"+x+"' type='checkbox' style='width: 20px; height: 20px' />"+arrDictFileList[x].filename+"</p>";
  149. }
  150. }
  151. document.getElementById('basic_dict_list').innerHTML=fileList;
  152. if(g_findWord.length>0){
  153. menu_dict_match();
  154. }
  155. }
  156. else
  157. {
  158. document.getElementById('basic_dict_list')="Problem retrieving data:" + xmlhttp.statusText;
  159. }
  160. }
  161. }
  162. function dict_windowsInit(){
  163. var strSertch = location.search;
  164. if(strSertch.length>0){
  165. strSertch = strSertch.substr(1);
  166. var sertchList=strSertch.split('&');
  167. for (x in sertchList){
  168. var item = sertchList[x].split('=');
  169. if(item[0]=="word"){
  170. //g_findWord=item[1];
  171. }
  172. if(item[0]=="mode"){
  173. //g_findMode=item[1];
  174. }
  175. }
  176. }
  177. checkCookie();
  178. dict_getDictFileList();
  179. document.getElementById('id_info_window_select').value="view_dict_curr";
  180. windowsSelected(document.getElementById('id_info_window_select'));
  181. }
  182. function menu_dict_match(){
  183. currMatchingDictNum=0;
  184. g_dictFindParentLevel=0;
  185. g_dictFindAllDone=false;
  186. g_currShowDeep=0;
  187. dict_dict_match();
  188. }
  189. function dict_dict_match(){
  190. if(currMatchingDictNum<g_dictList.length){
  191. if(g_dictList[currMatchingDictNum].used){
  192. dict_loadDictFromDB(g_filename,g_dictList[currMatchingDictNum]);
  193. }
  194. else{
  195. currMatchingDictNum++;
  196. dict_dict_match();
  197. }
  198. if(g_dictFindAllDone){
  199. dictShowCurrWordList();
  200. //dictFindShow();
  201. }
  202. }
  203. else{
  204. document.getElementById('id_dict_match_result_inner').innerHTML=dictShowAsTable();
  205. if(g_findMode=="parent"){
  206. if(g_dictFindParentLevel<3){
  207. currMatchingDictNum=0;
  208. g_dictFindParentLevel++;
  209. document.getElementById('id_dict_match_inner').innerHTML+="finding parent level "+g_dictFindParentLevel+"<br>";
  210. dict_dict_match();
  211. }
  212. else{
  213. document.getElementById('id_dict_match_inner').innerHTML+="Max Parent Level "+g_dictFindParentLevel+" Stop!<br>";
  214. dictShowCurrWordList();
  215. //dictFindShow();
  216. }
  217. }
  218. if(g_findMode=="children"){
  219. if(g_dictFindParentLevel>-2){
  220. currMatchingDictNum=0;
  221. g_dictFindParentLevel--;
  222. document.getElementById('id_dict_match_inner').innerHTML+="finding parent level "+g_dictFindParentLevel+"<br>";
  223. dict_dict_match();
  224. }
  225. else{
  226. document.getElementById('id_dict_match_inner').innerHTML+="Max Children Level "+g_dictFindParentLevel+" Stop!<br>";
  227. dictShowCurrWordList();
  228. //dictFindShow();
  229. }
  230. }
  231. }
  232. }
  233. var dict_DictXmlHttp=null;
  234. function dict_loadDictFromDB(strFileName,dictName){
  235. var xmlText="";
  236. if(window.XMLHttpRequest)
  237. {// code for IE7, Firefox, Opera, etc.
  238. dict_DictXmlHttp=new XMLHttpRequest();
  239. }
  240. else if(window.ActiveXObject)
  241. {// code for IE6, IE5
  242. dict_DictXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  243. }
  244. if (dict_DictXmlHttp!=null)
  245. {
  246. var d=new Date();
  247. dict_DictXmlHttp.onreadystatechange=dict_dict_serverResponse;
  248. var wordList=dict_getAllWordList();
  249. if(wordList!=null){
  250. document.getElementById('id_dict_msg').innerHTML="开始匹配字典"+dictName.name;
  251. dict_DictXmlHttp.open("POST", "./dict_find2.php", true);
  252. dict_DictXmlHttp.send(dictName.type+"$"+dictName.filename+"$"+g_dictFindParentLevel+"$"+wordList);
  253. }
  254. else{
  255. g_dictFindAllDone=true;
  256. document.getElementById('id_dict_match_inner').innerHTML+="all done!";
  257. }
  258. }
  259. else
  260. {
  261. alert("Your browser does not support XMLHTTP.");
  262. }
  263. }
  264. function dict_dict_serverResponse(){
  265. if (dict_DictXmlHttp.readyState==4)// 4 = "loaded"
  266. {
  267. document.getElementById('id_dict_msg').innerHTML="已经获取字典数据";
  268. if (dict_DictXmlHttp.status==200)
  269. {// 200 = "OK"
  270. var xmlText = dict_DictXmlHttp.responseText;
  271. if (window.DOMParser)
  272. {
  273. parser=new DOMParser();
  274. xmlDict=parser.parseFromString(xmlText,"text/xml");
  275. }
  276. else // Internet Explorer
  277. {
  278. xmlDict=new ActiveXObject("Microsoft.XMLDOM");
  279. xmlDict.async="false";
  280. xmlDict.loadXML(xmlText);
  281. }
  282. if (xmlDict == null){
  283. alert("error:can not load dict.");
  284. return;
  285. }
  286. document.getElementById('id_dict_match_inner').innerHTML+=g_dictList[currMatchingDictNum].name+":"+xmlDict.getElementsByTagName("word").length+"<br />";
  287. dictDataParse(xmlDict,g_dictList[currMatchingDictNum].name);
  288. }
  289. else
  290. {
  291. document.getElementById('id_dict_match_inner')="Problem retrieving data:" + xmlhttp.statusText;
  292. }
  293. currMatchingDictNum++;
  294. dict_dict_match();
  295. }
  296. }
  297. /*解析字典数据*/
  298. function dictDataParse(xmlDictData,dictname){
  299. document.getElementById('id_dict_msg').innerHTML="正在解析字典数据";
  300. var xDict = xmlDictData.getElementsByTagName("word");
  301. var tOut="";
  302. var sDictPali="";
  303. var sDictId="";
  304. var sDictOrg="";
  305. var sDictMean="";
  306. var sDictCase="";
  307. for(iword=0;iword<xDict.length;iword++)
  308. {
  309. var objDictItem=new Object();/*一个字典元素*/
  310. objDictItem.Id = getNodeText(xDict[iword],"id");
  311. objDictItem.Pali = getNodeText(xDict[iword],"pali");
  312. objDictItem.Mean = getNodeText(xDict[iword],"mean");
  313. objDictItem.Type = getNodeText(xDict[iword],"type");
  314. objDictItem.Gramma = getNodeText(xDict[iword],"gramma");
  315. objDictItem.Parent = getNodeText(xDict[iword],"parent");
  316. objDictItem.Factors = getNodeText(xDict[iword],"factors");
  317. objDictItem.FactorMean = getNodeText(xDict[iword],"factormean");
  318. objDictItem.Note = getNodeText(xDict[iword],"note");
  319. objDictItem.Confer = getNodeText(xDict[iword],"confer");
  320. objDictItem.Status = getNodeText(xDict[iword],"status");
  321. objDictItem.Delete = getNodeText(xDict[iword],"delete");
  322. objDictItem.Tag = getNodeText(xDict[iword],"tag");
  323. objDictItem.dictname=dictname;
  324. objDictItem.ParentLevel = g_dictFindParentLevel;
  325. if(objDictItem.Type==".v." && objDictItem.Pali.slice(-2)=="ti" && objDictItem.Pali.slice(-3)!="nti"){
  326. if(objDictItem.Pali!=objDictItem.Parent){
  327. objDictItem.Type=".v:base.";
  328. }
  329. }
  330. if(objDictItem.Case!="?" || objDictItem.Org!="?" || objDictItem.Mean!="?")
  331. {
  332. g_DictWordList[g_DictCount]=objDictItem;
  333. g_DictCount++;
  334. }
  335. }
  336. //dict end
  337. }
  338. function dictShowAsTable(){
  339. var outData="<table>";
  340. for(var i=0;i<g_DictWordList.length;i++){
  341. outData+="<tr class='dict_row"+g_DictWordList[i].ParentLevel+"'>";
  342. outData=outData+"<td>"+g_DictWordList[i].dictname+"</td>";
  343. outData=outData+"<td>"+g_DictWordList[i].Pali+"</td>";
  344. outData=outData+"<td>"+g_DictWordList[i].Type+"</td>";
  345. outData=outData+"<td>"+g_DictWordList[i].Gramma+"</td>";
  346. outData=outData+"<td>"+g_DictWordList[i].Parent+"</td>";
  347. outData=outData+"<td>"+g_DictWordList[i].Mean+"</td>";
  348. outData=outData+"<td>"+g_DictWordList[i].Factors+"</td>";
  349. outData=outData+"</tr>";
  350. }
  351. outData+="</table>";
  352. return outData;
  353. }
  354. var g_CurrActiveRecorder="new";
  355. function setCurrActiveRecorder(recorderName){
  356. g_CurrActiveRecorder=recorderName;
  357. }
  358. function updataCurrActiveRecorder(filder,value){
  359. if(filder=="all"){
  360. }
  361. else{
  362. document.getElementById(filder+"_"+g_CurrActiveRecorder).value=value;
  363. mean_change(g_CurrActiveRecorder);
  364. }
  365. }
  366. function addToCurrActiveRecorder(filder,value){
  367. if(filder=="all"){
  368. }
  369. else{
  370. meanString=document.getElementById(filder+"_"+g_CurrActiveRecorder).value;
  371. meanList=meanString.split("$");
  372. for(i in meanList)
  373. {
  374. if(meanList[i]==value){
  375. return;
  376. }
  377. }
  378. document.getElementById(filder+"_"+g_CurrActiveRecorder).value+="$"+value;
  379. mean_change(g_CurrActiveRecorder);
  380. }
  381. }
  382. function updataFactorMeanPrev(id,strNew){
  383. //if(strNew!=null){
  384. //document.getElementById("id_factormean_prev_"+id).value=strNew;
  385. //}
  386. }
  387. function factorMeanItemChange(id,iPos,count,newMean){
  388. //alert(id+":"+iPos+":"+newMean);
  389. var factorMeanPrevString = document.getElementById("id_factormean_prev_"+id).value;
  390. currFactorMeanPrevList=factorMeanPrevString.split("+");
  391. currFactorMeanPrevList[iPos]=newMean;
  392. document.getElementById("id_factormean_prev_"+id).value=currFactorMeanPrevList.join("+");
  393. }
  394. function makeFactorBlock(factorStr,id){
  395. var output="";
  396. var factorList=factorStr.split("+");
  397. var defualtFactorMeanList=new Array;
  398. for(iFactor in factorList){
  399. arrFM=findAllMeanInDict(factorList[iFactor],10);
  400. if(arrFM.length==0){
  401. arrFM[0]="unkow";
  402. }
  403. output +="<div class='case_dropdown'>";
  404. output += "<p class='case_dropbtn' >";
  405. output += arrFM[0];
  406. defualtFactorMeanList.push(arrFM[0]);
  407. output +="</p>";
  408. output+="<div class=\"case_dropdown-content\">";
  409. for(iFM in arrFM){
  410. output+="<a onclick=\"factorMeanItemChange('"+id+"','"+iFactor+"','"+factorList.length+"','"+arrFM[iFM]+"')\" >"+arrFM[iFM]+"</a>";
  411. }
  412. output+="</div>";
  413. output+="</div>";
  414. if(iFactor<factorList.length-1){
  415. output+="+";
  416. }
  417. }
  418. //updataFactorMeanPrev(id,defualtFactorMeanList.join("+"));
  419. g_FactorMean=defualtFactorMeanList.join("+");
  420. return(output);
  421. }
  422. function factor_change(id){
  423. var factorString = document.getElementById("id_dict_user_factors_"+id).value;
  424. document.getElementById("id_factor_block_"+id).innerHTML=makeFactorBlock(factorString,id);
  425. }
  426. function makeMeanBlock(meanStr,id){
  427. var output="";
  428. var meanList=meanStr.split("$");
  429. for(i in meanList){
  430. output+="<div class=\"mean_cell\">";
  431. output+="<div class=\"button_shell\">";
  432. output+="<p class=\"mean_button\" onclick=\"meanBlockMove('"+id+"',"+i+","+(i-1)+")\">«</p>";
  433. output+="</div>";
  434. output+="<p class=\"mean_inner\" onclick=\"meanBlockMove('"+id+"',"+i+","+0+")\">"+meanList[i]+"</p>";
  435. output+="<div class=\"button_shell\">";
  436. output+="<p class=\"mean_button\" onclick=\"meanBlockDelete('"+id+"',"+i+")\">x</p>";
  437. output+="</div>";
  438. output+="</div>";
  439. }
  440. return(output);
  441. }
  442. function mean_change(id){
  443. var meanString = document.getElementById("id_dict_user_mean_"+id).value;
  444. document.getElementById("id_mean_block_"+id).innerHTML=makeMeanBlock(meanString,id);
  445. }
  446. function meanBlockDelete(id,indexDelete){
  447. var meanString = document.getElementById("id_dict_user_mean_"+id).value;
  448. var meanBlock="";
  449. var meanList=meanString.split("$");
  450. meanList.splice(indexDelete,1);
  451. var newString = meanList.join("$");
  452. document.getElementById("id_dict_user_mean_"+id).value=newString;
  453. mean_change(id);
  454. }
  455. function meanBlockMove(id,moveFrom,moveTo){
  456. var meanString = document.getElementById("id_dict_user_mean_"+id).value;
  457. var meanBlock="";
  458. var meanList=meanString.split("$");
  459. if(moveTo<0){
  460. moveTo=0;
  461. }
  462. if(moveFrom==moveTo){
  463. return;
  464. }
  465. var temp=meanList[moveTo];
  466. meanList[moveTo]=meanList[moveFrom];
  467. for(i=moveFrom-1;i>moveTo;i--){
  468. meanList[i+1]=meanList[i];
  469. }
  470. meanList[moveTo+1]=temp;
  471. var newString = meanList.join("$");
  472. /*
  473. for(x in meanList){
  474. newString+=meanList[x]+"$";
  475. }
  476. */
  477. document.getElementById("id_dict_user_mean_"+id).value=newString;
  478. mean_change(id);
  479. }
  480. function addAutoMeanToFactorMean(id){
  481. document.getElementById("id_dict_user_fm_"+id).value=document.getElementById("id_factormean_prev_"+id).value;
  482. }
  483. //show current selected word in the word window to modify
  484. var g_WordTableCurrWord="";
  485. function dictCurrWordShowAsTable(inCurrWord){
  486. g_WordTableCurrWord = inCurrWord;
  487. g_CurrActiveRecorder="new";
  488. var outData="";
  489. var listParent= new Array();
  490. var listFactors= new Array();
  491. var listChildren = new Array();
  492. outData+="<p class='word_parent'>Parent:";
  493. for(var i=0;i<g_DictWordList.length;i++){
  494. if(g_DictWordList[i].Pali==inCurrWord){
  495. if(g_DictWordList[i].Parent.length>0){
  496. var find=false;
  497. for(x in listParent){
  498. if(listParent[x]==g_DictWordList[i].Parent){
  499. find=true;
  500. break;
  501. }
  502. }
  503. if(!find){
  504. listParent.push(g_DictWordList[i].Parent);
  505. }
  506. }
  507. if(g_DictWordList[i].Factors.length>0){
  508. arrFactors=g_DictWordList[i].Factors.split("+");
  509. for(iFactors in arrFactors){
  510. var find=false;
  511. for(x in listFactors){
  512. if(listFactors[x]==arrFactors[iFactors]){
  513. find=true;
  514. break;
  515. }
  516. }
  517. if(!find){
  518. listFactors.push(arrFactors[iFactors]);
  519. }
  520. }
  521. }
  522. }
  523. }
  524. for(x in listParent){
  525. outData+="<a onclick=\"showCurrWordTable('"+listParent[x]+"')\">"+listParent[x]+"</a> "
  526. }
  527. for(x in listFactors){
  528. outData+="[<a onclick=\"showCurrWordTable('"+listFactors[x]+"')\">"+listFactors[x]+"</a>] "
  529. }
  530. outData+="</p>";
  531. outData=outData+"<p class=\"word_current\">└"+inCurrWord+"</p>";
  532. outData+="<p class='word_child'>└Children: ";
  533. for(var i=0;i<g_DictWordList.length;i++){
  534. if(g_DictWordList[i].Parent==inCurrWord){
  535. if(g_DictWordList[i].Pali.length>0){
  536. var find=false;
  537. for(x in listChildren){
  538. if(listChildren[x]==g_DictWordList[i].Pali){
  539. find=true;
  540. break;
  541. }
  542. }
  543. if(!find){
  544. listChildren.push(g_DictWordList[i].Pali);
  545. }
  546. }
  547. }
  548. }
  549. for(x in listChildren){
  550. outData+="<a onclick=\"showCurrWordTable('"+listChildren[x]+"')\">"+listChildren[x]+"</a> "
  551. }
  552. outData+="</p>";
  553. //get new recorder filder
  554. var newRecorder = new Object();
  555. newRecorder.Type="";
  556. newRecorder.Gramma="";
  557. newRecorder.Parent="";
  558. newRecorder.Mean="";
  559. newRecorder.Note="";
  560. newRecorder.Factors="";
  561. newRecorder.FactorMean="";
  562. newRecorder.Confer="";
  563. newRecorder.Status="";
  564. newRecorder.Lock="";
  565. newRecorder.Tag="";
  566. var newMeanList= new Array();
  567. for(var i=0;i<g_DictWordList.length;i++){
  568. if(g_DictWordList[i].Pali==inCurrWord){
  569. if(newRecorder.Type=="" && g_DictWordList[i].Type.length>0){
  570. newRecorder.Type=g_DictWordList[i].Type
  571. }
  572. if(newRecorder.Gramma=="" && g_DictWordList[i].Gramma.length>0){
  573. newRecorder.Gramma=g_DictWordList[i].Gramma;
  574. }
  575. if(newRecorder.Parent=="" && g_DictWordList[i].Parent.length>0){
  576. newRecorder.Parent=g_DictWordList[i].Parent;
  577. }
  578. if(g_DictWordList[i].Mean.length>0){
  579. otherMean = g_DictWordList[i].Mean.split("$");
  580. for(iMean in otherMean){
  581. pushNewToList(newMeanList,otherMean[iMean]);
  582. }
  583. newRecorder.Mean=newMeanList.join("$");
  584. }
  585. if(newRecorder.Factors=="" && g_DictWordList[i].Factors.length>0){
  586. newRecorder.Factors=g_DictWordList[i].Factors;
  587. }
  588. if(newRecorder.FactorMean=="" && g_DictWordList[i].FactorMean.length>0){
  589. newRecorder.FactorMean=g_DictWordList[i].FactorMean;
  590. }
  591. if(newRecorder.Note=="" && g_DictWordList[i].Note.length>0){
  592. newRecorder.Note=g_DictWordList[i].Note;
  593. }
  594. }
  595. }
  596. newMeanBlock=makeMeanBlock(newRecorder.Mean,"new");
  597. newFactorBlock=makeFactorBlock(newRecorder.Factors,"new");
  598. newFactorMeanPrevString=g_FactorMean;
  599. //draw new
  600. outData=outData+"<h3>New:</h3>";
  601. outData+="<table>";
  602. outData+="<tr class='dict_row_new'><td></td><td>Type</td><td>Parent</td><td>Meaning</td></tr>";
  603. outData+="<tr class='dict_row_new'><td><input type='radio' name='dictupdata' checked onclick=\"setCurrActiveRecorder('new')\" /></td>"+
  604. "<td><input type=\"input\" id=\"id_dict_user_id_new\" hidden value=\"0\" >"+
  605. "<input type=\"input\" id=\"id_dict_user_pali_new\" hidden value=\""+inCurrWord+"\" >"+
  606. " <select name=\"type\" id=\"id_dict_user_type_new\" onchange=\"typeChange(this)\">";
  607. for (x in gLocal.type_str){
  608. if(gLocal.type_str[x].id==newRecorder.Type){
  609. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\" selected>"+gLocal.type_str[x].value+"</option>";
  610. }
  611. else{
  612. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\">"+gLocal.type_str[x].value+"</option>";
  613. }
  614. }
  615. outData=outData+" </select>";
  616. outData=outData+"</td>";
  617. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_parent_new\" size=\"12\" value=\""+newRecorder.Parent+"\" /></td>";
  618. 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>";
  619. outData+="</tr>";
  620. outData+="<tr class='dict_row_new'><td></td><td>Gramma</td><td>Parts</td><td>Parts Meaning</td></tr>";
  621. outData+="<tr class='dict_row_new'><td><button type=\"button\" onclick=\"dict_UserDictUpdata('new',this)\">Submit</button></td>";
  622. outData+="<td><input type=\"input\" id=\"id_dict_user_gramma_new\" size=\"12\" value=\""+newRecorder.Gramma+"\" /></td>";
  623. outData+="<td><input type=\"input\" id=\"id_dict_user_factors_new\" size=\""+inCurrWord.length*1.2+"\" value=\""+newRecorder.Factors+"\" onkeyup=\"factor_change('new')\" />";
  624. outData+="<br /><input type='text' id='id_factormean_prev_new' value='"+newFactorMeanPrevString+"' hidden />";
  625. outData+="<div class='factor' id='id_factor_block_new'>"+newFactorBlock+"</div>";
  626. outData+="<button type=\"button\" onclick=\"addAutoMeanToFactorMean('new')\" >√</button></td>";
  627. outData+="<td><input type=\"input\" id=\"id_dict_user_fm_new\" size=\""+inCurrWord.length*1.5+"\" value=\""+newRecorder.FactorMean+"\" /></td></tr>";
  628. outData+="<tr class='dict_row_new'><td>Note</td>";
  629. outData+="<td colspan=3><textarea id=\"id_dict_user_note_new\" rows='3' cols='100'>"+newRecorder.Note+"</textarea></td></tr>"
  630. outData+="</table>";
  631. outData+="<h3>User Dict</h3>";
  632. outData+="<table>";
  633. /*
  634. outData=outData+"<tr><th></th><th>dict</th> <th>Type</th> <th>Gramma</th> <th>Parent</th> <th>Meaning</th> <th>Parts</th> <th>Parts Meaning</th> <th></th> </tr>";
  635. for(var i=0;i<g_DictWordList.length;i++){
  636. if(g_DictWordList[i].Pali==inCurrWord){
  637. if(g_DictWordList[i].dictname=="用户字典"){
  638. outData+="<tr class='dict_row"+g_DictWordList[i].ParentLevel+"'>";
  639. outData+="<td><input type=radio name='dictupdata' onclick=\"setCurrActiveRecorder('"+i+"')\" /></td>";
  640. outData=outData+"<td>"+g_DictWordList[i].dictname+"</td>";
  641. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_id_"+i+"\" hidden value=\""+g_DictWordList[i].Id+"\" >";
  642. outData=outData+"<input type=\"input\" id=\"id_dict_user_pali_"+i+"\" hidden value=\""+g_DictWordList[i].Pali+"\" >";
  643. outData=outData+" <select name=\"type\" id=\"id_dict_user_type_"+i+"\" onchange=\"typeChange(this)\">";
  644. for (x in gLocal.type_str){
  645. if(gLocal.type_str[x].id==g_DictWordList[i].Type){
  646. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\" selected>"+gLocal.type_str[x].value+"</option>";
  647. }
  648. else{
  649. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\">"+gLocal.type_str[x].value+"</option>";
  650. }
  651. }
  652. outData=outData+" </select>";
  653. outData=outData+"</td>";
  654. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_gramma_"+i+"\" size=\"12\" value=\""+g_DictWordList[i].Gramma+"\" /></td>";
  655. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_parent_"+i+"\" size=\"12\" value=\""+g_DictWordList[i].Parent+"\" />";
  656. outData=outData+"<button type='button' onclick=\"showCurrWordTable('"+g_DictWordList[i].Parent+"')\">»</button></td>";
  657. outData=outData+"<td><input type=\"input\" size='50' id=\"id_dict_user_mean_"+i+"\" value=\""+g_DictWordList[i].Mean+"\" onkeyup='mean_change("+i+")' /><div class='mean_block' id='id_mean_block_"+i+"'></div></td>";
  658. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_factors_"+i+"\" size=\"15\" value=\""+g_DictWordList[i].Factors+"\" /></td>";
  659. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_fm_"+i+"\" size=\"15\" value=\""+g_DictWordList[i].FactorMean+"\" /></td>";
  660. outData=outData+"<td><button type=\"button\" onclick=\"dict_UserDictUpdata('"+i+"',this)\">Updata</button></td>";
  661. outData=outData+"</tr>";
  662. }
  663. }
  664. }
  665. */
  666. for(var i=0;i<g_DictWordList.length;i++){
  667. if(g_DictWordList[i].Pali==inCurrWord){
  668. if(g_DictWordList[i].dictname=="用户字典"){
  669. outData+="<tr ><td></td><td>Type</td><td>Parent</td><td>Meaning</td></tr>";
  670. outData+="<tr ><td><input type='radio' name='dictupdata' checked onclick=\"setCurrActiveRecorder('new')\" /></td>"+
  671. "<td><input type=\"input\" id=\"id_dict_user_id_new"+i+"\" hidden value=\"0\" >"+
  672. "<input type=\"input\" id=\"id_dict_user_pali_"+i+"\" hidden value=\""+inCurrWord+"\" >"+
  673. " <select name=\"type\" id=\"id_dict_user_type_"+i+"\" onchange=\"typeChange(this)\">";
  674. for (x in gLocal.type_str){
  675. if(gLocal.type_str[x].id==g_DictWordList[i].Type){
  676. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\" selected>"+gLocal.type_str[x].value+"</option>";
  677. }
  678. else{
  679. outData=outData+"<option value=\""+gLocal.type_str[x].id+"\">"+gLocal.type_str[x].value+"</option>";
  680. }
  681. }
  682. outData=outData+" </select>";
  683. outData=outData+"</td>";
  684. outData=outData+"<td><input type=\"input\" id=\"id_dict_user_parent_"+i+"\" size=\"12\" value=\""+g_DictWordList[i].Parent+"\" /></td>";
  685. 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>";
  686. outData+="</tr>";
  687. outData+="<tr ><td></td><td>Gramma</td><td>Parts</td><td>Parts Meaning</td></tr>";
  688. outData+="<tr ><td><button type=\"button\" onclick=\"dict_UserDictUpdata('"+i+"',this)\">Submit</button></td>";
  689. outData+="<td><input type=\"input\" id=\"id_dict_user_gramma_"+i+"\" size=\"12\" value=\""+g_DictWordList[i].Gramma+"\" /></td>";
  690. 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')\" />";
  691. outData+="<br /><input type='text' id='id_factormean_prev_"+i+"' value='"+newFactorMeanPrevString+"' hidden />";
  692. outData+="<div class='factor' id='id_factor_block_"+i+"'>"+newFactorBlock+"</div>";
  693. outData+="<button type=\"button\" onclick=\"addAutoMeanToFactorMean('"+i+"')\" >√</button></td>";
  694. outData+="<td><input type=\"input\" id=\"id_dict_user_fm_"+i+"\" size=\""+inCurrWord.length*1.5+"\" value=\""+g_DictWordList[i].FactorMean+"\" /></td></tr>";
  695. outData+="<tr ><td>Note</td>";
  696. outData+="<td colspan=3><textarea id=\"id_dict_user_note_"+i+"\" rows='3' cols='100'>"+g_DictWordList[i].Note+"</textarea></td></tr>"
  697. }
  698. }
  699. }
  700. outData=outData+"</table>";
  701. outData+="<h3>Other Dict</h3>";
  702. outData+="<table>";
  703. outData=outData+"<tr><th></th><th>dict</th> <th>Type</th> <th>Gramma</th> <th>Parent</th> <th>Meaning</th> <th>Parts</th> <th>Parts Meaning</th> <th>use</th> </tr>";
  704. for(var i=0;i<g_DictWordList.length;i++){
  705. if(g_DictWordList[i].Pali==inCurrWord){
  706. if(g_DictWordList[i].dictname=="用户字典"){
  707. }
  708. else{
  709. outData+="<tr class='dict_row"+g_DictWordList[i].ParentLevel+"'>";
  710. outData+="<td><button type=\"button\" >√</button></td>";
  711. outData=outData+"<td>"+g_DictWordList[i].dictname+"</td>";
  712. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_type','"+g_DictWordList[i].Type+"')\" >√</button><span id=\"id_dict_user_gramma_"+i+"\">"+g_DictWordList[i].Type+"</span></td>";
  713. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_gramma','"+g_DictWordList[i].Gramma+"')\">√</button>"+g_DictWordList[i].Gramma+"</td>";
  714. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_parent','"+g_DictWordList[i].Parent+"')\">√</button>"+g_DictWordList[i].Parent;
  715. outData=outData+"<button type='button' onclick=\"showCurrWordTable('"+g_DictWordList[i].Parent+"')\">»</button></td>";
  716. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_mean','"+g_DictWordList[i].Mean+"')\">√</button>"+g_DictWordList[i].Mean+"<br />"+makeMeanLink(g_DictWordList[i].Mean)+"</td>";
  717. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_factors','"+g_DictWordList[i].Factors+"')\">√</button>"+g_DictWordList[i].Factors+"</td>";
  718. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_fm','"+g_DictWordList[i].FactorMean+"')\">√</button>"+g_DictWordList[i].FactorMean+"</td>";
  719. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('all','"+g_DictWordList[i].Type+"')\">√</button></td>";
  720. outData=outData+"</tr>";
  721. }
  722. }
  723. }
  724. outData+="</table>";
  725. //children
  726. for(x in listChildren){
  727. wordChildren=listChildren[x]
  728. outData+="<h4>"+wordChildren+"</h4> ";
  729. outData+="<table>";
  730. outData=outData+"<tr><th></th><th>dict</th> <th>Type</th> <th>Gramma</th> <th>Parent</th> <th>Meaning</th> <th>Parts</th> <th>Parts Meaning</th> <th></th> </tr>";
  731. for(var i=0;i<g_DictWordList.length;i++){
  732. if(g_DictWordList[i].Pali==wordChildren){
  733. {
  734. outData+="<tr class='dict_row"+g_DictWordList[i].ParentLevel+"'>";
  735. outData+="<td><button type=\"button\" >√</button></td>";
  736. outData=outData+"<td>"+g_DictWordList[i].dictname+"</td>";
  737. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_type','"+g_DictWordList[i].Type+"')\" >√</button><span id=\"id_dict_user_gramma_"+i+"\">"+g_DictWordList[i].Type+"</span></td>";
  738. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_gramma','"+g_DictWordList[i].Gramma+"')\">√</button>"+g_DictWordList[i].Gramma+"</td>";
  739. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_parent','"+g_DictWordList[i].Parent+"')\">√</button>"+g_DictWordList[i].Parent;
  740. outData=outData+"<button type='button' onclick=\"showCurrWordTable('"+g_DictWordList[i].Parent+"')\">»</button></td>";
  741. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_mean','"+g_DictWordList[i].Mean+"')\">√</button>"+g_DictWordList[i].Mean+"<br />"+makeMeanLink(g_DictWordList[i].Mean)+"</td>";
  742. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_factors','"+g_DictWordList[i].Factors+"')\">√</button>"+g_DictWordList[i].Factors+"</td>";
  743. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('id_dict_user_fm','"+g_DictWordList[i].FactorMean+"')\">√</button>"+g_DictWordList[i].FactorMean+"</td>";
  744. outData=outData+"<td><button type=\"button\" onclick=\"updataCurrActiveRecorder('all','"+g_DictWordList[i].Type+"')\">√</button></td>";
  745. outData=outData+"</tr>";
  746. }
  747. }
  748. }
  749. outData+="</table>";
  750. }
  751. return outData;
  752. }
  753. function makeMeanLink(inStr){
  754. var arrList=inStr.split("$");
  755. var output="";
  756. for(i in arrList){
  757. output+="<a onclick=\"addToCurrActiveRecorder('id_dict_user_mean','"+arrList[i]+"')\">"+arrList[i]+"</a> "
  758. }
  759. return(output);
  760. }
  761. function showCurrWordTable(currWord){
  762. document.getElementById('id_dict_curr_word_inner').innerHTML=dictCurrWordShowAsTable(currWord);
  763. }
  764. //匹配字典数据到文档
  765. function dictMatchXMLDoc(){
  766. document.getElementById('id_dict_msg').innerHTML=gLocal.gui.dict_match;
  767. var docWordCounter=0;
  768. var matchedCounter=0;
  769. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  770. for(var iword=0;iword<xDocWords.length;iword++){
  771. var sPaliWord = getNodeText(xDocWords[iword],"real");
  772. var sFactorsWord = getNodeText(xDocWords[iword],"org");
  773. var sMeanWord = getNodeText(xDocWords[iword],"mean");
  774. var sTypeWord = getNodeText(xDocWords[iword],"case");
  775. if(isPaliWord(sPaliWord)){
  776. docWordCounter++;
  777. /*将这个词与字典匹配,*/
  778. var iDict=0;
  779. //if(sMeanWord=="?"){
  780. var thisWord = sPaliWord
  781. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  782. if(thisWord==g_DictWordList[iDict].Pali && g_DictWordList[iDict].ParentLevel==0){
  783. if(sMeanWord=="?"){
  784. setNodeText(xDocWords[iword],"bmc","bmca");
  785. }
  786. modifyWordDetailByWordIndex(iword);
  787. matchedCounter++;
  788. break;
  789. }
  790. }
  791. //}
  792. /*
  793. else{
  794. if(isPaliWord(sPaliWord)){
  795. matchedCounter++;
  796. }
  797. }*/
  798. }
  799. }
  800. var progress=matchedCounter*100/docWordCounter;
  801. document.getElementById('id_dict_msg').innerHTML=gLocal.gui.match_end+Math.round(progress)+"%";
  802. }
  803. function dictGetFirstMean(strMean){
  804. var arrMean=strMean.split("$");
  805. if(arrMean.length>0){
  806. for(var i=0;i<arrMean.length;i++){
  807. if(arrMean[i].length>0){
  808. return(arrMean[i]);
  809. }
  810. else{
  811. return "";
  812. }
  813. }
  814. return "";
  815. }
  816. else{
  817. return "";
  818. }
  819. }
  820. //test word is pali word or not
  821. function isPaliWord(inWord){
  822. if(inWord.length<2){
  823. return false;
  824. }
  825. if(inWord.match(/[x]/)){
  826. return false;
  827. }
  828. if(inWord.match(/[q]/)){
  829. return false;
  830. }
  831. if(inWord.match(/[w]/)){
  832. return false;
  833. }
  834. if(inWord.match(/[a-y]/)){
  835. return true;
  836. }
  837. else{
  838. return false;
  839. }
  840. }
  841. function submenu_show_detail(obj){
  842. eParent = obj.parentNode;
  843. var x=eParent.getElementsByTagName("div");
  844. if(x[0].style.display=="none"){
  845. x[0].style.display="block";
  846. obj.getElementsByTagName("span")[0].innerHTML="-";
  847. }
  848. else{
  849. x[0].style.display="none";
  850. obj.getElementsByTagName("span")[0].innerHTML="+";
  851. }
  852. }
  853. //在导航窗口中显示与此词匹配的字典中的词
  854. function showMatchedWordsInNavi(wordId){
  855. //var matchedCounter=0;
  856. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  857. //var outText="";
  858. //var sLastDict="";
  859. var sPaliWord = getNodeText(xDocWords[wordId],"real");
  860. showWordInNavi(sPaliWord);
  861. }
  862. //在导航窗口中显示与此词匹配的字典中的词
  863. function showWordInNavi(inWord){
  864. var matchedCounter=0;
  865. var outText="";
  866. var sLastDict="";
  867. var sPaliWord = inWord;
  868. outText=outText+"<h3>"+sPaliWord+"</h3>";
  869. /*将这个词与字典匹配,*/
  870. var iDict=0;
  871. var thisWord = sPaliWord;
  872. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  873. if(thisWord==g_DictWordList[iDict].Pali){
  874. if(g_DictWordList[iDict].dictname!=sLastDict){
  875. outText=outText+"<dict><span>"+g_DictWordList[iDict].dictname+"<span></dict>";
  876. sLastDict=g_DictWordList[iDict].dictname;
  877. }
  878. outText=outText+"<input type='input' id=\"id_dict_word_list_"+iDict+"\" size='5' value='"+g_DictWordList[iDict].Type+"' />";
  879. outText=outText+"<input type='input' size='15' value='"+g_DictWordList[iDict].Gramma+"' /><br />";
  880. outText=outText+"<input type='input' size='20' value='"+g_DictWordList[iDict].Parent+"' /> <button type='button' onclick=\"showWordInNavi('"+g_DictWordList[iDict].Parent+"')\">»</button><br />";
  881. outText=outText+"<textarea name=\"dict_mean\" rows=\"3\" col=\"25\" style=\"width:20em;\">"+g_DictWordList[iDict].Mean+"</textarea>"
  882. outText=outText+"<input type='input' size='20' value='"+g_DictWordList[iDict].Factors+"' /><br />";
  883. outText=outText+"<input type='input' size='20' value='"+g_DictWordList[iDict].FactorMean+"' /><br />";
  884. outText=outText+"<button type='button' onclick=\"updataDict('"+iDict+"','userdict')\">Modify</button><br />";
  885. /*
  886. outText=outText+"<mean onclick=\"updataWordFromDict(this,'mean')\">"+g_DictWordList[iDict].Mean+"</mean>";
  887. outText=outText+"<org onclick=\"updataWordFromDict(this,'org')\">"+g_DictWordList[iDict].Factors+"</org>";
  888. outText=outText+"<om onclick=\"updataWordFromDict(this,'om')\">"+g_DictWordList[iDict].FactorMean+"</om>";
  889. outText=outText+"<case onclick=\"updataWordFromDict(this,'case')\">"+g_DictWordList[iDict].Type+"#"+g_DictWordList[iDict].Gramma+"</case>";
  890. */
  891. matchedCounter++;
  892. }
  893. }
  894. document.getElementById("id_dict_matched").innerHTML=outText;
  895. document.getElementById('id_dict_curr_word_inner').innerHTML=dictCurrWordShowAsTable(inWord);
  896. }
  897. function updataWordFromDict(obj,field){
  898. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  899. var strValue = obj.innerHTML;
  900. var applayTo = document.getElementById("id_dict_applay_to").value;
  901. var strCurrPali=getNodeText(xDocWords[g_currEditWord],"pali");
  902. switch(applayTo)
  903. {
  904. case "current":
  905. setNodeText(xDocWords[g_currEditWord],field,strValue);
  906. modifyWordDetailByWordIndex(g_currEditWord);
  907. break;
  908. case "sys":
  909. for(i=0;i<xDocWords.length;i++){
  910. var strPali=getNodeText(xDocWords[i],"pali");
  911. if(strCurrPali==strPali){
  912. var isAuto = getNodeText(xDocWords[i],"bmc");
  913. if(isAuto=="bmca"){
  914. setNodeText(xDocWords[g_currEditWord],field,strValue);
  915. modifyWordDetailByWordIndex(i);
  916. }
  917. }
  918. }
  919. break;
  920. case "all":
  921. for(i=0;i<xDocWords.length;i++){
  922. var strPali=getNodeText(xDocWords[i],"pali");
  923. if(strCurrPali==strPali){
  924. setNodeText(xDocWords[g_currEditWord],field,strValue);
  925. modifyWordDetailByWordIndex(i);
  926. }
  927. }
  928. break;
  929. }
  930. }
  931. /*
  932. function select_modyfy_type(itemname){
  933. document.getElementById("modify_detaile").style.display="none";
  934. document.getElementById("modify_bookmark").style.display="none";
  935. document.getElementById("modify_note").style.display="none";
  936. document.getElementById(itemname).style.display="block";
  937. }*/
  938. function select_modyfy_type(itemname,idname){
  939. document.getElementById("modify_detaile").style.display="none";
  940. document.getElementById("modify_bookmark").style.display="none";
  941. document.getElementById("modify_note").style.display="none";
  942. document.getElementById("modify_spell").style.display="none";
  943. document.getElementById("modify_apply").style.display="block";
  944. document.getElementById("detail_li").className = "common-tab_li";
  945. document.getElementById("mark_li").className = "common-tab_li";
  946. document.getElementById("note_li").className = "common-tab_li";
  947. document.getElementById("spell_li").className = "common-tab_li";
  948. document.getElementById(itemname).style.display="block";
  949. document.getElementById(idname).className = "common-tab_li_act";
  950. }
  951. function setBookMarkColor(obj,strColor){
  952. var items = obj.parentNode.getElementsByTagName("li");
  953. for(var i=0;i<items.length;i++)
  954. {
  955. items[i].style.border="2px solid #EEE";
  956. }
  957. if(strColor!="bmc0"){
  958. obj.style.border="2px solid #555";
  959. }
  960. g_currBookMarkColor=strColor;
  961. }
  962. function getBookMarkColor(idColor){
  963. var items = document.getElementById("id_book_mark_color_select").getElementsByTagName("li");
  964. for(var i=0;i<items.length;i++)
  965. {
  966. items[i].style.border="2px solid #EEE";
  967. }
  968. if(document.getElementById("id_"+idColor)){
  969. document.getElementById("id_"+idColor).style.border="2px solid #555";
  970. }
  971. }
  972. /*
  973. function casePrev(obj){
  974. var strCase = obj.value;
  975. strCase=strCase.replace(/f./g,"阴");
  976. strCase=strCase.replace(/m./g,"阳");
  977. strCase=strCase.replace(/n./g,"中");
  978. strCase=strCase.replace(/sg./g,"单");
  979. strCase=strCase.replace(/pl./g,"复");
  980. strCase=strCase.replace(/acc./g,"宾");
  981. document.getElementById("id_case_prev").innerHTML=strCase;
  982. }
  983. */
  984. function menu_file_convert(){
  985. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  986. var outText="";
  987. var sLastDict="";
  988. for(var iword=0;iword<xDocWords.length;iword++){
  989. var sPaliWord = getNodeText(xDocWords[iword],"pali");
  990. var sPaliMean = getNodeText(xDocWords[iword],"mean");
  991. var thisWord = sPaliWord.toLowerCase();
  992. thisWord = thisWord.replace(/-/g,"");
  993. thisWord = thisWord.replace(/'/g,"");
  994. thisWord = thisWord.replace(/’/g,"");
  995. setNodeText(xDocWords[iword],"real",thisWord);
  996. setNodeText(xDocWords[iword],"om",sPaliMean);
  997. }
  998. alert("convert "+xDocWords.length+"words.");
  999. }
  1000. function save(){
  1001. xmlHttp=null;
  1002. var_dump(gLocal.gui.loading);
  1003. if (window.XMLHttpRequest)
  1004. {// code for IE7, Firefox, Opera, etc.
  1005. xmlHttp=new XMLHttpRequest();
  1006. var_dump("test XMLHttpRequest<br/>");
  1007. }
  1008. else if (window.ActiveXObject)
  1009. {// code for IE6, IE5
  1010. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  1011. var_dump("testing Microsoft.XMLHTTP<br/>");
  1012. }
  1013. if (xmlHttp!=null)
  1014. {
  1015. var_dump("ok");
  1016. xmlHttp.open("POST", "./dom_http.php", false);
  1017. var sendHead="filename="+g_filename+"#";
  1018. xmlHttp.send(sendHead+xmlToString(xmlDoc));
  1019. var_dump(xmlHttp.responseText);
  1020. }
  1021. else
  1022. {
  1023. alert("Your browser does not support XMLHTTP.");
  1024. }
  1025. }
  1026. function menu_file_export_csv(){
  1027. xmlHttp=null;
  1028. var_dump(gLocal.gui.loading);
  1029. if (window.XMLHttpRequest)
  1030. {// code for IE7, Firefox, Opera, etc.
  1031. xmlHttp=new XMLHttpRequest();
  1032. var_dump("test XMLHttpRequest<br/>");
  1033. }
  1034. else if (window.ActiveXObject)
  1035. {// code for IE6, IE5
  1036. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  1037. var_dump("testing Microsoft.XMLHTTP<br/>");
  1038. }
  1039. if (xmlHttp!=null)
  1040. {
  1041. var_dump("ok");
  1042. xmlHttp.open("POST", "./export_csv.php", false);
  1043. var sendHead="filename="+g_filename+"#";
  1044. xmlHttp.send(sendHead+xmlToString(xmlDoc));
  1045. var_dump(xmlHttp.responseText);
  1046. }
  1047. else
  1048. {
  1049. alert("Your browser does not support XMLHTTP.");
  1050. }
  1051. }
  1052. function menu_file_import_csv(){
  1053. var filename = document.getElementById('import_csv_filename').value;
  1054. dict_loadDataFromCSV(filename);
  1055. }
  1056. //import csv begin
  1057. var dict_CSVXmlHttp=null;
  1058. function dict_loadDataFromCSV(strFileName){
  1059. if(window.XMLHttpRequest)
  1060. {// code for IE7, Firefox, Opera, etc.
  1061. dict_CSVXmlHttp=new XMLHttpRequest();
  1062. }
  1063. else if(window.ActiveXObject)
  1064. {// code for IE6, IE5
  1065. dict_CSVXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  1066. }
  1067. if (dict_CSVXmlHttp!=null)
  1068. {
  1069. var d=new Date();
  1070. var strLink = "./import_csv.php?filename="+strFileName;
  1071. dict_CSVXmlHttp.onreadystatechange=dict_csv_serverResponse;
  1072. dict_CSVXmlHttp.open("GET", strLink, true);
  1073. dict_CSVXmlHttp.send(null);
  1074. document.getElementById('id_csv_msg_inner').innerHTML="Importing..."+strFileName;
  1075. }
  1076. else
  1077. {
  1078. alert("Your browser does not support XMLHTTP.");
  1079. }
  1080. }
  1081. function dict_csv_serverResponse()
  1082. {
  1083. if (dict_CSVXmlHttp.readyState==4)// 4 = "loaded"
  1084. {
  1085. document.getElementById('id_csv_msg_inner').innerHTML="receve csv data";
  1086. if (dict_CSVXmlHttp.status==200)
  1087. {// 200 = "OK"
  1088. var xmlText = dict_CSVXmlHttp.responseText;
  1089. if (window.DOMParser)
  1090. {
  1091. parser=new DOMParser();
  1092. xmlCsv=parser.parseFromString(xmlText,"text/xml");
  1093. }
  1094. else // Internet Explorer
  1095. {
  1096. xmlCsv=new ActiveXObject("Microsoft.XMLDOM");
  1097. xmlCsv.async="false";
  1098. xmlCsv.loadXML(xmlText);
  1099. }
  1100. if (xmlCsv == null){
  1101. alert("error:can not load dict.");
  1102. return;
  1103. }
  1104. csvDataParse(xmlCsv);
  1105. }
  1106. else
  1107. {
  1108. document.getElementById('id_dict_match_inner')="Problem retrieving data:" + xmlhttp.statusText;
  1109. }
  1110. }
  1111. }
  1112. /*Parse csv data and fill this document*/
  1113. function csvDataParse(xmlCSVData){
  1114. document.getElementById('id_csv_msg_inner').innerHTML="Parseing CSV Data";
  1115. var xCSV = xmlCSVData.getElementsByTagName("word");
  1116. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1117. for(iword=0;iword<xCSV.length;iword++){
  1118. setNodeText(xDocWords[iword],"pali",getNodeText(xCSV[iword],"pali"));
  1119. setNodeText(xDocWords[iword],"real",getNodeText(xCSV[iword],"real"));
  1120. setNodeText(xDocWords[iword],"id",getNodeText(xCSV[iword],"id"));
  1121. setNodeText(xDocWords[iword],"mean",getNodeText(xCSV[iword],"mean"));
  1122. setNodeText(xDocWords[iword],"org",getNodeText(xCSV[iword],"org"));
  1123. setNodeText(xDocWords[iword],"om",getNodeText(xCSV[iword],"om"));
  1124. setNodeText(xDocWords[iword],"case",getNodeText(xCSV[iword],"case"));
  1125. setNodeText(xDocWords[iword],"bmc",getNodeText(xCSV[iword],"bmc"));
  1126. setNodeText(xDocWords[iword],"bmt",getNodeText(xCSV[iword],"bmt"));
  1127. setNodeText(xDocWords[iword],"note",getNodeText(xCSV[iword],"note"));
  1128. setNodeText(xDocWords[iword],"lock",getNodeText(xCSV[iword],"lock"));
  1129. modifyWordDetailByWordIndex(iword);
  1130. }
  1131. document.getElementById('id_csv_msg_inner').innerHTML="Updata Document Data OK!";
  1132. }
  1133. //import csv end
  1134. function menu_file_tools_empty(opt){
  1135. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  1136. if(opt=='all'){
  1137. for(var iword=0;iword<xDocWords.length;iword++){
  1138. setNodeText(xDocWords[iword],"mean","?");
  1139. setNodeText(xDocWords[iword],"org","?");
  1140. setNodeText(xDocWords[iword],"om","?");
  1141. setNodeText(xDocWords[iword],"case","?");
  1142. setNodeText(xDocWords[iword],"bmc","");
  1143. setNodeText(xDocWords[iword],"bmt","");
  1144. setNodeText(xDocWords[iword],"note","");
  1145. setNodeText(xDocWords[iword],"lock","FALSE");
  1146. modifyWordDetailByWordIndex(iword);
  1147. }
  1148. }
  1149. else if(opt=='mean'){
  1150. for(var iword=0;iword<xDocWords.length;iword++){
  1151. setNodeText(xDocWords[iword],"mean","[]");
  1152. //setNodeText(xDocWords[iword],"org","?");
  1153. setNodeText(xDocWords[iword],"om","");
  1154. //setNodeText(xDocWords[iword],"case","?");
  1155. //setNodeText(xDocWords[iword],"bmc","");
  1156. //setNodeText(xDocWords[iword],"bmt","");
  1157. //setNodeText(xDocWords[iword],"note","");
  1158. //setNodeText(xDocWords[iword],"lock","FALSE");
  1159. modifyWordDetailByWordIndex(iword);
  1160. }
  1161. }
  1162. else if(opt=='case'){
  1163. for(var iword=0;iword<xDocWords.length;iword++){
  1164. //setNodeText(xDocWords[iword],"mean","[]");
  1165. //setNodeText(xDocWords[iword],"org","?");
  1166. //setNodeText(xDocWords[iword],"om","");
  1167. setNodeText(xDocWords[iword],"case","?#?");
  1168. //setNodeText(xDocWords[iword],"bmc","");
  1169. //setNodeText(xDocWords[iword],"bmt","");
  1170. //setNodeText(xDocWords[iword],"note","");
  1171. //setNodeText(xDocWords[iword],"lock","FALSE");
  1172. modifyWordDetailByWordIndex(iword);
  1173. }
  1174. }
  1175. else if(opt=='bookmark'){
  1176. for(var iword=0;iword<xDocWords.length;iword++){
  1177. //setNodeText(xDocWords[iword],"mean","[]");
  1178. //setNodeText(xDocWords[iword],"org","?");
  1179. //setNodeText(xDocWords[iword],"om","");
  1180. //setNodeText(xDocWords[iword],"case","?#?");
  1181. setNodeText(xDocWords[iword],"bmc","");
  1182. setNodeText(xDocWords[iword],"bmt","");
  1183. //setNodeText(xDocWords[iword],"note","");
  1184. //setNodeText(xDocWords[iword],"lock","FALSE");
  1185. modifyWordDetailByWordIndex(iword);
  1186. }
  1187. }
  1188. else if(opt=='note'){
  1189. for(var iword=0;iword<xDocWords.length;iword++){
  1190. //setNodeText(xDocWords[iword],"mean","[]");
  1191. //setNodeText(xDocWords[iword],"org","?");
  1192. //setNodeText(xDocWords[iword],"om","");
  1193. //setNodeText(xDocWords[iword],"case","?#?");
  1194. //setNodeText(xDocWords[iword],"bmc","");
  1195. //setNodeText(xDocWords[iword],"bmt","");
  1196. setNodeText(xDocWords[iword],"note","");
  1197. //setNodeText(xDocWords[iword],"lock","FALSE");
  1198. modifyWordDetailByWordIndex(iword);
  1199. }
  1200. }
  1201. }
  1202. function showDebugPanal(){
  1203. var w=window.innerWidth
  1204. || document.documentElement.clientWidth
  1205. || document.body.clientWidth;
  1206. var h=window.innerHeight
  1207. || document.documentElement.clientHeight
  1208. || document.body.clientHeight;
  1209. }
  1210. function show_popup(strMsg)
  1211. {
  1212. var p=window.createPopup()
  1213. var pbody=p.document.body
  1214. pbody.style.backgroundColor="red"
  1215. pbody.style.border="solid black 1px"
  1216. pbody.innerHTML=strMsg+"<br />外面点击,即可关闭它!"
  1217. p.show(150,150,200,50,document.body)
  1218. }
  1219. function setInfoPanalSize(inSize){
  1220. var w=window.innerWidth
  1221. || document.documentElement.clientWidth
  1222. || document.body.clientWidth;
  1223. var h=window.innerHeight
  1224. || document.documentElement.clientHeight
  1225. || document.body.clientHeight;
  1226. var objInfoPanal = document.getElementById("id_info_panal");
  1227. //show_popup(w);
  1228. //alert(objInfoPanal.style.right);
  1229. objInfoPanal.style.left="0px";
  1230. objInfoPanal.style.width=(w-20)+"px";
  1231. switch(inSize){
  1232. case "hidden"://min
  1233. objInfoPanal.style.display="none";
  1234. break;
  1235. case "min"://min
  1236. objInfoPanal.style.top=(h-30)+"px";
  1237. objInfoPanal.style.height=(30)+"px";
  1238. break;
  1239. case "half"://half
  1240. objInfoPanal.style.top=h/2+"px";
  1241. objInfoPanal.style.height=h/2+"px";
  1242. break;
  1243. case "0.6"://2/3
  1244. objInfoPanal.style.top=(h*0.4)+"px";
  1245. objInfoPanal.style.height=(h*0.6)+"px";
  1246. break;
  1247. case "max"://max
  1248. objInfoPanal.style.top="0px";
  1249. objInfoPanal.style.height=(h)+"px";
  1250. break;
  1251. }
  1252. }
  1253. function windowsSelected(obj){
  1254. document.getElementById('word_table').style.display = "none";
  1255. document.getElementById('id_dict_match_result').style.display = "none";
  1256. document.getElementById('id_dict_curr_word').style.display = "none";
  1257. document.getElementById('id_debug').style.display = "none";
  1258. switch(obj.value){
  1259. case "view_vocabulary":
  1260. document.getElementById('word_table').style.display = "block";
  1261. break;
  1262. case "view_dict_all":
  1263. document.getElementById('id_dict_match_result').style.display = "block";
  1264. break;
  1265. case "view_dict_curr":
  1266. document.getElementById('id_dict_curr_word').style.display = "block";
  1267. break;
  1268. case "view_debug":
  1269. document.getElementById('id_debug').style.display = "block";
  1270. break;
  1271. }
  1272. }
  1273. function userDictUpdata(){
  1274. }
  1275. var dict_DictUpdataXmlHttp=null;
  1276. function dict_UserDictUpdata(recorderName,thisObj){
  1277. thisObj.disabled=true;
  1278. var xmlText="";
  1279. if(window.XMLHttpRequest)
  1280. {// code for IE7, Firefox, Opera, etc.
  1281. dict_DictUpdataXmlHttp=new XMLHttpRequest();
  1282. }
  1283. else if(window.ActiveXObject)
  1284. {// code for IE6, IE5
  1285. dict_DictUpdataXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  1286. }
  1287. if (dict_DictUpdataXmlHttp!=null)
  1288. {
  1289. var queryString="<wordlist>";
  1290. queryString+="<word>";
  1291. var d_id=document.getElementById('id_dict_user_id_'+recorderName).value;
  1292. var d_pali=document.getElementById('id_dict_user_pali_'+recorderName).value;
  1293. var d_type=document.getElementById('id_dict_user_type_'+recorderName).value;
  1294. var d_gramma=document.getElementById('id_dict_user_gramma_'+recorderName).value;
  1295. var d_parent=document.getElementById('id_dict_user_parent_'+recorderName).value;
  1296. var d_mean=document.getElementById('id_dict_user_mean_'+recorderName).value;
  1297. var d_note=document.getElementById('id_dict_user_note_'+recorderName).value;
  1298. var d_factors=document.getElementById('id_dict_user_factors_'+recorderName).value;
  1299. var d_fm=document.getElementById('id_dict_user_fm_'+recorderName).value;
  1300. var d_confer="";
  1301. var d_status="";
  1302. var d_delete="";
  1303. var d_tag="";
  1304. queryString+="<id>"+d_id+"</id>";
  1305. queryString+="<pali>"+d_pali+"</pali>";
  1306. queryString+="<type>"+d_type+"</type>";
  1307. queryString+="<gramma>"+d_gramma+"</gramma>";
  1308. queryString+="<parent>"+d_parent+"</parent>";
  1309. queryString+="<mean>"+d_mean+"</mean>";
  1310. queryString+="<note>"+d_note+"</note>";
  1311. queryString+="<factors>"+d_factors+"</factors>";
  1312. queryString+="<fm>"+d_fm+"</fm>";
  1313. queryString+="<confer>"+d_confer+"</confer>";
  1314. queryString+="<status>"+d_status+"</status>";
  1315. queryString+="<delete>"+d_delete+"</delete>";
  1316. queryString+="<tag>"+d_tag+"</tag>";
  1317. queryString+="</word>";
  1318. queryString+="</wordlist>";
  1319. dict_DictUpdataXmlHttp.onreadystatechange=dict_UserDictUpdata_serverResponse;
  1320. debugOutput("updata user dict start.",0);
  1321. dict_DictUpdataXmlHttp.open("POST", "./dict_updata_user.php", true);
  1322. dict_DictUpdataXmlHttp.send(queryString);
  1323. var i=recorderName;
  1324. g_DictWordUpdataIndex=i;
  1325. g_DictWordNew.Id = d_id;
  1326. g_DictWordNew.Pali = d_pali;
  1327. g_DictWordNew.Mean = d_mean;
  1328. g_DictWordNew.Type = d_type;
  1329. g_DictWordNew.Gramma = d_gramma;
  1330. g_DictWordNew.Parent = d_parent;
  1331. g_DictWordNew.Factors = d_factors;
  1332. g_DictWordNew.FactorMean = d_fm;
  1333. g_DictWordNew.Note = d_note;
  1334. g_DictWordNew.Confer = d_confer;
  1335. g_DictWordNew.Status = d_status;
  1336. g_DictWordNew.Delete = d_delete;
  1337. g_DictWordNew.dictname="用户字典";
  1338. g_DictWordNew.ParentLevel=0;
  1339. }
  1340. else
  1341. {
  1342. alert("Your browser does not support XMLHTTP.");
  1343. }
  1344. }
  1345. function dict_UserDictUpdata_serverResponse(){
  1346. if (dict_DictUpdataXmlHttp.readyState==4)// 4 = "loaded"
  1347. {
  1348. debugOutput("server response.",0);
  1349. if (dict_DictUpdataXmlHttp.status==200)
  1350. {// 200 = "OK"
  1351. var serverText = dict_DictUpdataXmlHttp.responseText;
  1352. debugOutput(serverText,0);
  1353. obj = JSON.parse(serverText);
  1354. if(obj.msg[0].server_return==-1){
  1355. alert(obj.msg[0].server_error);
  1356. }
  1357. else{
  1358. var_dump("user dict "+obj.msg[0].server_op+" ok");
  1359. switch(obj.msg[0].server_op){
  1360. case "insert":
  1361. g_DictWordNew.Id=obj.msg[0].server_return;
  1362. g_DictWordList.unshift(g_DictWordNew);
  1363. break;
  1364. case "update":
  1365. g_DictWordList[g_DictWordUpdataIndex]=g_DictWordNew;
  1366. break;
  1367. }
  1368. }
  1369. showCurrWordTable(g_WordTableCurrWord);
  1370. modifyWordDetailByWordIndex(g_currEditWord);
  1371. }
  1372. else
  1373. {
  1374. debugOutput(xmlhttp.statusText,0);
  1375. }
  1376. }
  1377. }
  1378. // word by word dict updata
  1379. var dict_wbwUpdataXmlHttp=null;
  1380. function dict_WbwUpdata(wordIdFrom,wordIdTo){
  1381. var xmlText="";
  1382. if(window.XMLHttpRequest)
  1383. {// code for IE7, Firefox, Opera, etc.
  1384. dict_wbwUpdataXmlHttp=new XMLHttpRequest();
  1385. }
  1386. else if(window.ActiveXObject)
  1387. {// code for IE6, IE5
  1388. dict_wbwUpdataXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  1389. }
  1390. if (dict_wbwUpdataXmlHttp!=null)
  1391. {
  1392. var queryString="<wordlist>";
  1393. var x = gXmlBookDataBody.getElementsByTagName("word");
  1394. for(var wordID=wordIdFrom; wordID<=wordIdTo;wordID++){
  1395. var wordNode = x[wordID];
  1396. var d_pali=getNodeText(wordNode,"real");
  1397. var d_mean=getNodeText(wordNode,"mean");
  1398. var d_factors=getNodeText(wordNode,"org");
  1399. var d_fm=getNodeText(wordNode,"om");
  1400. var d_case = getNodeText(wordNode,"case");
  1401. if(d_pali.length>0 && !(d_mean=="?" && d_factors=="?" && d_fm=="?" && d_case=="?")){
  1402. queryString+="<word>";
  1403. var iPos=d_case.indexOf("#");
  1404. if(iPos>=0){
  1405. var d_type=d_case.substring(0,iPos);
  1406. if(iPos<d_case.length-1){
  1407. var d_gramma=d_case.substring(iPos+1);
  1408. }
  1409. else{
  1410. var d_gramma="";
  1411. }
  1412. }
  1413. else{
  1414. var d_type="";
  1415. var d_gramma=d_case;
  1416. }
  1417. var d_parent="";
  1418. var d_note="";
  1419. var d_confer="";
  1420. var d_status="";
  1421. var d_lock="";
  1422. var d_tag="";
  1423. queryString+="<pali>"+d_pali+"</pali>";
  1424. queryString+="<type>"+d_type+"</type>";
  1425. queryString+="<gramma>"+d_gramma+"</gramma>";
  1426. queryString+="<parent>"+d_parent+"</parent>";
  1427. queryString+="<mean>"+d_mean+"</mean>";
  1428. queryString+="<note>"+d_note+"</note>";
  1429. queryString+="<factors>"+d_factors+"</factors>";
  1430. queryString+="<fm>"+d_fm+"</fm>";
  1431. queryString+="<confer>"+d_confer+"</confer>";
  1432. queryString+="<status>"+d_status+"</status>";
  1433. queryString+="<lock>"+d_lock+"</lock>";
  1434. queryString+="<tag>"+d_tag+"</tag>";
  1435. queryString+="</word>";
  1436. }
  1437. }
  1438. queryString+="</wordlist>";
  1439. dict_wbwUpdataXmlHttp.onreadystatechange=dict_wbwDictUpdata_serverResponse;
  1440. debugOutput("updata user dict start.",0);
  1441. dict_wbwUpdataXmlHttp.open("POST", "./dict_updata_wbw.php", true);
  1442. dict_wbwUpdataXmlHttp.send(queryString);
  1443. }
  1444. else
  1445. {
  1446. alert("Your browser does not support XMLHTTP.");
  1447. }
  1448. }
  1449. function dict_wbwDictUpdata_serverResponse(){
  1450. if (dict_wbwUpdataXmlHttp.readyState==4)// 4 = "loaded"
  1451. {
  1452. debugOutput("server response.",0);
  1453. if (dict_wbwUpdataXmlHttp.status==200)
  1454. {// 200 = "OK"
  1455. var serverText = dict_wbwUpdataXmlHttp.responseText;
  1456. alert(serverText);
  1457. debugOutput(serverText,0);
  1458. }
  1459. else
  1460. {
  1461. debugOutput(xmlhttp.statusText,0);
  1462. }
  1463. }
  1464. }
  1465. function uploadAllWordData(){
  1466. var x = gXmlBookDataBody.getElementsByTagName("word");
  1467. if(x.length>0){
  1468. dict_WbwUpdata(0,x.length-1);
  1469. }
  1470. else{
  1471. }
  1472. }
  1473. function setInfoPanalVisibility(){
  1474. document.getElementById("id_info_panal").style.display="block";
  1475. }
  1476. function removeFormula(inStr){
  1477. if(inStr.indexOf("[")>=0){
  1478. return(inStr);
  1479. }
  1480. pos=0;
  1481. copy=true;
  1482. var output="";
  1483. for(i=0;i<inStr.length;i++){
  1484. if(inStr[i]=="{"){
  1485. copy=false;
  1486. }
  1487. if(copy){
  1488. output+=inStr[i];
  1489. }
  1490. if(inStr[i]=="}"){
  1491. copy=true;
  1492. }
  1493. }
  1494. return output;
  1495. }
  1496. function dict_getAllWordList(){
  1497. var output=new Array();
  1498. if(g_findMode=="parent"){
  1499. if(g_dictFindParentLevel==0){
  1500. output.push(g_findWord);
  1501. }
  1502. else{
  1503. var currLevel=g_dictFindParentLevel-1;
  1504. for(i=0;i<g_DictWordList.length;i++){
  1505. if(g_DictWordList[i].ParentLevel==currLevel){
  1506. if(g_DictWordList[i].Parent.length>0 && g_DictWordList[i].Parent!=g_DictWordList[i].Pali){
  1507. var arrList=g_DictWordList[i].Parent.split("$");
  1508. var paliInParent=false;
  1509. for(x=0;x<arrList.length;x++){
  1510. if(arrList[x]==g_DictWordList[i].Pali){
  1511. paliInParent=true;
  1512. }
  1513. }
  1514. if(paliInParent==false){
  1515. output.push(g_DictWordList[i].Parent);
  1516. }
  1517. }
  1518. if(g_DictWordList[i].Factors.length>0){
  1519. arrList=g_DictWordList[i].Factors.split("+");
  1520. for(x=0;x<arrList.length;x++){
  1521. if(arrList[x]!=g_DictWordList[i].Pali){
  1522. output.push(arrList[x]);
  1523. }
  1524. }
  1525. }
  1526. }
  1527. }
  1528. }
  1529. }
  1530. if(g_findMode=="children"){
  1531. if(g_dictFindParentLevel==0){
  1532. output.push(g_findWord);
  1533. }
  1534. else{
  1535. var currLevel=g_dictFindParentLevel+1;
  1536. for(i=0;i<g_DictWordList.length;i++){
  1537. if(g_DictWordList[i].ParentLevel==currLevel){
  1538. if(g_DictWordList[i].Type==".v:base." || g_DictWordList[i].Type==".root.")
  1539. {
  1540. var paliInList=false;
  1541. for(x=0;x<output.length;x++){
  1542. if(output[x]==g_DictWordList[i].Pali){
  1543. paliInList=true;
  1544. }
  1545. }
  1546. if(paliInList==false){
  1547. output.push(g_DictWordList[i].Pali);
  1548. }
  1549. }
  1550. }
  1551. }
  1552. }
  1553. }
  1554. if(output.length>0){
  1555. return output.join("$");
  1556. }
  1557. else{
  1558. return null;
  1559. }
  1560. }
  1561. function showChildrenList(arrChildren){
  1562. var outChildrenString="";
  1563. var arrChildrenList = new Array();
  1564. g_currShowDeep++;
  1565. if(g_currShowDeep>3){
  1566. g_currShowDeep=g_currShowDeep-1;
  1567. return("");
  1568. }
  1569. outChildrenString+="<div class=\"subnote\">";
  1570. outChildrenString+="<ol>";
  1571. for(iChild in arrChildren){
  1572. outChildrenString+="<li>";
  1573. newChild = getChildrenList(arrChildren[iChild]);
  1574. if(newChild.length>0){
  1575. outChildrenString+="<button type='button' onclick='showSubNode(this)'>+</button>";
  1576. }
  1577. outChildrenString+=g_DictWordList[arrChildren[iChild]].Pali;
  1578. outChildrenString+='['+g_DictWordList[arrChildren[iChild]].Type+"@"+g_DictWordList[arrChildren[iChild]].Gramma+"]"+g_DictWordList[arrChildren[iChild]].Mean+"["+g_DictWordList[arrChildren[iChild]].Factors+"]";
  1579. if(newChild.length>0){
  1580. outChildrenString+=showChildrenList(newChild);
  1581. }
  1582. outChildrenString+="</li>";
  1583. }
  1584. outChildrenString+="</ol>";
  1585. outChildrenString+="</div>";
  1586. g_currShowDeep--;
  1587. return(outChildrenString);
  1588. }
  1589. function preOpParentInfo(){
  1590. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  1591. var arrParentFactor=g_DictWordList[iDict].Factors.split("+");
  1592. if(g_DictWordList[iDict].Type==".root."){
  1593. for(iSub=0;iSub<g_DictWordList.length;iSub++){
  1594. if(iSub!=iDict && g_DictWordList[iSub].Parent.length==0 && g_DictWordList[iSub].Type==".v:base."){
  1595. var arrFactor=g_DictWordList[iSub].Factors.split("+");
  1596. if(arrFactor.length>2){
  1597. if(arrFactor[arrFactor.length-3]==g_DictWordList[iDict].Pali && arrFactor[arrFactor.length-2]!="ṇe"){
  1598. g_DictWordList[iSub].Parent=g_DictWordList[iDict].Pali;
  1599. }
  1600. }
  1601. }
  1602. }
  1603. }
  1604. if(g_DictWordList[iDict].Type==".v:base."){
  1605. var arrHead=arrParentFactor;
  1606. arrHead.pop();
  1607. var sHead=arrHead.join("+");
  1608. for(iSub=0;iSub<g_DictWordList.length;iSub++){
  1609. if(iSub!=iDict && g_DictWordList[iSub].Parent.length==0){
  1610. {
  1611. if(g_DictWordList[iSub].Factors.indexOf(sHead)==0){
  1612. g_DictWordList[iSub].Parent=g_DictWordList[iDict].Pali;
  1613. }
  1614. }
  1615. }
  1616. }
  1617. }
  1618. }
  1619. document.getElementById('id_dict_match_result_inner').innerHTML=dictShowAsTable();
  1620. }
  1621. function getChildrenList(wordId){
  1622. var arrChildList = new Array();
  1623. if(g_DictWordList[wordId].Type==".n." || g_DictWordList[wordId].Type==".adj." || g_DictWordList[wordId].Type==".ti." || g_DictWordList[wordId].Type==".v."){
  1624. return(arrChildList);
  1625. }
  1626. var pos=g_DictWordList[wordId].Factors.lastIndexOf("+");
  1627. var head=g_DictWordList[wordId].Factors.substring(0,pos);
  1628. var end=g_DictWordList[wordId].Factors.substring(pos);
  1629. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  1630. /*
  1631. var isSameHead=false;
  1632. if(end=="+ti"){
  1633. if(g_DictWordList[iDict].Factors.indexOf(head)==0){
  1634. isSameHead=true;
  1635. }
  1636. }
  1637. */
  1638. if(g_DictWordList[wordId].Pali==g_DictWordList[iDict].Parent)// || isSameHead==true || g_DictWordList[iDict].Factors.indexOf("+"+g_DictWordList[wordId].Pali+"+")>0 || g_DictWordList[iDict].Factors.indexOf(g_DictWordList[wordId].Pali+"+")==0)
  1639. {
  1640. {
  1641. thisChildPali=g_DictWordList[iDict].Pali;
  1642. thisChildType=g_DictWordList[iDict].Type;
  1643. if(thisChildPali==g_DictWordList[wordId].Pali && g_DictWordList[iDict].Type==g_DictWordList[wordId].Type){
  1644. }
  1645. else
  1646. {
  1647. isFind=false;
  1648. for(iWord in arrChildList){
  1649. if(g_DictWordList[arrChildList[iWord]].Pali==thisChildPali && g_DictWordList[arrChildList[iWord]].Type==thisChildType){
  1650. isFind=true;
  1651. }
  1652. }
  1653. if(!isFind){
  1654. arrChildList.push(iDict);
  1655. }
  1656. }
  1657. }
  1658. }
  1659. }
  1660. return(arrChildList);
  1661. }
  1662. function showParentList(arrParent){
  1663. var outChildrenString="";
  1664. var arrParentList = new Array();
  1665. g_currShowDeep++;
  1666. if(g_currShowDeep>3){
  1667. g_currShowDeep=g_currShowDeep-1;
  1668. return("");
  1669. }
  1670. outChildrenString+="<ol>";
  1671. for(iParent in arrParent){
  1672. outChildrenString+="<li>";
  1673. outChildrenString+=arrParent[iParent];
  1674. newParent = getParentList(arrParent[iParent],"base");
  1675. outChildrenString+=newParent.length;
  1676. if(newParent.length>0){
  1677. outChildrenString+=showParentList(newParent);
  1678. }
  1679. outChildrenString+="</li>";
  1680. }
  1681. outChildrenString+="</ol>";
  1682. g_currShowDeep--;
  1683. return(outChildrenString);
  1684. }
  1685. function getParentList(word,findIn){
  1686. var arrParentList = new Array();
  1687. for(iDict=0;iDict<g_DictWordList.length;iDict++){
  1688. if(word==g_DictWordList[iDict].Pali){
  1689. if(findIn=="base"){
  1690. if(g_DictWordList[iDict].Type.slice(-5)=="base."){
  1691. thisParent=g_DictWordList[iDict].Parent;
  1692. if(thisParent.length>0){
  1693. isFind=false;
  1694. for(iWord in arrParentList){
  1695. if(arrParentList[iWord]==thisParent){
  1696. isFind=true;
  1697. }
  1698. }
  1699. if(!isFind){
  1700. arrParentList.push(thisParent);
  1701. }
  1702. }
  1703. }
  1704. }
  1705. else{
  1706. thisParent=g_DictWordList[iDict].Parent;
  1707. if(thisParent.length>0){
  1708. isFind=false;
  1709. for(iWord in arrParentList){
  1710. if(arrParentList[iWord]==thisParent){
  1711. isFind=true;
  1712. }
  1713. }
  1714. if(!isFind){
  1715. arrParentList.push(thisParent);
  1716. }
  1717. }
  1718. }
  1719. }
  1720. }
  1721. return(arrParentList);
  1722. }
  1723. function dictShowCurrWordList(){
  1724. preOpParentInfo();
  1725. var strWord="";
  1726. strWord+="<h2>"+g_findWord+"</h2>";
  1727. strWord+="<p>select a word</p>";
  1728. for(iDict in g_DictWordList){
  1729. if(g_findWord==g_DictWordList[iDict].Pali){
  1730. strWord+="<p><a onclick='dictFindShow("+iDict+")'>"+g_DictWordList[iDict].Pali+"</a>["+g_DictWordList[iDict].Type+"@"+g_DictWordList[iDict].Gramma+"]"+g_DictWordList[iDict].Mean+"["+g_DictWordList[iDict].Factors;
  1731. }
  1732. }
  1733. document.getElementById('id_dict_curr_word_inner').innerHTML=strWord;
  1734. }
  1735. //show dict find result
  1736. function dictFindShow(showId){
  1737. var strWordFamily="";
  1738. strWordFamily+="<h2>"+g_findWord+"</h2>";
  1739. strWordFamily+='<p>['+g_DictWordList[showId].Type+"@"+g_DictWordList[showId].Gramma+"]"+g_DictWordList[showId].Mean+"["+g_DictWordList[showId].Factors+"]</p>";
  1740. if(g_findMode=="parent"){
  1741. pList = getParentList(g_findWord,"");
  1742. if(pList.length>0){
  1743. strWordFamily+=showParentList(pList);
  1744. }
  1745. }
  1746. if(g_findMode=="children"){
  1747. cList = getChildrenList(showId);
  1748. if(cList.length>0){
  1749. strWordFamily+=showChildrenList(cList);
  1750. }
  1751. }
  1752. document.getElementById('id_dict_curr_word_inner').innerHTML=strWordFamily;
  1753. }
  1754. function showSubNode(obj){
  1755. eParent = obj.parentNode;
  1756. var x=eParent.getElementsByTagName("div");
  1757. if(x[0].style.display=="none"){
  1758. x[0].style.display="block";
  1759. obj.innerHTML="-";
  1760. }
  1761. else{
  1762. x[0].style.display="none";
  1763. obj.innerHTML="+";
  1764. }
  1765. }