Aurigma File Downloader 7.0.9
Helper Script Reference (iuembed.js)
In this topic:
Using Helper Script
- Linking iuembed.js to the Page
- Adding File Downloader to a Web Page
- Initializing File Downloader Parameters
- Configuring an Alternate Text for the Control
- Adding Event Handlers
- Getting a Reference to File Downloader by ID
- Working with Properties Dynamically
- Calling Methods
- Page Load and Initialization Events
- Helper Script Members
This script is used in the following way:
- Link the iuembed.js file to your HTML page.
- Create an instance of FileDownloaderWriter object.
- Initialize parameters of FileDownloader control.
- Add event handlers if necessary.
- Call the writeHtml method in the necessary part of your HTML code that will embed the FileDownloader instance into the page.
- After the FileDownloader control is embedded, you can get an instance of this control, edit its properties, and call its methods dynamically.
You can find iuembed.js in the root folder of the File Downloader SDK installation folder.
Linking iuembed.js to the Page
Adding File Downloader to a Web Page
To embed File Downloader into a Web page, you need to do at least the following:
- Create a new FileDownloaderWriter class instance.
- Call the writeHtml method of this object to generate code which will embed File Downloader and write it into the page. Alternatively you can use the getHtml method to get this code as a string.
Here is a short example of adding File Downloader to a Web page:
The FileDownloaderWriter constructor has three arguments: an ID of the control, a width, and a height. You can change these values later using appropriate properties.
Full list of FileDownloaderWriter members can be found at the end of this topic.
Initializing File Downloader Parameters
To initialize parameters of File Downloader you should use the addParam method of the FileDownloaderWriter class instance before calling writeHtml.
The addParam method takes two arguments: a name of the property and its value.
The following example should make it clear:
Configuring an Alternate Text for the Control
It takes a while to download and install File Downloader. After download completes, the browser requires the user to click a button on the security dialog. Furthermore, if File Downloader is installed on Windows XP with Service Pack 2, the user should also click an information bar before the security dialog appears.
It may be quite confusing for the user. They may misunderstand installation instructions and reject installation when security dialog pops up.
In this case, displaying installation instructions is a good idea. iuembed.js exposes a number of properties that enable this.
The instructionsEnabled property specifies whether to display instructions or not. Set it to true to make instructions appear. The instructionsCommon property specifies an HTML code for those instructions which are common for all client platforms. The instructionsWinXPSP2 and instructionsNotWinXPSP2 values are appended to the common instructions depending on the client platform (Windows XP with Service Pack 2 or other platforms respectively).
This code snippet demonstrates how to use these properties:
fd.instructionsEnabled=true; fd.instructionsCommon="File Downloader ActiveX control is necessary to " + "download files quickly and easily. You will be able to select required " + "files in a user-friendly interface and simply click the \"Download\" " + "button. Installation will take up to few minutes, please be patient. To " + "install File Downloader, "; fd.instructionsNotWinXPSP2="please reload the page and click the \"Yes\" " + "button when you see the control installation dialog." fd.instructionsWinXPSP2="please click the Information Bar. After page reloads " + "click \"Yes\" when you see the control installation dialog.";
Adding Event Handlers
File Downloader provides a number of useful events which you can handle. To add event listeners do the following:
- Use the addEventListener method of the FileDownloaderWriter object. This method has two arguments: the name of the event and the name of the function created on the first step.
This example demonstrates how this should look like:
See the full list of all FileDownloader events in the FileDownloader Events reference section.
Getting a Reference to File Downloader by ID
The iuembed.js script contains a special function - getFileDownloader. It takes a single argument - the ID of the control, which you want to reference (for example, specified when creating an instance of FileDownloaderWriter), and returns a reference to the control.
Here is an example of obtaining a referenece:
var downloader = getFileDownloader("FileDownloader1");
Working with Properties Dynamically
Sometimes you need to modify File Downloader properties after initialization. The typical situation is when you need to change the file list in response to some user actions.
To do that, you should get a reference to the FileDownloader control as described above and modify the value of a required property.
The syntax of runtime property modification is the following:
object.setPropertyName(value), where PropertyName is a name of the property as specified in the FileDownloader Properties reference.
To read a property value, use object.getPropertyName instead.
The code snippet below shows how to work with properties after initialization:
var downloader = getFileDownloader("FileDownloader1"); downloader.setFileList(downloader.getFileList());
To call methods of FileDownloader, use the same approach as you use for properties: get a reference to the FileDownloader instance and call methods:
object.MethodName(argument1, argument2, ...), where MethodName is a name of the method as specified in the FileDownloader Methods reference.
Here is a code example:
var downloader = getFileDownloader("FileDownloader1"); downloader.DownloadFileList();
Page Load and Initialization Events
Quite often it is necessary to work with the File Downloader control when you are sure that the page has been fully loaded and the control itself has been completely created and initialized.
That is why iuembed.js exposes a special event, which is raised when the page is loaded, and the control is completely ready to be used. This event handler can be assigned to the fullPageLoadListenerName property of FileDownloaderWriter as follows:
iuembed.js exposes only one class, FileDownloaderWriter, which corresponds to the only class of File Downloader, FileDownloader.
Adds a parameter with the specified name and value. The settings take effect when the writeHtml or getHtml method is run.
Verifies whether ActiveX control is installed. If yes, it returns true; otherwise it returns false.
Generates the HTML code which will embed File Downloader and returns it as a string. It will write all parameters added with the addParam method and append all event handlers specified by the addEventListener method.
Generates the HTML code, which will embed File Downloader, and writes this code directly into the page. It will write all parameters added with the addParam method and append all event handlers specified by the addEventListener method.
The URL that specifies where to download the ActiveX version of File Downloader from. It is an analogue of the codebase attribute of the <object> element.
The URL that specifies where to download the 64-bit ActiveX version of File Downloader from. It is an analogue of the codebase attribute of the <object> element.
Switch that specifies whether to use the ActiveX version of File Downloader.
The minimum required version of the ActiveX version of File Downloader.
The URL that specifies the folder where to download the Java version of File Downloader from.
Name of the .jar file.
Switch that specifies whether to use the Java version of File Downloader.
The minimum required version of the Java version of File Downloader.
|height||N/A (provided in the constructor)||
Height of the control. You should provide an integer number. Syntax like 100% is acceptable.
|id||N/A (provided in the constructor)||
ID of the control that is used to get a reference with the help of the getFileDownloader function.
Value that specifies whether to display instructionsCommon, instructionsNotWinXPSP2, and instructionsWinXPSP2 when File Downloader fails to be installed.
|instructionsCommon||See code snippet above||
Common part of instructions displayed during download failure (regardless of the Windows version). Can contain any HTML code.
|instructionsNotWinXPSP2||See code snippet above||
Part of instructions which is displayed if the current Windows is not Windows XP with Service Pack 2. Appended to the instructionsCommon string. Can contain any HTML code.
|instructionsWinXPSP2||See code snippet above||
Part of instructions which is displayed if the current Windows is Windows XP with Service Pack 2. Appended to the instructionsCommon string. Can contain any HTML code.
|noFileSystemAccessInSafari||<p>The browser does not allow File Downloader to access the local file system. To enable the access perform the following steps:</p><ul><li style='margin-top:10px'>Go to <b>Safari</b>→<b>Preferences</b>, choose the <b>Security</b> tab, and click <b>Manage Website Settings</b>.</li><li style='margin-top:10px'>Select <b>Java</b> in the left column, click on the dropdown box next to the <b>[name]</b> website, and choose <b>Run in Unsafe Mode</b>.</li></ul>||
The message which states that File Downloader cannot access the local file system due to Safari security settings. It can contain the following placeholder:
[name] replaced by the host name of the currently opened website.
|width||N/A (provided in the constructor)||
Width of the control. You should provide an integer number. Syntax like 100% is acceptable.
Returns a reference to the control with the specified ID.
Members for Private-Label Versions
When private-label version is used, you need to customize the following properties (that should not be changed in the standard version):
|activeXControlCodeBase||Name of the .cab file.|
|activeXControlCodeBase64||Name of the x64 .cab file.|
|activeXClassId||CLSID of the ActiveX control.|
|activeXProgId||PROGID of the ActiveX control.|
|javaAppletJarFileName||Name of the .jar file.|
|javaAppletClassName||Java applet class name.|
The following code snippet demonstrates how to use these properties: