D
David J Trower
I am not that familiar with JavaScript, just enough that I can piece
together a script when looking at some examples that are similar to
what I want. However, I have reached a snag. I am working on a
script that I can have a list of multiple upcoming events, and the
JavaScript go through them and when it finds the one that should
currently be shown, displays it. I have the script working if I have
only one event in the code for it to parse, but I am wanting to avoid
having to edit the code on a weekly basis. Below is my code as it
currently stands. Any help would be greatly appreciated.
// var expireEvents = "06-24-2010-13-00-07-01-2010-12-59-Upcoming
Program-Greg Evans, 2010-2011 Northwest Waco Rotary President-July
1, 2010";
// var expireEvents = "07-01-2010-13-00-07-08-2010-12-59-Upcoming
Program-Kurt Slaughter, Texas Parks and Wildlife Game Warden-July 8,
2010";
// var expireEvents = "07-08-2010-13-00-07-15-2010-12-59-Upcoming
Program-Mike Cain, Oncor Area Manager-July 15, 2010";
var expireEvents = "07-15-2010-13-00-07-22-2010-12-59-Upcoming Program-
TBA-July 22, 2010";
// var expireEvents = "07-22-2010-13-00-07-29-2010-12-59-Upcoming
Program-Jason Jennings, Hillcrest COO-July 29, 2010";
// var expireEvents = "07-29-2010-13-00-08-05-2010-12-59-Upcoming
Program-Wes Allison, HOT Fair-August 5, 2010";
// var expireEvents = "08-05-2010-13-00-08-12-2010-12-59-Upcoming
Program-John Morris, 2010 Baylor Football Preview-August 12, 2010";
// var expireEvents = "08-12-2010-13-00-08-15-2010-00-00-Upcoming
Event-Beach Party with <em>The Morticians</em>-August 14, 2010";
// var expireEvents = "07-20-2010-15-30-07-25-2010-22-29-Upcoming
Program-Guest Speaker, XYZ Company-July 20, 2010";
var expireEvents = expireEvents.split('-');
var goLiveMonth;
var goLiveDay;
var goLiveYear;
var goLiveHour;
var goLiveMinute;
var expireMonth;
var expireDay;
var expireYear;
var expireHour;
var expireMinute;
var expireDST;
var exeventHeader;
var exeventSpeaker;
var exeventDate;
var goLiveDate;
var expireDate;
var mycontent;
goLiveMonth = expireEvents[0];
goLiveDay = expireEvents[1];
goLiveYear = expireEvents[2];
goLiveHour = expireEvents[3];
goLiveMinute = expireEvents[4];
expireMonth = expireEvents[5];
expireDay = expireEvents[6];
expireYear = expireEvents[7];
expireHour = expireEvents[8];
expireMinute = expireEvents[9];
exeventHeader = expireEvents[10];
exeventSpeaker = expireEvents[11];
exeventDate = expireEvents[12];
var goLiveDate = goLiveYear + goLiveMonth + goLiveDay + ' ' +
goLiveHour + ':' + goLiveMinute;
var expireDate = expireYear + expireMonth + expireDay + ' ' +
expireHour + ':' + expireMinute;
var mycontent = '<div id="labelzone"><br /><h3>' + exeventHeader + '</
h3><p>' + exeventSpeaker + '<br />' + exeventDate + '</p></div><!--
#labelzone-->';
var nowDate = new Date();
var day = nowDate.getDate();
var month = nowDate.getMonth();
var correctedMonth = month + 1; //month - JavaScript starts at "0"
for January, so we add "1"
if (correctedMonth < 10) { /* if less than "10", put a "0" in front
of the number. */
correctedMonth = "0" + correctedMonth;
}
if (day < 10) { /* if less than "10", put a "0" in front of the
number. */
day = "0" + day;
}
var year = nowDate.getYear(); /* Get the year. Firefox and Netscape
might use century bit, and two-digit year. */
if (year < 1900) {
year = year + 1900; /*This is to make sure Netscape AND FireFox
doesn't show the year as "107" for "2007." */
}
var hour = nowDate.getHours(); /* Get the hour. */
if (hour < 10) {
hour = "0" + hour;
}
var minute = nowDate.getMinutes(); /* Get the minute. */
if (minute < 10) {
minute = "0" + minute;
}
var GMTdate = year + "" + correctedMonth + "" + day + " " + hour + ":"
+ minute; //corrected month GMT date.
if ((GMTdate <= expireDate) && (GMTdate >= goLiveDate)) {
document.write(mycontent)
}
together a script when looking at some examples that are similar to
what I want. However, I have reached a snag. I am working on a
script that I can have a list of multiple upcoming events, and the
JavaScript go through them and when it finds the one that should
currently be shown, displays it. I have the script working if I have
only one event in the code for it to parse, but I am wanting to avoid
having to edit the code on a weekly basis. Below is my code as it
currently stands. Any help would be greatly appreciated.
// var expireEvents = "06-24-2010-13-00-07-01-2010-12-59-Upcoming
Program-Greg Evans, 2010-2011 Northwest Waco Rotary President-July
1, 2010";
// var expireEvents = "07-01-2010-13-00-07-08-2010-12-59-Upcoming
Program-Kurt Slaughter, Texas Parks and Wildlife Game Warden-July 8,
2010";
// var expireEvents = "07-08-2010-13-00-07-15-2010-12-59-Upcoming
Program-Mike Cain, Oncor Area Manager-July 15, 2010";
var expireEvents = "07-15-2010-13-00-07-22-2010-12-59-Upcoming Program-
TBA-July 22, 2010";
// var expireEvents = "07-22-2010-13-00-07-29-2010-12-59-Upcoming
Program-Jason Jennings, Hillcrest COO-July 29, 2010";
// var expireEvents = "07-29-2010-13-00-08-05-2010-12-59-Upcoming
Program-Wes Allison, HOT Fair-August 5, 2010";
// var expireEvents = "08-05-2010-13-00-08-12-2010-12-59-Upcoming
Program-John Morris, 2010 Baylor Football Preview-August 12, 2010";
// var expireEvents = "08-12-2010-13-00-08-15-2010-00-00-Upcoming
Event-Beach Party with <em>The Morticians</em>-August 14, 2010";
// var expireEvents = "07-20-2010-15-30-07-25-2010-22-29-Upcoming
Program-Guest Speaker, XYZ Company-July 20, 2010";
var expireEvents = expireEvents.split('-');
var goLiveMonth;
var goLiveDay;
var goLiveYear;
var goLiveHour;
var goLiveMinute;
var expireMonth;
var expireDay;
var expireYear;
var expireHour;
var expireMinute;
var expireDST;
var exeventHeader;
var exeventSpeaker;
var exeventDate;
var goLiveDate;
var expireDate;
var mycontent;
goLiveMonth = expireEvents[0];
goLiveDay = expireEvents[1];
goLiveYear = expireEvents[2];
goLiveHour = expireEvents[3];
goLiveMinute = expireEvents[4];
expireMonth = expireEvents[5];
expireDay = expireEvents[6];
expireYear = expireEvents[7];
expireHour = expireEvents[8];
expireMinute = expireEvents[9];
exeventHeader = expireEvents[10];
exeventSpeaker = expireEvents[11];
exeventDate = expireEvents[12];
var goLiveDate = goLiveYear + goLiveMonth + goLiveDay + ' ' +
goLiveHour + ':' + goLiveMinute;
var expireDate = expireYear + expireMonth + expireDay + ' ' +
expireHour + ':' + expireMinute;
var mycontent = '<div id="labelzone"><br /><h3>' + exeventHeader + '</
h3><p>' + exeventSpeaker + '<br />' + exeventDate + '</p></div><!--
#labelzone-->';
var nowDate = new Date();
var day = nowDate.getDate();
var month = nowDate.getMonth();
var correctedMonth = month + 1; //month - JavaScript starts at "0"
for January, so we add "1"
if (correctedMonth < 10) { /* if less than "10", put a "0" in front
of the number. */
correctedMonth = "0" + correctedMonth;
}
if (day < 10) { /* if less than "10", put a "0" in front of the
number. */
day = "0" + day;
}
var year = nowDate.getYear(); /* Get the year. Firefox and Netscape
might use century bit, and two-digit year. */
if (year < 1900) {
year = year + 1900; /*This is to make sure Netscape AND FireFox
doesn't show the year as "107" for "2007." */
}
var hour = nowDate.getHours(); /* Get the hour. */
if (hour < 10) {
hour = "0" + hour;
}
var minute = nowDate.getMinutes(); /* Get the minute. */
if (minute < 10) {
minute = "0" + minute;
}
var GMTdate = year + "" + correctedMonth + "" + day + " " + hour + ":"
+ minute; //corrected month GMT date.
if ((GMTdate <= expireDate) && (GMTdate >= goLiveDate)) {
document.write(mycontent)
}