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
|
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()
|
function clearLocalData()
|
||||||
{
|
{
|
||||||
document.getElementById("dispMsg").innerHTML = '<h3>Received FLO Data : </h3><br/>';
|
document.getElementById("dispMsg").innerHTML = '<h3>Received FLO Data : </h3><br/>';
|
||||||
@ -5131,6 +5160,7 @@ Bitcoin.Util = {
|
|||||||
}
|
}
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
|
|
||||||
function monitorData(){
|
function monitorData(){
|
||||||
|
|
||||||
var addrList = document.getElementById("getAddr").value;
|
var addrList = document.getElementById("getAddr").value;
|
||||||
@ -5222,26 +5252,21 @@ Bitcoin.Util = {
|
|||||||
row.insertCell(3).innerHTML = 'floData';
|
row.insertCell(3).innerHTML = 'floData';
|
||||||
|
|
||||||
var obs = db.transaction(addr, "readwrite").objectStore(addr);
|
var obs = db.transaction(addr, "readwrite").objectStore(addr);
|
||||||
|
var objreq = obs.getAll();
|
||||||
var cursorRequest = obs.openCursor();
|
objreq.onsuccess = function(event){
|
||||||
cursorRequest.onsuccess = function(event) {
|
data = event.target.result;
|
||||||
var cursor = event.target.result;
|
// console.log(data);
|
||||||
if(cursor) {
|
data.forEach(tx => {
|
||||||
// cursor.value contains the current record being iterated through
|
var time = new Date(tx.time*1000);
|
||||||
// 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 row = table.insertRow(1) ;
|
var row = table.insertRow(1) ;
|
||||||
row.insertCell(0).innerHTML = cursor.value.sender;
|
row.insertCell(0).innerHTML = tx.sender;
|
||||||
row.insertCell(1).innerHTML = cursor.value.receiver;
|
row.insertCell(1).innerHTML = tx.receiver;
|
||||||
row.insertCell(2).innerHTML = time;
|
row.insertCell(2).innerHTML = time;
|
||||||
row.insertCell(3).innerHTML = cursor.value.floData;
|
row.insertCell(3).innerHTML = tx.floData;
|
||||||
//tmpResult = '<tr><td>'++'</td><td>'++'</td><td>'++'</td><td>'++'</td></tr>' + tmpResult;
|
})
|
||||||
cursor.continue();
|
refreshdata(dispMsgAddr);
|
||||||
} else {
|
|
||||||
refreshdata(dispMsgAddr);
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
db.close();
|
db.close();
|
||||||
window["refreshwait"] -= 1;
|
window["refreshwait"] -= 1;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user