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

📄 common.js

📁 一个asp写的论坛源代码,论坛所需要的功能都有
💻 JS
📖 第 1 页 / 共 2 页
字号:
	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,"&lt;$1&gt;").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;         //当前页数
 this.pageCount = 1;    //总页数
 this.dispCount = 1;    //所有贴数
 this.argName = 'page'; //参数名
 this.showTimes = 1;    //打印次数
}

showPages.prototype.getPage = function(){ //丛url获得当前页数,如果变量重复只获取最后一个
 var args = location.search;
 var reg = new RegExp('[\?&]?' + this.argName + '=([^&]*)[&$]?', 'gi');
 var chk = args.match(reg);
 this.page = RegExp.$1;
}

showPages.prototype.checkPages = function(){ //进行当前页数和总页数的验证
 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">&#171;</a>';
       strHtml += '<a class="p_num">&#139;</a>';
     } else {
       strHtml += '<a href="javascript:' + this.name + '.toPage(1);" class="p_num">&#171;</a>';
       strHtml += '<a href="javascript:' + this.name + '.toPage(' + prevPage + ');" class="p_num">&#139;</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">&#155;</a>';
       strHtml += '<a class="p_num" title="Last Page">&#187;</a>';
     } else {
       strHtml += '<span  title="Next Page"><a class="p_num" href="javascript:' + this.name + '.toPage(' + nextPage + ');">&#155;</a></span>';
       strHtml += '<span title="Last Page"><a class="p_num" href="javascript:' + this.name + '.toPage(' + this.pageCount + ');">&#187;</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) { //生成页面跳转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){ //页面跳转
 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){ //限定输入页数格式
 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);
  }

⌨️ 快捷键说明

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