Added Startup monitor function and fast requests
opening the page now loads all data from idb by default. Changed IDB cursorRequest to getAllRequest since IDB cursorRequest is slower compared to getAllRequest.
This commit is contained in:
parent
66cb7fc1b7
commit
fa6051cf10
@ -144,7 +144,36 @@ top:194px;
|
||||
|
||||
|
||||
getDataMode(); //default start
|
||||
startup();
|
||||
function startup(){
|
||||
var idb = indexedDB.open("FLO_Walletless");
|
||||
new Promise(function(resolve,reject){
|
||||
idb.onerror = function(event) {
|
||||
//console.log("Error in opening IndexedDB!");
|
||||
reject(Error("Error in opening IndexedDB!"));
|
||||
};
|
||||
idb.onupgradeneeded = function(event) {
|
||||
var objectStore = event.target.result.createObjectStore('Label');
|
||||
};
|
||||
idb.onsuccess = function(event) {
|
||||
var db = event.target.result;
|
||||
var obslabel = db.transaction('Label', "readwrite").objectStore('Label');
|
||||
var val = obslabel.getAllKeys();
|
||||
// console.log(val.result);
|
||||
val.onsuccess = function(event){
|
||||
resolve(event.target.result);
|
||||
}
|
||||
}
|
||||
}).then(res => {
|
||||
var input = document.getElementById("getAddr");
|
||||
input.value = res.join(',');
|
||||
monitorData();
|
||||
input.value = "";
|
||||
}).catch(error => {
|
||||
console.log(error.message);
|
||||
});
|
||||
|
||||
}
|
||||
function clearLocalData()
|
||||
{
|
||||
document.getElementById("dispMsg").innerHTML = '<h3>Received FLO Data : </h3><br/>';
|
||||
@ -5131,6 +5160,7 @@ Bitcoin.Util = {
|
||||
}
|
||||
};*/
|
||||
|
||||
|
||||
function monitorData(){
|
||||
|
||||
var addrList = document.getElementById("getAddr").value;
|
||||
@ -5222,26 +5252,21 @@ Bitcoin.Util = {
|
||||
row.insertCell(3).innerHTML = 'floData';
|
||||
|
||||
var obs = db.transaction(addr, "readwrite").objectStore(addr);
|
||||
|
||||
var cursorRequest = obs.openCursor();
|
||||
cursorRequest.onsuccess = function(event) {
|
||||
var cursor = event.target.result;
|
||||
if(cursor) {
|
||||
// cursor.value contains the current record being iterated through
|
||||
// this is where you'd do something with the result
|
||||
//console.log(cursor.value.sender+":"+cursor.value.receiver+":"+cursor.value.time+":"+cursor.value.txid+":"+cursor.value.floData);
|
||||
var time = new Date(cursor.value.time*1000);
|
||||
var objreq = obs.getAll();
|
||||
objreq.onsuccess = function(event){
|
||||
data = event.target.result;
|
||||
// console.log(data);
|
||||
data.forEach(tx => {
|
||||
var time = new Date(tx.time*1000);
|
||||
var row = table.insertRow(1) ;
|
||||
row.insertCell(0).innerHTML = cursor.value.sender;
|
||||
row.insertCell(1).innerHTML = cursor.value.receiver;
|
||||
row.insertCell(0).innerHTML = tx.sender;
|
||||
row.insertCell(1).innerHTML = tx.receiver;
|
||||
row.insertCell(2).innerHTML = time;
|
||||
row.insertCell(3).innerHTML = cursor.value.floData;
|
||||
//tmpResult = '<tr><td>'++'</td><td>'++'</td><td>'++'</td><td>'++'</td></tr>' + tmpResult;
|
||||
cursor.continue();
|
||||
} else {
|
||||
refreshdata(dispMsgAddr);
|
||||
}
|
||||
};
|
||||
row.insertCell(3).innerHTML = tx.floData;
|
||||
})
|
||||
refreshdata(dispMsgAddr);
|
||||
|
||||
}
|
||||
db.close();
|
||||
window["refreshwait"] -= 1;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user