⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.js

📁 asp的bbs程序
💻 JS
📖 第 1 页 / 共 4 页
字号:
    tip.style.left = Global.GetOffsetLeft(th) + 'px';
    tip.style.top = Global.GetOffsetTop(th) + 20 + 'px';

    function mouseout () {
        tip.style.display = 'none';
        Events.RemoveEvent(th, 'mouseout', mouseout);
    }
    Events.AttactEvent(th, 'mouseout', mouseout);
}
// 显示验证码
showVCode.c = null;
showVCode.current = null;
showVCode.tip = null;
function showVCode (th, src) {
    var c = showVCode.c;
    if (c && showVCode.current != th) {
        showVCode.current = th;
        showVCode.tip.style.display = '';
        c.src = BBSMAX.CodeUrl + src;
        c._src = '';
        reloadImage(c);
    }

    if (!c) {
        c = showVCode.c = oNode.CreateNode('img');
        oNode.AddNode(c);
        c.style.position = 'absolute';
        c.style.cursor = 'pointer';
        c.style.left = '-100px';
        c.style.top = '-100px';
        c.title = '看不清,点击刷新';
        c.src = BBSMAX.CodeUrl + src;
        Events.AttachEvent(c, 'click', function () {
            reloadImage(c);
        });
        c.onload = function () {
            c.style.border = '1px solid #ccc';
            showVCode.show(c, th);
            showVCode.tip.style.display = 'none';
        };

        var mousedown = showVCode.mousedown = function (e) {
            var obj = $EO(e);
            if (obj == showVCode.current || obj == showVCode.c) return;
            showVCode.hide();
        };
        Events.AttachEvent(document, 'mousedown', mousedown);
    }

    var tip = showVCode.tip;
    if (!tip) {
        tip = showVCode.tip = oNode.CreateNode('div');
        oNode.AddNode(tip);
        CSS.AddClass(tip, 'validcode-loader');
        tip.style.position = 'absolute';
        tip.style.zIndex = 11;
        tip.innerHTML = '载入验证码...';
        //tip.style.border = '1px solid #ccc';
        //tip.src = BBSMAX.CodeLoadingImage;
        //tip.onload = function () {
            tip.style.left = Global.GetOffsetLeft(th) + 'px';
            tip.style.top = Global.GetOffsetTop(th) - tip.offsetHeight + 'px';
        //};
        c.style.display = 'none';
    }
    //tip.style.left = Global.GetOffsetLeft(th) + 'px';
    //tip.style.top = Global.GetOffsetTop(th) - tip.offsetHeight + 'px';

    if (showVCode.current != th) {
        reloadImage(c);
        showVCode.current = th;
    }
    c.style.zIndex = 10;
    showVCode.show(c, th);
}
showVCode.show = function () {
    c = showVCode.c;
    th = showVCode.current;
    c.style.display = 'block';
    c.style.left = Global.GetOffsetLeft(th) + 'px';
    c.style.top = Global.GetOffsetTop(th) - c.offsetHeight + 'px';
};
showVCode.hide = function () {
    this.c.style.display = 'none';
};
showVCode.clear = function () {
    this.c = null;
    this.current = null;
    this.tip && oNode.RemoveNode(this.tip);
    this.tip = null;
    this.mousedown && Events.RemoveEvent(document, 'mousedown', this.mousedown);
};

// 选择列表
function selectListAll (th, name) {
    var list = document.getElementsByName(name);
    for (var i = 0, len = list.length; i < len; i++) {
        list[i].checked = th.checked;
        var p = list[i].parentNode.parentNode;
        list[i].c = th;
        th.checked ? CSS.AddClass(p, 'current') : CSS.RemoveClass(p, 'current');
    }
}
// 选择其中一个
function selectListOne (th) {
    var p = th.parentNode.parentNode;
    th.checked ? CSS.AddClass(p, 'current') : CSS.RemoveClass(p, 'current');
    th.c && (th.c.checked = false);
}
// 取消全选按钮的选择状态
function cancelSelected() {
    $('selecteAll').checked = false;
}


