You are here: Re: For Those On The Cutting Edge Of Web Design « HTML « IT news, forums, messages
Re: For Those On The Cutting Edge Of Web Design

Posted by Onideus Mad Hatter on 07/11/05 02:22

On Sun, 10 Jul 2005 22:35:13 GMT, Michael Winter
<m.winter@blueyonder.co.uk> wrote:

>On 10/07/2005 16:37, ^reaper^ wrote:
>
>[snip]
>
>> The point *was* you accomplish the same end result. Obviously the
>> approach is differnt. One does not even need to know js to see that.
>
>But people less familiar with ECMAScript wouldn't associate one with the
>other unless they were shown side-by-side, which was why I did it. It
>wasn't for your benefit. :)
>
>> The primary question is, does the browser support it? [...]
>
>Of course.
>
>> if( document.getElementById )return document.getElementById(name).style;
>> else if( document.links )return document.links[name].style;
>> else if( document.all )return eval('document.all.'+name+'.style');
>
>If you do still use that code, you should swap the order of the links
>and all collection branches (as well as replace the eval call). Whilst
>IE does support the links collection, you cannot use strings as indices
>so you shouldn't allow it to reach that statement. That said, only IE4
>would get that far (IE 3 doesn't implement the all collection), so it's
>clearly not a concern if you don't care about something that old.
>
>[snip]
>
>>> The alternative to this is to create a large switch statement with each
>>> clause containing a separate function call with a finite number of
>>> arguments. [...]
>>
>> Why not simply set the function to accept an array argument?
>
>That's a possible solution if you have control over the called function,
>as is using an object.
>
>[snip]
>
>>> Well, part of it seems to be missing [...]
>>
>> There is no "full code." It was nothing more than speculation in response
>> to other psoted code. Though, I did upload both example snippets (as per my
>> response to Michael).
>
>I'm Michael. He's Richard. :P
>
>I did find that thread when looking for the original post, but it's a
>bit difficult when you don't allow your posts to be archived. ;) Noodles
>also seems to have removed his page.
>
>There's a vast amount of redundancy in the original code, and from what
>I remember, that's almost entirely due to the markup with which the
>script is supposed to interact.
>
>For instance, rather than using groups of radio buttons to determine
>over what period the input relates, he seems to have used individual
>checkboxes, giving the impression that one must check each one,
>producing that massive if..else statement.
>
>As for your code, it is a vast improvement, but it still has its own
>redundancy.
>
>The functions all set the output themselves. It would be better if they
>returned the value, not only because writing the output would occur in
>one place, but it also shouldn't be the responsibility of that
>particular code to perform any kind of I/O.
>
>The statements within each clause of the switch statement only really
>differ in three ways: multiplication versus division; where the data
>comes from; and what arguments are passed to the calculation function.
>As I don't like code duplication, I'd probably have the data retrieval
>code (for want of a better expression) execute whether the data was
>needed or not. The execution time would be marginal anyway. As you'd now
>have all of the data, you could just homogenise the interface to each
>function and pass the lot. I don't really like that idea though, but
>changing the scope of the functions isn't any better, either. The final
>issue is also awkward. Perhaps the data could be normalised, or the two
>functions that are called later could take the reciprocal of the
>relevant argument.
>
>[snip]
>
>>> alt.2600 remains cross-posted purely for your benefit, and perhaps that
>>> of OMH.
>>
>> You wouldn't want teh /Guru/ of teh interweb to miss out on this, would
>> you?
>
>Guru? You are still talking about OMH, right?
>
>> Though... you *do* realize he's a t0rll, right? o_O
>
>Of course. He might not be courteous, but I am (usually). :)
>
>[snip]
>
>Mike

Speakin of code, unlike you silly little alt.html screwballs I
actually step the fuck up and produce.

Here's teh new quasi future green layout I'm workin on:
http://www.backwater-productions.net/_test_platform/quasifuturegreen/

I just got through rewriting teh code from this:
: IE = document.all ? true : false;
:
:
: if (IE)
: {
: document.write("<div style='position:absolute; left:0px; top:0px; width:1000px; height:600px; background:url(background1.gif)'>");
: document.write("<div style='position:absolute; left:0px; top:0px; width:1000px; height:600px'><img src='background2.png'></div>");
: document.write("<div style='position:absolute; left:0px; top:0px; width:1000px; height:600px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=background3.png, sizingMethod=scale)'></div>");
: document.write("<div style='position:absolute; left:125px; top:75px; width:78px; height:280px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=circuit1.png, sizingMethod=scale)'></div>");
: document.write("<div style='position:absolute; left:290px; top:422px; width:45px; height:34px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=circuit3.png, sizingMethod=scale)'></div>");
: document.write("<div style='position:absolute; left:640px; top:42px; width:90px; height:146px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=circuit2.png, sizingMethod=scale)'></div>");
: document.write("<div style='position:absolute; left:50px; top:200px; width:726px; height:167px'><img src='window1.png' ></div>");
: document.write("<div style='position:absolute; left:51px; top:223px; width:724px; height:119px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=window2.png, sizingMethod=scale)'></div>");
: document.write("<div style='position:absolute; left:250px; top:250px; width:182px; height:21px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=text.png, sizingMethod=scale)'></div>");
: document.write("</div>");
: }
:
: else
: {
: document.write("<div style='position:absolute; left:0px; top:0px; width:1000px; height:600px; background:url(background1.gif)'>");
: document.write("<div style='position:absolute; left:0px; top:0px; width:1000px; height:600px'><img src='background2.png'></div>");
: document.write("<div style='position:absolute; left:0px; top:0px; width:1000px; height:600px'><img src='background3.png'></div>");
: document.write("<div style='position:absolute; left:125px; top:75px; width:78px; height:280px'><img src='circuit1.png' ></div>");
: document.write("<div style='position:absolute; left:290px; top:422px; width:45px; height:34px '><img src='circuit3.png' ></div>");
: document.write("<div style='position:absolute; left:640px; top:42px; width:90px; height:146px'><img src='circuit2.png' ></div>");
: document.write("<div style='position:absolute; left:50px; top:200px; width:726px; height:167px'><img src='window1.png' ></div>");
: document.write("<div style='position:absolute; left:51px; top:223px; width:724px; height:119px'><img src='window2.png' ></div>");
: document.write("<div style='position:absolute; left:250px; top:250px; width:182px; height:21px '><img src='text.png' ></div>");
: document.write("</div>");
: }


To this:
: var IE = document.all ? true : false;
: var $A = "<div style='position:absolute; left:";
: var $B = "px; top:";
: var $C = "px; width:";
: var $D = "px; height:";
: var $E1 = "px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=";
: var $F1 = ", sizingMethod=scale)'></div>";
: var $E2 = "px; background:url(";
: var $F2 = ")'>";
: var $E3 = "px'><img src='";
: var $F3 = "' ></div>";
: var $G = "</div>";
: var L = new Array(9);
: var T = new Array(9);
: var W = new Array(9);
: var H = new Array(9);
: var I = new Array(9);
: var i = 1;
:
:
: L[1] = 0; T[1] = 0; W[1] = 1000; H[1] = 600; I[1] = "background1.gif";
: L[2] = 0; T[2] = 0; W[2] = 1000; H[2] = 600; I[2] = "background2.png";
: L[3] = 0; T[3] = 0; W[3] = 1000; H[3] = 600; I[3] = "background3.png";
: L[4] = 290; T[4] = 422; W[4] = 45; H[4] = 34; I[4] = "circuit3.png";
: L[5] = 640; T[5] = 42; W[5] = 90; H[5] = 146; I[5] = "circuit2.png";
: L[6] = 125; T[6] = 75; W[6] = 78; H[6] = 280; I[6] = "circuit1.png";
: L[7] = 50; T[7] = 200; W[7] = 726; H[7] = 167; I[7] = "window1.png";
: L[8] = 51; T[8] = 223; W[8] = 724; H[8] = 119; I[8] = "window2.png";
: L[9] = 250; T[9] = 250; W[9] = 182; H[9] = 21; I[9] = "text.png";
:
:
: do
: {
: if ( i == 1 ) { document.write( $A + L[i] + $B + T[i] + $C + W[i] + $D + H[i] + $E2 + I[i] + $F2 ); }
: else if ( i == 10 ) { document.write( $G ); }
: else
: {
: if (IE) { document.write( $A + L[i] + $B + T[i] + $C + W[i] + $D + H[i] + $E1 + I[i] + $F1 ); }
: else { document.write( $A + L[i] + $B + T[i] + $C + W[i] + $D + H[i] + $E3 + I[i] + $F3 ); }
: }
: i++;
: }
: while (i <= 10);

I could probably make it even more efficient if I used case instead of
do/while. Oh, even further, I could cram all that + L[i] + $B + T[i]
+ $C + W[i] + $D + H[i] + stuff into a another variable that way I
would only need to use it once instead of 3 times. Oh and then I
could change all my variables to single letters. Oh and then I could
lose the whole easy to view list of arrays and then just lay them out
across using commas. Oh and I could change all my image names to one
letter...oh even better I could assign the file extensions to single
letter variables. And then I could take off all the var's cause it'll
parse just fine without em and then heck, it'll be even MORE
efficient! Oh and then I could assign "new Array(9)" to a single
letter variable and then I would only need to use it once!

....of course, if I did even half of that...boy it'd sorta make teh
code a lil hard to read, wouldn't it?

Bottom line is...teh code works, one way or the other. Working,
functional code that's actually in use...that's better than anything
lil Richie or this Michael guy has produced thus far.

--

Onideus Mad Hatter
mhm ¹ x ¹
http://www.backwater-productions.net

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация