madeupname wrote on 28 Nov 2003:
Oh dear, here we go. Did it occur to you that Gino might be a
kid or a Newbie? Goggled eyed & amazed at the (USEFUL and
USELESS - FUN and SERIOUS) stuff that JavaScript can do.
No it didn't, and my comments are valid even if Gino is. That might
seem callous, but a script like that teaches nothing but bad
practice. By encouraging new users to avoid such scripts, you are
doing them a favour by not exposing them to such terrible scripting.
You can't learn from that script: it's badly formatted, uncommented,
and browser dependent.
Instead of encouraging possible new "JavaScripters" into the
fold thus expanding and continuing the language, you think it's
better to put them down and put them off.
No, I think it's better to steer them away from bad practice
techniques and annoying their users.
If we look at it your way, why bother with images, fonts,
colours, themes and layouts? They serve no purpose other than
eye candy taking up download time and hard drive space.
Don't talk to me about inappropriate comments, then spout rubbish
like that. It's been proven that visual elements in presentations
help convey ideas and aid understanding. They add interest and help
attract users. Nothing but plain text in monochrome will bore them
and drive them away. However, a clock that follows the cursor doesn't
aid understanding or convey ideas. It does add interest, but only
until the user gets bored of it and prays for some way to disable it
(which I doubt the author will give them the option to do).
So, how about a comprimise. Gino, if you really do want this script
to appear on your page, by all means include it, but please add the
code below to your page. It will allow the user to disable and re-
enable the script at will.
Add this to the top of the clock script:
var delayTimer = null;
....then find in the Delay() function the setTimeout(...) line, and
change it to:
delayTimer = setTimeout('Delay()',20);
Those lines allow my code to reference the timer that updates the
clock and disable it.
Then place this code below with the script
<SCRIPT type="text/javascript">
function disableClock( isDisabled ) {
if (isDisabled) {
// If the timeout has been set, disable it
if (delayTimer) window.clearTimeout( delayTimer );
// ...then hide the clock
hideClock( true );
} else {
// Call the function that performs the clock updates
Delay();
// ...then show the clock
hideClock( false );
}
}
function hideClock( isShown ) {
var i, showValue;
if (ns) {
showValue = isShown ? show : hide;
for (i=0; i < n; i++) {
document.layers['nsFace'+i].visibility = showValue;
}
for (i=0; i < H.length; i++) {
document.layers['nsHours'+i].visibility = showValue;
}
for (i=0; i < M.length; i++) {
document.layers['nsMinutes'+i].visibility = showValue;
}
for (i=0; i < S.length; i++) {
document.layers['nsSeconds'+i].visibility = showValue;
}
for (i=0; i < D.length; i++) {
document.layers['nsDate'+i].visibility = showValue;
}
} else if (ie) {
showValue = isShown ? 'none' : 'inline';
for (i=0; i < n; i++) {
ieFace
.style.display = showValue;
}
for (i=0; i < H.length; i++) {
ieHours.style.display = showValue;
}
for (i=0; i < M.length; i++) {
ieMinutes.style.display = showValue;
}
for (i=0; i < S.length; i++) {
ieSeconds.style.display = showValue;
}
for (i=0; i < D.length; i++) {
ieDate.style.display = showValue;
}
}
}
</SCRIPT>
That disables (or re-enables) the clock updates, then hides the clock
elements.
Then place this in your document. As it is, the checkbox will sit to
the right of your page with the rest of your content unaffected by
it.
<DIV style="float: right">
<INPUT type="checkbox" id="disable-clock" value="disable"
onclick="disableClock(this.checked)">
Hey Gino! I've checked your page.
So did I. Odd that you didn't comment on that...
In Explorer 6, it throws up a warning about an unterminated string
constant at line 4 but the clock works after wards!
Strange. When I tested it, IE 6 reported an invalid argument on line
124 (a Math.sin() call), though it's valid.
Although it's rare, the "advertising/whatever" script Geocities
inserts into all its hosted pages might be causing a conflict???
That's what I thought, too. When testing my code addition above,
removing the rubbish that GeoCities adds allows the script to run
again.
PS: Never let anyone tell you what to do with YOUR web pages.
No, don't. But if it's good advice and you don't take it, don't
expect many happy visitors.
Be aware that adding any other scripts (or something to the onload
intrinsic event) will cause serious incompatibility problems. This
script needs a complete overhaul...
Mike