Added parsing of newer certificate format
This commit is contained in:
parent
969e337e9f
commit
6a22f3857e
58
css/main.css
58
css/main.css
@ -52,6 +52,22 @@ button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.capitalize {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.align-items-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.space-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.wrap-around {
|
||||
overflow-wrap: break-word;
|
||||
word-wrap: break-word;
|
||||
@ -68,6 +84,15 @@ button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#loader {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
#home > * {
|
||||
width: min(100%, 56rem);
|
||||
margin: 0 auto;
|
||||
@ -102,7 +127,7 @@ button {
|
||||
#home header {
|
||||
width: 100%;
|
||||
background-color: rgba(var(--text-color), 0.06);
|
||||
padding-bottom: 2rem;
|
||||
padding-bottom: 3rem;
|
||||
margin-bottom: -2rem;
|
||||
}
|
||||
|
||||
@ -128,7 +153,7 @@ button {
|
||||
#issued_cert_list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
gap: 0.5rem;
|
||||
padding: 1rem;
|
||||
padding-bottom: 4rem;
|
||||
margin-top: 1rem;
|
||||
@ -138,7 +163,7 @@ button {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
padding: 1rem;
|
||||
background-color: rgba(var(--text-color), 0.06);
|
||||
background-color: rgba(var(--text-color), 0.03);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
.cert-card h4 {
|
||||
@ -148,11 +173,33 @@ button {
|
||||
font-size: 0.9rem;
|
||||
color: rgba(var(--text-color), 0.9);
|
||||
}
|
||||
.cert-card a {
|
||||
padding: 0.6rem 1rem;
|
||||
text-decoration: none;
|
||||
background-color: var(--accent-color);
|
||||
color: white;
|
||||
border-radius: 3rem;
|
||||
margin-left: auto;
|
||||
font-weight: 500;
|
||||
}
|
||||
.cert-card .tag {
|
||||
padding: 0.3rem 0.5rem;
|
||||
border-radius: 0.3rem;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: rgba(var(--text-color), 0.9);
|
||||
background-color: rgba(var(--text-color), 0.06);
|
||||
margin-right: auto;
|
||||
}
|
||||
.cert-card .tag::first-letter {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
#certificate {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
#certificate * {
|
||||
font-family: "Times New Roman", Times, serif;
|
||||
@ -163,6 +210,11 @@ button {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.cert-card {
|
||||
margin: 0 -1rem;
|
||||
}
|
||||
}
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
2
css/main.min.css
vendored
2
css/main.min.css
vendored
@ -1 +1 @@
|
||||
*{padding:0;margin:0;box-sizing:border-box;font-family:"Roboto",sans-serif}:root{font-size:clamp(1rem,1.2vmax,1.2rem)}html,body{height:100%}body{--accent-color: #3d5afe;--secondary-color: #ffac2e;--text-color: 34, 34, 34;--foreground-color: 252, 253, 255;--background-color: 241, 243, 248;--danger-color: rgb(255, 75, 75);--green: #1cad59;--yellow: rgb(220, 165, 0);color:rgba(var(--text-color), 1);background-color:rgba(var(--background-color), 1)}body[data-theme=dark]{--accent-color: #92a2ff;--secondary-color: #d60739;--text-color: 200, 200, 200;--foreground-color: 27, 28, 29;--background-color: 21, 22, 22;--danger-color: rgb(255, 106, 106);--green: #00e676;--yellow: rgb(255, 213, 5)}body[data-theme=dark] ::-webkit-calendar-picker-indicator{filter:invert(1)}button{padding:1rem;font-size:inherit;background-color:var(--accent-color);border:none;border-radius:.3rem;color:#fff;font-weight:500;cursor:pointer}.wrap-around{overflow-wrap:break-word;word-wrap:break-word;word-break:break-word;-webkit-hyphens:auto;hyphens:auto}.observe-empty-state:empty{display:none}.observe-empty-state:not(:empty)~.empty-state{display:none}#home>*{width:min(100%,56rem);margin:0 auto}#home h1{padding:1rem;padding-top:10vmax;font-size:max(1.8rem,4vw);text-align:center;background:linear-gradient(135deg, #fa00ff, #00e0ff 50%, #fa00ff);-webkit-background-clip:text;-webkit-text-fill-color:rgba(0,0,0,0);background-size:200%;animation:gradient 20s ease infinite alternate-reverse}@-webkit-keyframes gradient{0%{background-position:0% 50%}100%{background-position:100% 50%}}@keyframes gradient{0%{background-position:0% 50%}100%{background-position:100% 50%}}#home header{width:100%;background-color:rgba(var(--text-color), 0.06);padding-bottom:2rem;margin-bottom:-2rem}#cert_sec{padding:1.5rem;font-family:"intern"}#search_certificates{position:-webkit-sticky;position:sticky;top:1rem;width:min(24rem,100% - 2rem);margin:0 auto;--border-radius: 0.5rem;border-radius:.5rem;--padding: 1rem 1.2rem;background-color:rgba(var(--foreground-color), 1);box-shadow:0 .5rem 1.5rem rgba(0,0,0,.1);border:solid thin rgba(var(--text-color), 0.2)}#issued_cert_list{display:flex;flex-direction:column;gap:1rem;padding:1rem;padding-bottom:4rem;margin-top:1rem}.cert-card{display:grid;gap:.5rem;padding:1rem;background-color:rgba(var(--text-color), 0.06);border-radius:.5rem}.cert-card h4{font-size:1.2rem}.cert-card p{font-size:.9rem;color:rgba(var(--text-color), 0.9)}#certificate{display:flex;align-items:center;justify-content:center}#certificate *{font-family:"Times New Roman",Times,serif}#certificate_svg{flex-shrink:0;background-color:#fff}.hidden{display:none !important}
|
||||
*{padding:0;margin:0;box-sizing:border-box;font-family:"Roboto",sans-serif}:root{font-size:clamp(1rem,1.2vmax,1.2rem)}html,body{height:100%}body{--accent-color: #3d5afe;--secondary-color: #ffac2e;--text-color: 34, 34, 34;--foreground-color: 252, 253, 255;--background-color: 241, 243, 248;--danger-color: rgb(255, 75, 75);--green: #1cad59;--yellow: rgb(220, 165, 0);color:rgba(var(--text-color), 1);background-color:rgba(var(--background-color), 1)}body[data-theme=dark]{--accent-color: #92a2ff;--secondary-color: #d60739;--text-color: 200, 200, 200;--foreground-color: 27, 28, 29;--background-color: 21, 22, 22;--danger-color: rgb(255, 106, 106);--green: #00e676;--yellow: rgb(255, 213, 5)}body[data-theme=dark] ::-webkit-calendar-picker-indicator{filter:invert(1)}button{padding:1rem;font-size:inherit;background-color:var(--accent-color);border:none;border-radius:.3rem;color:#fff;font-weight:500;cursor:pointer}.capitalize{text-transform:capitalize}.flex{display:flex}.align-items-center{align-items:center}.space-between{justify-content:space-between}.wrap-around{overflow-wrap:break-word;word-wrap:break-word;word-break:break-word;-webkit-hyphens:auto;hyphens:auto}.observe-empty-state:empty{display:none}.observe-empty-state:not(:empty)~.empty-state{display:none}#loader{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:1rem}#home>*{width:min(100%,56rem);margin:0 auto}#home h1{padding:1rem;padding-top:10vmax;font-size:max(1.8rem,4vw);text-align:center;background:linear-gradient(135deg, #fa00ff, #00e0ff 50%, #fa00ff);-webkit-background-clip:text;-webkit-text-fill-color:rgba(0,0,0,0);background-size:200%;animation:gradient 20s ease infinite alternate-reverse}@-webkit-keyframes gradient{0%{background-position:0% 50%}100%{background-position:100% 50%}}@keyframes gradient{0%{background-position:0% 50%}100%{background-position:100% 50%}}#home header{width:100%;background-color:rgba(var(--text-color), 0.06);padding-bottom:3rem;margin-bottom:-2rem}#cert_sec{padding:1.5rem;font-family:"intern"}#search_certificates{position:-webkit-sticky;position:sticky;top:1rem;width:min(24rem,100% - 2rem);margin:0 auto;--border-radius: 0.5rem;border-radius:.5rem;--padding: 1rem 1.2rem;background-color:rgba(var(--foreground-color), 1);box-shadow:0 .5rem 1.5rem rgba(0,0,0,.1);border:solid thin rgba(var(--text-color), 0.2)}#issued_cert_list{display:flex;flex-direction:column;gap:.5rem;padding:1rem;padding-bottom:4rem;margin-top:1rem}.cert-card{display:grid;gap:.5rem;padding:1rem;background-color:rgba(var(--text-color), 0.03);border-radius:.5rem}.cert-card h4{font-size:1.2rem}.cert-card p{font-size:.9rem;color:rgba(var(--text-color), 0.9)}.cert-card a{padding:.6rem 1rem;text-decoration:none;background-color:var(--accent-color);color:#fff;border-radius:3rem;margin-left:auto;font-weight:500}.cert-card .tag{padding:.3rem .5rem;border-radius:.3rem;font-size:.9rem;font-weight:500;color:rgba(var(--text-color), 0.9);background-color:rgba(var(--text-color), 0.06);margin-right:auto}.cert-card .tag::first-letter{text-transform:uppercase}#certificate{display:flex;align-items:center;justify-content:center;flex-direction:column}#certificate *{font-family:"Times New Roman",Times,serif}#certificate_svg{flex-shrink:0;background-color:#fff}@media(max-width: 768px){.cert-card{margin:0 -1rem}}.hidden{display:none !important}
|
||||
@ -51,6 +51,18 @@ button {
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
}
|
||||
.capitalize {
|
||||
text-transform: capitalize;
|
||||
}
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
.align-items-center {
|
||||
align-items: center;
|
||||
}
|
||||
.space-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
.wrap-around {
|
||||
overflow-wrap: break-word;
|
||||
word-wrap: break-word;
|
||||
@ -65,6 +77,14 @@ button {
|
||||
.observe-empty-state:not(:empty) ~ .empty-state {
|
||||
display: none;
|
||||
}
|
||||
#loader {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
gap: 1rem;
|
||||
}
|
||||
#home {
|
||||
& > * {
|
||||
width: min(100%, 56rem);
|
||||
@ -92,7 +112,7 @@ button {
|
||||
header {
|
||||
width: 100%;
|
||||
background-color: rgba(var(--text-color), 0.06);
|
||||
padding-bottom: 2rem;
|
||||
padding-bottom: 3rem;
|
||||
margin-bottom: -2rem;
|
||||
}
|
||||
}
|
||||
@ -115,7 +135,7 @@ button {
|
||||
#issued_cert_list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
gap: 0.5rem;
|
||||
padding: 1rem;
|
||||
padding-bottom: 4rem;
|
||||
margin-top: 1rem;
|
||||
@ -124,7 +144,7 @@ button {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
padding: 1rem;
|
||||
background-color: rgba(var(--text-color), 0.06);
|
||||
background-color: rgba(var(--text-color), 0.03);
|
||||
border-radius: 0.5rem;
|
||||
h4 {
|
||||
font-size: 1.2rem;
|
||||
@ -133,11 +153,33 @@ button {
|
||||
font-size: 0.9rem;
|
||||
color: rgba(var(--text-color), 0.9);
|
||||
}
|
||||
a {
|
||||
padding: 0.6rem 1rem;
|
||||
text-decoration: none;
|
||||
background-color: var(--accent-color);
|
||||
color: white;
|
||||
border-radius: 3rem;
|
||||
margin-left: auto;
|
||||
font-weight: 500;
|
||||
}
|
||||
.tag {
|
||||
padding: 0.3rem 0.5rem;
|
||||
border-radius: 0.3rem;
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: rgba(var(--text-color), 0.9);
|
||||
background-color: rgba(var(--text-color), 0.06);
|
||||
margin-right: auto;
|
||||
&::first-letter {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
}
|
||||
#certificate {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
* {
|
||||
font-family: "Times New Roman", Times, serif;
|
||||
}
|
||||
@ -146,7 +188,10 @@ button {
|
||||
flex-shrink: 0;
|
||||
background-color: white;
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
@media (max-width: 768px) {
|
||||
.cert-card {
|
||||
margin: 0 -1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.hidden {
|
||||
|
||||
102
index.html
102
index.html
@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<title>RanchiMall Certificates</title>
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800;900&family=Roboto:wght@400;500;700&display=swap"
|
||||
@ -32,7 +32,11 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<section id="home" class="page">
|
||||
<section id="loader" class="page">
|
||||
<sm-spinner></sm-spinner>
|
||||
<p>Getting your certificates</p>
|
||||
</section>
|
||||
<section id="home" class="page hidden">
|
||||
<header>
|
||||
<h1>RanchiMall Certificates</h1>
|
||||
</header>
|
||||
@ -49,7 +53,7 @@
|
||||
<h2>No related certificates issued yet</h2>
|
||||
</div>
|
||||
</section>
|
||||
<section id="certificate" class="page hidden">
|
||||
<section id="certificate" class="grid page hidden">
|
||||
<svg id="certificate_svg" width="1400" height="980" viewBox="0 0 1400 980" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="certificate">
|
||||
@ -205,6 +209,7 @@
|
||||
appState.params = params
|
||||
switch (pageId) {
|
||||
case 'home':
|
||||
getRef('search_certificates').focusIn()
|
||||
renderElem(getRef('issued_cert_list'), html`${[...floGlobals.validCerts.values()].map(cert => render.issuedCertCard(cert))}`)
|
||||
break;
|
||||
}
|
||||
@ -241,46 +246,6 @@
|
||||
</script>
|
||||
<script>
|
||||
const { html, render: renderElem } = uhtml;
|
||||
const slideInLeft = [
|
||||
{
|
||||
opacity: 0,
|
||||
transform: 'translateX(1rem)'
|
||||
},
|
||||
{
|
||||
opacity: 1,
|
||||
transform: 'translateX(0)'
|
||||
}
|
||||
]
|
||||
const slideOutLeft = [
|
||||
{
|
||||
opacity: 1,
|
||||
transform: 'translateX(0)'
|
||||
},
|
||||
{
|
||||
opacity: 0,
|
||||
transform: 'translateX(-1rem)'
|
||||
},
|
||||
]
|
||||
const slideInRight = [
|
||||
{
|
||||
opacity: 0,
|
||||
transform: 'translateX(-1rem)'
|
||||
},
|
||||
{
|
||||
opacity: 1,
|
||||
transform: 'translateX(0)'
|
||||
}
|
||||
]
|
||||
const slideOutRight = [
|
||||
{
|
||||
opacity: 1,
|
||||
transform: 'translateX(0)'
|
||||
},
|
||||
{
|
||||
opacity: 0,
|
||||
transform: 'translateX(1rem)'
|
||||
},
|
||||
]
|
||||
const slideInDown = [
|
||||
{
|
||||
opacity: 0,
|
||||
@ -380,6 +345,12 @@
|
||||
})
|
||||
renderElem(getRef('issued_cert_list'), html`${filteredCerts.map(cert => render.issuedCertCard(cert))}`)
|
||||
})
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === '/') {
|
||||
e.preventDefault();
|
||||
getRef('search_certificates').focusIn()
|
||||
}
|
||||
})
|
||||
}
|
||||
function convertSvgToPdf(element) {
|
||||
const margin = 5
|
||||
@ -438,18 +409,21 @@
|
||||
}
|
||||
const render = {
|
||||
issuedCertCard(details) {
|
||||
const { floData, txid, name, floId } = details
|
||||
const { floData, txid, name, floId, certType } = details
|
||||
return html`
|
||||
<li class="cert-card">
|
||||
<h4>${name}</h4>
|
||||
<h4 class="capitalize">${name.toLowerCase()}</h4>
|
||||
<p class="wrap-around">${floId}</p>
|
||||
<a href=${`#/certificate?id=${txid}`}>View</a>
|
||||
<div class="flex align-items-center space-between">
|
||||
<span class="tag">${certType.toLowerCase()}</span>
|
||||
<a href=${`#/certificate?id=${txid}`}>Download</a>
|
||||
</div>
|
||||
</li>
|
||||
`;
|
||||
},
|
||||
certificate(txid) {
|
||||
const { floData, time, name, floId } = floGlobals.validCerts.get(txid)
|
||||
getRef('certificate_type').firstElementChild.textContent = getFirstThreeWords(floData).toUpperCase();
|
||||
const { floData, time, name, floId, certType, isNewer, certPara } = floGlobals.validCerts.get(txid)
|
||||
getRef('certificate_type').firstElementChild.textContent = certType.toUpperCase();
|
||||
alignTextCenter(getRef('certificate_type').firstElementChild)
|
||||
getRef('main_name').firstElementChild.textContent = name.toUpperCase();
|
||||
alignTextCenter(getRef('main_name').firstElementChild)
|
||||
@ -458,7 +432,8 @@
|
||||
getRef('intern_flo_id').firstElementChild.textContent = floId
|
||||
alignTextCenter(getRef('intern_flo_id').firstElementChild)
|
||||
getRef('cert_data').innerHTML = ''
|
||||
splitIntoLines(removeWordsBefore(floData, 'worked')).forEach((line, index) => {
|
||||
const remarks = isNewer ? certPara : removeWordsBefore(floData, 'worked')
|
||||
splitIntoLines(remarks).forEach((line, index) => {
|
||||
let tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan')
|
||||
tspan.textContent = line
|
||||
tspan.setAttribute('x', '0')
|
||||
@ -470,7 +445,7 @@
|
||||
alignTextCenter(tspan)
|
||||
})
|
||||
let certificateVerification = ''
|
||||
switch (getFirstThreeWords(floData)) {
|
||||
switch (certType) {
|
||||
case "CERTIFICATE OF INTERNSHIP":
|
||||
certificateVerification = 'internCertificate';
|
||||
break;
|
||||
@ -499,17 +474,26 @@
|
||||
function readTx() {
|
||||
return new Promise((resolve, reject) => {
|
||||
floBlockchainAPI.readAllTxs('FFCpiaZi31TpbYw5q5VNk8qJMeDiTLgsrE').then(res => {
|
||||
res.forEach(tx => {
|
||||
// res.unshift({ floData: 'CERTIFICATE OF INTERNSHIP|FPFeL5PXzW9bGosUjQYCxTHSMHidnygvvd|Sairaj mote|worked as an intern on projects for RanchiMall from 11th September 2020 to 2nd February 2021: Twitter Marketing and Peer-to-Peer Content Collaboration on FLO Blockchain. She contributed mostly to Twitter marketing and also collaborated with other content writers on writing articles for RanchiMall Times. She performed well under the guidance of the RIBC team of RanchiMall.', time: Date.now() })
|
||||
for (tx of res) {
|
||||
const { vin, vout, time, floData } = tx
|
||||
const iVerify = vin.some(i => i.addr === floGlobals.RM_CertificateIssuer_id);
|
||||
const oVerify = vout.some(o => [floGlobals.RMincorporationID, floGlobals.RIBC_id].includes(o.scriptPubKey.addresses[0]));
|
||||
const cVerify = tx.floData.startsWith('CERTIFICATE OF')
|
||||
const floId = floData.match(/\b\w{30,36}\b/)?.[0]
|
||||
if (iVerify && oVerify && cVerify && floId) {
|
||||
const name = getBetween(floData, 'certifies that', 'FLO ID')
|
||||
floGlobals.validCerts.set(tx.txid, { name, ...tx, floId })
|
||||
if (!vin.some(i => i.addr === floGlobals.RM_CertificateIssuer_id)) continue;
|
||||
if (!vout.some(o => [floGlobals.RMincorporationID, floGlobals.RIBC_id].includes(o.scriptPubKey.addresses[0]))) continue;
|
||||
if (!floData.startsWith('CERTIFICATE OF')) continue;
|
||||
let name, floId, certType, certPara = ''
|
||||
let isNewer = true
|
||||
// check if certificates are of newer format
|
||||
if (floData.includes('|')) {
|
||||
[certType, floId, name, certPara] = floData.split('|')
|
||||
} else {
|
||||
floId = floData.match(/\b\w{30,36}\b/)?.[0]
|
||||
name = getBetween(floData, 'certifies that', 'FLO ID')
|
||||
certType = getFirstThreeWords(floData)
|
||||
isNewer = false
|
||||
}
|
||||
})
|
||||
if (!floId) continue;
|
||||
floGlobals.validCerts.set(tx.txid, { name, ...tx, floId, certType, isNewer, certPara })
|
||||
}
|
||||
resolve()
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user