Specific Properties and User Methods
Last edit by:
Walter Davis
7 Apr, 2009
Pages in this section:
- A Hello World tutorial
- Action Elements
- Class FWAction
- Class FWActionList
- Class FWAttribute
- Class FWColor
- Class FWLinkParameter
- Class FWListData
- Class FWOSAInterpreter
- Class FWOutput
- Class FWPage
- Class FWParameter
- Class FWParameterList
- Class FWTag
- Files and Freeway Actions
- Organisation of Classes
- Specific Properties and User Methods
- Weaver
Global Properties and Methods
These properties and user methods are global and are not attached to a particular object.
fwFreewayVersion (read only)
This returns a string with the version of Freeway that is running.
fwRegion (read only)
This returns the region code to which Freeway is currently localized. In a dual-language build such as Freeway 3J, which has an interface that can be switched between English and Japanese, it will return the region of the current interface. For a full list of regions see the support document “Localising Freeway Actions” on the Actions web site.
Examples:
if (fwRegion==0)
alert("Freeway is localised for the United States.");
else
alert("Freeway is NOT localised for the United States.");
or
if (fwRegion==14)
alert("Freeway is localised for Japan.");
else
alert("Freeway is NOT localised for Japan.");
fwTimeout (read/write)
This is the interval in 60ths of a second that can elapse before the JavaScript interpreter automatically terminates a JavaScript interface method in your Action. You should avoid writing code which takes so long to execute that it will time out. So this value is unlikely to need changing, the default is 5 seconds (5 !60). Effectively, you should not need to alter this default – fix your code instead!
Example:
// set the timeout to 10 seconds
fwTimeout=10*60;
Methods
alert(string[,string])
This will cause Freeway to put a dialog box on your screen displaying the
text passed in. The dialog One or more strings has an OK and an Abort
button. Clicking on the Abort button will cause execution of the JavaScript
to abort.
The internal timer, which times out interface methods when they exceed the
limit set in the global property fwTimeout, is paused during the execution of
this method.
Note: This method differs from the alert method that is present within the JavaScript of most browsers in that it accepts multiple arguments separated by commas.
Examples
alert("Hello")
causes an alert dialog box with the text “Hello” to appear.
alert(1+2);
(non-string or numerical parameter) causes an alert dialog box with the text “3” to appear.
alert("My name is ","Gustav.");
causes an alert dialog with the text “My name is Gustav.” to appear (concatenating the strings).
confirm(string[,string])
This will cause Freeway to put a dialog box up on your screen displaying
the text that is passed one or more strings in the parameters. The dialog
has an OK button, a Cancel button and an Abort button.
The method returns true if the user clicks on the OK button but if the user
clicks Cancel it returns false. Clicking on the Abort button will cause
execution of the JavaScript to abort. If you are building a site then the build
process will stop in the same way as if you had clicked on the Stop button
in the Progress dialog when publishing.
The internal timer, which times out interface methods that exceed the limit
set in the global property fwTimeout is paused during the execution of this
method.
Note: This method differs from the confirm method that is present within the JavaScript of most browsers in that it accepts multiple arguments separated by commas.
Examples:
confirm("It is a nice day?");
Causes a confirm dialog with the text “It is a nice day?” to appear:
confirm("Your name is ","Gustav?");
Causes a confirm dialog with the text “Your name is Gustav?” to appear.
fwAbort(string[,string])
This method will cause the publishing process to be aborted. It should only be called while you One or more strings are publishing and do not want to continue uploading. The strings passed will be concatenated together and non-string parameters converted to strings, and posted as an alert. The effect of this is the same as someone manually aborting publishing. It is not possible to abort publishing without the dialog appearing. You might use this in the case of an error occurring.
Example:
The following Action will abort publishing, with the message as shown in the dialog box
<item-action name="test">
<action-javascript>
function fwAfterEndBody()
{
fwAbort("Your coat is to dark for publishing to continue.");
}
</action-javascript>
</item-action>
fwEncode(string[,page][,delimiters])
This method will convert the string into the encoding specified for the page. The string that is returned is in an encoded form, suitable for use in the HTML on the page specified. For example, if the page is set to “ISO8859- 1” encoding, the text will be converted to that specific encoding for this page, allowing coding to be consistent with the current page. This means that the text will be correctly encoded if the page is, for example, Japanese. It will also ensure that special characters are correctly translated into the required HTML. If no page is passed it will merely ensure that special characters are correctly translated.
Arguments:
string: The string to be encoded
page (optional)
The encoding for this page will be used to encode the stringdelimiters (optional)the returned string will be delimited by these characters
Example:
The following code adds the markup for a text area. It uses fwEncode to produce an encoded form of the value parameter in the output.
function addTextArea(name, value)
{
// this adds the code and encodes the value
// appropriately
// <textarea ‘name= name value> </textarea>
fwDocument.fwWrite("<textarea name = '", name, "'>",
fwEncode(value, fwPage),
"</textarea>");
}
fwQuote(string[, newQuote[, oldQuote]])
This method allows you to return a string in its quoted form. Now if you pass in the original quotes it will remove them (if present) and replace them with the new ones you have defined. This function is particularly useful if you are retrieving the values of properties and need them quoted in a different form. For example if you need to change the quotes from double to single.
fwQuote("bat") will yield "bat"
fwQuote("bat","'") will yield 'bat'
fwQuote("'bat'",'"',"'") will yield "bat"
prompt(string[,string,[script]])
Arguments:
- String that appears as a prompt.
- Default Text.
- Script for the text to be input in (default is roman).
Return Value:
Null if the user clicked cancel otherwise the string that they entered. This will prompt the user for input.
Example:
var s = prompt("Enter Your Name:","Gustav");
Will give rise to this dialog, with “Gustav” as the default value.
Note: this dialog is intended for the user to enter small amounts of text. It is not possible to enter more than 255 characters. If you want the user to edit a lot of text you should use fwBigPrompt.
fwBigPrompt(string[,string])
Arguments:
- String that appears as a prompt
- Default Text
Return Value:
Null if the user clicked cancel otherwise the string that they entered. This will prompt the user for input.
Example:
var s = fwBigPrompt("Chapter 1","It was a hot sunny day but mistakenly Gustav put on his felt hat and a green coat...");
Will give rise to this dialog: (image missing)
