<script type="text/javascript" language="javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script> <script type="text/javascript" language="javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/lang-css.js"></script> <script type="text/javascript"><code class="prettyprint linenums:4">
<!-----------------
Global Functions
------------------>
<cffunction name="makeHeader"
hint="Makes page headers, wrapping the header in standard HTML for this web site">
<cfargument name="header"
required="true">
<cfset var returnContent = "">
<cfoutput>
<cfsavecontent variable="returnContent">
<table class="boxHeader"
width="550"
border="0"
cellpadding="3"
cellspacing="0">
<tr>
<td class="boxHeader">
#header#</td>
</tr>
</table>
</cfsavecontent>
</cfoutput>
<cfreturn returnContent>
</cffunction>
<cffunction name="wrapTable"
hint="Wraps content in a standard style table for this web site.">
<cfargument name="content"
required="true">
<cfargument name="header"
required="true">
<cfset var returnContent = "">
<cfoutput>
<cfsavecontent variable="returnContent">
<table width="550"
class="form"
cellpadding="5"
cellspacing="0"
border="0">
<tr>
<td class="boxHeader">
#header#</td>
</tr>
<tr>
<td bgcolor="##D1DFEC" width="529" valign="top">
#arguments.content#</td>
</tr>
</table>
</cfsavecontent>
</cfoutput>
<cfreturn returnContent>
</cffunction>
<cffunction name="getRenderer"
hint="Factory method for Renderer objects for the form style of this web site">
<cfargument name="width"
required="false"
default="525">
<cfscript>
var renderer = getSAMSFormBuilder().getOverUnderRenderer(arguments.width);
renderer.setCellPadding(3);
renderer.setSubmitButtonAlignment(renderer.RIGHT);
renderer.setErrorMessageStyle("formError");
renderer.setRequiredSymbolStyle("requiredSymbol");
return renderer;
</cfscript>
</cffunction>
<cfscript>
// Factory method for Form objects
function getForm(name)
{
var theForm = getSAMSFormBuilder().getForm(name);
theForm.setSubmitButtonImageURL("images/but_continue.jpg");
theForm.useSubmitButtonImageOnRender(true);
return theForm;
}
// Factory method for Formatter objects
function getFormatter()
{
return CreateObject("component", "com.westgateresorts.web.Formatter");
}
// Factory method for SAMSFormBuilder objects
function getSAMSFormBuilder()
{
return application.G_SAMS_FORMBUILDER;
}
// Converts return characters in plain text to HTML <br> tags
function plainTextToHTML(convertString)
{
return Replace(convertString, Chr(10), "<br>", "ALL");
}
// Standard Fusebox JSP forward function
function fuseboxForward(XFA, attributesScope)
{
GetPageContext().forward("#request.G_SELF_FUSEACTION##XFA#&#attributesToURLString(attributesScope)#");
}
// Standard attributes to URL encoded string function
function attributesToURLString(attributesScope)
{
var returnValue = "";
var listOfKeys = StructKeyList(attributesScope);
var listArray = ListToArray(listOfKeys);
for (i = 1; i LTE ArrayLen(listArray); i = i + 1)
{
if ((CompareNoCase(listArray[i], 'FIELDNAMES') NEQ 0) AND (CompareNoCase(listArray[i], 'FUSEACTION') NEQ 0))
{
returnValue = returnValue & listArray[i] & "=" & URLEncodedFormat(StructFind(attributesScope, listArray[i])) & "&";
}
}
// Trim trailing ampersand
if (Len(returnValue) gt 0)
{
returnValue = Mid(returnvalue, 1, (Len(returnValue) - 1));
}
return returnValue;
}
// Adds BreadCrumb objects to the global breadcrumb stack for this page request
function addBreadCrumb(newBreadCrumb)
{
ArrayAppend(request.G_BREADCRUMB, newBreadCrumb);
}
// Factory method for BreadCrumb objects
function breadCrumb(BCText, BCLink)
{
return CreateObject("Component", "objects.BreadCrumb").init(BCText, BCLink);
}
// Factory method for WGRMenu object
function getWGRMenuObject()
{
return CreateObject("Component", "objects.WGRMenu");
}
// Renders the BreadCrumb objects on the global breadcrumb stack for this page request
function renderBreadCrumb(breadCrumbArray)
{
var returnString = "";
var currentBreadCrumb = "";
var currentText = "";
var currentLink = "";
var finalText = "";
for (i = 1; i lte ArrayLen(breadCrumbArray); i = i + 1)
{
currentBreadCrumb = breadCrumbArray[i];
currentText = currentBreadCrumb.getText();
currentLink = currentBreadCrumb.getLink();
if ((currentLink eq "") or (i eq ArrayLen(breadCrumbArray)))
{
finalText = currentText;
}
else
{
finalText = '<a href ="' & currentLink & '">' & currentText & "</a>";
}
if (returnString eq "")
{
returnString = " " & finalText;
}
else
{
returnString = returnString & " | " & finalText;
}
}
return returnString;
}
function populateSelectListWithDestinations(selectListObject)
{
var currentDestination = "";
var destinationName = "";
// Get all of the resort destinations
var resortDestinations = application.G_WGRESORTS.getResortLocations();
// Go through all the resort local destinations
for(i = 1; i lte ArrayLen(resortDestinations); i = i + 1)
{
// Get the destination at the i-th location and prepare the name
currentDestination = resortDestinations[i];
destinationName = (currentDestination.getTwoLetterState() & " - " & currentDestination.getName());
// Add the name of the i-th destination to the select list object
selectListObject.addOption(destinationName, destinationName);
}
}</cfscript>
<cffunction name="getWestgateResortsObject"
access="public"
output="false"
returnType="com.westgateresorts.wgr.WGResorts"
hint="Returns a reference to the global WGResorts component">
<cfreturn application.G_WGRESORTS>
</cffunction>
<cffunction name="getHotWeeksPhone"
access="public"
output="false"
returnType="string"
hint="Returns the phone number displayed on the Hot Weeks page.">
<cfreturn application.G_HOTWEEKS_PHONE>
</cffunction>
<cffunction name="getGoogleAnalyticsCode"
access="public"
returnType="string"
hint="Outputs google analytics code according to the environment settings.">
<cfset var googleAnalyticsEnabled = application.G_GOOGLE_ANALYTICS_ENABLED>
<cfset var returnContent = "">
<cfoutput>
<cfsavecontent variable="returnContent">
<cfif googleAnalyticsEnabled>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-758430-2";
urchinTracker();
</script>
</cfif>
</cfsavecontent>
</cfoutput>
<cfreturn returnContent>
</cffunction>
</code>
Read more: http://forum.codecall.net/topic/34933-coldfusion-example-code/#ixzz2JDDVncdq
<style type="text/css"> /* Pretty printing styles. Used with prettify.js. */ .str { color: #080; } .kwd { color: #008; } .com { color: #800; } .typ { color: #606; } .lit { color: #066; } .pun { color: #660; } .pln { color: #000; } .tag { color: #008; } .atn { color: #606; } .atv { color: #080; } .dec { color: #606; } pre.prettyprint { padding: 2px; border: 1px solid #888; } @media print { .str { color: #060; } .kwd { color: #006; font-weight: bold; } .com { color: #600; font-style: italic; } .typ { color: #404; font-weight: bold; } .lit { color: #044; } .pun { color: #440; } .pln { color: #000; } .tag { color: #006; font-weight: bold; } .atn { color: #404; } .atv { color: #060; } } </style>
- <script type="text/javascript">
- // Say hello world until the user starts questioning
- // the meaningfulness of their existence.
- function helloWorld(world) {
- for (var i = 42; --i >= 0;) {
- alert('Hello ' + String(world));
- }
- }
- </script>
- <style>
- p { color: pink }
- b { color: blue }
- u { color: "umber" }
- </style>
No comments:
Post a Comment