Adobe Extending Dreamweaver CS4 User Manual

Page 348

Advertising
background image

342

EXTENDING DREAMWEAVER CS4

Data translators

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 computers
// 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;

}

// Now determine which photo to show based on whether it's a work day or a
// weekend; what time it is; and, if it's a time and day when Kent is
// working, what platform the user is on.

//If it's not Sunday
if (day != 0){

//And it's between 10am and noon, inclusive
if (SFhour >= 10 && SFhour <= 12){

imageRef = "images/kent_tiredAndIrritated.jpg";

//Or else it's between 1pm and 3pm, inclusive

}else if (SFhour >= 13 && SFhour <= 15){

imageRef ="images/kent_hungry.jpg";

//Or else it's between 4pm and 5pm, inclusive
}else if (SFhour >= 16 && SFhour <= 17){

//If user is on Mac, show Kent working on Mac
if (platform == "MacPPC"){

imageRef = "images/kent_gettingStartedOnMac.jpg";

//If user is on Win, show Kent working on Win
}else{

imageRef = "images/kent_gettingStartedOnWin.jpg";

}

//Or else it's after 6pm but before the stroke of midnight
}else if (SFhour >= 18){

//If it's Saturday
if (day == 6){

imageRef = "images/kent_dancing.jpg";

//If it's not Saturday, check the user's platform
}else if (platform == "MacPPC"){

imageRef = "images/kent_hardAtWorkOnMac.jpg";

Advertising
This manual is related to the following products: