Gossamer Forum
Home : General : Chit Chat :

Old Script - New problem

Quote Reply
Old Script - New problem
Hello All,

I used this holiday java script years ago and found a new need for it but now it does not work. I'm assuming it’s a browser issue - can some of you look at it and help me to get it working again.

Thanks in advance to this new challenge.

<script type="text/javascript"> <!-- ONE STEP TO EDITING TILL CHRISTMAS: --> <!-- Edit date and description. Add as necessary. --> <!-- Change D to number of dates to display. --> <!-- Change WHEN to change cutoff day. --> <!-- Change AFTER to change cutoff day after the holiday. --> <!-- This will allow display for a few days after holiday is done --> <!-- Beginning --> <!-- Holiday text color and size -->
holidaystring= "<font color='#000000' size='2'>";
var d = 61
var when = 30
var after = -2
var date1 = new Date("Jan 19, 2004");
var desc1 = "Martin Luther King Day";
var date2 = new Date("Jan 22, 2004");
var desc2 = "Chinese New Year";
var date3 = new Date("Feb 2, 2004");
var desc3 = "Groundhog Day";
var date4 = new Date("Feb 02, 2004");
var desc4 = "Black History Month";
var date5 = new Date("Feb 07 2004");
var desc5 = "Tu B'Shvat";
var date6 = new Date("Feb 12, 2004");
var desc6 = "Lincoln's Birthday";
var date7 = new Date("Feb 14, 2004");
var desc7 = "Valentine's Day";
var date8 = new Date("Feb 21, 2004");
var desc8 = "Carnival";
var date9 = new Date("Feb 22, 2004");
var desc9 = "Washington's Birthday";
var date10 = new Date("Feb 24, 2004");
var desc10 = "Mardi Gras";
var date11 = new Date("Feb 25, 2004");
var desc11 = "Lenten Season";
var date12 = new Date("Mar 01, 2004");
var desc12 = "Women's History Month";
var date13 = new Date("Mar 01, 2004");
var desc13 = "Pulaski Day";
var date14 = new Date("Mar 06, 2004");
var desc14 = "Holi";
var date15 = new Date("Mar 07, 2004");
var desc15 = "Purim";
var date16 = new Date("Mar 17, 2004");
var desc16 = "St. Patrick's Day";
var date17 = new Date("Apr 1, 2004");
var desc17 = "April Fools's Day";
var date18 = new Date("Apr 06, 2004");
var desc18 = "Passover";
var date19 = new Date("Apr 11, 2004");
var desc19 = "Easter";
var date20 = new Date("Apr 13, 2004");
var desc20 = "Baisakhi";
var date21 = new Date("Apr 15, 2004");
var desc21 = "Tax Day";
var date22 = new Date("Apr 18, 2004");
var desc22 = "National Volunteer Week";
var date23 = new Date("Apr 21, 2004");
var desc23 = "Administrative Professionals Day";
var date24 = new Date("Apr 22, 2004");
var desc24 = "Earth Day";
var date25 = new Date("Apr 30, 2004");
var desc25 = "Arbor Day";
var date26 = new Date("May 01, 2004");
var desc26 = "May Day";
var date27 = new Date("May 01, 2004");
var desc27 = "Derby Day";
var date28 = new Date("May 02, 2004");
var desc28 = "National Teacher Appreciation Week";
var date29 = new Date("May 06, 2004");
var desc29 = "Nurses Day";
var date30 = new Date("May 06, 2004");
var desc30 = "National Prayer Day";
var date31 = new Date("May 09, 2004");
var desc31 = "Mother's Day";
var date32 = new Date("May 26, 2004");
var desc32 = "Shavuot";
var date33 = new Date("May 31, 2004");
var desc33 = "Memorial Day";
var date34 = new Date("Jun 20, 2004");
var desc34 = "Father's Day";
var date35 = new Date("July 01, 2004");
var desc35 = "Canada Day";
var date36 = new Date("July 04, 2004");
var desc36 = "4th of July";
var date37 = new Date("July 14, 2004");
var desc37 = "Bastille Day";
var date38 = new Date("Sep 06, 2004");
var desc38 = "Labor Day";
var date39 = new Date("Sep 12, 2004");
var desc39 = "Grandparents Day";
var date40 = new Date("Sep 15, 2004");
var desc40 = "Jewish New Year";
var date41 = new Date("Sep 22, 2004");
var desc41 = "Business Women's Day";
var date42 = new Date("Sep 29, 2004");
var desc42 = "Sukkot";
var date43 = new Date("Oct 08, 2004");
var desc43 = "Simchat Torah";
var date44 = new Date("Oct 11, 2004");
var desc44 = "Columbus Day";
var date45 = new Date("Oct 11, 2004");
var desc45 = "Canadian Thanksgiving";
var date46 = new Date("Oct 15, 2004");
var desc46 = "Ramadan";
var date47 = new Date("Oct 16, 2004");
var desc47 = "Boss's Day";
var date48 = new Date("Oct 16, 2004");
var desc48 = "Sweetest Day";
var date49 = new Date("Oct 18, 2004");
var desc49 = "Sweetest Day";
var date50 = new Date("Oct 24, 2004");
var desc50 = "Mother-in-law's Day";
var date51 = new Date("Oct 31, 2004");
var desc51 = "Halloween";
var date52 = new Date("Nov 4, 2004");
var desc52 = "Election Day";
var date53 = new Date("Nov 11, 2004");
var desc53 = "Veterans Day";
var date54 = new Date("Nov 27, 2004");
var desc54 = "Thanksgiving";
var date55 = new Date("Nov 11, 2004");
var desc55 = "Remembrance Day";
var date56 = new Date("Nov 14, 2004");
var desc56 = "Hari Raya";
var date57 = new Date("Dec 07, 2004");
var desc57 = "Hanukkah";
var date58 = new Date("Dec 25, 2004");
var desc58 = "Christmas Day";
var date59 = new Date("Dec 26, 2004");
var desc59 = "Boxing Day";
var date60 = new Date("Dec 26, 2004");
var desc60 = "Kwanzaa";
var date61 = new Date("Jan 1, 2005");
var desc61 = "New Years Day";
<!-- DO NOT EDIT PASS HERE -->
var i
var arr = new Array(date1,date2,date3,date4,date5,date6,date7,date8,date9,date10,date11,date12,date13,date14,date15,date16,date17,date18,date19,date20,date21,date22,date23,date24,date25,date26,date27,date28,date29,date30,date31,date32,date33,date34,date35,date36,date37,date38,date39,date40,date41,date42,date43,date44,date45,date46,date47,date48,date49,date50,date51,date52,date53,date54,date55,date56,date57,date58,date59,date60,date61);
var desc= new Array(desc1,desc2,desc3,desc4,desc5,desc6,desc7,desc8,desc9,desc10,desc11,desc12,desc13,desc14,desc15,desc16,desc17,desc18,desc19,desc20,desc21,desc22,desc23,desc24,desc25,desc26,desc27,desc28,desc29,desc30,desc31,desc32,desc33,desc34,desc35,desc36,desc37,desc38,desc39,desc40,desc41,desc42,desc43,desc44,desc45,desc46,desc47,desc48,desc49,desc50,desc51,desc52,desc53,desc54,desc55,desc56,desc57,desc58,desc59,desc60,desc61);
var now = new Date();
for (i=0;i<d;i++) {
var diff = arr.getTime() - now.getTime();
var days = Math.floor (diff / (1000 * 60 * 60 * 24));
document.write(holidaystring)
if (days> 1) {
if (days <when) {
document.write(days+1 + " days until " + desc);
}}
else if (days == 1) {
document.write("<center><B><font color='blue' size='2'>")
document.write ("Only two days<br> until " + desc);
}
else if (days == 0) {
document.write("<center><B><font color='red' size='2'>")
document.write ("Tomorrow is " + desc);
}
else if (days == -1) {
document.write("<center><B><font color='red' size='2'>")
document.write ("It's " + desc + "!");
}
else { if (days> after) {
document.write("<center><B><font color='red' size='2'>")
document.write ("It's not too late for " + desc + "!");
}}
document.write("</B></center>");
}
<!-- End holiday --> </script>


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Old Script - New problem In reply to
Could it be from having html comment tags "<!-- comment -->" between the javascript tags?

Javascript comments are usually proceed with two slashes "// comment" for single line comments.
Quote Reply
Re: [Watts] Old Script - New problem In reply to
This line is causing your script to break (as best as I can tell):

var diff = arr.getTime() - now.getTime();
Quote Reply
Re: [Watts] Old Script - New problem In reply to
The comment lines are not a problem.

I am thinking it’s a browser issue but not sure in what capacity.

The script worked fine 2 years ago, so I took a peek at the site using Alexa WayBack Machine and the script is no longer working in that ... which leaves me to believe its not written correctly for the browsers now?????


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Post deleted by mkp In reply to

Last edited by:

mkp: May 11, 2006, 7:40 AM
Quote Reply
Re: [SandraR] Old Script - New problem In reply to
Seems to obvious but did you try changing 2004 to the current year?

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Old Script - New problem In reply to
Below is where the problem starts
=========================

var diff = arr.getTime() - now.getTime();
var days = Math.floor (diff / (1000 * 60 * 60 * 24));
document.write(holidaystring)
if (days> 1) {
if (days <when) {
document.write(days+1 + " days until " + desc);
}}
else if (days == 1) {
document.write("<center><B><font color='blue' size='2'>")
document.write ("Only two days<br> until " + desc);
}
else if (days == 0) {
document.write("<center><B><font color='red' size='2'>")
document.write ("Tomorrow is " + desc);
}
else if (days == -1) {
document.write("<center><B><font color='red' size='2'>")
document.write ("It's " + desc + "!");
}
else { if (days> after) {


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Old Script - New problem In reply to
Try changing:

var diff = arr.getTime() - now.getTime();

to:

var diff = arr{i}.getTime() - now.getTime();

Replace {} with [] as cannot use - markup tags italicize instead.

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln

Last edited by:

dan: May 30, 2006, 3:31 PM
Quote Reply
Re: [dan] Old Script - New problem In reply to
Did not work - ended up with a completely new error.

I bet its something simple like a bracket{ or ; missing.



Darn it.. (scratching head)


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Old Script - New problem In reply to
Worked for me when I made that one line edit. Did you replace the {} with [] in the line I suggested the revision? Do you have URL to script?

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] Old Script - New problem In reply to
 
Woohoo - ITS working :D

Thank so much WOOhOO

Doing the little jig at my desk!



THANK you
Dan - The Man!


Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Quote Reply
Re: [SandraR] Old Script - New problem In reply to
Good to hear, and you're welcome =)

----
Cheers,

Dan
Founder and CEO

LionsGate Creative
GoodPassRobot
Magelln
Quote Reply
Re: [dan] Old Script - New problem In reply to
for anyone wanting to use it -

also change the last holiday line from

var desc61 = "New Years Day";

to
var desc61 = "New Years Day"





Sandra Roussel
Chonsa Group Design - Fresh Start Housing