mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
re-implement mdict lookup support
This commit is contained in:
parent
c033aee378
commit
936181547e
1 changed files with 31 additions and 14 deletions
|
@ -74,30 +74,47 @@
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
<script>
|
<script>
|
||||||
//?file=./xxx/xx.xx,./xx/xx.xxx#word=
|
//?file=.../xx.xx,.../xx.xxx#word=
|
||||||
var dictinput = document.getElementById('dictfile');
|
var dictinput = document.getElementById('dictfile');
|
||||||
var wordinput = document.getElementById('word');
|
var wordinput = document.getElementById('word');
|
||||||
var btnLookup = document.getElementById('btnLookup');
|
var btnLookup = document.getElementById('btnLookup');
|
||||||
|
|
||||||
window.onload = function() {
|
window.onhashchange = function() {
|
||||||
|
let v = location.hash.substring(6);
|
||||||
|
if(v.length>0){
|
||||||
|
wordinput.value = v;
|
||||||
|
//wordinput.dispatchEvent(new Event('change', {'bubbles': true}));
|
||||||
|
btnLookup.click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
let v = location.hash.substring(6);
|
let v = location.hash.substring(6);
|
||||||
wordinput.value = v;
|
wordinput.value = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
let filenames = location.search.substring(6);
|
let filenames = location.search.substring(6);
|
||||||
|
window.onload = function(){
|
||||||
if(filenames.length>0){
|
if(filenames.length>0){
|
||||||
dictinput.setAttribute('accept',filenames);
|
let clickurl = "i:5fdictinput.click():"+filenames;
|
||||||
location.href="i:5fdictinput.click()";
|
location.href=clickurl;
|
||||||
setTimeout(()=>{dictinput.dispatchEvent(new Event('change'));dictinput.removeAttribute('accept')},500);
|
//setTimeout(()=>{dictinput.dispatchEvent(new Event('change', {'bubbles': true}));},100);
|
||||||
}
|
|
||||||
window.onhashchange = function() {
|
|
||||||
let v = location.hash.substring(6);
|
|
||||||
if(v.length>0){
|
|
||||||
wordinput.value = v;
|
|
||||||
//wordinput.dispatchEvent(new Event('change', {'bubbles': true}));
|
|
||||||
btnLookup.click();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
var callbackTimer = setInterval(function() {
|
||||||
|
let files = dictinput.files;
|
||||||
|
if(files.length>0){
|
||||||
|
if(!btnLookup.disabled){
|
||||||
|
clearInterval(callbackTimer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
location.href=clickurl;
|
||||||
|
dictinput.dispatchEvent(new Event('change', {'bubbles': true}));
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue