Constructor
new DiaryLoader(success_callbackopt, error_callbackopt, hash_parse_policyopt)
Parameters:
Name |
Type |
Attributes |
Description |
success_callback |
function
|
<optional>
|
called when a new file is loaded successfully |
error_callback |
function
|
<optional>
|
called when a file cannot be loaded |
hash_parse_policy |
number
|
<optional>
|
how to handle URL hashes:
- 0 or undefined - always parse the URL hash
- 1 - parse each URL hash once, skip it if e.g. the user navigates away then clicks back
- 2 - never parse the URL hash
|
- Source:
Example
function my_success_callback( diary, source ) {
console.log( "Loaded diary", diary, source );
}
function my_error_callback( raw, source ) {
console.log( "Could not load diary", raw, source );
}
let loader = new DiaryLoader(my_success_callback,my_error_callback);
Methods
load(raw, sourceopt)
Load a sleep diary from some source
Parameters:
Name |
Type |
Attributes |
Description |
raw |
Event
|
FileList
|
string
|
Object
|
|
raw data to load |
source |
Event
|
FileList
|
string
|
Object
|
<optional>
|
identifier passed to the callbacks |
- Source:
Example
my_file_input.addEventListener( "change", event => diary_loader.load(event) );