You can use the results window API to create a stand-alone report. Stand-alone reports are regular commands that directly use the results window API rather than the reports API. You can access a stand-alone report the same way you access any other command, through the menus or through another command.
Stand-alone reports reside in the Dreamweaver Configuration/Commands folder. A custom command for a stand-alone report appears on the Commands menu.
Dreamweaver creates a new Results window each time the user runs a new stand-alone report.
Path |
File |
Description |
---|---|---|
Configuration/Commands |
commandname.htm |
Defines the UI for the dialog box that appears when the user selects the command and contains the JavaScript code or a reference to the JavaScript file that performs the actions needed to generate the report. |
Configuration/Commands |
commandname.js |
Generates a Results window and puts the report in it. |
-
When the command calls resWin.startProcessing(), Dreamweaver calls the processFile() function for each file URL in the list. Define the processFile() function in the stand-alone command. It receives the file URL as its only argument. Use the setCallbackCommands() function of the Results window object if you want Dreamweaver to call the processFile() function in some other command.
The simple stand-alone report extension lists all the images referenced in a particular file and displays the report in the Results window.
You create this extension by creating the dialog box UI and writing the JavaScript code.
This example creates two files in the Configuration/Commands folder: List images.htm, which defines the UI of the dialog box that appears when the user selects the custom command, and Listimages.js, which contains the JavaScript code specific to this report.
The body section of the HTML file specifies the contents of the dialog box that appears when the user selects the custom command and calls any JavaScript files required.
Create the JavaScript file that contains any functions that are specific to your stand-alone report.
-
function stdaloneresultwin() { var curDOM = dw.getDocumentDOM("document"); var tagList = curDOM.getElementsByTagName('img'); var imgfilename; var iOffset = 0; var iLineNumber = 0; var resWin = dw.createResultsWindow("Images in File", ["Line", "Image"]); for (var i=0; i < tagList.length; i++) { // Get the name of the source file. imgfilename = tagList[i].getAttribute('src'); // Get the character offset from the start of the file // to the start of the img tag. iOffset = curDOM.nodeToOffsets(curDOM.images[i]); // Based on the offset, figure out what line in the file // the img tag is on. iLineNumber = curDOM.getLineFromOffset(iOffset[0]); // As long as the src attribute specifies a file name, if (imgfilename != null) { // display the line number, and image path. resWin.addItem(resWin, "0", "Images in Current File", null, ¬ null, null, [iLineNumber, imgfilename]); } } return; } // add buttons to dialog function commandButtons() { return new Array("OK", "stdaloneresultwin()", "Cancel", "window.close()"); }