beautypg.com

Adobe Extending Dreamweaver CS4 User Manual

Page 347

background image

341

EXTENDING DREAMWEAVER CS4

Data translators

// locking tags. For more information on the repacement operation, see
// the comments in the replaceKentTag() function.
outStr = outStr + replCode;

// Copy everything after the KENT tag.
outStr = outStr + inStr.substring(start+6);

// Use the string you just created for the next trip through
// the document. This is the most inefficient part of all.
inStr = outStr;
start = inStr.indexOf('');

}
// When there are no more KENT tags in the document, return outStr.
return outStr;

}

/**************************************************************
* 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 = 'Kent\n';
// 1st part of the opening lock tag. The remainder of the tag is assembled
below.
var start = '// The closing lock tag.
var end = '';

//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.

This manual is related to the following products: