diff --git a/www/js/update.js b/www/js/update.js index 16c2cc3..e8b3b8c 100644 --- a/www/js/update.js +++ b/www/js/update.js @@ -59,20 +59,20 @@ async function submit() { console.assert(priceinput); if (!validNumber(priceinput)) { - document.getElementById("price-alarming").innerText = " * Please fill in number."; - enableInputs(); - } else { - let price = parseInt(priceinput); - - if (price <= showPrice) { - document.getElementById("price-alarming").innerText = " * Your price shall be greater than the current"; + document.getElementById("price-alarming").innerText = " * Please fill in number."; enableInputs(); - } else { - await storeMessage(contractAbi, - contractAddress, - message, - price); - } + } else { + let price = parseInt(priceinput); + + if (price <= showPrice) { + document.getElementById("price-alarming").innerText = " * Your price shall be greater than the current"; + enableInputs(); + } else { + await storeMessage(contractAbi, + contractAddress, + message, + price); + } } } @@ -81,9 +81,9 @@ function validNumber(inputNumber) { console.log(inputNumber); if (regular.test(inputNumber)) { - return true; + return true; } else { - return false; + return false; } } @@ -119,8 +119,8 @@ async function storeMessage(contractAbi, contractAddress, message, priceinput) { console.log(message); let addedNode = node.add({ - path: 'message.txt', - content: message + path: 'message.txt', + content: message }); addedNode = await addedNode; let cid = addedNode.cid.toString(); @@ -138,31 +138,31 @@ async function storeMessage(contractAbi, contractAddress, message, priceinput) { contract.methods .setContent(cid) .send({from: account, value: priceinput}) - .on('transactionHash', function(hash){ - console.log('transactionHash'); - console.log(hash); + .on('transactionHash', function(hash){ + console.log('transactionHash'); + console.log(hash); uiUpdateEthTransactionHash(hash); - }) - .on('receipt', function(receipt){ - console.log('receipt'); - console.log(receipt); + }) + .on('receipt', function(receipt){ + console.log('receipt'); + console.log(receipt); // todo - }) - .on('confirmation', function(confirmationNumber, receipt){ - console.log('confirmation'); - console.log(confirmationNumber); - console.log(receipt); + }) + .on('confirmation', function(confirmationNumber, receipt){ + console.log('confirmation'); + console.log(confirmationNumber); + console.log(receipt); uiUpdateEthTransactionConfirmation(confirmationNumber); if (confirmationNumber == 0) { uiEndProcessSuccess(); } - }) - .on('error', function(error){ - console.log('error'); - console.log(error); + }) + .on('error', function(error){ + console.log('error'); + console.log(error); uiUpdateEthTransactionError(error); - }); + }); console.log("waiting on Ethereum"); }