/// 帖子浏览页面
// ·大·,·中·,·小·三状态浏览
PostViewStyle.current_css = '';
function PostViewStyle (th, css) {
    var current_css = PostViewStyle.current_css;
    while (th) {
        if (th.tagName.toLowerCase() == 'table') {
            th = th.getElementsByTagName('div');
            for (var i = 0, len = th.length; i < len; i++) {
                if (th[i].className.indexOf('post-content') > -1) {
                    CSS.RemoveClass(th[i], current_css);
                    CSS.AddClass(th[i], css);
                    PostViewStyle.current_css = css;
                    break;
                }
            }
            break;
        }
        th = th.parentNode;
    }
}
// 帖子内图片自动缩放
function ImageScalePost () {
    var posts = [];
    var divs = document.getElementsByTagName('div');
    for (var i = 0, len = divs.length; i < len; i++) {
        if (divs[i].className.indexOf('post-content') > -1) {
            posts.push(divs[i]);
        }
    }

    for (i = 0, len = posts.length; i < len; i++) {
        var imgs = posts[i].getElementsByTagName('img');
        for (var j = 0, _len = imgs.length; j < _len; j++) {
			var border = parseInt(imgs[j].style.borderWidth) * 2;
            border = isNaN(border) ? 0 : border;
            imgs[j].w = imgs[j].width - border;
            imgs[j].h = imgs[j].height - border;
            imgs[j].width = 1;
        }
    }
    for (i = 0, len = posts.length; i < len; i++) {
        var W = posts[i].offsetWidth;
        var H = posts[i].offsetHeight;
        var imgs = posts[i].getElementsByTagName('img');
        for (var j = 0, _len = imgs.length; j < _len; j++) {
            var w, h;
            if (imgs[j].w > W) {
                w = W * 0.9;
                h = imgs[j].h * W / imgs[j].w * 0.9;
            }
			else {
				w = imgs[j].w;
				h = imgs[j].h;
			}
            imgs[j].width = w;
            imgs[j].height = h;
        }
    }

    // 通过window.onresize动态设置图片缩放 ***
    /*
    if (!ImageScalePost.resizable) {
        ImageScalePost.resizable = true;
        Events.AttachEvent(window, 'resize', function () {
            ImageScalePost();
        });
    }
    */
}

// 显示帖子用户信息
function showMemberInfo (th) {
	var mouseover = function (e) {
		if (th.process) return;
		th.process = true;
		th.interval = setTimeout(show, 200);
	};
	var mouseout = function (e) {
		hide();
	};
	
	var show = function () {
		if (th.display) return;
		th.display = true;
		if (Browser.IsIE) {
			th.parentNode.style.height = th.parentNode.offsetHeight + 'px';
		}
		else {
			th.parentNode.style.borderWidth = '1px';
			th.parentNode.style.height = th.parentNode.offsetHeight - 2 + 'px';
			//th.parentNode.style.border = '0';
		}
		th.parentNode.style.position = 'relative';
		th.style.zIndex = 10;
		CSS.AddClass(th, 'author-infolist-expand');
	};
	
	var hide = function () {
		clearTimeout(th.interval);
		th.process = false;
		th.display = false;
		th.style.zIndex = 0;
		th.parentNode.style.position = 'static';
		CSS.RemoveClass(th, 'author-infolist-expand');
		th.parentNode.style.height = 'auto';
	};
	
	th.onmouseover = mouseover;
	//th.onmouseout = mouseout;
	
	Events.AttachEvent(document, 'mousemove', function (e) {
		//if (!th.display) return;
		var obj = $EO(e);
		while (obj) {
			if (obj == th) break;
			obj = obj.parentNode;
		}
		if (!obj) hide();
	});

/*
	return;
    if (th.display) return;
    th.display = true;
    if (Browser.IsIE) {
        th.parentNode.style.height = th.parentNode.offsetHeight + 'px';
    }
    else {
        th.parentNode.style.border = '1px solid #fff';
        th.parentNode.style.height = th.parentNode.offsetHeight - 2 + 'px';
        //th.parentNode.style.border = '0';
    }
    th.parentNode.style.position = 'relative';
    th.style.zIndex = 10;
    CSS.AddClass(th, 'author-infolist-expand');
    th.onmouseout || (
        th.onmouseout = function () {
            th.display = false;
            th.style.zIndex = 0;
            th.parentNode.style.position = 'static';
            CSS.RemoveClass(th, 'author-infolist-expand');
            th.parentNode.style.height = 'auto';
        }
    )
    return;

    ///
    showMemberInfo.tip && (showMemberInfo.tip.style.visibility = 'hidden');
    Events.RemoveEvent(document, 'mousemove', showMemberInfo.mousemove);

    var url = th.getElementsByTagName('a');
    if (!url || !url[0]) return;
    url = url[0].href;
    var arr = /userid=(\d+)/i.exec(url);
    var id = arr && arr[1] ? arr[1] : 0;
    if (!id) return;

    // 显示
    var tip = showMemberInfo.tip = $('userid_' + id);
    if (!tip.ispopup) {
        tip.ispopup = true;
        oNode.RemoveNode(tip, tip.parentNode);
        oNode.AddNode(tip, document.body);
        PopUp.Panel(tip);
        PopUp.AddPopUp(tip);
    }
    tip.display = true;
    tip.style.visibility = 'visible';
    tip.style.left = Global.GetOffsetLeft(th) - 10 + 'px';
    tip.style.top = Global.GetOffsetTop(th) - 4 + 'px';

    var mousemove = showMemberInfo.mousemove = function (e) {
        if (!tip.display) return;
        var obj = $EO(e);
        while (obj) {
            if (obj == tip) {
                break;
            }
            obj = obj.parentNode;
        }
        if (!obj) {
            tip.display = false;
            tip.style.visibility = 'hidden';
            Events.RemoveEvent(document, 'mousemove', mousemove);
        }
        Events.CancelAll(e);
    }
    setTimeout(function () {Events.AttachEvent(document, 'mousemove', mousemove)}, 10);
*/
}

