?? common.js
字號:
smiliewindow = window.open('post.php?action=smilies' + (editorid ? '&editorid=' + editorid : ''), 'Popup', 'width=' + width + ',height=' + height + ',resizable=yes,scrollbars=yes');
window.onunload = closesmiliewindow;
}
function mb_strlen(str) {
return (is_ie && str.indexOf('\n') != -1) ? str.replace(/\r?\n/g, '_').length : str.length;
}
function insertSmiley(smilieid) {
checkFocus();
var src = $('smilie_' + smilieid).src;
var code = $('smilie_' + smilieid).pop;
if(typeof wysiwyg != 'undefined' && wysiwyg && allowsmilies && (!$('smileyoff') || $('smileyoff').checked == false)) {
if(is_moz) {
applyFormat('InsertImage', false, src);
var smilies = findtags(editdoc.body, 'img');
for(var i = 0; i < smilies.length; i++) {
if(smilies[i].src == src && smilies[i].getAttribute('smilieid') < 1) {
smilies[i].setAttribute('smilieid', smilieid);
smilies[i].setAttribute('border', "0");
}
}
} else {
insertText('<img src="' + src + '" border="0" smilieid="' + smilieid + '" alt="" /> ', false);
}
} else {
code += ' ';
AddText(code);
}
}
function announcement() {
$('announcement').innerHTML = '<marquee style="filter:progid:DXImageTransform.Microsoft.Alpha(startX=0, startY=0, finishX=10, finishY=100,style=1,opacity=0,finishOpacity=100); margin: 0px 8px" direction="left" scrollamount="2" scrolldelay="1" onMouseOver="this.stop();" onMouseOut="this.start();">' +
$('announcement').innerHTML + '</marquee>';
$('announcement').style.display = 'block';
}
function $(id) {
return document.getElementById(id);
}
function $f(id) {
return document.getElementById(ID).value;
}
function in_array(needle, haystack) {
if(typeof needle == 'string') {
for(var i in haystack) {
if(haystack[i] == needle) {
return true;
}
}
}
return false;
}
document.write("<style type='text/css' id='defaultPopStyle'>");
document.write(".cPopText { font-family: Tahoma, Verdana; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; line-height: 18px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80)}");
document.write("</style>");
document.write("<div id='popLayer' style='position:absolute;z-index:1000' class='cPopText'></div>");
function showPopupText(event) {
if(event.srcElement) o = event.srcElement; else o = event.target;
if(!o) {
return;
}
MouseX = event.clientX;
MouseY = event.clientY;
if(o.alt != null && o.alt != '') {
o.pop = o.alt;
o.alt = '';
}
if(o.title != null && o.title != '') {
o.pop = o.title;
o.title = '';
}
if(o.pop != sPop) {
sPop = o.pop;
if(sPop == null || sPop == '') {
$('popLayer').style.visibility = "hidden";
} else {
popStyle = o.dyclass != null ? o.dyclass : 'cPopText';
$('popLayer').style.visibility = "visible";
showIt();
}
}
}
function showIt() {
$('popLayer').className = popStyle;
$('popLayer').innerHTML = sPop.replace(/<(.*)>/g,"<$1>").replace(/\n/g,"<br>");
var popWidth = $('popLayer').clientWidth;
var popHeight = $('popLayer').clientHeight;
var popLeftAdjust = MouseX + 12 + popWidth > document.body.clientWidth ? -popWidth - 24 : 0;
var popTopAdjust = MouseY + 12 + popHeight > document.body.clientHeight ? -popHeight - 24 : 0;
$('popLayer').style.left = (MouseX + 12 + document.body.scrollLeft + popLeftAdjust) + 'px';
$('popLayer').style.top = (MouseY + 12 + document.body.scrollTop + popTopAdjust) + 'px';
}
if(!document.onmouseover) {
document.onmouseover = function(e) {
var event = e ? e : window.event;
showPopupText(event);
};
}
// ==page's== //
function showPages(name) { //初始化屬性
this.name = name; //對象名稱
this.page = 1; //當(dāng)前頁數(shù)
this.pageCount = 1; //總頁數(shù)
this.dispCount = 1; //所有貼數(shù)
this.argName = 'page'; //參數(shù)名
this.showTimes = 1; //打印次數(shù)
}
showPages.prototype.getPage = function(){ //叢url獲得當(dāng)前頁數(shù),如果變量重復(fù)只獲取最后一個
var args = location.search;
var reg = new RegExp('[\?&]?' + this.argName + '=([^&]*)[&$]?', 'gi');
var chk = args.match(reg);
this.page = RegExp.$1;
}
showPages.prototype.checkPages = function(){ //進行當(dāng)前頁數(shù)和總頁數(shù)的驗證
if (isNaN(parseInt(this.page))) this.page = 1;
if (isNaN(parseInt(this.pageCount))) this.pageCount = 1;
if (this.page < 1) this.page = 1;
if (this.pageCount < 1) this.pageCount = 1;
this.page = parseInt(this.page);
this.pageCount = parseInt(this.pageCount);
if (this.page > this.pageCount) this.page = this.pageCount;
}
showPages.prototype.createHtml = function(mode){ //生成html代碼
var ispages = parseInt(this.page);
var strHtml = '', prevPage = ispages - 1, nextPage = ispages + 1;
strHtml += '<table width="100%" cellspacing="0" cellpadding="0" align="center" style="margin-bottom: 4px"><tr><td valign="bottom"><div class="p_bar"> <a class="p_total">' + this.dispCount + '</a> <a class="p_pages">' + ispages + '/' + this.pageCount + '</a>';
if (prevPage < 1) {
strHtml += '<a class="p_num">«</a>';
strHtml += '<a class="p_num">‹</a>';
} else {
strHtml += '<a href="javascript:' + this.name + '.toPage(1);" class="p_num">«</a>';
strHtml += '<a href="javascript:' + this.name + '.toPage(' + prevPage + ');" class="p_num">‹</a>';
}
if (ispages % 10 ==0) {
var startPage = ispages - 9;
} else {
var startPage = ispages - ispages % 10 + 1;
}
if (startPage > 10) strHtml += '<a href="javascript:' + this.name + '.toPage(' + (startPage - 1) + ');" class="p_num">...</a>';
for (var i = startPage; i < startPage + 10; i++) {
if (i > this.pageCount) break;
if (i == ispages) {
strHtml += '<a class="p_curpage" title="Page ' + i + '" >' + i + '</a>';
} else {
strHtml += '<span title="Page ' + i + '"><a href="javascript:' + this.name + '.toPage(' + i + ');" class="p_num">' + i + '</a></span>';
}
}
if (this.pageCount >= startPage + 10) strHtml += '<span title="Next 10 Pages"><a href="javascript:' + this.name + '.toPage(' + (startPage + 10) + ');" class="p_num">...</a></span>';
if (nextPage > this.pageCount) {
strHtml += '<a class="p_num" title="Next Page">›</a>';
strHtml += '<a class="p_num" title="Last Page">»</a>';
} else {
strHtml += '<span title="Next Page"><a class="p_num" href="javascript:' + this.name + '.toPage(' + nextPage + ');">›</a></span>';
strHtml += '<span title="Last Page"><a class="p_num" href="javascript:' + this.name + '.toPage(' + this.pageCount + ');">»</a></span>';
}
strHtml += '<input type="text" id="pageInput' + this.showTimes + '" value="' + ispages + '" title="Input page" onkeypress="return ' + this.name + '.formatInputPage(event);" onfocus="this.select()" size="1"> <input type="button" name="go" value="GO" onclick="' + this.name + '.toPage(document.getElementById(\'pageInput' + this.showTimes + '\').value);"></div></td><td align="right" valign="bottom"></td></tr></table>';
return strHtml;
}
showPages.prototype.createUrl = function (page) { //生成頁面跳轉(zhuǎn)url
if (isNaN(parseInt(page))) page = 1;
if (page < 1) page = 1;
if (page > this.pageCount) page = this.pageCount;
var url = location.protocol + '//' + location.host + location.pathname;
var args = location.search;
var reg = new RegExp('([\?&]?)' + this.argName + '=[^&]*[&$]?', 'gi');
args = args.replace(reg,'$1');
if (args == '' || args == null) {
args += '?' + this.argName + '=' + page;
} else if (args.substr(args.length - 1,1) == '?' || args.substr(args.length - 1,1) == '&') {
args += this.argName + '=' + page;
} else {
args += '&' + this.argName + '=' + page;
}
return url + args;
}
showPages.prototype.toPage = function(page){ //頁面跳轉(zhuǎn)
var turnTo = 1;
if (typeof(page) == 'object') {
turnTo = page.options[page.selectedIndex].value;
} else {
turnTo = page;
}
self.location.href = this.createUrl(turnTo);
}
showPages.prototype.printHtml = function(mode){ //顯示html代碼
this.getPage();
this.checkPages();
this.showTimes += 1;
document.write('<div id="pages_' + this.name + '_' + this.showTimes + '" class="a4"></div>');
document.getElementById('pages_' + this.name + '_' + this.showTimes).innerHTML = this.createHtml(mode);
}
showPages.prototype.formatInputPage = function(e){ //限定輸入頁數(shù)格式
var ie = navigator.appName=="Microsoft Internet Explorer"?true:false;
if(!ie) var key = e.which;
else var key = event.keyCode;
if (key == 8 || key == 46 || (key >= 48 && key <= 57)) return true;
return false;
}
//Ajax
function ajaxRead(file,fun){
var xmlObj = null;
if(window.XMLHttpRequest){
xmlObj = new XMLHttpRequest();
} else if(window.ActiveXObject){
xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
} else {
return;
}
xmlObj.onreadystatechange = function(){
if(xmlObj.readyState == 4){
if (xmlObj.status ==200){
obj = xmlObj.responseXML;
eval(fun);
}
else{
alert("讀取文件出錯,錯誤號為 [" + xmlObj.status + "]");
}
}
}
xmlObj.open ('GET', file, true);
xmlObj.send (null);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -