[OpenLayers-Users] why is your code entirely lacking in whitespace

mfrumin mfrumin at rpa.org
Tue May 15 01:05:15 EDT 2007


it is often useful to look at the code in the libraries to figure out how to
do do stuff.  unfortunately, it lacks any sane whitespacing scheme, and is
impossible to peruse.  eg (from
http://openlayers.org/api/2.4-rc3/OpenLayers.js or the OpenLayers.js that
comes in the download):

OpenLayers.Util.modifyAlphaImageDiv=function(div,id,px,sz,imgURL,position,border,sizing,opacity){OpenLayers.Util.modifyDOMElement(div,id,px,sz);var
img=div.childNodes[0];if(imgURL){img.src=imgURL;}
OpenLayers.Util.modifyDOMElement(img,div.id+"_innerImage",null,sz,"relative",border);if(opacity){div.style.opacity=opacity;div.style.filter='alpha(opacity='+(opacity*100)+')';}
if(OpenLayers.Util.alphaHack()){div.style.display="inline-block";if(sizing==null){sizing="scale";}
div.style.filter="progid:DXImageTransform.Microsoft"+".AlphaImageLoader(src='"+img.src+"',
"+"sizingMethod='"+sizing+"')";if(div.style.opacity){div.style.filter+="
alpha(opacity="+div.style.opacity*100+")";}
img.style.filter="progid:DXImageTransform.Microsoft"+".Alpha(opacity=0)";}};OpenLayers.Util.createAlphaImageDiv=function(id,px,sz,imgURL,position,border,sizing,opacity,delayDisplay){var
div=OpenLayers.Util.createDiv();var
img=OpenLayers.Util.createImage(null,null,null,null,null,null,null,false);div.appendChild(img);if(delayDisplay){img.style.display="none";OpenLayers.Event.observe(img,"load",OpenLayers.Util.onImageLoad.bindAsEventListener(div));OpenLayers.Event.observe(img,"error",OpenLayers.Util.onImageLoadError.bindAsEventListener(div));}
OpenLayers.Util.modifyAlphaImageDiv(div,id,px,sz,imgURL,position,border,sizing,opacity);return
div;};OpenLayers.Util.upperCaseObject=function(object){var uObject=new
Object();for(var key in object){uObject[key.toUpperCase()]=object[key];}
return uObject;};OpenLayers.Util.applyDefaults=function(to,from){for(var key
in
from){if(to[key]==null){to[key]=from[key];}}};OpenLayers.Util.getParameterString=function(params){paramsArray=new
Array();for(var key in params){var
value=params[key];if((value!=null)&&(typeof value!='function')){var
encodedValue;if(typeof value=='object'&&value.constructor==Array){var
encodedItemArray=new Array();for(var
itemIndex=0;itemIndex<value.length;itemIndex++){encodedItemArray.push(encodeURIComponent(value[itemIndex]));}
encodedValue=encodedItemArray.join(",");}
else{encodedValue=encodeURIComponent(value);}
paramsArray.push(encodeURIComponent(key)+"="+encodedValue);}}
return
paramsArray.join("&");};OpenLayers.ImgPath='';OpenLayers.Util.getImagesLocation=function(){return
OpenLayers.ImgPath||(OpenLayers._getScriptLocation()+"img/");};OpenLayers.Util.Try=function(){var
returnValue;for(var i=0;i<arguments.length;i++){var
lambda=arguments[i];try{returnValue=lambda();break;}catch(e){}}
return returnValue;}


does that look helpful to you?  clean your stuff up, then maybe when we have
bugs we can possibly help report where they might be coming from.

thanks,
mike

-- 
View this message in context: http://www.nabble.com/why-is-your-code-entirely-lacking-in-whitespace-tf3756357.html#a10616661
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list