Skip to content

Commit

Permalink
adjust block checking interval + another cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rixombea committed Sep 14, 2018
1 parent e245c26 commit 7252596
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 48 deletions.
12 changes: 10 additions & 2 deletions src/css/common.css
Expand Up @@ -1159,7 +1159,7 @@ div.about-links a{

/* NEW TX */
.transaction-table-wrapper{
max-height: 420px;
max-height: 400px;
height:80%;
overflow-x: hidden;
overflow-y: auto;
Expand All @@ -1168,9 +1168,12 @@ div.about-links a{
.tx-tools{
overflow:hidden;
padding: 0;
margin: -20px 0 0 00;
margin: -20px 0 0.5rem 00;
height:100%;
}
.tx-tools input{
margin-bottom: 0;
}
.tx-tools .tx-search{
display: relative;
float: left;
Expand Down Expand Up @@ -1270,6 +1273,11 @@ padding: 10px 0 0 0;
font-weight:bold;
}

progress.light{
width: 100%;
height: 0.25em;
}

@media only screen and (max-width : 780px) {
.section > div, .section-contents{
width: 81.4%;
Expand Down
2 changes: 1 addition & 1 deletion src/html/transactions.html
Expand Up @@ -13,7 +13,7 @@
<span class="csort" data-dir="0" id="txSortTime">Date</span>
</div>
</div>

<!-- <progress class="light block-progress-extra"></progress> -->
<div class="transaction-table-wrapper">
<table class="custom-table transaction-list-table" id="transaction-list-table">
<tbody class="list"></tbody>
Expand Down
4 changes: 2 additions & 2 deletions src/js/svc_worker.js
@@ -1,7 +1,7 @@
const svcRequest = require('./svc_request.js');

//var LAST_KNOW_BALANCE = 0.00;
const CHECK_INTERVAL = 3 * 1000;
const CHECK_INTERVAL = 5 * 1000;
var BLOCK_COUNT_LOCAL = 1;
var BLOCK_COUNT_NETWORK = 1;
var LAST_BLOCK_COUNT_LOCAL = 0;
Expand Down Expand Up @@ -34,7 +34,7 @@ function checkBlockUpdate(){

if(LAST_BLOCK_COUNT_LOCAL !== BLOCK_COUNT_LOCAL || !TX_CHECK_STARTED){
let newBlocks = (BLOCK_COUNT_LOCAL - LAST_BLOCK_COUNT_LOCAL);
if( newBlocks >= 2 ){
if( newBlocks >= 4 ){
//console.log(`${newBlocks} block detected (${BLOCK_COUNT_LOCAL}), check for new transaction...`);
checkTransactionsUpdate();
LAST_BLOCK_COUNT_LOCAL = BLOCK_COUNT_LOCAL;
Expand Down
77 changes: 40 additions & 37 deletions src/js/ui_event.js
Expand Up @@ -80,6 +80,13 @@ function changeSection (sectionId) {
if(activeBtn) activeBtn.classList.add('btn-active');
}

function showToast(msg, duration){
duration = duration || 1800;
if(!document.getElementById('datoaste')){
iqwerty.toast.Toast(msg, {settings: {duration:duration}});
}
}

var NODES_COMPLETION;
var ADDR_COMPLETION;
/* basic listeners */
Expand Down Expand Up @@ -111,16 +118,12 @@ function initBaseEvent(){
&& !remote.getGlobal('wsession').serviceReady
){
changeSection('section-welcome');
if(!document.getElementById('datoaste')){
iqwerty.toast.Toast("Please create/open your wallet!", {settings: {duration:1800}});
}
showToast("Please create/open your wallet!");
}else if(targetSection === 'section-welcome' && remote.getGlobal('wsession').serviceReady){
// the opposite
changeSection('section-overview');
}else if(targetSection === 'section-send' && syncText !== 'SYNCED'){
if(!document.getElementById('datoaste')){
iqwerty.toast.Toast("Please wait until syncing process completed!", {settings: {duration:1800}});
}
showToast("Please wait until syncing process completed!");
return;
}else{
if(button.getAttribute('id')) svcmain.onSectionChanged(button.getAttribute('id'));
Expand All @@ -136,7 +139,7 @@ function initBaseEvent(){
el.select();
if(!wv.length) return;
clipboard.writeText(wv);
iqwerty.toast.Toast('Copied to clipboard!', {settings: {duration:1800}});
showToast('Copied to clipboard!');
});

gutils.liveEvent('.tctcl', 'click', (event) => {
Expand All @@ -145,7 +148,7 @@ function initBaseEvent(){
gutils.selectText(el);
if(!wv.length) return;
clipboard.writeText(wv);
iqwerty.toast.Toast('Copied to clipboard!', {settings: {duration:1800}});
showToast('Copied to clipboard!');
});

let walletAddressInput = document.getElementById('wallet-address');
Expand Down Expand Up @@ -736,7 +739,7 @@ ${keys.mnemonicSeed}`;
settings.set('recentWalletDir', createPathField.value);
document.getElementById('input-load-path').value = walletFile;
document.getElementById('button-welcome-openwallet').click();
iqwerty.toast.Toast('Wallet has been created, you can now open your wallet!', {settings: {duration:8000}});
showToast('Wallet has been created, you can now open your wallet!',8000);
}).catch((err) => {
formStatusMsg('create', 'error', err);
return;
Expand Down Expand Up @@ -768,7 +771,7 @@ ${keys.mnemonicSeed}`;
settings.set('recentWalletDir', importKeyPathField.value);
document.getElementById('input-load-path').value = walletFile;
document.getElementById('button-welcome-openwallet').click();
iqwerty.toast.Toast('Wallet has been imported, you can now open your wallet!', {settings: {duration:8000}});
showToast('Wallet has been imported, you can now open your wallet!', 8000);
}).catch((err) => {
formStatusMsg('import', 'error',err);
return;
Expand Down Expand Up @@ -799,7 +802,7 @@ ${keys.mnemonicSeed}`;
settings.set('recentWalletDir', importSeedPathField.value);
document.getElementById('input-load-path').value = walletFile;
document.getElementById('button-welcome-openwallet').click();
iqwerty.toast.Toast('Wallet has been imported, you can now open your wallet!', {settings: {duration:8000}});
showToast('Wallet has been imported, you can now open your wallet!', 8000);
}).catch((err) => {
formStatusMsg('import-seed', 'error',err);
return;
Expand Down Expand Up @@ -878,6 +881,22 @@ ${keys.mnemonicSeed}`;
dialog.showModal();
}

function sortAmount(a, b){
var aVal = parseFloat(a._values.amount.replace(/[^0-9.-]/g, ""));
var bVal = parseFloat(b._values.amount.replace(/[^0-9.-]/g, ""));
if (aVal > bVal) return 1;
if (aVal < bVal) return -1;
return 0;
}

function resetTxSortMark(){
let sortedEl = document.querySelectorAll('#transaction-lists .asc, #transaction-lists .desc');
Array.from(sortedEl).forEach((el)=>{
el.classList.remove('asc');
el.classList.remove('desc');
});
}

function listTransactions(){
if(remote.getGlobal('wsession').txLen <=0) return;
let txs = remote.getGlobal('wsession').txNew;
Expand All @@ -893,33 +912,24 @@ ${keys.mnemonicSeed}`;
}];
}
TXLIST = new List('transaction-lists', txListOpts, txs);
txSortTimeButton.click();
TXLIST.sort('timestamp', {order: 'desc'});
resetTxSortMark();
txSortTimeButton.classList.add('desc');
}else{
TXLIST.add(txs);
txSortTimeButton.click();
TXLIST.sort('timestamp', {order: 'desc'});
resetTxSortMark();
txSortTimeButton.classList.add('desc');
//showToast(`Transaction list updated`);
}
}

function sortAmount(a, b){
var aVal = parseFloat(a._values.amount.replace(/[^0-9.-]/g, ""));
var bVal = parseFloat(b._values.amount.replace(/[^0-9.-]/g, ""));
if (aVal > bVal) return 1;
if (aVal < bVal) return -1;
return 0;
}

txSortAmountButton.addEventListener('click',(event)=>{
event.preventDefault();
let currentDir = event.target.dataset.dir;
let targetDir = (currentDir === 'desc' ? 'asc' : 'desc');
event.target.dataset.dir = targetDir;

let sortedEl = document.querySelectorAll('.asc, .desc');
Array.from(sortedEl).forEach((el)=>{
el.classList.remove('asc');
el.classList.remove('desc');
});

resetTxSortMark();
event.target.classList.add(targetDir);
TXLIST.sort('amount', {
order: targetDir,
Expand All @@ -932,21 +942,14 @@ ${keys.mnemonicSeed}`;
let currentDir = event.target.dataset.dir;
let targetDir = (currentDir === 'desc' ? 'asc' : 'desc');
event.target.dataset.dir = targetDir;
let sortedEl = document.querySelectorAll('.asc, .desc');
Array.from(sortedEl).forEach((el)=>{
el.classList.remove('asc');
el.classList.remove('desc');
});

resetTxSortMark();
event.target.classList.add(targetDir);
TXLIST.sort('timestamp', {
order: targetDir
});
});

refreshButton.addEventListener('click', (event) => {
listTransactions();
});
refreshButton.addEventListener('click', listTransactions);
/** ------------------ END Transaction --------------------- */
}
initBaseEvent();
22 changes: 16 additions & 6 deletions src/js/ui_updater.js
Expand Up @@ -20,6 +20,18 @@ const connAddrText = document.getElementById('status-node-addr');
const connFeeText = document.getElementById('status-node-fee');
const connWarnText = document.getElementById('status-node-warning');

function toggleProgressExtra(show){
const progressExtra = document.querySelectorAll('.block-progress-extra');
show = show || false;
Array.from(progressExtra).forEach( (el) => {
if(show){
el.classList.remove('hidden');
}else{
el.classList.add('hidden');
}
});
}

function setWinTitle(title){
let defaultTitle = remote.getGlobal('wsession').defaultTitle;
let newTitle = defaultTitle;
Expand All @@ -36,15 +48,12 @@ function updateSyncProgres(data){

// restore/reset
if(knownBlockCount === -100){
//toggleProgressExtra(false);
syncDiv.className = '';
syncText.innerHTML = 'IDLE';
//syncCountText.innerHTML = '';
gutils.clearChild(syncCountText);
//syncKnownText.innerHTML = '';
gutils.clearChild(syncKnownText);
//syncSlash.innerHTML = '';
gutils.clearChild(syncSlash);
//syncPercent.innerHTML = '';
gutils.clearChild(syncPercent);

iconSync.setAttribute('data-icon', 'pause-circle');
Expand All @@ -58,6 +67,7 @@ function updateSyncProgres(data){
setWinTitle();
}else if(knownBlockCount <=1){
// not connected
//toggleProgressExtra(false);
syncDiv.className = 'failed';
syncText.innerHTML = 'NOT CONNECTED';
gutils.clearChild(syncCountText);
Expand Down Expand Up @@ -86,13 +96,12 @@ function updateSyncProgres(data){
if(blockCount+1 >= knownBlockCount && knownBlockCount != 0) {
syncDiv.classList = 'synced';
syncText.innerHTML = 'SYNCED ';
//syncPercent.innerHTML = '';
gutils.clearChild(syncPercent);
iconSync.setAttribute('data-icon', 'check');
iconSync.classList.remove('fa-spin');
remote.getGlobal('wsession').synchronized = true;
remote.getGlobal('wsession').syncStarted = true;

//toggleProgressExtra(false);
} else {
syncDiv.className = 'syncing';
syncText.innerHTML = 'SYNCING ';
Expand All @@ -102,6 +111,7 @@ function updateSyncProgres(data){
iconSync.classList.add('fa-spin');
remote.getGlobal('wsession').syncStarted = true;
remote.getGlobal('wsession').synchronized = false;
//toggleProgressExtra(true);
}

let nFee = remote.getGlobal('wsession').nodeFee;
Expand Down

0 comments on commit 7252596

Please sign in to comment.