328 lines
12 KiB
HTML
328 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>Ranchimall Certificate Verifier</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com">
|
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
|
|
<script id="floGlobals">
|
|
/* Constants for FLO blockchain operations !!Make sure to add this at begining!! */
|
|
const floGlobals = {
|
|
|
|
//Required for all
|
|
blockchain: "FLO",
|
|
|
|
//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,
|
|
}
|
|
</script>
|
|
<style>
|
|
* {
|
|
box-sizing: border-box;
|
|
padding: 0;
|
|
margin: 0;
|
|
font-family: 'Roboto', sans-serif;
|
|
}
|
|
|
|
:root {
|
|
font-size: clamp(16px, 1.2vmax, 40px);
|
|
}
|
|
|
|
html,
|
|
body {
|
|
height: 100%;
|
|
scroll-behavior: smooth;
|
|
}
|
|
|
|
body {
|
|
display: grid;
|
|
grid-template-columns: 2rem 1fr 2rem;
|
|
}
|
|
|
|
body>* {
|
|
grid-column: 2;
|
|
}
|
|
|
|
#main {
|
|
display: grid;
|
|
gap: 1.5rem;
|
|
align-content: flex-start;
|
|
}
|
|
|
|
h4 {
|
|
font-size: 1.5rem;
|
|
line-height: 1.6;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.hide-completely {
|
|
display: none !important;
|
|
}
|
|
|
|
.icon {
|
|
height: 4rem;
|
|
width: 4rem;
|
|
margin-bottom: 1rem;
|
|
align-self: center;
|
|
background-color: rgba(0, 0, 0, 0.06);
|
|
border-radius: 50%;
|
|
padding: 1rem;
|
|
}
|
|
|
|
header h3 {
|
|
font-weight: 500;
|
|
}
|
|
|
|
#verification_status {
|
|
align-content: center;
|
|
display: grid;
|
|
text-align: center;
|
|
justify-items: center;
|
|
padding: 1.5rem 0;
|
|
}
|
|
|
|
#verification_status p {
|
|
color: rgba(0, 0, 0, 0.7);
|
|
}
|
|
|
|
.verified .icon {
|
|
fill: #1cad59;
|
|
}
|
|
|
|
.unverified .icon {
|
|
fill: rgb(255, 75, 75);
|
|
}
|
|
|
|
.error .icon {
|
|
fill: rgb(146, 146, 146);
|
|
}
|
|
|
|
#result_box {
|
|
display: grid;
|
|
gap: 0.5rem;
|
|
align-items: center;
|
|
}
|
|
|
|
#result_box time {
|
|
font-size: 0.9rem;
|
|
color: rgba(0, 0, 0, 0.8);
|
|
}
|
|
|
|
#result_box p {
|
|
font-size: 1rem;
|
|
line-height: 1.7;
|
|
max-width: 70ch;
|
|
opacity: 0.8;
|
|
margin-top: 1rem;
|
|
overflow-wrap: break-word;
|
|
}
|
|
|
|
#result_box h2 {
|
|
text-transform: capitalize;
|
|
}
|
|
|
|
.transaction-link {
|
|
align-self: flex-start;
|
|
text-decoration: none;
|
|
background-color: rgba(0, 0, 0, 0.06);
|
|
padding: 0.5rem 0.8rem;
|
|
font-size: 0.9rem;
|
|
border-radius: 0.3rem;
|
|
color: rgba(0, 0, 0, 0.7);
|
|
margin-top: 1.5rem;
|
|
}
|
|
|
|
@media screen and (max-width: 640px) {
|
|
#verification_status {
|
|
margin-top: 1.5rem;
|
|
}
|
|
}
|
|
|
|
@media screen and (min-width: 640px) {
|
|
body {
|
|
grid-template-columns: 1fr 90vw 1fr;
|
|
place-content: center;
|
|
}
|
|
|
|
#main {
|
|
align-self: center;
|
|
grid-template-columns: 18rem 1fr;
|
|
justify-content: center;
|
|
border-radius: 0.5rem;
|
|
border: solid 0.2rem dodgerblue;
|
|
padding: 5rem 3rem;
|
|
}
|
|
|
|
#verification_status {
|
|
padding-right: 1.5rem;
|
|
border-right: thin solid rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
#result_box {
|
|
grid-template-columns: 1fr auto;
|
|
padding-left: 1.5rem;
|
|
}
|
|
|
|
#result_box p {
|
|
grid-column: span 2;
|
|
align-self: flex-start;
|
|
}
|
|
}
|
|
|
|
@media screen and (min-width: 1080px) {
|
|
body {
|
|
grid-template-columns: 1fr 80vw 1fr;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body onload="onLoadStartUp()">
|
|
<div id="main">
|
|
<div id="verification_status"></div>
|
|
<div id="result_box"></div>
|
|
</div>
|
|
|
|
<script src="https://github.com/ranchimall/Standard_Operations/releases/latest/download/floCrypto.js"></script>
|
|
<script
|
|
src="https://github.com/ranchimall/Standard_Operations/releases/latest/download/floBlockchainAPI.js"></script>
|
|
<script id="onLoadStartUp">
|
|
function onLoadStartUp() {
|
|
console.log("Ranchimall Certificate Verifier")
|
|
floBlockchainAPI.getBalance(floCrypto.generateNewID().floID).then(r => {
|
|
let req = window.location.search.substring(1).split('=')
|
|
let key = req[0],
|
|
value = req[1]
|
|
console.log(key, value)
|
|
switch (key) {
|
|
case "internCertificate":
|
|
verifyCertificate(value, "RIBC certificate", "CERTIFICATE OF INTERNSHIP");
|
|
break;
|
|
case "employeeCertificate":
|
|
verifyCertificate(value, "Employee certificate", "CERTIFICATE OF EMPLOYMENT");
|
|
break;
|
|
case "volunteerCertificate":
|
|
verifyCertificate(value, "Volunteer certificate", "CERTIFICATE OF VOLUNTEERSHIP");
|
|
break;
|
|
case "participationCertificate":
|
|
verifyCertificate(value, "Participation certificate", "CERTIFICATE OF PARTICIPATION");
|
|
break;
|
|
|
|
}
|
|
}).catch(e => {
|
|
console.error(e)
|
|
showVerificationStatus('error')
|
|
})
|
|
}
|
|
|
|
const verificationStatus = document.getElementById('verification_status')
|
|
function showVerificationStatus(status, link) {
|
|
let statusComposition = ''
|
|
verificationStatus.className = status
|
|
switch (status) {
|
|
case 'verified':
|
|
statusComposition = `
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
|
|
<path fill-rule="evenodd" d="M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
|
</svg>
|
|
<h4>
|
|
Verified
|
|
</h4>
|
|
<p>
|
|
This is a genuine certificate issued by RanchiMall
|
|
</p>
|
|
<a href="${link}" target="_blank" class="transaction-link">View on blockchain</a>
|
|
`
|
|
break;
|
|
case 'unverified':
|
|
statusComposition = `
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
|
|
<path fill-rule="evenodd"
|
|
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
|
|
clip-rule="evenodd" />
|
|
</svg>
|
|
<h4>
|
|
Verification failed!
|
|
</h4>
|
|
`
|
|
break;
|
|
case 'error':
|
|
statusComposition = `
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 20 20" fill="currentColor">
|
|
<path
|
|
d="M3.707 2.293a1 1 0 00-1.414 1.414l6.921 6.922c.05.062.105.118.168.167l6.91 6.911a1 1 0 001.415-1.414l-.675-.675a9.001 9.001 0 00-.668-11.982A1 1 0 1014.95 5.05a7.002 7.002 0 01.657 9.143l-1.435-1.435a5.002 5.002 0 00-.636-6.294A1 1 0 0012.12 7.88c.924.923 1.12 2.3.587 3.415l-1.992-1.992a.922.922 0 00-.018-.018l-6.99-6.991zM3.238 8.187a1 1 0 00-1.933-.516c-.8 3-.025 6.336 2.331 8.693a1 1 0 001.414-1.415 6.997 6.997 0 01-1.812-6.762zM7.4 11.5a1 1 0 10-1.73 1c.214.371.48.72.795 1.035a1 1 0 001.414-1.414c-.191-.191-.35-.4-.478-.622z" />
|
|
</svg>
|
|
<h4>
|
|
Try Again Later!
|
|
</h4>
|
|
`
|
|
break
|
|
}
|
|
verificationStatus.innerHTML = statusComposition
|
|
}
|
|
|
|
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}/, `<i>$&</i>`);
|
|
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)}`
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html> |