From 76e8ca1838a24594e467b4786809d6848d3cc2f7 Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Sat, 25 Sep 2021 19:43:51 +0530 Subject: [PATCH] UI update --- index.html | 559 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 312 insertions(+), 247 deletions(-) diff --git a/index.html b/index.html index 40805c1..efb588f 100644 --- a/index.html +++ b/index.html @@ -1,263 +1,328 @@ + - Ranchimall Certificate Verifier - - - - - + //Required for blockchain API operators + apiURL: { + FLO: ['https://livenet.flocha.in/', 'https://flosight.duckdns.org/'], + FLO_TEST: ['https://testnet-flosight.duckdns.org/', 'https://testnet.flocha.in/'] + }, + //adminID: null, + RMincorporationID: "FKNW5eCCp2SnJMJ6pLLpUCvk5hAage8Jtk", + RMcertificateProvider: "FFCpiaZi31TpbYw5q5VNk8qJMeDiTLgsrE", + //sendAmt: 0.001, + //fee: 0.0005, + } + + -
-

Ranchimall Certificate Verifier

-
-
- - success - - - -

- Verified, This is a genuine certificate issued by RanchiMall. -

+
+
+
-
- - failed - - - - -

- Verification failed! -

-
-
- - error - - - - -

- Try Again Later! -

-
-
- - - + + + function verifyCertificate(id, certType, verifierContent) { + floBlockchainAPI.getTx(id).then(tx => { + let iVerify = false, + oVerify = false, + cVerify = false; + for (let i of tx.vin) + if (floGlobals.RMcertificateProvider === i.addr) { + iVerify = true; + break; + } + for (let o of tx.vout) + if (floGlobals.RMincorporationID === o.scriptPubKey.addresses[0]) { + oVerify = true; + break; + } + cVerify = tx.floData.startsWith(verifierContent); + if (iVerify && oVerify && cVerify) { + console.log(`${certType} (${id}) verified`); + let link = getBlockchainLink(`tx/${id}`), + content = tx.floData.substring(verifierContent.length).trim(), + time = `Issued: ${trimDate(tx.time * 1000)}`; + outputUI(certType, verifierContent, content, time); + showVerificationStatus('verified', link) + } else { + console.log(`${certType} (${id}) verification failed`); + showVerificationStatus('unverified') + } + }).catch(error => { + console.log(`${certType} (${id}) not verified`); + showVerificationStatus('error') + }) + } + + function outputUI(head, type, body, foot, link) { + let t = document.createElement('h3'); + t.textContent = type; + let b = document.createElement('p'); + b.innerHTML = body.replace(/([a-zA-Z0-9]){30,36}/, `$&`); + let f = document.createElement('time'); + f.textContent = foot; + document.getElementById("result_box").append(t, f, b); + } + + function getBlockchainLink(path) { + let flosight = floBlockchainAPI.util.serverList[floBlockchainAPI.util.curPos] + return flosight + path + } + + function trimDate(d) { + d = new Date(d).toString() + return `${d.substring(4, 10)}, ${d.substring(11, 15)}` + } + - + + \ No newline at end of file