step3.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. require_once '../pcdl/html_head.php';
  3. ?>
  4. <body>
  5. <style>
  6. #step3{
  7. background-color: #f1e7a4;
  8. }
  9. </style>
  10. <?php
  11. require_once 'nav_bar.php';
  12. ?>
  13. <h3>Step 3 Dictionary</h3>
  14. <div style="margin:1em;background-color:#f1e7a4;">
  15. 生成字典数据库。约需要10分钟。您可以从网络下载已经生成好的数据库。
  16. <a href="https://www.dropbox.com/s/naf7sk9i9sf0dfi/appdata.7z?dl=0">drobox 7z format 754MB</a>
  17. 解压缩后放在项目目录中
  18. <pre>
  19. [project dir]
  20. └app
  21. └appdata
  22. └dict
  23. └3rd
  24. └system
  25. └palicanon
  26. └user
  27. </pre>
  28. </div>
  29. <div id="response"></div>
  30. <script>
  31. <?php
  32. echo "var rich_file_list = new Array();\n";
  33. $filelist = array();
  34. if(($handle=fopen(_DIR_DICT_TEXT_.'/rich/list.txt','r'))!==FALSE){
  35. while(($data=fgetcsv($handle,0,','))!==FALSE){
  36. $filelist[] = $data;
  37. }
  38. }
  39. else{
  40. exit("无法打开rich文件列表");
  41. }
  42. foreach($filelist as $value){
  43. echo "rich_file_list.push(['{$value[0]}','{$value[1]}']);\n";
  44. }
  45. echo "var sys_file_list = new Array();\n";
  46. $filelist = array();
  47. if(($handle=fopen(_DIR_DICT_TEXT_.'/system/list.txt','r'))!==FALSE){
  48. while(($data=fgetcsv($handle,0,','))!==FALSE){
  49. $filelist[] = $data;
  50. }
  51. }
  52. else{
  53. exit("无法打开system文件列表");
  54. }
  55. foreach($filelist as $value){
  56. echo "sys_file_list.push(['{$value[0]}','{$value[1]}']);\n";
  57. }
  58. ?>
  59. var iCurrRichDictIndex = 0;
  60. var iCurrSysDictIndex = 0;
  61. function run_rich_dict(index){
  62. if(index >= rich_file_list.length){
  63. $("#response").html($("#response").html()+"rich dict Down");
  64. run_sys_dict(0);
  65. }
  66. else{
  67. $.get("step3_run.php",
  68. {
  69. dbtype:"rich",
  70. filename:rich_file_list[index][0],
  71. dbname:rich_file_list[index][1]
  72. },
  73. function(data,status){
  74. $("#response").html($("#response").html()+data+"<br>");
  75. iCurrRichDictIndex++;
  76. run_rich_dict(iCurrRichDictIndex);
  77. });
  78. }
  79. }
  80. function run_sys_dict(index){
  81. if(index >= sys_file_list.length){
  82. $("#response").html($("#response").html()+"All Down");
  83. }
  84. else{
  85. iCurrSysDictIndex = index;
  86. $.get("step3_run.php",
  87. {
  88. dbtype:"system",
  89. filename:sys_file_list[index][0],
  90. dbname:sys_file_list[index][1]
  91. },
  92. function(data,status){
  93. $("#response").html($("#response").html()+data+"<br>");
  94. iCurrSysDictIndex++;
  95. run_sys_dict(iCurrSysDictIndex);
  96. });
  97. }
  98. }
  99. function run_part_dict(){
  100. $.get("step3_run.php",
  101. {
  102. dbtype:"part",
  103. filename:"",
  104. dbname:""
  105. },
  106. function(data,status){
  107. $("#response").html($("#response").html()+data+" done<br>");
  108. });
  109. }
  110. </script>
  111. <h2>
  112. <button onclick="run_rich_dict(0)">Build rich dictionary </button><span style="请注意!此操作将会覆盖原有数据库。"><br>
  113. <button onclick="run_part_dict()">Build part dictionary</button><span style="请注意!此操作将会覆盖原有数据库。">
  114. </h2>
  115. <hr>
  116. <h2><a href="step4.php">[Next]</a></h2>
  117. </body>
  118. </html>