📄 common.js
字号:
if(!obj) {
return;
}
obj.onload = null;
file = obj.src;
zw = obj.offsetWidth;
zh = obj.offsetHeight;
if(zw < 2) {
if(!obj.id) {
obj.id = 'img_' + Math.random();
}
setTimeout("thumbImg($('" + obj.id + "'), " + method + ")", 100);
return;
}
zr = zw / zh;
method = !method ? 0 : 1;
if(method) {
fixw = obj.getAttribute('_width');
fixh = obj.getAttribute('_height');
if(zw > fixw) {
zw = fixw;
zh = zw / zr;
}
if(zh > fixh) {
zh = fixh;
zw = zh * zr;
}
} else {
fixw = typeof imagemaxwidth == 'undefined' ? '600' : imagemaxwidth;
if(zw > fixw) {
zw = fixw;
zh = zw / zr;
obj.style.cursor = 'pointer';
if(!obj.onclick) {
obj.onclick = function() {
zoom(obj, obj.src);
};
}
}
}
obj.width = zw;
obj.height = zh;
}
var zoomstatus = 1;
function zoom(obj, zimg, nocover, pn) {
$F('_zoom', arguments);
}
function showselect(obj, inpid, t, rettype) {
$F('_showselect', arguments);
}
function showColorBox(ctrlid, layer, k, bgcolor) {
$F('_showColorBox', arguments);
}
function ctrlEnter(event, btnId, onlyEnter) {
if(isUndefined(onlyEnter)) onlyEnter = 0;
if((event.ctrlKey || onlyEnter) && event.keyCode == 13) {
$(btnId).click();
return false;
}
return true;
}
function parseurl(str, mode, parsecode) {
if(isUndefined(parsecode)) parsecode = true;
if(parsecode) str= str.replace(/\s*\[code\]([\s\S]+?)\[\/code\]\s*/ig, function($1, $2) {return codetag($2);});
str = str.replace(/([^>=\]"'\/@]|^)((((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|qqdl|synacast):\/\/))([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&;~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]');
str = str.replace(/([^\w>=\]"'\/@]|^)((www\.)([\w\-]+\.)*[:\.@\-\w\u4e00-\u9fa5]+\.([\.a-zA-Z0-9]+|\u4E2D\u56FD|\u7F51\u7EDC|\u516C\u53F8)((\?|\/|:)+[\w\.\/=\?%\-&;~`@':+!#]*)*)/ig, mode == 'html' ? '$1<a href="$2" target="_blank">$2</a>' : '$1[url]$2[/url]');
str = str.replace(/([^\w->=\]:"'\.\/]|^)(([\-\.\w]+@[\.\-\w]+(\.\w+)+))/ig, mode == 'html' ? '$1<a href="mailto:$2">$2</a>' : '$1[email]$2[/email]');
if(parsecode) {
for(var i = 0; i <= DISCUZCODE['num']; i++) {
str = str.replace("[\tDISCUZ_CODE_" + i + "\t]", DISCUZCODE['html'][i]);
}
}
return str;
}
function codetag(text) {
DISCUZCODE['num']++;
if(typeof wysiwyg != 'undefined' && wysiwyg) text = text.replace(/<br[^\>]*>/ig, '\n').replace(/<(\/|)[A-Za-z].*?>/ig, '');
DISCUZCODE['html'][DISCUZCODE['num']] = '[code]' + text + '[/code]';
return '[\tDISCUZ_CODE_' + DISCUZCODE['num'] + '\t]';
}
function saveUserdata(name, data) {
if(BROWSER.ie){
if(data.length < 54889) {
with(document.documentElement) {
setAttribute("value", data);
save('Discuz_' + name);
}
}
} else if(window.localStorage){
localStorage.setItem('Discuz_' + name, data);
} else if(window.sessionStorage){
sessionStorage.setItem('Discuz_' + name, data);
}
setcookie('clearUserdata', '', -1);
}
function loadUserdata(name) {
if(BROWSER.ie){
with(document.documentElement) {
load('Discuz_' + name);
return getAttribute("value");
}
} else if(window.localStorage){
return localStorage.getItem('Discuz_' + name);
} else if(window.sessionStorage){
return sessionStorage.getItem('Discuz_' + name);
}
}
function initTab(frameId, type) {
$F('_initTab', arguments);
}
function openDiy(){
window.location.href = ((window.location.href + '').replace(/[\?\&]diy=yes/g, '').split('#')[0] + ( window.location.search && window.location.search.indexOf('?diy=yes') < 0 ? '&diy=yes' : '?diy=yes'));
}
function hasClass(elem, className) {
return elem.className && (" " + elem.className + " ").indexOf(" " + className + " ") != -1;
}
function runslideshow() {
$F('_runslideshow', []);
}
function toggle_collapse(objname, noimg, complex, lang) {
$F('_toggle_collapse', arguments);
}
function updatestring(str1, str2, clear) {
str2 = '_' + str2 + '_';
return clear ? str1.replace(str2, '') : (str1.indexOf(str2) == -1 ? str1 + str2 : str1);
}
function getClipboardData() {
window.document.clipboardswf.SetVariable('str', CLIPBOARDSWFDATA);
}
function setCopy(text, msg) {
$F('_setCopy', arguments);
}
function copycode(obj) {
$F('_copycode', arguments);
}
function showdistrict(container, elems, totallevel, changelevel, containertype) {
$F('_showdistrict', arguments);
}
function setDoodle(fid, oid, url, tid, from) {
$F('_setDoodle', arguments);
}
function initSearchmenu(searchform, cloudSearchUrl) {
var defaultUrl = 'search.php?searchsubmit=yes';
if(typeof cloudSearchUrl == "undefined" || cloudSearchUrl == null || cloudSearchUrl == '') {
cloudSearchUrl = defaultUrl;
}
var searchtxt = $(searchform + '_txt');
if(!searchtxt) {
searchtxt = $(searchform);
}
var tclass = searchtxt.className;
searchtxt.className = tclass + ' xg1';
searchtxt.onfocus = function () {
if(searchtxt.value == '请输入搜索内容') {
searchtxt.value = '';
searchtxt.className = tclass;
}
};
searchtxt.onblur = function () {
if(searchtxt.value == '' ) {
searchtxt.value = '请输入搜索内容';
searchtxt.className = tclass + ' xg1';
}
};
if(!$(searchform + '_type_menu')) return false;
var o = $(searchform + '_type');
var a = $(searchform + '_type_menu').getElementsByTagName('a');
var formobj = searchtxt.form;
for(var i=0; i<a.length; i++){
if(a[i].className == 'curtype'){
o.innerHTML = a[i].innerHTML;
$(searchform + '_mod').value = a[i].rel;
formobj.method = 'post';
if((a[i].rel == 'forum' || a[i].rel == 'curforum') && defaultUrl != cloudSearchUrl) {
formobj.action = cloudSearchUrl;
formobj.method = 'get';
} else {
formobj.action = defaultUrl;
}
if($('cloudsearchforumId')) {
$('cloudsearchforumId').value = '0';
if (a[i].rel == 'curforum') {
$('cloudsearchforumId').value = $('dzsearchforumid').value
}
}
}
a[i].onclick = function(){
o.innerHTML = this.innerHTML;
$(searchform + '_mod').value = this.rel;
formobj.method = 'post';
if((this.rel == 'forum' || this.rel == 'curforum') && defaultUrl != cloudSearchUrl) {
formobj.action = cloudSearchUrl;
formobj.method = 'get';
} else {
formobj.action = defaultUrl;
}
if($('cloudsearchforumId')) {
$('cloudsearchforumId').value = '0';
if (this.rel == 'curforum') {
$('cloudsearchforumId').value = $('dzsearchforumid').value
}
}
};
}
}
function searchFocus(obj) {
if(obj.value == '请输入搜索内容') {
obj.value = '';
}
if($('cloudsearchquery') != null) {
$('cloudsearchquery').value = obj.value;
}
}
function extstyle(css) {
$F('_extstyle', arguments);
}
function widthauto(obj) {
$F('_widthauto', arguments);
}
var secST = new Array();
function updatesecqaa(idhash) {
$F('_updatesecqaa', arguments);
}
function updateseccode(idhash, play) {
$F('_updateseccode', arguments);
}
function checksec(type, idhash, showmsg, recall) {
$F('_checksec', arguments);
}
function createPalette(colorid, id, func) {
$F('_createPalette', arguments);
}
function cardInit() {
var cardShow = function (obj) {
if(BROWSER.ie && BROWSER.ie < 7 && obj.href.indexOf('username') != -1) {
return;
}
pos = obj.getAttribute('c') == '1' ? '43' : obj.getAttribute('c');
USERCARDST = setTimeout(function() {ajaxmenu(obj, 500, 1, 2, pos, null, 'p_pop card');}, 250);
};
var a = document.body.getElementsByTagName('a');
for(var i = 0;i < a.length;i++){
if(a[i].getAttribute('c')) {
a[i].setAttribute('mid', hash(a[i].href));
a[i].onmouseover = function() {cardShow(this)};
a[i].onmouseout = function() {clearTimeout(USERCARDST);};
}
}
}
function navShow(id) {
var mnobj = $('snav_mn_' + id);
if(!mnobj) {
return;
}
var uls = $('mu').getElementsByTagName('ul');
for(i = 0;i < uls.length;i++) {
if(uls[i].className != 'cl current') {
uls[i].style.display = 'none';
}
}
if(mnobj.className != 'cl current') {
showMenu({'ctrlid':'mn_' + id,'menuid':'snav_mn_' + id,'pos':'*'});
mnobj.className = 'cl floatmu';
mnobj.style.width = ($('nv').clientWidth) + 'px';
mnobj.style.display = '';
}
}
function strLenCalc(obj, checklen, maxlen) {
var v = obj.value, charlen = 0, maxlen = !maxlen ? 200 : maxlen, curlen = maxlen, len = strlen(v);
for(var i = 0; i < v.length; i++) {
if(v.charCodeAt(i) < 0 || v.charCodeAt(i) > 255) {
curlen -= charset == 'utf-8' ? 2 : 1;
}
}
if(curlen >= len) {
$(checklen).innerHTML = curlen - len;
} else {
obj.value = mb_cutstr(v, maxlen, true);
}
}
function noticeTitle() {
NOTICETITLE = {'State':0, 'oldTitle':document.title, flashNumber:0, sleep:15};
if(!getcookie('noticeTitle')) {
window.setInterval('noticeTitleFlash();', 500);
} else {
window.setTimeout('noticeTitleFlash();', 500);
}
setcookie('noticeTitle', 1, 600);
}
function noticeTitleFlash() {
if(NOTICETITLE.flashNumber < 5 || NOTICETITLE.flashNumber > 4 && !NOTICETITLE['State']) {
document.title = (NOTICETITLE['State'] ? '【 】' : '【新提醒】') + NOTICETITLE['oldTitle'];
NOTICETITLE['State'] = !NOTICETITLE['State'];
}
NOTICETITLE.flashNumber = NOTICETITLE.flashNumber < NOTICETITLE.sleep ? ++NOTICETITLE.flashNumber : 0;
}
function relatedlinks(rlinkmsgid) {
$F('_relatedlinks', arguments);
}
function con_handle_response(response) {
return response;
}
function showTopLink() {
if($('ft')){
var viewPortHeight = parseInt(document.documentElement.clientHeight);
var scrollHeight = parseInt(document.body.getBoundingClientRect().top);
var basew = parseInt($('ft').clientWidth);
var sw = $('scrolltop').clientWidth;
if (basew < 1000) {
var left = parseInt(fetchOffset($('ft'))['left']);
left = left < sw ? left * 2 - sw : left;
$('scrolltop').style.left = ( basew + left ) + 'px';
} else {
$('scrolltop').style.left = 'auto';
$('scrolltop').style.right = 0;
}
if (BROWSER.ie && BROWSER.ie < 7) {
$('scrolltop').style.top = viewPortHeight - scrollHeight - 150 + 'px';
}
if (scrollHeight < -100) {
$('scrolltop').style.visibility = 'visible';
} else {
$('scrolltop').style.visibility = 'hidden';
}
}
}
function showCreditmenu() {
$F('_showCreditmenu', []);
}
function showUpgradeinfo() {
showMenu({'ctrlid':'g_upmine', 'pos':'21'});
}
function addFavorite(url, title) {
try {
window.external.addFavorite(url, title);
} catch (e){
try {
window.sidebar.addPanel(title, url, '');
} catch (e) {
showDialog("请按 Ctrl+D 键添加到收藏夹", 'notice');
}
}
}
function setHomepage(sURL) {
if(BROWSER.ie){
document.body.style.behavior = 'url(#default#homepage)';
document.body.setHomePage(sURL);
} else {
showDialog("非 IE 浏览器请手动将本站设为首页", 'notice');
doane();
}
}
function smilies_show(id, smcols, seditorkey) {
$F('_smilies_show', arguments, 'smilies');
}
if(typeof IN_ADMINCP == 'undefined') {
if(creditnotice != '' && getcookie('creditnotice')) {
_attachEvent(window, 'load', showCreditPrompt, document);
}
if(typeof showusercard != 'undefined' && showusercard == 1) {
_attachEvent(window, 'load', cardInit, document);
}
}
if(BROWSER.ie) {
document.documentElement.addBehavior("#default#userdata");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -