Working in the JavaScript editor

Use the JavaScript editor to work on your script with syntax coloring and content assist.

About this task

Syntax coloring specifies how the JavaScript source code is rendered with its own color and style. To change the default syntax color preferences, in Document Studio select Window > Preferences > JavaScript > Editor > Syntax Coloring.

Content assist shows a list of valid alternatives for completing the current line of code. To activate the content assist, press Ctrl + Space.

This is a screen capture of the JavaScript editor.

Procedure

  1. Double-click the JavaScript code element.
    The Input code for JavaScript code element window opens.
  2. Optional: If you are including a new script from another file, click Include script and select a file from your computer, a remote server, or from the Publishing Document Builder component. Click OK.

    For files selected from your computer or a remote server, a copy of the JavaScript code from your selected file opens in the JavaScript editor.

    For files that are selected from the Publishing Document Builder, the Use Script Reference window opens. Choose whether to include the JavaScript as a reference link in the template:
    • If you select Yes, the link to the JavaScript (.js) file is embedded inside a <Script> tag. For example, the following reference link is added into the JavaScript editor that you must not modify:
      <Script src= "library://api/scripts/51"></Script>
      Remember: When you run document-style report generation from the template, and you have a JavaScript as a reference link in the template, the Publishing Document Builder must be up and connected to Document Studio. For details, see Connecting to the Publishing Document Builder component topic.
    • If you select No, a copy of the JavaScript code from your selected file opens in the JavaScript editor.
  3. Optional: Click Open in editor to enter the script in an Eclipse JavaScript editor.
    The script opens in a new editor tab as a temporary .js file, such that you can edit the JavaScript and manage the script through the options in the Outline view. After you edit the script, save your changes and close the temporary JavaScript editor tab to return to the Input Code for JavaScript Code Element window.
  4. Click Test script to validate the code.
  5. Click OK to save the changes and exit the window.