//
// 表情标题滚动
function scrollFaceTitle () {
    var list = $('face_title_list');
    if (!list) return;
    var w = 0;
    var titles = list.getElementsByTagName('div');
    for (var i = 0; i < titles.length; i++) {
        if (i == 0) {
            titles[i].className = 'focus';
            viewGroup.current = titles[i];
        }
        w += titles[i].offsetWidth + 2;
    }
    w += 2;
    list.style.width = w + 'px';
    list.style.left = '0';
    $('face_title').style.overflow = 'hidden';
    // 滚动
    var scope = $('face_title').offsetWidth - $('control').offsetWidth;

    if (w < scope) {
        $('face_prev').style.display = 'none';
        $('face_next').style.display = 'none';
        return;
    }
    
    var step = 60;
    $('face_prev').onclick = function () {
        var l = parseInt(list.style.left);
        if (l + step > 0) l = 0;
        else l += step;
        list.style.left = l + 'px';
    };
    $('face_next').onclick = function () {
        var l = parseInt(list.style.left);
        if (l - step + w < scope) l = scope - w ;
        else l -= step;
        list.style.left = l + 'px';
    };

/*
    var dir;
    var step = 5;
    var interval = 0;
    function startMove () {
        var l = parseInt(list.style.left);
        if (dir) {
            if (l - step + w < scope) l = scope - w ;
            else l -= step;
        }
        else {
            if (l + step > 0) l = 0;
            else l += step;
        }
        list.style.left = l + 'px';
        interval = setTimeout(startMove, 30);
    }
    function stopMove () {
        clearTimeout(interval);
    }

    $('face_prev').onmouseover = function () {
        dir = 0;
        startMove();
    };
    $('face_prev').onmouseout = function () {
        stopMove();
    };
    $('face_next').onmouseover = function () {
        dir = 1;
        startMove();
    };
    $('face_next').onmouseout = function () {
        stopMove();
    };
*/
}
// 浏览分组
function viewGroup (th, url) {
    if (viewGroup.current)
        viewGroup.current.className = '';
    viewGroup.current = th;
    th.className = 'focus';
    AjaxRequest.Render(url);
}
// 添加表情到内容框
function addFace (src) {
    var enableHtml = $('enableHtml');
    var enableMaxCode = $('enableMaxCode');
    var str = '';
    if (enableMaxCode && enableMaxCode.checked) {
        str = '[img]' + src + '[/img]'
    }
    else if (enableHtml && enableMaxCode.checked) {
        str = '<img src="' + src + '" />';
    }
    if (str) {
        var editor = $('Editor')
        editor && (editor.value += str);
    }
}
function showPreview (th, src) {
    //
    var preview = $('face_preview');
    var container = $('preview_container');
    var img = oNode.CreateNode('img');
    oNode.AddNode(img, container);
    img.onload = function () {
        if (!this.parentNode) return;
        AvatarLoaded(this);
        preview.style.visibility = 'visible';
    };
    img.width = preview.offsetWidth;
    img.height = preview.offsetHeight;
    img.src = src;

    var l = Global.GetOffsetLeft(th, $('face_list'));
    preview.style.left = l > 100 ? '10px' : 'auto';
    preview.style.right = l > 100 ? 'auto' : '10px';

    th.onmouseout || (th.onmouseout = hidePreview);
}
function hidePreview () {
    //
    $('preview_container').innerHTML = '';
    $('face_preview').style.visibility = 'hidden';
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -