📄 common.js
字号:
flow.style.top = '-1000px';
};
function sameSetting (th, tagId) {
$(tagId).style.display = !th.checked ? '' : 'none';
}
// 拷贝到剪贴板
function copyToClipboard (txt) {
if(window.clipboardData) {
window.clipboardData.clearData();
window.clipboardData.setData("Text", txt);
}
else if(navigator.userAgent.indexOf("Opera") != -1) {
window.location = txt;
}
else if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch (e) {
alert("被浏览器拒绝!\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
return;
}
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip)
return;
var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans)
return;
trans.addDataFlavor('text/unicode');
var str = new Object();
var len = new Object();
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
var copytext = txt;
str.data = copytext;
trans.setTransferData("text/unicode",str,copytext.length * 2);
var clipid = Components.interfaces.nsIClipboard;
if (!clip)
return;
clip.setData(trans, null, clipid.kGlobalClipboard);
}
alert("复制成功!");
}
// 头像加载成功处理
function AvatarLoaded (th, nonMargin) {//alert(th);
th.onload = null;
th.onerror = null;
function reload () {
if (th.width == 0 && th.height == 0) {
setTimeout(reload, 10);
return;
}
th.style.visibility = 'inherit';
var w = th.width, h = th.height;
th.style.width = 'auto';
th.style.height = 'auto';
w && h && imageScale(th, w, h, !!nonMargin);
th.parentNode && (th.parentNode.style.backgroundImage = 'url(' + BBSMAX.SpaceImage + ')');
}
reload();
}
// 头像加载错误处理
function AvatarError (th, defaultImage) {
th.onload = null;
th.onerror = null;
//th.src = BBSMAX.AvatarDefault;
//th.style.width = 'auto';
//th.style.height = 'auto';
th.src = BBSMAX.SpaceImage;
th.parentNode && (th.parentNode.style.background = 'url(' + (defaultImage || BBSMAX.AvatarDefault) + ') no-repeat center center');
//th.style.visibility = 'visible';
}
function PictureError (th) {
var value = th.src;
var index = value.lastIndexOf('.');
var ext;
/*
if (value == '' || index == -1)
ext = 'default';
else
ext = value.substr(index + 1).toLowerCase();
if (!BBSMAX.NetExistsExtImage.test(ext))
ext = 'default';
*/
ext = BBSMAX.NetExistsPath + 'exe.gif';
th.parentNode.innerHTML = '<img src="' + ext + '" style="margin: ' + (BBSMAX.NetDefaultHeight - BBSMAX.NetExistsHeight) + 'px 0 0;" />';
//AvatarError(th, ext);
}
// 帖子内图片加载成功处理
function ImageLoaded (th, w, h) {
if (th.width == 0 && th.height == 0) {
setTimeout(function () {ImageLoaded (th, w, h)}, 10);
return;
}
if (typeof ImageLoaded.List == 'undefined')
ImageLoaded.List = [];
ImageLoaded.List.push({src:th.src,ow:th.width,oh:th.height});
th.index = ImageLoaded.List.length - 1;
if (typeof ImageLoaded.container == 'undefined') {
var c = ImageLoaded.container = oNode.CreateNode('div');
//oNode.InsertBefore(c, document.body.firstChild);
//c.style.zIndex = 1000;
c.innerHTML = [
'<!-- 帖子图片浮动提示层 -->',
'<div id="image_tip_container" class="imageviewer-tips" style="position:absolute;left:0;top:0;display:none;">',
' <span id="image_tip_save_container"><a href="javascript:;" id="image_tip_save">保存</a> - </span><a href="javascript:;" id="image_tip_newin">在新窗口打开</a>',
'</div>',
'<!-- 帖子图片浏览 -->',
'<div id="image_viewer_container" style="position:absolute;left:0;top:0;">',
'<div id="image_viewer" class="imageviewer" style="display:none;">',
' <p class="imageviewer-control" style="position:absolute;z-index:1;">',
' <a href="javascript:;" id="image_viewer_zoomin" class="imageviewer-zoomin" title="放大">放大</a>',
' <a href="javascript:;" id="image_viewer_zoomout" class="imageviewer-zoomout" title="缩小">缩小</a>',
' <a href="javascript:;" id="image_viewer_origin" class="imageviewer-origin" title="实际大小">原始大小</a>',
' <a href="javascript:;" id="image_viewer_intro" class="imageviewer-screensize" title="推荐大小">原始推荐大小</a>',
' <a href="javascript:;" id="image_viewer_open" class="imageviewer-open" title="新窗口打开">新窗口打开</a>',
' <a href="javascript:;" id="image_viewer_close" class="imageviewer-closer" title="关闭">关闭</a>',
' </p>',
' <div id="image_viewer_move" style="position:absolute;left:0;top:0;background-image:url(\'' + BBSMAX.SpaceImage + '\');"></div>',
' <div id="image_viewer_img"></div>',
'</div>',
'</div>'].join('');
}
Events.OnLoadTasks[Events.OnLoadTasks.length] = function () {
oNode.AddNode(ImageLoaded.container);
// 显示尺寸范围控制
if (s.w <= 100 && s.w <= 100) return;
th.style.border = '1px solid #fff';
th.style.padding = '2px';
/// tip
var tip = $('image_tip_container');
th.onmouseover = function () {
show();
tip.style.left = Global.GetOffsetLeft(this) + 'px';
tip.style.top = Global.GetOffsetTop(this) + 'px';
tip.onmouseover = function () {
show();
};
tip.onmouseout = function () {
hide();
};
var _self = /Attachment\.aspx\?ID=\d+(?:&\?mode=image)?/i.test(th.src);
$('image_tip_save_container').style.display = _self ? '' : 'none';
$('image_tip_save').onclick = function () {
window.open(th.src.replace(/&?mode=image/i, ''), Browser.IsIE56 ? '_blank' : '_self');
};
$('image_tip_newin').onclick = function () {
newin();
};
};
th.onmouseout = function () {
hide();
};
function show () {
if (ImageLoaded.interval) {
clearTimeout(ImageLoaded.interval);
ImageLoaded.intervalFunc();
}
th.style.background = '#fff';
th.style.borderColor = '#666';
tip && (tip.style.display = '');
}
function hide () {
ImageLoaded.intervalFunc = function () {
tip && (tip.style.display = 'none');
th.style.background = 'transparent';
th.style.borderColor = '#fff';
}
ImageLoaded.interval = setTimeout(ImageLoaded.intervalFunc, 100);
}
};
function newin () {
var win = window.open('about:blank');
win.document.open();
win.document.write('<img src="' + th.src + '">');
win.document.close();
}
th.onload = null;
th.onerror = null;
th.style.backgroundImage = 'url(' + BBSMAX.SpaceImage + ')';
// 原尺寸
var img = new Image();
img.src = th.src;
var W = img.width;
var H = img.height;
// 自动缩放显示的尺寸
var ow = w = th.width;
var oh = h = th.height;
var s = oImage.Scale(w, h, Global.GetClientWidth() * 0.9, h);
th.width = s.w;
th.height = s.h;
/// view
s = oImage.Scale(w, h, Global.GetClientWidth() * 0.9, Global.GetClientHeight() * 0.9);
var iw = w = s.w;
var ih = h = s.h;
/*
$('image_viewer_container').style.overflow = 'hidden';
$('image_viewer_container').style.border = '1px solid #f00';
$('image_viewer_container').style.width = Global.GetDocWidth() + 'px';
$('image_viewer_container').style.height = Global.GetDocHeight() + 'px';
*/
// 原始尺寸范围
if (W > 100 || H > 100)
th.onclick = function () {
//document.getElementsByTagName('html')[0].style.overflow = 'hidden';
//document.getElementsByTagName('body')[0].style.overflow = 'hidden';
var panel = PopUp.Panel($('image_viewer'));
PopUp.AddPopUp(panel, true);
PopUp.AddMask(panel);
panel.style.display = '';
panel.style.backgroundColor = '#fff';
$('image_viewer_img').innerHTML = '<img id="image_viewer_object" src="' + th.src + '" width="' + w + '" height="' + h + '" />';
panel.Center(true);
// 淡入
var node = $('image_viewer_object');
var alpha = 0;
var gradual = function () {
if (alpha > 100) {
CSS.SetAlpha(node, 100);
return;
}
CSS.SetAlpha(node, alpha);
alpha += 15;
setTimeout(gradual, 0);
}
gradual();
panel.$D.style.background = '#000';
var _alpha = 60;
CSS.SetAlpha(panel.$D, _alpha);
//document.body.style.overflow = 'hidden';
var relateBody = true;
var moveObj = $('image_viewer_move')
Effects.Move(moveObj, panel, {modal:false, relateBody:relateBody, upFunc:function (e, p) {
if (p[0] == p[2] && p[1] == p[3]) {
_close();
return;
}
ox = parseInt(panel.style.left) + panel.offsetWidth / 2;
oy = parseInt(panel.style.top) + panel.offsetHeight / 2;
}});
moveObj.style.width = panel.offsetWidth + 'px';
moveObj.style.height = panel.offsetHeight + 'px';
moveObj.style.lineHeight = panel.offsetHeight + 'px';
moveObj.style.fontWeight = 'bolder';
moveObj.style.textAlign = 'center';
moveObj.style.color = '#fff';
PopUp.ResetSize(panel);
Events.AttachEvent(window, 'resize', function () {
panel.$D.Show();
PopUp.ResetXY(panel);
})
// 放大
$('image_viewer_zoomin').onclick = function () {
zoomIn();
};
// 缩小
$('image_viewer_zoomout').onclick = function () {
zoomOut();
};
// 原图尺寸
$('image_viewer_origin').onclick = function () {
_w = ow;
_h = oh;
resize();
};
// 推荐大小
$('image_viewer_intro').onclick = function () {
_w = iw;
_h = ih;
resize();
};
// 新窗口
$('image_viewer_open').onclick = function () {
newin();
};
// 关闭
$('image_viewer_close').onclick = function () {
_close();
//document.body.style.overflow = 'auto';
};
function _close () {
panel.RemoveEvent();
mw.RemoveEvent();
// 淡出
var node = panel.$D;
var alpha = _alpha;
var gradual = function () {
if (alpha < 0) {
panel.$D.Hide();
CSS.SetAlpha(node, 0);
PopUp.RestorePopUp(panel);
return;
}
CSS.SetAlpha(node, alpha);
alpha -= 25;
setTimeout(gradual, 0);
}
gradual();
panel.style.display = 'none';
//PopUp.RestorePopUp(panel);
//document.getElementsByTagName('html')[0].style.overflow = 'auto';
//document.getElementsByTagName('body')[0].style.overflow = 'auto';
}
var _w = w, _h = h;
var mw = new MouseWheel();
mw.Handle = function (delta) {
delta < 0 ? zoomOut() : zoomIn();
};
var zoom = '';
function zoomIn () {
_w += _w * 0.1;
_h += _h * 0.1;
if (_w >= 3 / 2 * w || _h >= 3 / 2 * h) {
_w = 3 / 2 * w;
_h = 3 / 2 * h;
zoom = '150';
}
else {
zoom = '';
}
resize();
}
function zoomOut () {
_w -= _w * 0.1;
_h -= _h * 0.1;
if (_w <= w / 2 || _h <= h / 2) {
_w = w / 2;
_h = h / 2;
zoom = '50';
}
else {
zoom = '';
}
resize();
}
var interval;
var ox = parseInt(panel.style.left) + panel.offsetWidth / 2;
var oy = parseInt(panel.style.top) + panel.offsetHeight / 2;
function resize () {
clearTimeout(interval);
CSS.SetAlpha(moveObj, alpha = 60);
var img = $('image_viewer_object');
img.style.width = _w + 'px';
img.style.height = _h + 'px';
panel.style.left = ox - panel.offsetWidth / 2 + 'px';//(relateBody ? Global.GetScrollLeft() : 0) + (Global.GetClientWidth() - _w) / 2 + 'px';
panel.style.top = oy - panel.offsetHeight / 2 + 'px';//(relateBody ? Global.GetScrollTop() : 0) + (Global.GetClientHeight() - _h) / 2 + 'px';
moveObj.style.width = panel.offsetWidth + 'px';
moveObj.style.height = panel.offsetHeight + 'px';
moveObj.style.lineHeight = panel.offsetHeight + 'px';
moveObj.innerHTML = '<strong style="padding: 50px;background:transparent url(' + BBSMAX.ImagePreviewBg + ') no-repeat center center;">' + (zoom || Math.floor(_w * 100 / ow)) + '%' + '</strong>';
PopUp.ResetSize(panel);
interval = setTimeout(setAlpha, 2000);
}
var alpha = 60;
function setAlpha () {
if (alpha <= 0) return;
alpha -= 5;
CSS.SetAlpha(moveObj, alpha);
interval = setTimeout(setAlpha, 8);
}
};
}
/*
function ImageLoaded (th) {
th.onload = null;
th.onerror = null;
th.style.width = 'auto';
th.style.height = 'auto';
th.style.background = 'url()';
}
*/
// 帖子内图片加载错误处理
function ImageError (th) {
th.error = true;
th.onload = null;
th.onerror = null;
th.src = BBSMAX.ImageDefault;
th.style.width = 'auto';
th.style.height = 'auto';
th.style.background = 'url()';
}
// 显示附件信息
function showAttachment (th) {
var tip = $('attachment');
if (!tip.ispopup) {
tip.ispopup = true;
PopUp.Panel(tip);
PopUp.AddPopUp(tip);
}
tip.style.display = 'block';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -