Specifications
Data Translators 237
/**************************************************************
* The replaceKentTag() function assembles the HTML that will *
* replace the KENT tag and the special locking tags that will *
* surround the HTML. It calls the getImage() function to *
* determine the SRC of the IMG tag. *
**************************************************************/
function replaceKentTag(){
// The image to display.
var image = getImage();
// The location of the image on the local disk.
var depFiles = dreamweaver.getSiteRoot() + image;
// The IMG tag that will be inserted between the lock tags.
var imgTag = ’<IMG SRC="/’ + image + ’" WIDTH="320" HEIGHT="240"
ALT="Kent">\n’;
// 1st part of the opening lock tag. The remainder of the tag is assembled
below.
var start = ’<MM:BeginLock translatorClass="DREAMWEAVER_TEAM" type="kent"’;
// The closing lock tag.
var end = ’<MM:EndLock>’;
//Assemble the lock tags and the replacement HTML.
var replCode = start + ’ depFiles="’ + depFiles + ’"’;
replCode = replCode + ’ orig="%3Ckent%3E">\n’;
replCode = replCode + imgTag;
replCode = replCode + end;
return replCode;
}
/******************************************************************
* The getImage() function determines which image to display *
* based on the day of the week, the time of day and the *
* user’s platform. The day and time are figured based on UTC *
* time (Greenwich Mean Time) minus 8 hours, which gives *
* Pacific Standard Time (PST). No allowance is made for Daylight *
* Savings Time in this routine. *
******************************************************************/
function getImage(){
var today = new Date(); // Today’s date & time.
var day = today.getUTCDay(); // Day of the week in the GMT time zone.
// 0=Sunday, 1=Monday, and so on.
var hour = today.getUTCHours(); // The current hour in GMT, based on the
// 24-hour clock.
var SFhour = hour - 8; // The time in San Francisco, based on the
// 24-hour clock.
var platform = navigator.platform; // User’s platform. All Windows machines
// are identified by Dreamweaver as "Win32",
// all Macs as "MacPPC".
var imageRef; // The image reference to be returned.
// If SFhour is negative, you have two adjustments to make.
// First, subtract one from the day count because it is already the wee
// hours of the next day in GMT. Second, add SFhour to 24 to
// give a valid hour in the 24-hour clock.
if (SFhour < 0){
day = day - 1;
// The day count back one would make it negative, and it’s Saturday,
// so set the count to 6.
if (day < 0){
day = 6;
}
SFhour = SFhour + 24;
}