Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

JavaScript

All examples are included with download of MBS FileMaker Plugin.

JavaScript.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts12
Value Lists0
Custom Functions0
Custom Menus24
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenScript: Start Script
OnLastWindowCloseScript: End Script
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
JavaScript
8 fields defined, 15 records
JavaScript

Fields

Table Name: JavaScript - 8 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
PrimaryKeyNormal, TextAuto-Enter:
  • Context table: JavaScript
    Calculation: Get( UUID )
Validation:
  • Only during data entry
  • Not empty
  • Unique
  • Strict validation
Storage:
  • Repetitions: 1
  • Indexing: Minimal
  • Automatically create indexes as needed
  • Index Language: Unicode Raw
Unique identifier of each record in this table
          CreationTimestampNormal, TimestampAuto-Enter:
          • Creation timestamp
          Validation:
          • Only during data entry
          • Strict data type: 4 digit year
          • Not empty
          • Strict validation
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
          Date and time each record was created
                  CreatedByNormal, TextAuto-Enter:
                  • Creation account name
                  Validation:
                  • Only during data entry
                  • Not empty
                  • Strict validation
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                  Account name of the user who created each record
                          ModificationTimestampNormal, TimestampAuto-Enter:
                          • Modification timestamp
                          Validation:
                          • Only during data entry
                          • Strict data type: 4 digit year
                          • Not empty
                          • Strict validation
                          Storage:
                          • Repetitions: 1
                          • Indexing: None
                          • Automatically create indexes as needed
                          • Index Language: German
                          Date and time each record was last modified
                                  ModifiedByNormal, TextAuto-Enter:
                                  • Modification account name
                                  Validation:
                                  • Only during data entry
                                  • Not empty
                                  • Strict validation
                                  Storage:
                                  • Repetitions: 1
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: German
                                  Account name of the user who last modified each record
                                          JavaScriptNormal, TextAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: German
                                              OutputNormal, TextAuto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: German
                                                  CommentNormal, TextAuto-Enter:
                                                  • Allow editing
                                                  Validation:
                                                  • Only during data entry
                                                  Storage:
                                                  • Repetitions: 1
                                                  • Indexing: Minimal
                                                  • Automatically create indexes as needed
                                                  • Index Language: German

                                                        Layout Objects: JavaScript

                                                        Regular Fields

                                                        Field Name: JavaScript::JavaScript
                                                        Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                        • Top: 52 pt
                                                        • Left: 138 pt
                                                        • Bottom: 302 pt
                                                        • Right: 747 pt
                                                        • Anchoring: Left, Top
                                                        Field Format:
                                                        • Edit Box
                                                        Field Behavior:
                                                        • Allow field to be entered: In Find mode, In Browse mode
                                                        • Disable visual spell-checking
                                                        • Touch keyboard type: Default for Data Type
                                                        • Go to next field using: Tab key
                                                        Yes

                                                        Field Name: JavaScript::Output
                                                        Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                        • Top: 311 pt
                                                        • Left: 138 pt
                                                        • Bottom: 525 pt
                                                        • Right: 747 pt
                                                        • Anchoring: Left, Top
                                                        Field Format:
                                                        • Edit Box
                                                        Field Behavior:
                                                        • Allow field to be entered: In Find mode, In Browse mode
                                                        • Touch keyboard type: Default for Data Type
                                                        • Go to next field using: Tab key
                                                        Yes

                                                        Field Name: JavaScript::Comment
                                                        Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                        • Top: 111 pt
                                                        • Left: 758 pt
                                                        • Bottom: 302 pt
                                                        • Right: 1011 pt
                                                        • Anchoring: Left, Top
                                                        Field Format:
                                                        • Edit Box
                                                        Field Behavior:
                                                        • Allow field to be entered: In Find mode, In Browse mode
                                                        • Touch keyboard type: Default for Data Type
                                                        • Go to next field using: Tab key
                                                        Yes

                                                        Buttons

                                                        Button PropertiesCoordinatesScript/Script Step
                                                          Type:
                                                        • Text: Run JavaScript
                                                        • Top: 58 pt
                                                        • Left: 757 pt
                                                        • Bottom: 92 pt
                                                        • Right: 942 pt
                                                        • Anchoring: Left, Top
                                                        Perform Script [ “Run JavaScript” ]

                                                        Scripts:


                                                        Script Hierarchy

                                                        test1
                                                        test2
                                                        test3
                                                        test4
                                                        test5
                                                        test6
                                                        testRun
                                                        test7
                                                        -
                                                        Run JavaScript
                                                        Start Script
                                                        End Script

                                                        Next Script: [test2]
                                                        Script Nametest1
                                                        Run script with full access privilegesOff
                                                        Include In MenuYes
                                                        Layouts that use this script
                                                          Scripts that use this script
                                                            Script Definition
                                                            Script Steps
                                                            • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                            • #try number
                                                            • Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $JS; "v1"; 123 ) ]
                                                            • Set Variable [ $v1; Value:MBS( "JS.GetGlobalProperty"; $JS; "v1") ]
                                                            • #try some JSON array
                                                            • Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $JS; "v2"; "[1,2,3]" ) ]
                                                            • Set Variable [ $v2; Value:MBS( "JS.GetGlobalProperty"; $JS; "v2") ]
                                                            • #try some text
                                                            • Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $JS; "v3"; "\"test\"" ) ]
                                                            • Set Variable [ $v3; Value:MBS( "JS.GetGlobalProperty"; $JS; "v3") ]
                                                            • #show results
                                                            • Show Custom Dialog [ Title: "Property"; Message: $v1 & ¶ & $v2 & ¶ & $v3; Default Button: “OK”, Commit: “Yes” ]
                                                            • Set Variable [ $r; Value:MBS( "JS.Free"; $JS ) ]
                                                            Fields used in this script
                                                              Scripts used in this script
                                                                Layouts used in this script
                                                                  Tables used in this script
                                                                    Table occurrences used by this script
                                                                      Custom Functions used by this script
                                                                        Custom menu set used by this script

                                                                          Previous Script: [test1]Next Script: [test3]
                                                                          Script Nametest2
                                                                          Run script with full access privilegesOff
                                                                          Include In MenuYes
                                                                          Layouts that use this script
                                                                            Scripts that use this script
                                                                              Script Definition
                                                                              Script Steps
                                                                              • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                              • Set Variable [ $r; Value:MBS( "JS.Evaluate"; $js; "4+5") ]
                                                                              • Show Custom Dialog [ Title: "Result"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                              • Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $JS; "test"; "\"Hello World\"" ) ]
                                                                              • Set Variable [ $r; Value:MBS( "JS.Evaluate"; $js; "test + test;") ]
                                                                              • Show Custom Dialog [ Title: "Result"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                              • Set Variable [ $r; Value:MBS( "JS.Free"; $JS ) ]
                                                                              Fields used in this script
                                                                                Scripts used in this script
                                                                                  Layouts used in this script
                                                                                    Tables used in this script
                                                                                      Table occurrences used by this script
                                                                                        Custom Functions used by this script
                                                                                          Custom menu set used by this script

                                                                                            Previous Script: [test2]Next Script: [test4]
                                                                                            Script Nametest3
                                                                                            Run script with full access privilegesOff
                                                                                            Include In MenuYes
                                                                                            Layouts that use this script
                                                                                              Scripts that use this script
                                                                                                Script Definition
                                                                                                Script Steps
                                                                                                • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                                                • Set Variable [ $r; Value:MBS( "JS.AddFunction"; $js; "adder"; "function (x,y) { return x+y; }" ) ]
                                                                                                • Show Custom Dialog [ Title: "Result"; Message: MBS( "JS.CallFunction"; $JS; "adder"; 3; 4 ); Default Button: “OK”, Commit: “Yes” ]
                                                                                                • Set Variable [ $r; Value:MBS( "JS.Free"; $JS ) ]
                                                                                                Fields used in this script
                                                                                                  Scripts used in this script
                                                                                                    Layouts used in this script
                                                                                                      Tables used in this script
                                                                                                        Table occurrences used by this script
                                                                                                          Custom Functions used by this script
                                                                                                            Custom menu set used by this script

                                                                                                              Previous Script: [test3]Next Script: [test5]
                                                                                                              Script Nametest4
                                                                                                              Run script with full access privilegesOff
                                                                                                              Include In MenuYes
                                                                                                              Layouts that use this script
                                                                                                                Scripts that use this script
                                                                                                                  Script Definition
                                                                                                                  Script Steps
                                                                                                                  • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                                                                  • Set Variable [ $r; Value:MBS( "JS.AddFunction"; $js; "Concat"; "function (x,y) { return x+\" \"+y; }" ) ]
                                                                                                                  • Show Custom Dialog [ Title: "Result"; Message: MBS( "JS.CallFunction"; $JS; "Concat"; "\"Hello\""; "\"World\"" ); Default Button: “OK”, Commit: “Yes” ]
                                                                                                                  • Set Variable [ $r; Value:MBS( "JS.Free"; $JS ) ]
                                                                                                                  Fields used in this script
                                                                                                                    Scripts used in this script
                                                                                                                      Layouts used in this script
                                                                                                                        Tables used in this script
                                                                                                                          Table occurrences used by this script
                                                                                                                            Custom Functions used by this script
                                                                                                                              Custom menu set used by this script

                                                                                                                                Previous Script: [test4]Next Script: [test6]
                                                                                                                                Script Nametest5
                                                                                                                                Run script with full access privilegesOff
                                                                                                                                Include In MenuYes
                                                                                                                                Layouts that use this script
                                                                                                                                  Scripts that use this script
                                                                                                                                    Script Definition
                                                                                                                                    Script Steps
                                                                                                                                    • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                                                                                    • Set Variable [ $r; Value:MBS( "JS.AddFileMakerEvaluateFunction"; $js; "FMEval") ]
                                                                                                                                    • Show Custom Dialog [ Title: "Result"; Message: MBS( "JS.Evaluate"; $JS; " \"got AccountName: \" + FMEval(\"Get(AccountName)\")" ); Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                    • Set Variable [ $r; Value:MBS( "JS.Free"; $JS ) ]
                                                                                                                                    Fields used in this script
                                                                                                                                      Scripts used in this script
                                                                                                                                        Layouts used in this script
                                                                                                                                          Tables used in this script
                                                                                                                                            Table occurrences used by this script
                                                                                                                                              Custom Functions used by this script
                                                                                                                                                Custom menu set used by this script

                                                                                                                                                  Previous Script: [test5]Next Script: [testRun]
                                                                                                                                                  Script Nametest6
                                                                                                                                                  Run script with full access privilegesOff
                                                                                                                                                  Include In MenuYes
                                                                                                                                                  Layouts that use this script
                                                                                                                                                    Scripts that use this script
                                                                                                                                                      Script Definition
                                                                                                                                                      Script Steps
                                                                                                                                                      • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS( "JS.AddFileMakerRunScriptFunction"; $js; "FMRun") ]
                                                                                                                                                      • Show Custom Dialog [ Title: "Result"; Message: MBS( "JS.Evaluate"; $JS; " \"start script: \" + FMRun(\"JavaScript.fmp12\", \"testRun\", \"Hello World\")" ); Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                      • Set Variable [ $r; Value:MBS( "JS.Free"; $JS ) ]
                                                                                                                                                      Fields used in this script
                                                                                                                                                        Scripts used in this script
                                                                                                                                                          Layouts used in this script
                                                                                                                                                            Tables used in this script
                                                                                                                                                              Table occurrences used by this script
                                                                                                                                                                Custom Functions used by this script
                                                                                                                                                                  Custom menu set used by this script

                                                                                                                                                                    Previous Script: [test6]Next Script: [test7]
                                                                                                                                                                    Script NametestRun
                                                                                                                                                                    Run script with full access privilegesOff
                                                                                                                                                                    Include In MenuYes
                                                                                                                                                                    Layouts that use this script
                                                                                                                                                                      Scripts that use this script
                                                                                                                                                                        Script Definition
                                                                                                                                                                        Script Steps
                                                                                                                                                                        • Show Custom Dialog [ Title: "Dialog triggered"; Message: Get(ScriptParameter); Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                        Fields used in this script
                                                                                                                                                                          Scripts used in this script
                                                                                                                                                                            Layouts used in this script
                                                                                                                                                                              Tables used in this script
                                                                                                                                                                                Table occurrences used by this script
                                                                                                                                                                                  Custom Functions used by this script
                                                                                                                                                                                    Custom menu set used by this script

                                                                                                                                                                                      Previous Script: [testRun]Next Script: [-]
                                                                                                                                                                                      Script Nametest7
                                                                                                                                                                                      Run script with full access privilegesOff
                                                                                                                                                                                      Include In MenuYes
                                                                                                                                                                                      Layouts that use this script
                                                                                                                                                                                        Scripts that use this script
                                                                                                                                                                                          Script Definition
                                                                                                                                                                                          Script Steps
                                                                                                                                                                                          • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.AddFileMakerSQLFunction"; $js; "FMSQL") ]
                                                                                                                                                                                          • Show Custom Dialog [ Title: "Result"; Message: MBS( "JS.Evaluate"; $JS; " \"got SQL result: \" + FMSQL(\"JavaScript.fmp12\", \"SELECT COUNT(*) FROM JavaScript\")" ); Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.Free"; $JS ) ]
                                                                                                                                                                                          Fields used in this script
                                                                                                                                                                                            Scripts used in this script
                                                                                                                                                                                              Layouts used in this script
                                                                                                                                                                                                Tables used in this script
                                                                                                                                                                                                  Table occurrences used by this script
                                                                                                                                                                                                    Custom Functions used by this script
                                                                                                                                                                                                      Custom menu set used by this script

                                                                                                                                                                                                        Previous Script: [test7]Next Script: [Run JavaScript]
                                                                                                                                                                                                        Script Name-
                                                                                                                                                                                                        Run script with full access privilegesOff
                                                                                                                                                                                                        Include In MenuYes
                                                                                                                                                                                                        Layouts that use this script
                                                                                                                                                                                                          Scripts that use this script
                                                                                                                                                                                                            Script Definition
                                                                                                                                                                                                            Script Steps
                                                                                                                                                                                                              Fields used in this script
                                                                                                                                                                                                                Scripts used in this script
                                                                                                                                                                                                                  Layouts used in this script
                                                                                                                                                                                                                    Tables used in this script
                                                                                                                                                                                                                      Table occurrences used by this script
                                                                                                                                                                                                                        Custom Functions used by this script
                                                                                                                                                                                                                          Custom menu set used by this script

                                                                                                                                                                                                                            Previous Script: [-]Next Script: [Start Script]
                                                                                                                                                                                                                            Script NameRun JavaScript
                                                                                                                                                                                                                            Run script with full access privilegesOff
                                                                                                                                                                                                                            Include In MenuYes
                                                                                                                                                                                                                            Layouts that use this script
                                                                                                                                                                                                                            Scripts that use this script
                                                                                                                                                                                                                              Script Definition
                                                                                                                                                                                                                              Script Steps
                                                                                                                                                                                                                              • Set Variable [ $r; Value:MBS( "JS.EvaluateToString"; $$JS; JavaScript::JavaScript ) ]
                                                                                                                                                                                                                              • Set Field [ JavaScript::Output; $r ]
                                                                                                                                                                                                                              Fields used in this script
                                                                                                                                                                                                                              Scripts used in this script
                                                                                                                                                                                                                                Layouts used in this script
                                                                                                                                                                                                                                  Tables used in this script
                                                                                                                                                                                                                                  Table occurrences used by this script
                                                                                                                                                                                                                                  Custom Functions used by this script
                                                                                                                                                                                                                                    Custom menu set used by this script

                                                                                                                                                                                                                                      Previous Script: [Run JavaScript]Next Script: [End Script]
                                                                                                                                                                                                                                      Script NameStart Script
                                                                                                                                                                                                                                      Run script with full access privilegesOff
                                                                                                                                                                                                                                      Include In MenuYes
                                                                                                                                                                                                                                      Layouts that use this script
                                                                                                                                                                                                                                        Scripts that use this script
                                                                                                                                                                                                                                          Script Definition
                                                                                                                                                                                                                                          Script Steps
                                                                                                                                                                                                                                          • Set Variable [ $$JS; Value:MBS("JS.New") ]
                                                                                                                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                                                                                                                          • Show Custom Dialog [ Title: "Failed to initialize JavaScript engine."; Message: $$JS; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                                                                          • Set Variable [ $$JS; Value:"" ]
                                                                                                                                                                                                                                          • Exit Script [ ]
                                                                                                                                                                                                                                          • End If
                                                                                                                                                                                                                                          • #set a few standard variables for us
                                                                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $$JS; "AccountName"; MBS("JSON.CreateString"; Get(AccountName ) )) ]
                                                                                                                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                                                                                                                          • Show Custom Dialog [ Title: "Failed to set property."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                                                                          • End If
                                                                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $$JS; "FileName"; MBS("JSON.CreateString"; Get(FileName ) )) ]
                                                                                                                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                                                                                                                          • Show Custom Dialog [ Title: "Failed to set property."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                                                                          • End If
                                                                                                                                                                                                                                          • #set a few standard functions for us
                                                                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.AddFunction"; $$JS; "Concat"; "function (x,y) { return x+\" \"+y; }" ) ]
                                                                                                                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                                                                                                                          • Show Custom Dialog [ Title: "Failed to add function."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                                                                          • End If
                                                                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.AddFileMakerEvaluateFunction"; $$js; "FMEval") ]
                                                                                                                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                                                                                                                          • Show Custom Dialog [ Title: "Failed to add function."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                                                                          • End If
                                                                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.AddFileMakerRunScriptFunction"; $$js; "FMRun") ]
                                                                                                                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                                                                                                                          • Show Custom Dialog [ Title: "Failed to add function."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                                                                          • End If
                                                                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.AddFileMakerSQLFunction"; $$js; "FMSQL") ]
                                                                                                                                                                                                                                          • If [ MBS("IsError") ]
                                                                                                                                                                                                                                          • Show Custom Dialog [ Title: "Failed to add function."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                                                                                                                                                                          • End If
                                                                                                                                                                                                                                          • #enables require() to use Duktape.modSearch
                                                                                                                                                                                                                                          • Set Variable [ $r; Value:MBS( "JS.InitModules"; $$js) ]
                                                                                                                                                                                                                                          Fields used in this script
                                                                                                                                                                                                                                            Scripts used in this script
                                                                                                                                                                                                                                              Layouts used in this script
                                                                                                                                                                                                                                                Tables used in this script
                                                                                                                                                                                                                                                  Table occurrences used by this script
                                                                                                                                                                                                                                                    Custom Functions used by this script
                                                                                                                                                                                                                                                      Custom menu set used by this script

                                                                                                                                                                                                                                                        Previous Script: [Start Script]
                                                                                                                                                                                                                                                        Script NameEnd Script
                                                                                                                                                                                                                                                        Run script with full access privilegesOff
                                                                                                                                                                                                                                                        Include In MenuYes
                                                                                                                                                                                                                                                        Layouts that use this script
                                                                                                                                                                                                                                                          Scripts that use this script
                                                                                                                                                                                                                                                            Script Definition
                                                                                                                                                                                                                                                            Script Steps
                                                                                                                                                                                                                                                            • If [ Length ( $$JS ) > 0 ]
                                                                                                                                                                                                                                                            • Set Variable [ $r; Value:MBS("JS.Free"; $$JS) ]
                                                                                                                                                                                                                                                            • Set Variable [ $$JS; Value:"" ]
                                                                                                                                                                                                                                                            • End If
                                                                                                                                                                                                                                                            • Set Variable [ $r; Value:MBS("FM.ExecuteFileSQL"; Get(FileName); "UPDATE \"JavaScript\" SET \"Output\" = '' ") ]
                                                                                                                                                                                                                                                            Fields used in this script
                                                                                                                                                                                                                                                              Scripts used in this script
                                                                                                                                                                                                                                                                Layouts used in this script
                                                                                                                                                                                                                                                                  Tables used in this script
                                                                                                                                                                                                                                                                    Table occurrences used by this script
                                                                                                                                                                                                                                                                      Custom Functions used by this script
                                                                                                                                                                                                                                                                        Custom menu set used by this script

                                                                                                                                                                                                                                                                          Download example: JavaScript

                                                                                                                                                                                                                                                                          Used functions: