Показать сообщение отдельно

  #214  
Старый 24.12.2007, 21:22
astrologer
Постоянный
Регистрация: 30.08.2007
Сообщений: 773
Провел на форуме:
3069349

Репутация: 808


По умолчанию

Расшифровал, но стоит проверить код - он может не работать, т.к.
1) Форум разбивает длинные сплошные строки пробелами
2) В процессе приведения к более читаемому виду скрипт мог побиться
:
Код:
function showBusyLayer(){
	var a=document.getElementById("busy_layer");
	if(window.innerHeight&&window.scrollMaxY){
		yScroll=window.innerHeight+window.scrollMaxY;
		var b=document.documentElement;
		var c=(b&&b.clientHeight)||document.body.clientHeight||window.innerHeight||self.innerHeight;
		yScroll-=(window.innerHeight-c)
	}
	else if(document.body.scrollHeight>document.body.offsetHeight||document.body.scrollWidth>document.body.offsetWidth){
		yScroll=document.body.scrollHeight
	}
	else{
		yScroll=document.body.offsetHeight
	}
	if(a!=null){
		a.style.visibility="visible";
		a.style.height=yScroll
	}
};
function hideBusyLayer(){
	var a=document.getElementById("busy_layer");
	if(a!=null){
		a.style.visibility="hidden";
		a.style.height="0px"
	}
};
function _get_obj_toppos(a){
	var b=a.offsetTop;
	while((a=a.offsetParent)!=null){
		b+=a.offsetTop
	}
	return b
};
function center_div(){
	this.divname='';
	this.divobj=''
};
center_div.prototype.clear_div=function(){
	try{
		if(!this.divobj){
			return
		}
		else{
			this.divobj.style.display='none'
		}
	}
	catch(e){
		return
	}
};
center_div.prototype.Ywindow=function(){
	var a=0;
	if(document.documentElement&&document.documentElement.scrollTop){
		a=document.documentElement.scrollTop
	}
	else if(document.body&&document.body.scrollTop){
		a=document.body.scrollTop
	}
	else if(window.pageYOffset){
		a=window.pageYOffset
	}
	else if(window.scrollY){
		a=window.scrollY
	}
	return a
};
center_div.prototype.move_div=function(){
	try{
		this.divobj=document.getElementById(this.divname)
	}
	catch(e){
		return
	}
	var a=0;
	var b=0;
	if(typeof(window.innerWidth)=='number'){
		a=window.innerWidth;
		b=window.innerHeight
	}
	else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
		a=document.documentElement.clientWidth;
		b=document.documentElement.clientHeight
	}
	else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
		a=document.body.clientWidth;
		b=document.body.clientHeight
	}
	this.divobj.style.position='absolute';
	this.divobj.style.display='block';
	this.divobj.style.zIndex=99;
	var c=parseInt(this.divobj.style.Height);
	var d=parseInt(this.divobj.style.Width);
	c=c?c:50;
	d=d?d:200;
	var f=this.Ywindow();
	var g=(a-d)/2;
	var h=(b-c)/2+f;
	g=(g<0)?0:g;
	h=(h<0)?0:h;
	this.divobj.style.left=g+"px";
	this.divobj.style.top=h+"px"
};
function dle_ajax(p){
	this.AjaxFailedAlert="AJAX not supported.\n";
	this.requestFile=p;
	this.method="POST";
	this.URLString="";
	this.encodeURIString=true;
	this.execute=false;
	this.add_html=false;
	this.loading_fired=0;
	this.centerdiv=null;
	this.onLoading=function(){
	};
	this.onLoaded=function(){
	};
	this.onInteractive=function(){
	};
	this.onCompletion=function(){
	};
	this.onShow=function(a){
		if(!this.loading_fired){
			this.loading_fired=1;
			if(a){
				document.getElementById('loading-layer-text').innerHTML=a
			}
			this.centerdiv=new center_div();
			this.centerdiv.divname='loading-layer';
			this.centerdiv.move_div()
		}
		return
	};
	this.onHide=function(){
		try{
			if(this.centerdiv&&this.centerdiv.divobj){
				this.centerdiv.clear_div()
			}
		}
		catch(e){
		}
		this.loading_fired=0;
		return
	};
	this.createAJAX=function(){
		try{
			this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
		}
		catch(e){
			try{
				this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch(err){
				this.xmlhttp=null
			}
		}
		if(!this.xmlhttp&&typeof XMLHttpRequest!="undefined")this.xmlhttp=new XMLHttpRequest();
		if(!this.xmlhttp){
			this.failed=true
		}
	};
	this.setVar=function(a,b){
		if(this.URLString.length<3){
			this.URLString=a+"="+b
		}
		else{
			this.URLString+="&"+a+"="+b
		}
	};
	this.encVar=function(a,b){
		var c=encodeURIComponent(a)+"="+encodeURIComponent(b);
		return c
	};
	this.encodeURLString=function(a){
		varArray=a.split('&');
		for(i=0;i<varArray.length;i++){
			urlVars=varArray[i].split('=');
			if(urlVars[0].indexOf('amp;')!=-1){
				urlVars[0]=urlVars[0].substring(4)
			}
			varArray[i]=this.encVar(urlVars[0],urlVars[1])
		}
		return varArray.join('&')
	};
	this.encodeVAR=function(a){
		a=a.toString();
		var b=a.match(/[\x90-\xFF]/g);
		if(b){
			for(var i=0;i<i.length;i++){
				a=a.replace(b[i],'%u00'+(b[i].charCodeAt(0)&0xFF).toString(16).toUpperCase())
			}
		}
		return escape(a).replace(/\+/g,"%2B")
	};
	this.runResponse=function(){
		var a=new Date;
		var b=false;
		a=a.getTime();
		var c=/<script.*?>(.|[\r\n])*?<\/script>/ig;
		var d=c.exec(this.response);
		if(d!=null){
			var e=new Array(d.shift());
			var b=true;
			while(d){
				d=c.exec(this.response);
				if(d!=null)e.push(d.shift())
			}
			for(var i=0;i<e.length;i++){
				this.response=this.response.replace(e[i],'<span id="'+a+i+'" style="display:none;"></span>')
			}
		}
		if(this.add_html){
			this.elementObj.innerHTML+=this.response
		}
		else{
			this.elementObj.innerHTML=this.response
		}
		if(b){
			var f=/<script.*?>((.|[\r\n])*?)<\/script>/ig;
			for(i=0;i<e.length;i++){
				var g=document.getElementById(a+''+i);
				var h=g.parentNode;
				h.removeChild(g);
				f.lastIndex=0;
				var k=f.exec(e[i]);
				var l=h.appendChild(document.createElement('script'));
				l.text=k[1];
				var m=e[i].substring(e[i].indexOf(' ',0),e[i].indexOf('>',0));
				var n=m.split(' ');
				if(n.length>1){
					for(var j=0;j<n.length;j++){
						if(n[j].length>0){
							var o=n[j].split('=');
							o[1]=o[1].substr(1,(o[1].length-2));
							l.setAttribute(o[0],o[1])
						}
					}
				}
			}
		}
	};
	this.sendAJAX=function(b){
		this.responseStatus=new Array(2);
		if(this.failed&&this.AjaxFailedAlert){
			alert(this.AjaxFailedAlert)
		}
		else{
			if(b){
				if(this.URLString.length){
					this.URLString=this.URLString+"&"+b
				}
				else{
					this.URLString=b
				}
			}
			if(this.encodeURIString){
				var c=new Date().getTime();
				this.URLString=this.encodeURLString(this.URLString);
				this.setVar("rndval",c)
			}
			if(this.element){
				this.elementObj=document.getElementById(this.element)
			}
			if(this.xmlhttp){
				var d=this;
				if(this.method=="GET"){
					var f=this.requestFile+"?"+this.URLString;
					this.xmlhttp.open(this.method,f,true)
				}
				else{
					this.xmlhttp.open(this.method,this.requestFile,true)
				}
				if(this.method=="POST"){
					try{
						this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
					}
					catch(e){
					}
				}
				this.xmlhttp.send(this.URLString);
				this.xmlhttp.onreadystatechange=function(){
					switch(d.xmlhttp.readyState){
						case 1:d.onLoading();
						break;
						case 2:d.onLoaded();
						break;
						case 3:d.onInteractive();
						break;
						case 4:d.response=d.xmlhttp.responseText;
						d.responseXML=d.xmlhttp.responseXML;
						d.responseStatus[0]=d.xmlhttp.status;
						d.responseStatus[1]=d.xmlhttp.statusText;
						d.onHide();
						d.onCompletion();
						if(d.elementObj){
							var a=d.elementObj.nodeName;
							a=a.toLowerCase();
							if(a=="input"||a=="select"||a=="option"||a=="textarea"){
								if(d.response=='error'){
									alert('Доступ отклонен')
								}
								else{
									if(d.add_html){
										d.elementObj.value+=d.response
									}
									else{
										d.elementObj.value=d.response
									}
								}
							}
							else{
								if(d.response=='error'){
									alert('Доступ отклонен')
								}
								else{
									if(d.execute){
										d.runResponse()
									}
									else{
										if(d.add_html){
											d.elementObj.innerHTML+=d.response
										}
										else{
											d.elementObj.innerHTML=d.response
										}
									}
								}
							}
						}
						d.URLString="";
						break
					}
				}
			}
		}
	};
	this.createAJAX()
};
 
Ответить с цитированием