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

📄 x2.js

📁 如果要连接的数据库文件和当前文件在同一个目录下
💻 JS
字号:
/*if(Rico!=null){
	window.onload=function()
	{
		var roundClass=["round_corner","top_round","bottom_round","round_corner_small","top_round_small","bottom_round_small"];
		var flags=[{},{corners:"top"},{corners:"bottom",border:'#666'},{compact:true},{compact:true,corners:"top"},{compact:true,corners:"bottom"}];
		for(var j=0;j<roundClass.length;j++)
		{
			var roundCornerItems=document.getElementsByClassName(roundClass[j]);
			for(var i=0;i<roundCornerItems.length;i++)
			{
				Rico.Corner.round(roundCornerItems[i],flags[j]);
			}
		}
	}

	document.extend(this,{
		createElement2:function(elementName,text2)
		{
			var element=document.createElement(elementName);
			var textNode=document.createTextNode(text2);
			element.appendChild(textNode);
			return element;
		}
	})
}
*/

var MultiLang=new Object();
function escape2(str){
	return escape(str).replace(/\+/g,"%2b");
}

function $se(tag){
	return document.createElement(tag);
}
function externalLinks() { 
	if (!document.getElementsByTagName)return;
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank"; 
	} 
} 

document.createElementWithText=function(elementName,text2){

			var element=document.createElement(elementName);
			//var textNode=document.createTextNode(text2);
			element.innerHTML=text2;
			return element;
}

var _st = window.setTimeout; 
window.setTimeout = function(fRef, mDelay) { 
	if(typeof fRef == 'function'){ 
		var argu = Array.prototype.slice.call(arguments,2); 
		var f = (function(){ fRef.apply(null, argu); }); 
		return _st(f, mDelay); 
	} 
	return _st(fRef,mDelay); 
}

String.prototype.escapeHTML2=function(){
	return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/ /g,"&nbsp;").replace(/\t/g,"&nbsp;").replace(/\n/g,"<br />");
	
}
String.prototype.trim=function(){
	return this.replace(/^ +/,"").replace(/ +$/,"");
}

if(!Array.prototype.exist){
	Array.prototype.exist=function(k){
		for(var i=0;i<this.length;i++){
			if(this[i]==k)return true;
		}
		return false;
	}
}

var Mapping=Class.create();
Mapping.prototype={
	initialize:function(){
		this.key=new Array();
		this.value=new Array();
	},
	push:function(key,value){
		var i=this.findIndexByKey(key);
		if(i!=-1){
			this.value[i]=value;
		}
		else{
			this.key.push(key);
			this.value.push(value);
		}
	},
	findIndexByKey:function(key){
		for(var i=0;i<this.key.length;i++){
			if(this.key[i]==key)return i;
		}
		return -1;
	},
	getValue:function(key){
		for(var i=0;i<this.key.length;i++){
			if(this.key[i]==key)return this.value[i];
		}
		return null;
	},
	exist:function(key){
		for(var i=0;i<this.key.length;i++){
			if(this.key[i]==key)return true;
		}
		return false;
	},
	reset:function(){
		this.key=[];
		this.value=[];
	}
}

var TipBox=Class.create();
TipBox.prototype={
	initialize: function(msg, _options){
		this.options={
			delay:0,
			elementName:"dd"
		}.extend(_options || {});
		this.using=false;
		this.removed=false;
		this.text="";
		this.box=document.createElementWithText(this.options.elementName,msg);
		Element.addClassName(this.box,"tipBox");
		this.spanClose=$se("span");
		this.spanClose.innerHTML="[Close]";
		this.spanClose.className="close";
		this.spanClose.onclick=this.hide.bind(this);
		this.spanInfo=$se("span");
		this.spanInfo.className="info";
		this.box.appendChild(this.spanInfo);
		this.box.appendChild(this.spanClose);
		this.timeOutPtr=0;
		if(this.options.padding)this.box.style.padding=this.options.padding;
		if(this.options.color)this.box.style.color=this.options.color;
		if(this.options.backgroundColor)this.box.style.backgroundColor=this.options.bgColor;
		if(this.options.borderWidth)this.box.style.borderWidth="1px";
		if(this.options.borderStyle)this.box.style.borderStyle="solid"
		if(this.options.borderColor)this.box.style.borderColor=this.options.borderColor;
		if(this.options.marginTop)this.box.style.marginTop=this.options.marginTop;
		if(this.options.marginRight)this.box.style.marginRight=this.options.marginRight;
		if(this.options.marginLeft)this.box.style.marginLeft=this.options.marginLeft;
		if(this.options.marginBottom)this.box.style.marginBottom=this.options.marginBottom;
		if(this.options.textAlign)this.box.style.textAlign=this.options.textAlign;
		this.hide();
		if(this.options.delay>0)
		{
			this.timeOutPtr=window.setTimeout(this.hide,this.options.delay*1000);
		}
	},
	setText:function(msg,noCloseButton){
		this.text=msg;
		this.spanInfo.innerHTML=msg;
		if(noCloseButton){
			if(this.box.childNodes.length>1)this.spanClose=this.box.removeChild(this.spanClose);
		}else{
			this.box.appendChild(this.spanClose);
		}
	},
	removeAfterSeconds:function(delay){
		if(!this.removed){
			if(this.timeOutPtr)window.clearTimeout(this.timeOutPtr);
			this.timeOutPtr=window.setTimeout(this.remove.bind(this),delay*1000);
		}
	},
	hideAfterSeconds:function(delay){
		if(this.using){
			if(this.timeOutPtr)window.clearTimeout(this.timeOutPtr);
			this.timeOutPtr=window.setTimeout(this.hide.bind(this),delay*1000);
		}
	},
	remove:function()
	{
		this.removed=true;
		Element.remove(this.box);
	},
	show:function(){
		this.using=true;
		Element.show(this.box);
	},
	hide:function(){
		this.using=false;
		Element.hide(this.box);
	},
	clearDelay:function(){
		if(this.timeOutPtr)window.clearTimeout(this.timeOutPtr);
	},
	toggleText:function(msg,delay){
		this.box.innerHTML=msg;
		window.setTimeout(this.recoverText.bind(this),delay*1000);
	},
	recoverText:function(){
		this.box.innerHTML=this.text;
	}
}

function isie(){
	var user_agent=navigator.userAgent.toLowerCase();
	if(user_agent.indexOf("msie")!=-1)return true;
	return false;
}
function cc(e){
	var c=e.childNodes.length;
	if(c==0)return 0;
	if(isie())return c;
	else return (c-1)/2;
}
function ci(i){
	if(isie())return i;
	else return i*2+1;
}


Object.extend(Element, {
	show: function() { 
		for (var i = 0; i < arguments.length; i++) { 
		  var element = $(arguments[i]); 
		  element.style.display = 'block'; 
		} 
	}
})
/*
gnn=getNodeByName
cc=childsCount
cns=childNodes
*/
_element.prototype.getValue=function(){
	if(!arguments){
		if(this.contents[0])return this.contents[0].value;
		else return "";
	}
	for(var i=0;i<this.contents.length;i++){
		if(this.contents[i].name==arguments[0]){
			if(this.contents[i].contents[0])return this.contents[i].contents[0].value;
			return "";
		}
	}
}

var X2Doc=Class.create();
X2Doc.prototype={
	initialize:function(str){
		this.root=Xparse(str);
		this.root=this.root.contents[0];
		this.rootName=this.root.name;
		this.cns=this.root.contents;
		this.cc=this.cns.length;
	},
	gnn:function(node,name){
		for(var i=0;i<node.contents.length;i++){
			if(node.contents[i].name==name)return node.contents[i];
		}
		return null;
	}
}


//import a javascript file or style sheet;
function $import(path,type,title){
	var s,i;
	if(type=="js"){
		var ss=document.getElementsByTagName("script");
		for(i=0;i<ss.length;i++){
			if(ss[i].src && ss[i].src.indexOf(path)!=-1)return ss[i];
		}
		s=document.createElement("script");
		s.type="text/javascript";
		s.src=path;
	}else if(type=="css"){
		var ls=document.getElementsByTagName("link");
		for(i=0;i<ls.length;i++){
			if(ls[i].href && ls[i].href.indexOf(path)!=-1)return ls[i];
		}
		s=document.createElement("link");
		s.rel="alternate stylesheet";
		s.type="text/css";
		s.href=path;
		s.title=title;
		s.disabled=false;
	}
	else return;
	var head=document.getElementsByTagName("head")[0];
	head.appendChild(s);
	return s;
}

//cookie handler

var CookieHandler=new Object();
CookieHandler.extend({
	getValue:function(key){
		var cookieArray=document.cookie.split("; ");
		var cookie=new Object();
		alert(cookieArray.length);
		for(var i=0;i<cookieArray.length;i++){
			cookie[cookieArray[i].split("=")[0]]=cookieArray[i].split("=")[1];
		}
		if(cookie[key]){alert(1);return unescape(cookie[key]);}
		else return "";
	},
	setValue:function(key,value){
		var cookieArray=document.cookie.split("; ");
		var cookie=new Object();
		for(var i=0;i<cookieArray.length;i++){
			cookie[cookieArray[i].split("=")[0]]=cookieArray[i].split("=")[1];
		}
		
		cookie[key]=value;
		
		var c="";
		for(var p in cookie){
			if(p=="extend")continue;
			c+=p+"="+escape(cookie[p])+"; ";
		}
		alert(c);
		//var expireDate=new Date();
		//expireDate.setTime(expireDate.getTime()+1000*24*60*60*1000);
		//document.cookie=c+"expires="+expireDate.toGMTString();
		document.cookie=c+"a=1";
	
	},
	deleteValue:function(key){
	
	},
	clear:function(){
		document.cookie="a=1; expires="+(new Date()).setTime(0).toGMTString();
	}

});









 

⌨️ 快捷键说明

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