Writing the JavaScript code

Adobe Dreamweaver includes the Reports.js file. You can call any of the functions in Reports.js. However, you also have to create the JavaScript file that contains any functions that are specific to your custom site report.

To create the JavaScript file:

  1. Create the file Configuration/Reports/HTML Reports/List Images.js, with the following content:
    // Function: configureSettings// Description: Standard report API, used to initialize and load// the default values. Does not initialize the UI.//function configureSettings() { return false;}// Function: processFile// Description: Report command API called during file processing.//function processFile (fileURL) { if (!isHTMLType(fileURL)) //If the file isn't an HTML file return; //skip it. var curDOM = dw.getDocumentDOM(fileURL); // Variable for DOM var tagList = curDOM.getElementsByTagName('img'); // Variable for img tags var imgfilename; // Variable for file name specified in img tag for (var i=0; i < tagList.length; i++) { // For img tag list imgfilename = tagList[i].getAttribute('src'); // Get image filename if (imgfilename != null) { // If a filename is specified // Print the appropriate icon, HTML filename, // image filename, and line number reportItem(REP_ITEM_CUSTOM, fileURL, imgfilename, curDOM.nodeToSourceViewOffsets(tagList[i])); } }}
  2. Save the file as List Images.js in the Configuration/Reports/HTML Reports folder.