Single Quote Countdown Test

Psiklops

<font color=blue>Master of Useless Knowledge Coun
Joined
Mar 26, 2002
Messages
496
<Script language='Javascript'>var rndNum = Math.floor(Math.random() * 10000);eval("var CDTDate" + rndNum + " = 'May 17, 2003 1:00:00 PM EDT';");document.writeln("<form name='CDTform" + rndNum + "' action='Javascript:void(0);'>");document.writeln('<font size=2 color=darkblue>This is a test of a single quote\'s functionality</font><br>');document.writeln("<input type=text value='' size=40 name='WrittenByJamesMVenglarikII'>");document.writeln("</form>");if (theFunction) theFunction += "var d = new Date();";else var theFunction = "var d = new Date();";theFunction += "var c = new Date('" + eval("CDTDate" + rndNum) + "');";theFunction += "var tzo = (c.getTimezoneOffset() - d.getTimezoneOffset()) * 60;";theFunction += "var diff = ((c - d)/1000) + tzo;";theFunction += "var days = Math.floor(diff / 86400);";theFunction += "var rem = diff - (days * 86400);";theFunction += "var hours = Math.floor(rem / 3600);";theFunction += "rem = rem - (hours * 3600);";theFunction += "var minutes = Math.floor(rem / 60);";theFunction += "rem = rem - (minutes * 60);";theFunction += "var seconds = Math.floor(rem);";theFunction += "if ((days < 0) | (hours < 0) | (minutes < 0) | (seconds < 0)) ";theFunction += "var out = '';";theFunction += "else ";theFunction += "var out = ' ' + days + ' days ' + hours + ' hrs. ' + minutes + ' mins. ' + seconds + ' secs.';";theFunction += "document.forms.CDTform" + rndNum + ".elements.WrittenByJamesMVenglarikII.value = out;";setInterval(theFunction, 1000);</Script>
 
Ok, now with the escaped backslash...

<Script language='Javascript'>var rndNum = Math.floor(Math.random() * 10000);eval("var CDTDate" + rndNum + " = 'May 17, 2003 1:00:00 PM EDT';");document.writeln("<form name='CDTform" + rndNum + "' action='Javascript:void(0);'>");document.writeln('<font size=2 color=darkblue>This is a test of a single quote\\\'s functionality</font><br>');document.writeln("<input type=text value='' size=40 name='WrittenByJamesMVenglarikII'>");document.writeln("</form>");if (theFunction) theFunction += "var d = new Date();";else var theFunction = "var d = new Date();";theFunction += "var c = new Date('" + eval("CDTDate" + rndNum) + "');";theFunction += "var tzo = (c.getTimezoneOffset() - d.getTimezoneOffset()) * 60;";theFunction += "var diff = ((c - d)/1000) + tzo;";theFunction += "var days = Math.floor(diff / 86400);";theFunction += "var rem = diff - (days * 86400);";theFunction += "var hours = Math.floor(rem / 3600);";theFunction += "rem = rem - (hours * 3600);";theFunction += "var minutes = Math.floor(rem / 60);";theFunction += "rem = rem - (minutes * 60);";theFunction += "var seconds = Math.floor(rem);";theFunction += "if ((days < 0) | (hours < 0) | (minutes < 0) | (seconds < 0)) ";theFunction += "var out = '';";theFunction += "else ";theFunction += "var out = ' ' + days + ' days ' + hours + ' hrs. ' + minutes + ' mins. ' + seconds + ' secs.';";theFunction += "document.forms.CDTform" + rndNum + ".elements.WrittenByJamesMVenglarikII.value = out;";setInterval(theFunction, 1000);</Script>
 
Ok, now with an escaped backslash, but not escaped single quote...

Ok, that broke it (expected), so I'm reverting it back to the original...

<Script language='Javascript'>var rndNum = Math.floor(Math.random() * 10000);eval("var CDTDate" + rndNum + " = 'May 17, 2003 1:00:00 PM EDT';");document.writeln("<form name='CDTform" + rndNum + "' action='Javascript:void(0);'>");document.writeln('<font size=2 color=darkblue>This is a test of a single quote\'s functionality</font><br>');document.writeln("<input type=text value='' size=40 name='WrittenByJamesMVenglarikII'>");document.writeln("</form>");if (theFunction) theFunction += "var d = new Date();";else var theFunction = "var d = new Date();";theFunction += "var c = new Date('" + eval("CDTDate" + rndNum) + "');";theFunction += "var tzo = (c.getTimezoneOffset() - d.getTimezoneOffset()) * 60;";theFunction += "var diff = ((c - d)/1000) + tzo;";theFunction += "var days = Math.floor(diff / 86400);";theFunction += "var rem = diff - (days * 86400);";theFunction += "var hours = Math.floor(rem / 3600);";theFunction += "rem = rem - (hours * 3600);";theFunction += "var minutes = Math.floor(rem / 60);";theFunction += "rem = rem - (minutes * 60);";theFunction += "var seconds = Math.floor(rem);";theFunction += "if ((days < 0) | (hours < 0) | (minutes < 0) | (seconds < 0)) ";theFunction += "var out = '';";theFunction += "else ";theFunction += "var out = ' ' + days + ' days ' + hours + ' hrs. ' + minutes + ' mins. ' + seconds + ' secs.';";theFunction += "document.forms.CDTform" + rndNum + ".elements.WrittenByJamesMVenglarikII.value = out;";setInterval(theFunction, 1000);</Script>
 
If this is happening just when being saved into a signature, I can't think of any way to get it working because it seems to work properly in a post...

Gonna try it in my sig for a sec (will revert if it doesn't work)...

- Jim
 

Ok, after a few tests, I have determined the following in a signature:

\' - doesn't work - throws an error
\\' - works as intended
\\\' - doesn't work - throws an error

Same tests in a post:

\' - works as intended
\\' - doesn't work - throws an error
\\\' - doesn't work as intended - displays \'

So, it appears that there is a difference in if the Countdown Timer is posted in a signature or in a post. I would imagine the same thing would happen if someone put a single quote in the text to be displayed when the Countdown Timer reaches zero.

I've got nothing - anyone got any ideas?

- Jim
 
Can you eliminate the chracter alltogether?

JC
 
You mean just not allow single quotes? I guess I can do that (removing them from the text), but do you think anyone would raise a stink?

Come to think of it, this shouldn't be an issue in the text that appears when the timer reaches zero - the text for that part uses double quotes. I originally had it this way on the top text, but when the board translates the smilies into HTML, it messes up with the double quotes, so I had to go with single quotes, if that makes any sense. :)

- Jim
 
Can't everyone just use the ` character instead of ' ? Looks almost exactly the same to me.

JC
 
Can it substitute rather than remove?

JC
 
Works for me - gimmee a day or so to get it into the code and test it out...

- Jim
 
Ok, with the new character...

<Script language='Javascript'>var rndNum = Math.floor(Math.random() * 10000);eval("var CDTDate" + rndNum + " = 'May 17, 2003 1:00:00 PM EDT';");document.writeln("<form name='CDTform" + rndNum + "' action='Javascript:void(0);'>");document.writeln('<font size=2 color=darkblue>This is a test of a single quote`s functionality</font><br>');document.writeln("<input type=text value='' size=40 name='WrittenByJamesMVenglarikII'>");document.writeln("</form>");if (theFunction) theFunction += "var d = new Date();";else var theFunction = "var d = new Date();";theFunction += "var c = new Date('" + eval("CDTDate" + rndNum) + "');";theFunction += "var tzo = (c.getTimezoneOffset() - d.getTimezoneOffset()) * 60;";theFunction += "var diff = ((c - d)/1000) + tzo;";theFunction += "var days = Math.floor(diff / 86400);";theFunction += "var rem = diff - (days * 86400);";theFunction += "var hours = Math.floor(rem / 3600);";theFunction += "rem = rem - (hours * 3600);";theFunction += "var minutes = Math.floor(rem / 60);";theFunction += "rem = rem - (minutes * 60);";theFunction += "var seconds = Math.floor(rem);";theFunction += "if ((days < 0) | (hours < 0) | (minutes < 0) | (seconds < 0)) ";theFunction += "var out = '';";theFunction += "else ";theFunction += "var out = ' ' + days + ' days ' + hours + ' hrs. ' + minutes + ' mins. ' + seconds + ' secs.';";theFunction += "document.forms.CDTform" + rndNum + ".elements.WrittenByJamesMVenglarikII.value = out;";setInterval(theFunction, 1000);</Script>

Ok, that worked - and it worked in the signature. Should have the new code up in about 15 minutes...

- Jim
 
Ok, here's a post directly from the updated site...

<Script language='Javascript'>var rndNum = Math.floor(Math.random() * 10000);eval("var CDTDate" + rndNum + " = 'May 20, 2002 1:00:00 AM EST';");document.writeln("<form name='CDTform" + rndNum + "' action='Javascript:void(0);'>");document.writeln('<font size=2 color=darkblue>That`s all I have to say about that!</font><br>');document.writeln("<input type=text value='' size=40 name='WrittenByJamesMVenglarikII'>");document.writeln("</form>");if (theFunction) theFunction += "var d = new Date();";else var theFunction = "var d = new Date();";theFunction += "var c = new Date('" + eval("CDTDate" + rndNum) + "');";theFunction += "var tzo = (c.getTimezoneOffset() - d.getTimezoneOffset()) * 60;";theFunction += "var diff = ((c - d)/1000) + tzo;";theFunction += "var days = Math.floor(diff / 86400);";theFunction += "var rem = diff - (days * 86400);";theFunction += "var hours = Math.floor(rem / 3600);";theFunction += "rem = rem - (hours * 3600);";theFunction += "var minutes = Math.floor(rem / 60);";theFunction += "rem = rem - (minutes * 60);";theFunction += "var seconds = Math.floor(rem);";theFunction += "if ((days < 0) | (hours < 0) | (minutes < 0) | (seconds < 0)) ";theFunction += "var out = 'That\\\'s all, folks...';";theFunction += "else ";theFunction += "var out = ' ' + days + ' days ' + hours + ' hrs. ' + minutes + ' mins. ' + seconds + ' secs.';";theFunction += "document.forms.CDTform" + rndNum + ".elements.WrittenByJamesMVenglarikII.value = out;";setInterval(theFunction, 1000);</Script>

Seems to work just fine - now we just need to sit back and wait until someone finds a way to break this one! :D

- Jim
 
Lunch break...

I was already capturing the single quote to translate it into the escape-code sequence, so I just changed the code to translate to the backquote (whatever you call it). :)

- Jim
 












Receive up to $1,000 in Onboard Credit and a Gift Basket!
That’s right — when you book your Disney Cruise with Dreams Unlimited Travel, you’ll receive incredible shipboard credits to spend during your vacation!
CLICK HERE













DIS Facebook DIS youtube DIS Instagram DIS Pinterest DIS Tiktok DIS Twitter DIS Bluesky

Back
Top