module_function.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. 
  2. /*
  3. * Modle Init.
  4. * public
  5. * @param param1 (type)
  6. *
  7. * Example usage:
  8. * @code
  9. * @endcode
  10. */
  11. function edit_dictionary_init(){
  12. }
  13. function menu_file_import_wbw(filename){
  14. editor_loadDataFromILD(filename);
  15. }
  16. function menu_file_import_ild(){
  17. var filename = g_filename+".ild";
  18. editor_loadDataFromILD(filename);
  19. }
  20. //import csv begin
  21. var editor_ILDXmlHttp=null;
  22. function editor_loadDataFromILD(strFileName){
  23. if(window.XMLHttpRequest)
  24. {// code for IE7, Firefox, Opera, etc.
  25. editor_ILDXmlHttp=new XMLHttpRequest();
  26. }
  27. else if(window.ActiveXObject)
  28. {// code for IE6, IE5
  29. editor_ILDXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  30. }
  31. if (editor_ILDXmlHttp!=null)
  32. {
  33. var d=new Date();
  34. var strLink ="";
  35. if(strFileName.substr(-4)==".ild"){
  36. strLink = "./import_ild.php?filename="+strFileName;
  37. }
  38. else if(strFileName.substr(-4)==".pcs"){
  39. strLink = "./import_wbw.php?filename="+strFileName;
  40. }
  41. if(strLink.length>0){
  42. editor_ILDXmlHttp.onreadystatechange=editor_ild_serverResponse;
  43. editor_ILDXmlHttp.open("GET", strLink, true);
  44. editor_ILDXmlHttp.send(null);
  45. document.getElementById('id_ild_msg_inner').innerHTML="Importing..."+strFileName;
  46. }
  47. else{
  48. document.getElementById('id_ild_msg_inner').innerHTML="无法识别的文件类型";
  49. }
  50. }
  51. else
  52. {
  53. alert("Your browser does not support XMLHTTP.");
  54. }
  55. }
  56. function editor_ild_serverResponse(){
  57. if (editor_ILDXmlHttp.readyState==4)// 4 = "loaded"
  58. {
  59. document.getElementById('id_csv_msg_inner').innerHTML="receve csv data";
  60. if (editor_ILDXmlHttp.status==200)
  61. {// 200 = "OK"
  62. var xmlText = editor_ILDXmlHttp.responseText;
  63. if (window.DOMParser)
  64. {
  65. parser=new DOMParser();
  66. xmlILD=parser.parseFromString(xmlText,"text/xml");
  67. }
  68. else // Internet Explorer
  69. {
  70. xmlILD=new ActiveXObject("Microsoft.XMLDOM");
  71. xmlILD.async="false";
  72. xmlILD.loadXML(xmlText);
  73. }
  74. if (xmlILD == null){
  75. alert("error:can not load inline dictionary xml obj is null.");
  76. return;
  77. }
  78. ildDataParse(xmlILD);
  79. dictMatchXMLDoc();
  80. }
  81. else
  82. {
  83. document.getElementById('id_ild_msg_inner')="Problem retrieving data:" + xmlhttp.statusText;
  84. }
  85. }
  86. }
  87. /*Parse ild data and fill this document*/
  88. function ildDataParse(xmlILDData){
  89. document.getElementById('id_ild_msg_inner').innerHTML+="<br>Parseing ILD Data";
  90. var xILD = xmlILDData.getElementsByTagName("word");
  91. var xDocWords = gXmlBookDataBody.getElementsByTagName("word");
  92. for(iword=0;iword<xILD.length;iword++){
  93. objNewDict= new Object();
  94. objNewDict.Id = getNodeText(xILD[iword],"id");
  95. objNewDict.Guid = getNodeText(xILD[iword],"guid");
  96. objNewDict.Pali = getNodeText(xILD[iword],"pali");
  97. objNewDict.Mean = getNodeText(xILD[iword],"mean");
  98. objNewDict.Type = getNodeText(xILD[iword],"type");
  99. objNewDict.Gramma = getNodeText(xILD[iword],"gramma");
  100. objNewDict.Parent = getNodeText(xILD[iword],"parent");
  101. objNewDict.Factors = getNodeText(xILD[iword],"factors");
  102. objNewDict.FactorMean = getNodeText(xILD[iword],"factorMean");
  103. objNewDict.PartId = getNodeText(xILD[iword],"partid");
  104. objNewDict.Note = getNodeText(xILD[iword],"note");
  105. objNewDict.Confer = getNodeText(xILD[iword],"confer");
  106. objNewDict.Status = getNodeText(xILD[iword],"status");
  107. objNewDict.Delete = getNodeText(xILD[iword],"delete");
  108. objNewDict.Language = getNodeText(xILD[iword],"language");
  109. objNewDict.dictname=getNodeText(xILD[iword],"dict_name");
  110. objNewDict.dictType=getNodeText(xILD[iword],"dictType");
  111. objNewDict.fileName=getNodeText(xILD[iword],"fileName");
  112. objNewDict.ParentLevel=getNodeText(xILD[iword],"parentLevel");
  113. g_DictWordList.push(objNewDict);
  114. }
  115. document.getElementById('id_ild_msg_inner').innerHTML+="<br>Updata inline Dictionary Data OK!";
  116. document.getElementById('id_dict_match_result_inner').innerHTML=dictShowAsTable();
  117. }
  118. //import ild end