原生js实现的鼠标滑上去之后按照屏幕高度放大缩略图

来源:互联网 发布:守望先锋生涯数据出错 编辑:程序博客网 时间:2024/06/01 10:47


String.prototype.trim = function() {    return this.replace(/^\s*/, "").replace(/\s*$/, "")};String.prototype.left = function(n) {    return this.substring(0, n)};String.prototype.right = function(n) {    return this.substring(this.length - n, this.length)};var lastmenuid = 0;function showpopup(a) {    for (var i = 1; i <= lastmenuid; i++) {        if (i != a) {            var p = document.getElementById("popup" + i);            if (p) {                p.style.display = 'none'            }            document.getElementById("menu" + i).style.backgroundColor = '#FFB040'        }    }    document.getElementById("popup" + a).style.display = 'block';    document.getElementById("menu" + a).style.backgroundColor = '#FFD8A0'}function hidepopup(a) {    document.getElementById("popup" + a).style.display = 'none';    document.getElementById("menu" + a).style.backgroundColor = '#FFB040'}function hidepopups() {    for (var i = 1; i <= lastmenuid; i++) {        var p = document.getElementById("popup" + i);        if (p) {            p.style.display = 'none'        }        document.getElementById("menu" + i).style.backgroundColor = '#FFB040'    }}function showmenuicon(a) {    if (a) {        if (a == 'buy') {            if (icobuy) {                document.write('<img src="//www.just-great-software.com/imgsite/ico' + icobuy + '.png" ' + 'srcset="//www.just-great-software.com/imgsite/ico' + icobuy + '.png 1x, ' + '//www.just-great-software.com/imgsite125/ico' + icobuy + '.png 1.25x, ' + '//www.just-great-software.com/imgsite150/ico' + icobuy + '.png 1.5x, ' + '//www.just-great-software.com/imgsite175/ico' + icobuy + '.png 1.75x, ' + '//www.just-great-software.com/imgsite200/ico' + icobuy + '.png 2.0x, ' + '//www.just-great-software.com/imgsite225/ico' + icobuy + '.png 2.25x, ' + '//www.just-great-software.com/imgsite250/ico' + icobuy + '.png 2.5x, ' + '//www.just-great-software.com/imgsite300/ico' + icobuy + '.png 3.0x' + '" width=18 height=18>')            }        } else if (/^(?:act|ep[lp]|rx[bm])$/.test(a)) {            document.write('<img src="//www.just-great-software.com/imgsite/ico' + a + '.png" ' + 'srcset="//www.just-great-software.com/imgsite/ico' + a + '.png 1x, ' + '//www.just-great-software.com/imgsite150/ico' + a + '.png 1.5x' + '" width=16 height=16 style="padding: 1px">')        } else {            document.write('<img src="//www.just-great-software.com/imgsite/ico' + a + '.png" ' + 'srcset="//www.just-great-software.com/imgsite/ico' + a + '.png 1x, ' + '//www.just-great-software.com/imgsite125/ico' + a + '.png 1.25x, ' + '//www.just-great-software.com/imgsite150/ico' + a + '.png 1.5x, ' + '//www.just-great-software.com/imgsite175/ico' + a + '.png 1.75x, ' + '//www.just-great-software.com/imgsite200/ico' + a + '.png 2.0x, ' + '//www.just-great-software.com/imgsite250/ico' + a + '.png 2.5x, ' + '//www.just-great-software.com/imgsite300/ico' + a + '.png 3.0x' + '" width=18 height=18>')        }    }}function showmenu(a, b) {    document.write('<table cellpadding="0" cellspacing="0" border="0" class="menu"><tr>');    var c = '><div onmouseover="hidepopups(); this.style.backgroundColor=\'#FFD8A0\';" onmouseout="this.style.backgroundColor=\'#FFB040\';return false;">';    for (var i = 0; i < a.length; i++) {        lastmenuid++;        document.write('<td id="menu' + lastmenuid + '"');        var s = a[i].s;        if (s) {            document.write(' onmouseover="showpopup(' + lastmenuid + ');"')        }        if (b && (a[i].l.indexOf('//') < 0)) {            document.write('><a href="' + b + a[i].l + '" target=_top')        } else {            document.write('><a href="' + a[i].l + '" target=_top')        } if (s) {            document.write('><div>')        } else {            document.write(c)        }        showmenuicon(a[i].i);        document.write(a[i].c.replace(/ /g, ' ') + '</div></a>');        if (s) {            document.write('<table id="popup' + lastmenuid + '" onmouseout="hidepopup(' + lastmenuid + '); return false;" style="position: absolute; display: none;" cellpadding="0" cellspacing="0" border="0">');            var d = Math.ceil(s.length / 16);            for (var j = 0; j < s.length; j++) {                if (j % d == 0) {                    document.write('<tr>')                }                if (b && (s[j].l.indexOf('//') < 0)) {                    document.write('<td><a href="' + b + s[j].l + '" target=_top')                } else {                    document.write('<td><a href="' + s[j].l + '" target=_top')                }                document.write(c);                showmenuicon(s[j].i);                document.write(s[j].c.replace(/ /g, ' ') + '</div></a></td>');                if (j % d == d - 1 || j == s.length - 1) {                    document.write('</tr>')                }            }            document.write('</table>')        }        document.write('</td>')    }    document.write('</tr></table>')}var expandingid = 0;var expandingstep = 0;var expandingwidth = 0;var expandingheight = 0;var expandingtop = 0;var expandingleft = 0;var expandingtimeout = 0;var expandingtotalsteps = 15;function expandthumb(a, b, c) {    if (expandingtimeout != 0) {        clearTimeout(expandingtimeout)    }    if (expandingid > 0 && expandingid != a) {        restorethumb()    }    if (expandingid != a) {        img = document.getElementById("screen" + a);        img.style.display = 'block';        expandingid = a;        expandingstep = 1;        expandingwidth = b;        expandingheight = c;        expandingtop = img.offsetTop;        expandingleft = img.offsetLeft    } else if (expandingstep < 1) {        expandingstep = 1    }    expandstep()}function setsizes(a, b, c, d, e) {    a.style.left = b;    a.style.top = c;    a.style.width = d;    a.style.height = e}function doexpand() {    var a = document.getElementById("screen" + expandingid);    var b = document.getElementById("thumb" + expandingid);    var c = getScroll();    var d = Math.max(Math.min(expandingtop + b.height - expandingheight + 5, c.top + c.height - expandingheight), c.top);    var e = Math.max(Math.min(expandingleft - 5, c.left + c.width - expandingwidth), c.left);    setsizes(a, e + ((expandingleft - e) * (expandingtotalsteps - expandingstep) / expandingtotalsteps) + 'px', d + ((expandingtop - d) * (expandingtotalsteps - expandingstep) / expandingtotalsteps) + 'px', b.width + ((expandingwidth - b.width) * expandingstep / expandingtotalsteps) + 'px', b.height + ((expandingheight - b.height) * expandingstep / expandingtotalsteps) + 'px')}function restorethumb() {    img = document.getElementById("screen" + expandingid);    img.style.top = '';    img.style.left = '';    img.style.display = 'none';    expandingid = 0}function expandstep() {    expandingtimeout = 0;    doexpand();    if (expandingstep < expandingtotalsteps) {        expandingstep++;        expandingtimeout = setTimeout("expandstep()", 20)    }}function reducestep() {    expandingtimeout = 0;    doexpand();    if (expandingstep > 0) {        expandingstep--;        expandingtimeout = setTimeout("reducestep()", 20)    } else {        restorethumb()    }}function reducethumb(a) {    if (expandingtimeout != 0) {        clearTimeout(expandingtimeout)    }    if (expandingstep > 0) {        reducestep()    }}function getScroll() {    if (document.all && typeof document.body.scrollTop != "undefined") {        var a = document.compatMode != "CSS1Compat";        var b = a ? document.body : document.documentElement;        return {            left: b.scrollLeft,            top: b.scrollTop,            width: b.clientWidth,            height: b.clientHeight        }    } else {        return {            left: window.pageXOffset,            top: window.pageYOffset,            width: document.documentElement.clientWidth,            height: document.documentElement.clientHeight        }    }}function quicktable(a, b) {    var c = a.split(/搂/);    var d = '<table border=0 cellspacing=0 cellpadding=2 class=quicktable><tr>';    for (var i = 0; i < c.length; i++) {        d = d + "<th";        if (c[i].charAt(0) == 'C') {            d = d + ' align=center'        } else if (c[i].charAt(0) == 'R') {            d = d + ' align=right'        }        d = d + '>' + c[i].substring(1, c[i].length) + '</td>'    }    d = d + '</tr>';    var e = b.split(/\n/);    var f = 1;    for (var g = 0; g < e.length; g++) {        if (f == 1) {            f = 0;            d = d + "<tr class=quicktable>"        } else {            f = 1;            d = d + '<tr>'        }        var h = e[g].split(/搂/);        var i = 0;        var j = 1;        for (var k = 0; k < h.length; k++) {            if (h[k]) {                d = d + "<td";                if (c[i].charAt(0) == 'C') {                    d = d + ' align=center'                } else if (c[i].charAt(0) == 'R') {                    d = d + ' align=right'                }                if (j > 1) {                    d = d + ' colspan=' + j                }                d = d + '>' + h[k] + '</td>';                i = i + j;                j = 1            } else {                j++            }        }        d = d + '</tr>'    }    return d + '</table>'}function regexbuddyhighlight(a) {    document.getElementById("regex" + a).style.background = "#FFFF00";    document.getElementById("tree" + a).style.background = "#FFFF00"}function regexbuddyclear(a) {    document.getElementById("regex" + a).style.background = "white";    document.getElementById("tree" + a).style.background = "white"}function regexbuddyhighlightdup(a) {    document.getElementById("regex" + a).style.background = "#FFFF00";    document.getElementById("tree" + a + "dup").style.background = "#FFFF00"}function regexbuddycleardup(a) {    document.getElementById("regex" + a).style.background = "white";    document.getElementById("tree" + a + "dup").style.background = "white"}


阅读全文
0 0