Commit b14e6ce5 authored by kirtisingh's avatar kirtisingh

Linked backend with Blockchains

parent 49466459
This diff is collapsed.
...@@ -150,14 +150,14 @@ async function printOrderListOnt(hashlock){ ...@@ -150,14 +150,14 @@ async function printOrderListOnt(hashlock){
} }
// console.log(typeof(val)); // console.log(typeof(val));
ls.innerHTML = `<table> ls.innerHTML = `<table>
<tr><td>Initiator ONT Address:</td> <td>${orderList["initiatorOntAddress"]}</td></tr> <tr><td class="pd">Initiator ONT Address:</td> <td>${orderList["initiatorOntAddress"]}</td></tr>
<tr><td>Initiator ETH Address:</td> <td>${orderList["initiatorEthAddress"]}</td></tr> <tr><td class="pd">Initiator ETH Address:</td> <td>${orderList["initiatorEthAddress"]}</td></tr>
<tr><td>Buyer ONT Address:</td> <td>${orderList["buyerOntAddress"]}</td></tr> <tr><td class="pd">Buyer ONT Address:</td> <td>${orderList["buyerOntAddress"]}</td></tr>
<tr><td>Buyer ETH Address:</td> <td>${orderList["buyerEthAddress"]}</td></tr> <tr><td class="pd">Buyer ETH Address:</td> <td>${orderList["buyerEthAddress"]}</td></tr>
<tr><td>Amount Ont:</td> <td>${orderList["amountOnt"]}</td></tr> <tr><td class="pd">Amount Ont:</td> <td>${orderList["amountOnt"]}</td></tr>
<tr><td>Refund Time:</td> <td>${t}</td></tr> <tr><td class="pd">Refund Time:</td> <td>${t}</td></tr>
<tr><td>Secret:</td> <td>${orderList["secret"]}</td></tr> <tr><td class="pd">Secret:</td> <td>${orderList["secret"]}</td></tr>
<tr><td>Status:</td> <td>${orderList["status"]}</td></tr> <tr><td class="pd">Status:</td> <td>${orderList["status"]}</td></tr>
</table>`; </table>`;
// console.log(orderList); // console.log(orderList);
var slides = document.getElementsByName("hashlock"); var slides = document.getElementsByName("hashlock");
...@@ -247,19 +247,20 @@ async function notifyforstateineth(){ ...@@ -247,19 +247,20 @@ async function notifyforstateineth(){
// }, 10000); // }, 10000);
// } // }
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); // const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
async function getBidTimeLock(hashlock, tid){ async function getBidTimeLock(hashlock, tid){
if(tid == "bidtimer1"){ if(tid == "bidtimer1"){
await initiateBidding(hashlock); await initiateBidding(hashlock);
await sleep(10000); document.getElementById('todb').submit();
// await sleep(10000);
} }
const orderList = await window.contract2.methods.orderList(hashlock).call(); const orderList = await window.contract2.methods.orderList(hashlock).call();
var tl = parseInt(orderList["bidTimelock"]); var tl = parseInt(orderList["bidTimelock"]);
if(tid == "bidtimer1"){ // if(tid == "bidtimer1"){
document.getElementById('bidTimelock3').value=timeConverter(tl); // document.getElementById('bidTimelock3').value=timeConverter(tl);
document.getElementById('todb').submit();
} // }
countdown(tid, tl); countdown(tid, tl);
} }
......
...@@ -40,6 +40,9 @@ td, th { ...@@ -40,6 +40,9 @@ td, th {
text-align: left; text-align: left;
padding: 8px; padding: 8px;
} }
.pd{
padding: 8px;
}
tr:nth-child(even) { tr:nth-child(even) {
background-color: #dddddd; background-color: #dddddd;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head> </head>
<body> <body>
<h1 class="centeralign"">Atomic Swap</h1> <h1 class="centeralign"">Atomic Swap</h1>
<br > <br >
<div class="centeralign"> <div class="centeralign">
...@@ -22,7 +21,7 @@ ...@@ -22,7 +21,7 @@
<button type="button" class="btn btn-primary" id="ETHBut" onclick="hideElement('ONT'); showElement('ETH');">ETH</button> <button type="button" class="btn btn-primary" id="ETHBut" onclick="hideElement('ONT'); showElement('ETH');">ETH</button>
</div> </div>
<hr> <hr>
<div class="centeralign" id = "ONT"> <div class="centeralign setmargin" id = "ONT">
<!-- ORDER STATUS --> <!-- ORDER STATUS -->
<div> <div>
...@@ -109,10 +108,10 @@ ...@@ -109,10 +108,10 @@
</div> </div>
<iframe name="votar" style="display:none;"></iframe> <iframe name="votar" style="display:none;"></iframe>
<form id="todb" action="/txns" method="post" target="votar"> <form id="todb" action="/txns" method="post" target="votar" style="display:none;">
<input type="hidden" name="hashlock" id="hash12"><br><br> <input type="hidden" name="hashlock" id="hash12"><br><br>
<input type="hidden" name="amountOnt" id="amountOnt3"><br><br> <!-- <input type="hidden" name="amountOnt" id="amountOnt3"><br><br>
<input type="hidden" name="bidTimelock" id="bidTimelock3"><br><br> <input type="hidden" name="bidTimelock" id="bidTimelock3"><br><br> -->
<input style="display: none;" type="submit" value="Send to Database"> <input style="display: none;" type="submit" value="Send to Database">
</form> </form>
...@@ -154,7 +153,7 @@ ...@@ -154,7 +153,7 @@
</div> </div>
<hr> <hr>
</div> </div>
<div> <div class="setmargin">
Status: <span id="status">Loading...</span> Status: <span id="status">Loading...</span>
</div> </div>
......
<html lang="en"> <html lang="en">
<head> <head>
<meta charset='utf-8'> <meta charset='utf-8'>
<!-- <meta http-equiv='X-UA-Compatible' content='IE=edge'> --> <meta http-equiv='X-UA-Compatible' content='IE=edge'>
<!-- <meta http-equiv="refresh" content="15"> --> <meta http-equiv="refresh" content="10">
<title><%= title %></title> <title><%= title %></title>
<meta name='viewport' content='width=device-width, initial-scale=1'> <meta name='viewport' content='width=device-width, initial-scale=1'>
<script src='/web3.min.js'></script>
<link rel="stylesheet" href="/style.css"> <link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
...@@ -22,6 +23,7 @@ ...@@ -22,6 +23,7 @@
<% txns.forEach(txn => { %> <% txns.forEach(txn => { %>
<tr> <tr>
<td><%= txn.hashlock %></td> <td><%= txn.hashlock %></td>
<% %>
<td><%= txn.amountOnt %></td> <td><%= txn.amountOnt %></td>
<td><%= txn.bidTimelock %></td> <td><%= txn.bidTimelock %></td>
</tr> </tr>
...@@ -30,7 +32,6 @@ ...@@ -30,7 +32,6 @@
<% } else { %> <% } else { %>
<p>There are no transactions to display...</p> <p>There are no transactions to display...</p>
<% } %> <% } %>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment