@angloqq03/gpv
Version:
OCR-powered GCash screenshot proof validation for Node.js using Tesseract.js and Brain.js.
499 lines (421 loc) • 12.9 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon"
href="https://scontent.fcrk1-2.fna.fbcdn.net/v/t39.30808-6/650316481_122172706184789754_9188959231716923877_n.jpg?stp=dst-jpg_s206x206_tt6&_nc_cat=110&ccb=1-7&_nc_sid=7a06f5&_nc_eui2=AeHtCgpNib0RJABcczQPQm0W3oIJA5sTVFneggkDmxNUWXeC8QrF652zVeGFbAFdpkWZ3jGN8JJojRIdCy-JMpyT&_nc_ohc=HmqewOgVkW8Q7kNvwF9Y2rm&_nc_oc=AdpxoE-38M2YHn_ZcX3Q2XmkIuqCGYrfVPyEM7jJUGIlRkGdeedHCf8pFAqQnzBUQo8&_nc_zt=23&_nc_ht=scontent.fcrk1-2.fna&_nc_gid=v3IIMu3XBccr8Ips_ihSqA&_nc_ss=7a3a8&oh=00_Af0VwPPlF2OIZ5DEfICw94gETKRs1TXJVCOLLCbojMxxCA&oe=69D45C20"
type="image/x-icon">
<title>GPV Demo</title>
<style>
:root {
--bg: #f7efe2;
--panel: #fffaf2;
--panel-strong: #fff;
--text: #1d1a17;
--muted: #6f655c;
--accent: #1f8f76;
--accent-2: #f59e0b;
--border: #e6d8c8;
--shadow: 0 18px 40px rgba(72, 48, 24, 0.12);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: "Segoe UI", "Trebuchet MS", sans-serif;
color: var(--text);
background:
radial-gradient(circle at top left, rgba(245, 158, 11, 0.18), transparent 30%),
radial-gradient(circle at top right, rgba(31, 143, 118, 0.18), transparent 35%),
linear-gradient(180deg, #fff8ef 0%, var(--bg) 100%);
}
.shell {
max-width: 1180px;
margin: 0 auto;
padding: 32px 18px 60px;
}
.hero {
display: grid;
gap: 18px;
margin-bottom: 24px;
}
.hero-card,
.panel {
background: rgba(255, 250, 242, 0.94);
border: 1px solid var(--border);
border-radius: 24px;
box-shadow: var(--shadow);
}
.hero-card {
padding: 28px;
}
.kicker {
display: inline-block;
padding: 8px 12px;
border-radius: 999px;
background: rgba(31, 143, 118, 0.12);
color: var(--accent);
font-weight: 700;
letter-spacing: 0.03em;
}
h1 {
margin: 14px 0 10px;
font-size: clamp(2rem, 5vw, 4rem);
line-height: 0.95;
}
.hero p {
margin: 0;
color: var(--muted);
max-width: 780px;
font-size: 1rem;
}
.grid {
display: grid;
grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
gap: 20px;
}
.panel {
padding: 22px;
}
.panel h2 {
margin: 0 0 14px;
font-size: 1.15rem;
}
.section-title {
margin: 18px 0 10px;
font-size: 0.92rem;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--muted);
}
label {
display: block;
margin-bottom: 12px;
font-size: 0.95rem;
font-weight: 600;
}
input,
select,
textarea,
button {
width: 100%;
border-radius: 14px;
border: 1px solid var(--border);
padding: 12px 14px;
font: inherit;
}
textarea {
min-height: 120px;
resize: vertical;
}
input,
select,
textarea {
margin-top: 6px;
background: var(--panel-strong);
}
.row {
display: grid;
gap: 12px;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.row-4 {
display: grid;
gap: 12px;
grid-template-columns: repeat(4, minmax(0, 1fr));
}
.toggle {
display: flex;
align-items: center;
gap: 10px;
padding: 12px 14px;
border: 1px dashed var(--border);
border-radius: 14px;
background: rgba(255, 255, 255, 0.6);
}
.toggle input {
width: auto;
margin: 0;
}
.actions {
display: flex;
gap: 12px;
margin-top: 18px;
}
.actions button {
cursor: pointer;
border: none;
font-weight: 700;
transition: transform 0.15s ease, opacity 0.15s ease;
}
.primary {
background: linear-gradient(135deg, var(--accent), #166b59);
color: white;
}
.secondary {
background: linear-gradient(135deg, var(--accent-2), #d97706);
color: white;
}
.actions button:hover {
transform: translateY(-1px);
}
.result-header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
margin-bottom: 14px;
}
.pill {
display: inline-block;
padding: 8px 12px;
border-radius: 999px;
background: rgba(245, 158, 11, 0.14);
color: #9a5b00;
font-size: 0.9rem;
font-weight: 700;
}
.result-box {
background: #1f1d1a;
color: #f6efe4;
border-radius: 18px;
padding: 18px;
min-height: 520px;
overflow: auto;
white-space: pre-wrap;
line-height: 1.5;
font-family: Consolas, "Courier New", monospace;
font-size: 0.92rem;
}
.hint {
margin-top: 12px;
color: var(--muted);
font-size: 0.9rem;
}
.api-bar {
display: grid;
gap: 12px;
grid-template-columns: 1.2fr 0.8fr;
margin-bottom: 18px;
}
.status {
margin-bottom: 14px;
font-weight: 700;
}
@media (max-width: 920px) {
.grid {
grid-template-columns: 1fr;
}
.api-bar,
.row,
.row-4 {
grid-template-columns: 1fr;
}
.actions {
flex-direction: column;
}
}
</style>
</head>
<body>
<div class="shell">
<section class="hero">
<div class="hero-card">
<span class="kicker">GPV Demo Lab</span>
<h1>Test your proof validator like a real product.</h1>
<p>
Upload a proof image, switch between OCR-only mode and full validation,
tweak scanning options, and instantly see the results.
</p>
</div>
</section>
<div class="grid">
<section class="panel">
<h2>Interactive Controls</h2>
<div class="api-bar">
<label>
API base URL
<input id="apiBase" value="">
</label>
<label>
Server status
<input id="serverStatus" value="Checking..." readonly>
</label>
</div>
<form id="demo-form">
<label>
Proof image
<input id="proof" name="proof" type="file" accept="image/*" required>
</label>
<div class="row">
<label>
Mode
<select id="mode" name="mode">
<option value="ocr">OCR only</option>
<option value="validate">Validate with model</option>
<option value="full" selected>Full analysis</option>
</select>
</label>
<label>
OCR language
<input id="language" name="language" value="eng">
</label>
</div>
<div class="section-title">Expected transaction</div>
<div class="row">
<label>
Reference
<input id="reference" name="reference" placeholder="123456789012">
</label>
<label>
Amount
<input id="amount" name="amount" type="number" step="0.01" placeholder="250.00">
</label>
</div>
<div class="row">
<label>
Date
<input id="date" name="date" type="date">
</label>
<label>
Amount tolerance
<input id="amountTolerance" name="amountTolerance" type="number" step="0.01" value="0">
</label>
</div>
<div class="row">
<label>
Source bank
<input id="sourceBank" name="sourceBank" placeholder="gcash / cimb / maribank">
</label>
<label>
Destination
<input id="destination" name="destination" placeholder="gcash">
</label>
</div>
<div class="section-title">Scanning config</div>
<div class="row">
<label>
Page segmentation mode
<input id="pageSegMode" name="pageSegMode" type="number" value="6">
</label>
<label>
Bank label
<input id="bank" name="bank" placeholder="gcash">
</label>
</div>
<label class="toggle">
<input id="rectangleEnabled" name="rectangleEnabled" type="checkbox">
<span>Enable custom OCR rectangle crop</span>
</label>
<div class="row-4">
<label>
Top
<input id="rectangleTop" name="rectangleTop" type="number" value="0">
</label>
<label>
Left
<input id="rectangleLeft" name="rectangleLeft" type="number" value="0">
</label>
<label>
Width
<input id="rectangleWidth" name="rectangleWidth" type="number" value="1080">
</label>
<label>
Height
<input id="rectangleHeight" name="rectangleHeight" type="number" value="1920">
</label>
</div>
<div class="actions">
<button class="primary" type="submit">Run GPV Demo</button>
<button class="secondary" type="button" id="fill-sample">Fill sample values</button>
</div>
</form>
<p class="hint">
Tip: use OCR-only mode when you want raw extraction, then switch to full analysis
to see how the default model scores the same proof.
</p>
</section>
<section class="panel">
<div class="result-header">
<h2 style="margin:0;">Live Result</h2>
<span class="pill" id="mode-pill">waiting</span>
</div>
<div class="status" id="status">Upload a proof and press Run GPV Demo.</div>
<pre class="result-box" id="result-box">{
"hello": "GPV demo ready"
}</pre>
</section>
</div>
</div>
<script>
const form = document.getElementById("demo-form");
const resultBox = document.getElementById("result-box");
const status = document.getElementById("status");
const modePill = document.getElementById("mode-pill");
const fillSample = document.getElementById("fill-sample");
const apiBaseInput = document.getElementById("apiBase");
const serverStatusInput = document.getElementById("serverStatus");
function defaultApiBase() {
if (location.protocol === "file:") {
return "http://localhost:3210";
}
return location.origin;
}
apiBaseInput.value = defaultApiBase();
async function checkHealth() {
const apiBase = apiBaseInput.value.replace(/\/$/, "");
try {
const response = await fetch(`${apiBase}/api/demo/health`);
const payload = await response.json();
if (!response.ok || !payload.ok) {
throw new Error(payload.error || "Health check failed");
}
serverStatusInput.value = "Connected";
} catch (error) {
serverStatusInput.value = "Offline";
status.textContent = "Demo API is not reachable. Start it with npm run demo.";
}
}
fillSample.addEventListener("click", () => {
document.getElementById("reference").value = "123456789012";
document.getElementById("amount").value = "250";
document.getElementById("sourceBank").value = "gcash";
document.getElementById("destination").value = "gcash";
document.getElementById("bank").value = "gcash";
document.getElementById("pageSegMode").value = "6";
});
apiBaseInput.addEventListener("change", checkHealth);
form.addEventListener("submit", async (event) => {
event.preventDefault();
const data = new FormData(form);
const mode = data.get("mode");
const apiBase = apiBaseInput.value.replace(/\/$/, "");
status.textContent = "Running analysis...";
modePill.textContent = mode;
resultBox.textContent = "Loading...";
try {
const response = await fetch(`${apiBase}/api/demo/analyze`, {
method: "POST",
body: data
});
const payload = await response.json();
if (!response.ok) {
throw new Error(payload.error || "Request failed");
}
status.textContent = "Done. Review the output below.";
modePill.textContent = payload.mode;
resultBox.textContent = JSON.stringify(payload, null, 2);
} catch (error) {
status.textContent = "Something went wrong.";
modePill.textContent = "error";
resultBox.textContent = JSON.stringify({
error: error.message
}, null, 2);
}
});
checkHealth();
</script>
</body>
</html>