jsbetter: Javascript verbessern

Beitrag lesen

Hey.

Ich habe diese Javaascript-Funktion hier gebastelt. Ich bin aber nicht gerade der beste in JS und wollte euch fragen, wie man diese besser gestalten könnte, schneller, cross-browserkompatibler, sicherer.

  
/* Update Auction Status*/  
function uAs(){  
		var r=getReq(),m=0,n,c,x,p,i,j,num;  
		r.open('GET','http://example.com/index.php?c=Auction&a=getStats&x='+aid,true);r.onreadystatechange=function(){  
			if(4===r.readyState&&200===r.status){  
				//alert(r.responseText);  
					var x=r.responseText.split('|');  
					$('#dC').countdown('change',{until: new Date(x[0])});  
					var m=x[1]*0.01*1;  
					var num=new Number(m);  
					var price=num.toFixed(2);  
					// Auctionsprice  
					document.getElementById('auctionprice').innerHTML=price;document.getElementById('auctionprice2').innerHTML=price;  
					// Saving Dollar  
					var p=document.getElementById('retailprice').innerHTML;  
					var i=p-price;  
					var pp=new Number(i);  
					document.getElementById('savingsdol').innerHTML=pp.toFixed(2);  
					// Saving Percent  
					var i=100-(price/(p/100));  
					var pp=new Number(i);  
					document.getElementById('savingsper').innerHTML=pp.toFixed(2);  
					// Bid Rebate  
					var i=0.01*x[4]*1;  
					var num=new Number(i);  
					document.getElementById('bidrebate').innerHTML=num.toFixed(2);  
					// Buy now  
					var j=1*(55.35-i);  
					var num=new Number(j);  
					var p=j.toFixed(2);  
					document.getElementById('newprice').value=p;  
					document.getElementById('purchaseprice').innerHTML=p;  
					// Your Bids  
					document.getElementById('yourbids').innerHTML=x[6];  
					// lastbidders  
					if(x[2]){  
						document.getElementById('currentWinner').innerHTML=x[3];  
						var c=document.getElementById('lastbidders');  
						c.innerHTML=x[2];  
					}  
                                        // End of Auction  
					if('0'!=x[5]&&false!=x[5]&&''!=x[5]){  
						if(x[5]==0){  
							setTimeout("location.href='http://example.com/Auction/Winner/'+aid",2000);  
						}else{  
							document.getElementById('dC').innerHTML=x[3];  
							window.clearInterval(aS);  
						}  
					}  
			}  
		}  
		r.send(null);  
}  
  

Liebe Grüße,
JSBETTERER