mdict.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="UTF-8">
  5. <base href="https://fastly.jsdelivr.net/gh/fengdh/mdict-js/">
  6. <title>mdict</title>
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <link rel="stylesheet" type="text/css" href="selectize.default.css" media="screen">
  9. <style>
  10. #btnLookup {
  11. border: none;
  12. height: 36px;
  13. font-size: 12pt;
  14. font-weight: bold;
  15. vertical-align: top;
  16. border-radius: 3px;
  17. }
  18. #btnLookup:not([disabled]) {
  19. background: #1A4FDD;
  20. color: white;
  21. }
  22. #dict-title {
  23. position: fixed;
  24. bottom: 0;
  25. right: 0;
  26. max-width: 300px;
  27. font-size: 10px;
  28. opacity: 0.9;
  29. background: #DDD;
  30. box-shadow: -2px -2px 4px 4px rgba(0, 0, 0, 0.3);
  31. }
  32. #dict-title * {
  33. font-size: 10px!important;
  34. }
  35. #mdict-online-viewer {
  36. font-size: 14px;
  37. font-family: "Georgia", "Times New Roman";
  38. height: 100%;
  39. width: 100%;
  40. }
  41. #mdict-online-viewer #definition {
  42. font-size: 14px;
  43. height: 100%;
  44. overflow: auto;
  45. }
  46. #word + .selectize-control {
  47. display: inline-block;
  48. min-width: 18em;
  49. }
  50. </style>
  51. <script type="text/javascript" src="conf.js"></script>
  52. <script src="require.js" data-main="mdict"></script>
  53. </head>
  54. <body>
  55. <section class="main-content">
  56. <div id="mdict-online-viewer">
  57. Choose a dictionary file (*.mdx + optional *.mdd): <input id="dictfile" type="file" multiple>
  58. <p>
  59. <input id="word" type="text" value="">
  60. <input id="btnLookup" type="button" value="look up" disabled="false">
  61. <div id="dict-title"></div>
  62. <div id="definition">
  63. </div>
  64. </div>
  65. </section>
  66. <script>
  67. //?file=./xxx/xx.xx,./xx/xx.xxx#word=
  68. let dictinput = document.getElementById('dictfile');
  69. let wordinput = document.getElementById('word');
  70. let btnLookup = document.getElementById('btnLookup');
  71. let v = location.hash.substring(6);
  72. wordinput.value = v;
  73. window.onhashchange = function() {
  74. let v = location.hash.substring(6);
  75. if(v.length>0){
  76. wordinput.value = v;
  77. //wordinput.dispatchEvent(new Event('change', {'bubbles': true}));
  78. btnLookup.click();
  79. }
  80. };
  81. //dictinput.onClick = {(e)=>{e.target.value="";}};
  82. let filenames = location.search.substring(6);
  83. if(filenames.length>0){
  84. dictinput.setAttribute('accept',filenames);
  85. setTimeout(()=>{location.href="i:5fdictinput.click();"},100);
  86. setTimeout(()=>{location.href="i:5fdictinput.click();"},300);
  87. setTimeout(()=>{dictinput.dispatchEvent(new Event('change'));dictinput.removeAttribute('accept')},500);
  88. }
  89. </script>
  90. </body>
  91. </html>