mirror of
https://github.com/transatoshi-mw/grin-web-wallet.git
synced 2025-10-07 00:02:47 +00:00
contents of zip
This commit is contained in:
87
scripts/database_transaction.js
Executable file
87
scripts/database_transaction.js
Executable file
@@ -0,0 +1,87 @@
|
||||
// Use strict
|
||||
"use strict";
|
||||
|
||||
|
||||
// Classes
|
||||
|
||||
// Database transaction class
|
||||
class DatabaseTransaction {
|
||||
|
||||
// Public
|
||||
|
||||
// Constructor
|
||||
constructor(transaction, objectStoreNames, autocomplete = true) {
|
||||
|
||||
// Set transaction
|
||||
this.transaction = transaction;
|
||||
|
||||
// Set object store names
|
||||
this.objectStoreNames = objectStoreNames;
|
||||
|
||||
// Set autocomplete
|
||||
this.autocomplete = autocomplete;
|
||||
|
||||
// Set completed
|
||||
this.completed = false;
|
||||
|
||||
// Set aborted
|
||||
this.aborted = false;
|
||||
|
||||
// Set self
|
||||
var self = this;
|
||||
|
||||
// Transaction complete event
|
||||
$(this.transaction).on("complete", function() {
|
||||
|
||||
// Set completed
|
||||
self.completed = true;
|
||||
|
||||
// Transaction abort event
|
||||
}).on("abort", function() {
|
||||
|
||||
// Set aborted
|
||||
self.aborted = true;
|
||||
});
|
||||
}
|
||||
|
||||
// Get transaction
|
||||
getTransaction() {
|
||||
|
||||
// Return transaction
|
||||
return this.transaction;
|
||||
}
|
||||
|
||||
// Get object store names
|
||||
getObjectStoreNames() {
|
||||
|
||||
// Return object store names
|
||||
return this.objectStoreNames;
|
||||
}
|
||||
|
||||
// Get autocomplete
|
||||
getAutocomplete() {
|
||||
|
||||
// Return autocomplete
|
||||
return this.autocomplete;
|
||||
}
|
||||
|
||||
// Is completed
|
||||
isCompleted() {
|
||||
|
||||
// Return if completed
|
||||
return this.completed === true;
|
||||
}
|
||||
|
||||
// Is aborted
|
||||
isAborted() {
|
||||
|
||||
// Return if aborted
|
||||
return this.aborted === true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Main function
|
||||
|
||||
// Set global object's database transaction
|
||||
globalThis["DatabaseTransaction"] = DatabaseTransaction;
|
Reference in New Issue
Block a user