Storage of JS code

Attribute(s)

  • Storage of code

    Description

    Storage of JS code: Store JS code in general in the JS Header event. Use a form for local functions and a subform for general functions.

    Motivation

    The JS Header is the best place to store the JS code, because this event is meant for it. The code is easy to read because of the colors of comment and strings. It is a central place to maintain. And it is usable for both Notes and the Web.

    Example / Details

    Storage of code:
    Functions will always be stored in the JS Header event
    Calculate JS variable in @Formula language
    When a function is only used in one form, put the function in the JS Header of the Form
    When the function is used more generally, put the function in the JS Header of the Subform

    JS Header:
    JavaScript functions will always be stored in the JS Header. Separate the functions by a line of *****, function definition and comment header (see documentation). Do not use a line of ***** in the middle of a function.

    Calculate JS variable in @Formula language
    In some circumstances it is necessary to put JS code directly on the form: when the content of the JS variable has to be calculated in Notes before the HTML is sent to the browser. When you use this technique use the following guidelines:
  • The format of the naming of the variable will be sof<functional name> (sof is Set On Form)
  • The variable has to be declared in the JS Header of the Form/ Subform.

    Example:
    Create JavaScript Libraries
    When you create a general JavaScript Library, you have to use a subform. The JavaScript code will be stored in the JS Header event of the subform.
    Put the following text direct on the subform in green:
    Inserted JavaScript ---->S-JSLib-RFR-itemRefresh
    Inserted JavaScript ---->S-JSLib-RFR-itemRefresh
    Inserted JavaScript ----><SubForm alias>



    Example:
    Insert the JavaScript Library on Form.
    When a JavaScript Library is needed in a form, the subform will inserted in the Form. All the subforms are inserted in the Inserted JavaScript Section.




  • JS_Code_Specific_On_Form.jpg
    JS_Code_On_Subform.jpg