How:Write scripts in JavaScript for Memento: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
Line 2: Line 2:


{{NoteLine|THIS PAGE IS UNDER DEVELOPMENT.}}
{{NoteLine|THIS PAGE IS UNDER DEVELOPMENT.}}
The JavaScript field was the first JavaScript script type to be released. Prior to its introduction, the only way to calculate in Memento was with the Calculation field. With JavaScript there is a vast quantity of types of objects & methods (like:
* arrays & sets
* the ability to design & create '''custom object types''' with any methods (functions) you like
* variable types (like very large integers, symbols)
* and statements (like conditionals (if...else), '''custom function construction''' (function) or iteration (do...while), etc).
In short, a JavaScript has a plethora of features that make it tremendously more powerful than the Calculation field that came before it. By limiting yourself to a '''core subset''' of these features, you can keep the field type '''simple to learn & to use'''.


== The JavaScript language ==
== The JavaScript language ==
JavaScript is a language developed for programming Web sites. It has also been used as a language embedded within software tools like Memento, most prominently Node.js.
JavaScript was originally developed for programming Web sites. Since then, it has also been used as a language embedded within software tools like Memento, most prominently I've called Node.js.
 
The types of Memento JavaScript scripts are:
The types of Memento JavaScript scripts are:
* A trigger script, with event & phase options
* A ''JavaScript field'' within a library to calculate the values of expressions & formulas, often based on the values of other fields in the library or in other libraries that are linked
* An action script, applying to the current entry or library
* A ''trigger'' script, with event & phase options to perform custom calculations at certain crucial times, like ''before or after saving an entry'' or when ''a library or a field is opened''
* Shared code for use by trigger & action scripts
 
* A custom data source script to guide source data to the appropriate destination fields
* An ''action'' script, applying to the current entry or library to perform actions including actions on fields across all libraries in a user's database inundated by the touch or click of a button.
* ''Shared'' scripts for use by trigger & action scripts to hold standard & often repeated code. The scripts are available to any other script, so you can change it in one place and have the effect in ask other scripts.
* A ''custom data source'' script to guide source data from sources around the web or within the user's sphere of influence to the appropriate destination fields within the user's database.


== JavaScript field ==
== JavaScript field ==