Memento JavaScript Library: Difference between revisions

Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
{{Stamp|2017-03-25|4.3.0|1.1.0}}
{{Stamp|2018-04-07|4.4.5|1.3.5}}


Memento includes the capability for users to use JavaScript to accomplish complex tasks beyond the capabilities of the normal Memento user interface. Examples include JavaScript fields, Triggers, Actions, and Data Sources. The Memento JavaScript Library may be used to access Memento facilities.
Memento includes the capability for users to use JavaScript to accomplish complex tasks beyond the capabilities of the normal Memento user interface. Examples include JavaScript fields, Triggers, Actions, and Data Sources. The Memento JavaScript Library may be used to access Memento facilities.
Line 6: Line 6:


== Libraries and Entries ==
== Libraries and Entries ==
{stamp|2018-04-07|4.4.5|1.3.5}


=== ''Library'' Global Functions ===
=== ''Library'' Global Functions ===
Line 45: Line 44:


==== ''Library'' Methods ====
==== ''Library'' Methods ====
===== create(values) =====
: Create a new entry in the library
: '''Argument'''
::; values: [https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object '''''Object'''''] containing the field values
:; Result: [[#Object entry|'''''Entry''''' object]] — the new entry in the library
===== entries() =====
===== entries() =====
: Get all the entries of the library
: Get all the entries of the library
Line 60: Line 66:
::; name: the Entry Name field value
::; name: the Entry Name field value
:; Result: [[#Object Entry|'''''Entry''''' object]], if found. Otherwise, ''null''.
:; Result: [[#Object Entry|'''''Entry''''' object]], if found. Otherwise, ''null''.
===== create(values) =====
: Create a new entry in the library
: '''Argument'''
::; values: [https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object '''''Object'''''] containing the field values
:; Result: [[#Object entry|'''''Entry''''' object]] — the new entry in the library
===== show() =====
: Display the library


===== linksTo(entry) =====
===== linksTo(entry) =====
Line 75: Line 72:
::; entry: An entry to search for links to it.
::; entry: An entry to search for links to it.
:; Result: Array object containing entries.
:; Result: Array object containing entries.
===== show() =====
: Display the library


==== ''Library'' Properties ====
==== ''Library'' Properties ====
Line 85: Line 85:


==== ''Entry'' Methods ====
==== ''Entry'' Methods ====
===== field(name) =====
: Get the value of the named field
: '''Argument'''
::; name: name of the field
:; Result: The value of the field. The type of the result depends on the type of the field.
::{{FieldTypeReturnValues}}
===== link(name, entry) =====
: Add a link — to a Link to Entry field in the current library — to an entry in the related library.
: '''Arguments'''
::; name: Name of the Link to Entry field to which to add the link
::; entry: Entry in the field's related library to which to link
===== recalc() =====
: Recalculate values of entry fields.
===== set(name, value) =====
===== set(name, value) =====
: Set the value of the named field. Calling this method results in immediate writing of the value to the library.
: Set the value of the named field. Calling this method results in immediate writing of the value to the library.
Line 96: Line 114:
:::* For Link to Entry fields, an array of of strings — each of which may be a comma-separated list of field names — supplies the entry names of entries to which to link.
:::* For Link to Entry fields, an array of of strings — each of which may be a comma-separated list of field names — supplies the entry names of entries to which to link.
:::* For Link to File fields, an array of path names identifies the files to which to link.
:::* For Link to File fields, an array of path names identifies the files to which to link.
===== field(name) =====
: Get the value of the named field
: '''Argument'''
::; name: name of the field
:; Result: The value of the field. The type of the result depends on the type of the field.
::{{FieldTypeReturnValues}}
===== recalc() =====
: Recalculate values of entry fields.


===== show() =====
===== show() =====
: Display the entry
: Display the entry
===== link(name, entry) =====
: Add a link — to a Link to Entry field in the current library — to an entry in the related library.
: '''Arguments'''
::; name: Name of the Link to Entry field to which to add the link
::; entry: Entry in the field's related library to which to link


===== unlink(name, entry) =====
===== unlink(name, entry) =====
Line 138: Line 139:


==== ''DefaultEntry'' Methods ====
==== ''DefaultEntry'' Methods ====
===== set(name, value) =====
===== set(name, value) =====
: Set the value of the field
: Set the value of the field
Line 158: Line 160:


=== ''File'' Global Functions ===
=== ''File'' Global Functions ===
==== file(name) ====
==== file(name) ====
Open a file for read or write operations. If the file with the specified name does not exist yet, it will be created.
Open a file for read or write operations. If the file with the specified name does not exist yet, it will be created.
Line 216: Line 219:


==== ''Http'' Methods ====
==== ''Http'' Methods ====
===== get(url) =====
===== get(url) =====
: Execute HTTP get request
: Execute HTTP get request
Line 239: Line 243:


== Interaction with the System ==
== Interaction with the System ==
=== ''System'' Global Functions ===
=== ''System'' Global Functions ===
==== message(text) ====
==== message(text) ====
: Shows the user a brief notification
: Shows the user a brief notification
Line 285: Line 291:


==== ''Intent'' Methods ====
==== ''Intent'' Methods ====
===== data(uri) =====
===== data(uri) =====
: Define URI to reference the data
: Define URI to reference the data