vivaldi.translateHistory Modders API Reference
Use vivaldi.translateHistory
API fetch and save translate history elements.
Types
#TextItem
Properties:
- code
string
Language code.
- text
string
Text.
#HistoryItem
Properties:
- id
string
Unique identifier.
- srcItem
TextItem
Text and language code of original (non-translated) data.
- translatedItem
TextItem
Text and language code of translated data.
Listeners
How to use listeners
Each listener type has the same functions, used for each listener API in the same way:
.addListener(function
callback)
Adds a function to a listener for an event
.removeListener(function
callback)
Removes a function to a listener for an event
.hasListener(function
callback)
Returns a boolean if a function is attached to a listener for an event
.hasListeners()
Returns a boolean if a listener has any attached functions
.dispatch()
Returns array of promises dispatched to the listener
#onAdded
Fires when elements have been appended to the list.
Parameters:
- items
Elements in the order they have been added
Array
of:- HistoryItem
- index
number
Index where the elements are located.
#onMoved
Fires when an element has been moved within the list.
Parameters:
- id
string
Identifier of element that has been moved.
- index
number
Index to where element has been moved.
#onRemoved
Fires when elements have been appended to the list.
Parameters:
- ids
A list of ids that have been removed. An empty list means all.
Array
of:- string
Methods
#get
Retrieves the full history.
#add
Adds an item to the list. If item already exists that item is returned without adding a duplicate. The returned item's id it set up in the call.
Parameters:
- item
HistoryItem
Data to add. Note, the id element is ignored.
- index
number
Where to add element. -1 indicates end of list.
#remove
Removes one or more items.
Parameters:
- ids
List of identifiers representing items to be removed.
Array
of:- string
#reset
Removes items with matching timestamp.
Parameters:
- since
number
In milliseconds since epoch. Remove all items with a timestamp greater or equal to this value.