Using the JavaScript Editor

Using the JavaScript Editor

Access
Script Formatting
from the
Connect
tab to create custom scripts.
JavaScript Formatting is supported on Aurora Focus version 9 and above.
  1. Enable
    Script Formatting
    from the menu and click
    Open Editor
    to open a new editor window.
    accessing aurora JavaScript editor
  2. While in the editor, observe the following UI elements: the navigation menu, the run job button, and the script formatting slider.
    javascript editor
    JavaScript Editor UI Elements
    UI Element
    Description
    Navigation Menu
    The top navigation menu provides access to
    File
    ,
    Edit
    , and
    View
    functions for the application.
    • Open an existing file with JavaScript code and save JavaScript to an external file from the
      File
      menu. JavaScript, by default, is saved in a job file when saving a whole job or deploying a job to the device.
    • Use templates and snippets to quickly develop new JavaScript code that is specific to your use case from the
      Edit
      menu.
    • Adjust the editor font size from the
      View
      menu.
    Run Job Button
    Click
    Run Job
    on the control bar to validate test code in the editor by running a job on an image in the Filmstrip in Aurora Focus. You can also trigger a job by pressing F5 while in the editor.
    Script Formatting
    Disable JavaScript formatting by using the
    Script Formatting
    toggle in the top-right corner of the editor window.
  3. Press F1 while inside the editor for a list of all functionalities.
    suggested functions
  4. Use IntelliSense for script recommendations to enable code completion. When a function has JSDoc documentation, the editor assumes its variable types and provides a recommendation for object properties. IntelliSense is also useful for standard JavaScript interfaces such as JSON or Date.
    It is recommended to keep JSDoc comments for the
    onResult
    function. This is necessary to receive recommendations for input and output objects.
    using intellisense
  5. The code editor is powered by Monaco Editor to integrate functionalities such as adjusting the format, undo/redo, renaming symbols, and find/replace. The following code snippet is a basic script that copies the first detected barcode from the first tool to the output.
    /** Returns the OutputResult type object * @param {InputResult} inputResult * @returns {OutputResult} */ export function onResults(inputResult) { return { common: inputResult.tool_results[0].decodes[0].value }; }
  6. Use the console below the code editor to view logs. The log icon and text color change depending on the log category.
    console
    1. Use save logs to save the console logs to a file or clear the console.
    2. Use minimize console to minimize the console.