User Guide
230 Chapter 13: Floating Panels
/* display information for the next unprocessed layer.
displayLayer() is a function you would write to
perform the "magic". */
displayLayer(document.layers[document.numProcessed]);
/* if there's more work to do, set a timeout to process
* the next layer. If we're finished, set the document.running
* flag to false. */
document.numProcessed = document.numProcessed + 1;
if (document.numProcessed < document.numLayers){
setTimeout("processLayer()", 500);
}else{
document.running = false;
}
}
Script Editor: a floating panel extension
The Script Editor extension creates a floating panel to display the JavaScript code that underlies a
selected Script marker in Design view. The Script Editor displays the JavaScript code in the
textarea element of an HTML form that is defined in a layer called scriptlayer. If you make
changes to the selected code in the floating panel, the extension calls the
updateScript()
function to save your changes. If you have not selected a Script marker when you invoke the
Script Editor, the extension displays
(no script selected) in a layer called blanklayer.
To create the example extension:
1 Create an HTML layer (scriptlayer) to display the JavaScript code for a selected Script
marker and a second layer (
blanklayer) to display (no script selected) if a Script marker
has not been selected.
2 Write the JavaScript code
3 Save the JavaScript and HTML code in the scriptEditor.htm file in the Configuration/
Floaters folder.
4 Create a menuitem tag in the menus.xml file to invoke the extension.
Creating the floating panels
The beginning of the HTML file for this extension contains the standard document header
information and a
title tag that puts the words Script Editor in the title bar of the floating
panels. The following example shows the code:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Script Editor</title>
<script language="JavaScript">
The extension defines two floating panels that display either (no script selected) if the user
has not selected a Script marker or the JavaScript code that underlies a selected Script marker. The
following code defines these two floating panels, or layers, called
blanklayer and scriptlayer:
<body>
<div id="blanklayer" style="position:absolute; width:422px; ¬
height:181px; z-index:1; left: 8px; top: 11px; ¬
visibility: hidden">
<center>
<br>