leescott 发表于 2019-5-17 18:12:47

关于JAVA的修改

https://www.pdawiki.com/forum/forum.php?mod=viewthread&tid=34509

我不是内行,直接复制了象形字典的脚本。好处是点击图像,可以展开图像。


当有几个引申线索附图的时候,不能分别展开图像。手机深蓝词典问是不是打开图像。

有没有热心人帮我修改一下。

谢谢!

leescott 发表于 2019-5-31 08:14:53

两个脚本代码,怎么样合并在一起?谢谢!
脚本一,现代汉语规范字典:
window.onload=function(){
        JTsetup('x-hw');
        iterationSetup();
        specialSetup();
};

function specialSetup(){
        var _xa=document.querySelectorAll('x-a');
        if(!_xa) return;
        for(var i=0; i<_xa.length; ++i)
                _xa.parentNode.setAttribute('x-meaning', '');
}

function iterationSetup(){
        var _hw=document.querySelectorAll('x-hw');
        if(_hw.length<2) return;
        for(var i=0; i<_hw.length; ++i){
                var _it=document.createElement('sup');
                _it.textContent=(i+1);
                _hw.appendChild(_it);
        }
}

function JTsetup(str){
        var _eles=document.querySelectorAll(str);
        if(_eles.length<2){
                if(!!_eles){
                        _eles.removeAttribute('onclick');
                }
                return;
        }
        for(var i=0; i<_eles.length; ++i){
                _eles.setAttribute('onclick', scrollPosition(_eles));
        }
}

function scrollPosition(target){
        var _id=target.getAttribute('id');
        if(!_id){
                _id='random'+Math.round(Math.random()*1048576);
                target.setAttribute('id', _id);
        }
        if(!isBluedict())
                return "window.location.href='#"+_id+"'";
        return "window.location.href='entry://#"+_id+"'";
}

function isBluedict(){
        return !!document.querySelector('.bd_body');
}
脚本二,象形字典:
window.onload = function(){
if(document.getElementById("img_ysxs")){
document.getElementById("img_ysxs").style.maxWidth="100%";
document.getElementById("img_ysxs").onclick=function(){
        var now = document.getElementById ("img_ysxs");
        var i = now.style.maxWidth
        if(i=="100%"){document.getElementById("img_ysxs").style.maxWidth="none";}else{document.getElementById("img_ysxs").style.maxWidth="100%";}
        };
};
if(document.getElementById("img_zxyb")){
document.getElementById("img_zxyb").style.maxWidth="100%";
document.getElementById("img_zxyb").onclick=function(){
        var now = document.getElementById ("img_zxyb");
        var i = now.style.maxWidth
        if(i=="100%"){document.getElementById("img_zxyb").style.maxWidth="none";}else{document.getElementById("img_zxyb").style.maxWidth="100%";}
        };
};
};

页: [1]
查看完整版本: 关于JAVA的修改