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

📄 common.js

📁 动网论坛系列产品倍受用户赞誉的就是强大的功能和出色的用户体验表现
💻 JS
📖 第 1 页 / 共 2 页
字号:
	return this.replace(/(妈的|妈b|妈比|fuck|shit|我日|法轮|产党|泽东)/gi, "**");
}


//HtmlEncode
String.prototype.htmlEncode = function()
{
	var s = this.replace(/&/g, '&');
	s = s.replace(/[  ]*\r/g, '');
	s = s.replace(/  /g, '  ');
	s = s.replace(/\t/g, '    ');
	s = s.replace(/\"/, '"');
	s = s.replace(/\'/, ''');
	s = s.replace(/</g, '&lt;');
	s = s.replace(/>/g, '&gt;');
	s = s.replace(/\n/g, '<BR>');
	return s.shitEncode();
}


//TextEncode
String.prototype.textEncode = function()
{
	var s = this.replace(/&/g, '&amp;');
	s = s.replace(/</g, '&lt;');
	s = s.replace(/>/, '&gt;');
	return s.shitEncode();
}


//UbbCode
function UbbCode()
{
	//Protected Html
	this.protectHtml = function(str)
	{
		var s = str.replace(/<(\/?script)([^>]*)>/gi, '&lt;$1$2&gt;');
		s = s.replace(/<(\/?applet)([^>]*)>/gi, '&lt;$1$2&gt;');
		s = s.replace(/(javascript|vbscript|script)[\s]*:/gi, 'none:');
		s = s.replace(/<([%\?]{1})/gi, '&lt;$1');
		s = s.replace(/([%\?]{1})>/gi, '$1&gt;');
		s = s.replace(/<!\-\-[\s]*#[\s]*include/gi, '<!-- include');
		return s.shitEncode();
	}

	//Emotions
	this.showEmotion = function(str)
	{
		return str.replace(/\{\/em([\d]+)\}/gi, "<img src='<~>emotion/$1.gif' alt='emote' />&nbsp;");
	}

	//Seek URL
	this.findUrl = function(str)
	{
		var s = str.replace(/([^>=\]])((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9%\-_@]+\.[A-Za-z0-9%\-_@]+[A-Za-z0-9\.\/=\?%\-&_~`@:\+!;]*)/gi, "$1<a href='<~>$2' target='_blank'>$2</a>");
		s = s.replace(/(^|<br \/>)((http|https|ftp|rtsp|mms):(\/\/|\\\\)[A-Za-z0-9%\-_@]+\.[A-Za-z0-9%\-_@]+[A-Za-z0-9\.\/=\?%\-&_~`@:\+!;]*)/gi, "$1<a href='<~>$2' target='_blank'>$2</a>");
		s = s.replace(/(^|<br \/>)(www\.[A-Za-z0-9%\-_@]+[A-Za-z0-9\.\/=\?%\-&_~`@:\+!;]+)/gi, "$1<a href='http://$2' target='_blank'>$2</a>");
		return s;
	}
	
	this.supportUbb = function(str)
	{
		return this.regExp(this.findUrl(str.htmlEncode()));
	}
	this.supportHtml = function(str)
	{
		return this.regExp(str);
	}
	
	//Regex
	this.regExp = function(str)
	{
		//font styles & simple tags
		var s = str.replace(/\[((\/?b)|(\/?i)|(\/?u)|(\/?h[1-6])|(\/?sub)|(\/?sup)|(\/?center))\]/gi, "<$1>");
		s = s.replace(/\[color=((#[A-Fa-f0-9]{3})|(#[A-Fa-f0-9]{6})|[a-zA-Z]{3,12})\]/gi, "<span style='color:$1'>");
		s = s.replace(/\[size=([1-3][0-9])\]/gi, "<span style='font-size:$1px'>");
		s = s.replace(/\[face=([^\[]+)\]/gi, "<span style='font-family:$1'>");
		s = s.replace(/\[\/(color|size|face)\]/gi, "</span>");
		//image
		s = s.replace(/\[img\]([^\[]{5,})\[\/img\]/gi, "<img src='<~>$1' class='image-from-ubb' border='0' alt='image' style='cursor:hand' onload='if(this.width>515)this.width=515' onclick=\"window.open(this.src, null, '')\" />");
		s = s.replace(/\[img=(left|right)\]([^\[]{5,})\[\/img\]/gi, "<img src='<~>$2' align='$1' class='image-from-ubb' border='0' alt='image' style='cursor:hand' onload='if(this.width>515)this.width=515' onclick=\"window.open(this.src, null, '')\" />");
		//line
		s = s.replace(/\[line\/\]/gi, "<hr size='1' color='#cccccc' noshade='noshade' />");
		s = s.replace(/\[line\]\s*(\d{1})\s*,\s*((#[A-Fa-f0-9]{3})|(#[A-Fa-f0-9]{6})|[A-Za-z]{3,12})\s*\[\/line\]/gi, "<hr size='$1' color='$2' noshade='noshade' />");
		//url
		s = s.replace(/\[url\]([^\[<]{5,})\[\/url\]/gi, "<a href='<~>$1' target='_blank'>$1</a>");
		s = s.replace(/\[url=([^\[<]{5,})\]([^\[<]+)\[\/url\]/gi, "<a href='<~>$1' target='_blank'>$2</a>");
		//email
		s = s.replace(/\[email\]([^\s@]+@[^\[\.]+\.[^\[]+)\[\/email\]/gi, "<a href='mailto:$1'>$1</a>");
		s = s.replace(/\[email=([^\s@]+@[^\[\.]+\.[^\[]+)\]([^\[]+)\[\/email\]/gi, "<a href='mailto:$1'>$2</a>");
		//flash
		s = s.replace(/\[flash\](.[^\[]*\.swf)\[\/flash\]/gi, "<embed src='<~>$1' width='500' height='400' quality='high' type='application/x-shockwave-flash'></embed><br /><a href='<~>$1' target='_blank'>[全屏欣赏 提醒:Flash中可能包含不安全内容]</a>");
		s = s.replace(/\[flash=(\d+),(\d+)\](.[^\[]*\.swf)\[\/flash\]/gi, "<embed src='<~>$3' width='$1' height='$2' quality='high' type='application/x-shockwave-flash'></embed><br /><a href='<~>$3' target='_blank'>[全屏欣赏 提醒:Flash中可能包含不安全内容]</a>");
		//media
		s = s.replace(/\*/gi, "*;");
		//	\.(avi|asx|wpl|aif|aifc|aiff|au|asf|mpeg|mpg|m1v|mp2|mpv2|mp2v|mpa|mid|midi|rmi|snd|wma|wmv|wm|wav|wax|m3u|wpl|mp3)
		s = s.replace(/\[(\/)?(MP(=([0-9]+),([0-9]+))?)\]/gi, "*$1$2*").replace(/\*MP=([0-9]+),([0-9]+)\*(.[^\*]*)\*\/MP\*/gi, "<object align='middle' classid='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95' class='object' id='mediaplayer' width='$1' height='$2'><param name='showstatusbar' value='-1' /><param name='filename' value='$3' /><embed type='application/x-oleobject' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#version=5,1,52,701' filename='mp' src='<~>$3' width='$1' height='$2'></embed></object>");
		s = s.replace(/\*(\/)?(MP(=([0-9]+),([0-9]+))?)\*/gi, "[$1$2]").replace(/\*;/gi, "*");
		//real
		s = s.replace(/\*/gi, "*;");
		//	\.(rm|rma|ra|ram|rmm|rmvb|au|aif|mid|mp3|wav|wov|wma|smi|smil|m3u|mov|mpg|mpeg)
		s = s.replace(/\[(\/)?(RM(=([0-9]+),([0-9]+))?)\]/gi, "*$1$2*").replace(/\*RM=([0-9]+),([0-9]+)\*(.[^\*]*)\*\/RM\*/gi, "<object classid='clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa' class='object' id='raocx' width='$1' height='$2'><param name='src' value='$3'><param name='console' value='clip1' /><param name='controls' value='imagewindow' /><param name='autostart' value='0' /></object><br /><object classid='clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa' height='32' id='video2' width='$1'><param name='src' value='$3' /><param name='autostart' value='0' /><param name='controls' value='controlpanel' /><param name='console' value='clip1' /></object><br />[请确定您已安装了RealPlayer,并手动点击播放]");
		s = s.replace(/\*(\/)?(RM(=([0-9]+),([0-9]+))?)\*/gi, "[$1$2]").replace(/\*;/gi, "*");
		//code
		s = s.replace(/\[(\/?)code\]/gi, "[$1CODE]")
		//quote
		s = s.replace(/\[quotetitle\]([^\[]*)\[\/quotetitle\]/gi, " &nbsp;<span style='position:relative;top:10px;' class='highlight bg1'>$1</span>");
		s = s.replace(/\[quote\](<br \/>|&nbsp;)*/gi, "<div class='grid bg3' style='width:96%; padding:10px 10px 9px 10px; line-height:18px'>");
		s = s.replace(/(<br \/>)*\[\/quote\]/gi, "</div>");

		return this.showCodeBlock(s);
	}

	//Set Code Highlight (CSharp)
	this.codeHighLightCSharp = function(str)
	{
		var s = str.replace(/(^|\s|<br \/>|;\s*|\)\s*)(private|protected|internal|public|using|namespace|class|interface|struct|event|virtual|abstract|static|delegate|override|readonly|return|break|continue|goto|case|default|sealed|throw)/g, "$1<span style='color:blue'>$2</span>");
		s = s.replace(/(else\s+if|if|switch|try|catch|finally|while|for|for\s+each|do|typeof|sizeof)(\s*\(|\s*\{)/gi, "<span style='color:blue'>$1</span>$2");
		s = s.replace(/(\s+|;\s*|=\s*|\(\s*|,\s*)(null|int|string|void|bool|long|short|byte|char|decimal|double|enum|event|float|object|sbyte|base|this|ulong|ushort|DateTime|true|false|get|set|var)(\s+|\.|\[|\s*\)|\s*;)/g, "$1<span style='color:blue'>$2</span>$3");
		s = s.replace(/(\}\s*|\]\s*|\s*\)|^|\s+|<br \/>)(else|is|as|in|is)(\s*\{|\s*\(|$|\s+|<br \/>)/g, "$1<span style='color:blue'>$2</span>$3");
		s = s.replace(/&quot;/gi, "\"").replace(/\\\"/g, "““””").replace(/(\"[^\"]*\")/g, "<span style='color:#ff00ff'>$1</span>").replace(/““””/g, "\\\"");
		s = s.replace(/<span style=\'color:blue\'>class<\/span>(\s*=)/gi, "class$1");

		var i = 0;	//define start index
		while ( (i = s.indexOf("//", i)) != -1)
		{
			if (s.indexOf("<BR>", i) == -1) break;

			s = s.substring(0, i) + "<span style='color:green'>" + s.substring(i, s.indexOf("<BR>", i)).replace(/<span style=\'color:#?[0-9a-zA-Z]+\'>([^<]+)<\/span>/gi, "$1") + "</span>" + s.substring(s.indexOf("<BR>", i));
			i = s.indexOf("<BR>", i);
		}

		i = 0;	//reset start index
		while ((i = s.indexOf("/*", i)) != -1)
		{
			if (s.indexOf("*/", i + 2) == -1) break;

			s = s.substring(0, i) + "<span style='color:green'>" + s.substring(i, s.indexOf("*/", i + 2) + 2).replace(/<span style=\'color:#?[0-9a-zA-Z]+\'>([^<]+)<\/span>/gi, "$1") + "</span>" + s.substring(s.indexOf("*/", i + 2) + 2);
			i = s.indexOf("*/", i + 2);
		}
		return s;
	}

	// Set CodeSource Display Mode
	this.setCodeSourceDisplayMode = function(senderId, eventerId)
	{
		var sender  = document.getElementById(senderId);
		var eventer = document.getElementById(eventerId);
		if (eventer.style.overflow == '')
		{
			sender.innerHTML = '[滚动模式]';
			eventer.noWrap = 'nowrap';
			eventer.style.height	= '400px';
			eventer.style.overflow	= 'auto';
		}
		else 
		{
			sender.innerHTML = '[全显模式]';
			eventer.noWrap = '';
			eventer.style.height	= '';
			eventer.style.overflow	= '';
		}
	}

	//Set Code Block
	this.codeBlockIndex = 0;
	this.showCodeBlock = function(str)
	{
		var arr = str.split('[CODE]');
		var quoterBegin = " &nbsp;<span style='position:relative;top:10px;' class='highlight bg1'>本帖相关代码";
		quoterBegin    += " &nbsp; <a id='sender_$index' href=\"javascript:ubb.setCodeSourceDisplayMode('sender_$index', 'codesource_$index')\">[全显模式]</a></span>";
		quoterBegin    += "<div class='grid bg3' style='width:96%; padding:10px 10px 9px 10px; line-height:18px; font-family:宋体 !important; font-size:12px !important;' id='codesource_$index'>";

		for (var i=0; i<arr.length; i++)
		{
			var subArr = arr[i].split('[/CODE]');
			if (subArr.length == 1) continue;

			if (subArr[0].split('{').length > 1 && subArr[0].split(';').length > 4)
			{
				subArr[0] = this.codeHighLightCSharp(subArr[0]);	//如果不想语法高亮则把这行去掉
			}
			/* --- Show Line Number -------------			
			var lines = subArr[0].split('<br />');
			var maxLine = lines.length;
			for (var j=0; j<maxLine; j++)
			{
				lines[j] = "<span style='color:#bbbbbb;display:none'>"  + j.toString() + "</span > &nbsp;" + lines[j];
				for (var k=0; k<maxLine.toString().length - j.toString().length; k++)
				{
					if (k>10) break;
					lines[j] = '&nbsp;' + lines[j];
				}
			}
			subArr[0] = lines.join('<br />');
			*/
			subArr[0] = quoterBegin.replace(/\$index/g, this.codeBlockIndex++) + subArr[0];
			arr[i] = subArr.join('</div>');
		}
		return arr.join('');
	}

	//Explain The Attachment Mark
	this.showAttachment = function(str)
	{
		var s = str.replace(/\[uploadimage\]([\d]+),([0-9a-zA-Z_\.\/\\]+)\[\/uploadimage\]/gi, "<img src='<~>images/topic_hasimg.gif' align='absmiddle' alt='本帖包含图片' /> 本帖包含图片[<a href='additem.aspx?item=attach&itemid=$1'>收藏图片</a>]:<br /><a href='<~>attach.aspx?attachid=$1' target='_blank'><img src='<~>attach.aspx?attachid=$1' border='0' class='image-from-upload' alt='uploaded image' style='margin-top:3px' onload='if(this.width>515)this.width=515' /></a>");
		s = s.replace(/\[uploadimage=(left|right)\]([\d]+),([0-9a-zA-Z_\.\/\\]+)\[\/uploadimage\]/gi, "<img src='<~>images/topic_hasimg.gif' align='absmiddle' alt='本帖包含图片' /> 本帖包含图片[<a href='additem.aspx?item=attach&itemid=$1'>收藏图片</a>]:<br /><a href='<~>attach.aspx?attachid=$1' target='_blank'><img src='<~>attach.aspx?attachid=$2' style='margin:4px 6px 6px 6px' align='$1' border='0' class='image-from-upload' alt='uploaded image' onload='if(this.width>515)this.width=515' /></a>");
		s = s.replace(/\[uploadfile\]([0-9]+),([^\]]+),([0-9]+\.?[0-9\s]*kb)\[\/uploadfile\]/gi, "<img src='<~>images/topic_hasrar.gif' align='absmiddle' alt='本帖包含附件' /> 本帖包含附件[<a href='additem.aspx?item=attach&itemid=$1'>收藏附件</a>]:<br /><a href='<~>attach.aspx?attachid=$1' target='_blank'>$2</a> &nbsp;[附件大小:$3, <a href='<~>attach_list.aspx?attachid=$1&style=new_style' target='_blank'>查看信息...</a>]");
		return s;
	}

	//fix relative path
	this.fixRelativePath = function(str, pathUpSeek)
	{
		var s = str.replace(/ (href|src)=\'<~>(javascript|vbscript|script):([^\']*)\'/gi, " $1='$3'");
		s = s.replace(/ (href|src)=\'<~>(\/|[a-zA-Z]+:)([^\']*)\'/gi, " $1='$2$3'");
		s = s.replace(/ (href|src)=\'<~>([^\']*)\'/gi, " $1='" + pathUpSeek + "/$2'");
		return s;
	}

	//output
	this.print = function(str, currentPath, tagType, isFormat)
	{
		var s = isFormat ? str.format() : str;
		switch (tagType)
		{
			default:
				s = this.findUrl(s.htmlEncode());
				break;
			case 1:
				s = this.supportUbb(s);
				break;
			case -1:
				s = this.supportHtml(s);
				break;
			case 2:
				s = this.protectHtml(s);
				break;
		}

		s = this.showEmotion(this.showAttachment(s));
		s = this.fixRelativePath(s, currentPath);
		document.write(s);
	}
}
var ubb = new UbbCode();
var output;

function vgetCookie(parameter)
{
	var reg,allCookie,allCookie2,iLen,iStart,iEnd;
	allCookie = document.cookie;
	reg = new RegExp(parameter);
	if(allCookie.search(reg) == -1){
		return "";
	}
	else{
		iLen = parameter.length;
		iStart = allCookie.search(reg) + iLen +1;
		allCookie2 = allCookie.substr(iStart);
		iEnd = iStart + allCookie2.search(/;/i);		
		if((iStart - 1) == iEnd){
			return allCookie.substr(iStart);
		}
		else{
			return allCookie.substr(iStart,iEnd - iStart);
		}
	}
}

function frameon(url, img){
	if (window == top){
		top.location.href = "index_main.aspx?actleft="+escape(url);
		setCookie($app_prefix + "userleft","0");
	}else{
		setCookie($app_prefix + "userleft","1");
		top.location.href = url.indexOf("actleft") == -1 ? (url.indexOf("?") != -1 ? url + "&actleft=null" : url+"?actleft=null") : url;
	}
}
function changeframeicon(isleft, path){
	if (!isleft){return false;}
	
	if (window == top){
		isleft.innerHTML = "左右分栏";
	}else{
		isleft.innerHTML = "平版模式";
		//g.src = path + 'noleft.gif';

	}
}

// 检查并更改图片大小 added by 小点@20070612
function imgresize(o){
	var parentNode=o.parentNode;
	if (parentNode){
		if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
		}else{
		var parentNode=o.parentNode
		if (parentNode){
			if (o.offsetWidth>=parentNode.offsetWidth) o.style.width='98%';
			}
		}
}

function addTitleHead(obj, tovalue){	//modified by caoxin03 2007 0816
	var x = eval('obj.form.' + tovalue);
	if (obj.options.selectedIndex > 0 && x.value.length < 46 && len(x.value) < 64)
	{
		x.value = obj.options[obj.options.selectedIndex].text + x.value;
		obj.options.selectedIndex = 0;
	}
}

function PostShowTime(stat){
	if(1 == stat){
		document.getElementById("uncertainstarttime").style.display = 'block';
		document.getElementById("certainstarttime").style.display = 'none';
	}else{
		document.getElementById("uncertainstarttime").style.display = 'none';
		document.getElementById("certainstarttime").style.display = 'block';
	}
}

⌨️ 快捷键说明

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