|
Posted by Richard Cornford on 07/11/05 04:56
Onideus Mad Hatter wrote:
<snip>
> I just got through rewriting teh code from this:
<snip>
> To this:
>: var IE = document.all ? true : false;
<snip>
>: while (i <= 10);
>
> I could probably make it even more efficient if I used case
> instead of do/while.
You mean switch? That would not help, as you would still need a loop
round the switch statement.
<snip>
> ...of course, if I did even half of that...boy it'd sorta
> make teh code a lil hard to read, wouldn't it?
<snip>
Which is why whitespace removal and Identifier shortening is done with
software after development/debugging. Though the identifier shortening
cannot be done by machine when the eval function is used to execute code
as the software cannot tell when the contents of a string literal are
going to be executed and refer to an identifier.
But if the code was going to be less readable it may as well be rendered
more efficient in the process:-
var setIO, bO = [], c = 0;
var dO = [
'<div style="position:absolute;left:',,'px;top:',,'px;width:',,
'px;height:',,'px;',,'">',,'</div>'
];
var fO = [
'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=',,
', sizingMethod=scale);'
];
var iO = ['<img src="',,'">'];
var L = [0, 0, 290,640,125, 50, 51,250, 0];
var T = [0, 0, 422, 42, 75,200,223,250, 0];
var W = [1000,1000,45 , 90, 78,726,724,182,1000];
var H = [600, 600, 34 ,146,280,167,119, 21, 600];
var I = [
"background2.png","background3.png","circuit3.png",
"circuit2.png", "circuit1.png", "window1.png",
"window2.png", "text.png", "background1.gif"
];
function aO(){return this.join('');}
if(document.body.filters){
setIO = function(a, f){(a[9] = fO)[1] = f;};
}else{
setIO = function(a, f){(a[11] = iO)[1] = f;};
}
bO.toString = dO.toString = fO.toString = iO.toString = aO;
dO[1] = L[c]; dO[3] = T[c]; dO[5] = W[c]; dO[7] = H[c];
iO[1] = I[c]; dO[11] = iO;
bO[bO.length] = String(dO);
dO[11] = '';
do{
dO[1] = L[++c]; dO[3] = T[c]; dO[5] = W[c]; dO[7] = H[c];
setIO(dO, I[c]);
bO[bO.length] = String(dO);
}while(c < 7);
dO[11] = bO; dO[9] = 'background:url('+I[8]+');';
dO[1] = L[8]; dO[3] = T[8]; dO[5] = W[8]; dO[7] = H[8];
document.write(dO);
Richard.
[Back to original message]
|