Spaces:
Sleeping
Sleeping
Delete index.html
Browse files- index.html +0 -1682
index.html
DELETED
|
@@ -1,1682 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
-
<title>Eatlytic 2.0 — Know What You Eat</title>
|
| 7 |
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,900;1,700&family=DM+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
| 9 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
|
| 10 |
-
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
| 11 |
-
<style>
|
| 12 |
-
:root {
|
| 13 |
-
--forest:#1E3A2F; --moss:#2D5241; --sage:#4A7C59;
|
| 14 |
-
--mint:#7FB896; --cream:#FAF6EE; --parchment:#F0E9DA;
|
| 15 |
-
--gold:#C9A84C; --coral:#D96B47; --ink:#1A1A1A;
|
| 16 |
-
--mist:#6B7280; --whisper:#E8E0D5; --white:#FFFFFF;
|
| 17 |
-
--good:#2D7A4F; --moderate:#B07D22; --caution:#C94B1E; --bad:#8B1A1A;
|
| 18 |
-
--radius:18px; --radius-sm:12px;
|
| 19 |
-
--shadow:0 4px 20px rgba(30,58,47,0.10);
|
| 20 |
-
--nav-h:64px;
|
| 21 |
-
--streak:#FF6B35;
|
| 22 |
-
}
|
| 23 |
-
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
|
| 24 |
-
html{scroll-behavior:smooth}
|
| 25 |
-
body{font-family:'DM Sans',sans-serif;background:var(--cream);color:var(--ink);
|
| 26 |
-
height:100dvh;display:flex;flex-direction:column;overflow:hidden}
|
| 27 |
-
|
| 28 |
-
/* ── HEADER ── */
|
| 29 |
-
.header{padding:12px 16px;background:var(--forest);display:flex;
|
| 30 |
-
justify-content:space-between;align-items:center;flex-shrink:0;z-index:10}
|
| 31 |
-
.logo{font-family:'Playfair Display',serif;font-size:1.35rem;color:var(--cream)}
|
| 32 |
-
.logo em{color:var(--gold);font-style:italic}
|
| 33 |
-
.header-right{display:flex;gap:8px;align-items:center}
|
| 34 |
-
.hdr-btn{background:rgba(255,255,255,0.12);border:1px solid rgba(255,255,255,0.2);
|
| 35 |
-
color:var(--cream);padding:6px 12px;border-radius:50px;
|
| 36 |
-
font-size:0.76rem;font-weight:600;cursor:pointer;
|
| 37 |
-
font-family:'DM Sans',sans-serif;display:flex;align-items:center;gap:5px}
|
| 38 |
-
|
| 39 |
-
/* ── STREAK BADGE in header ── */
|
| 40 |
-
.streak-badge{display:flex;align-items:center;gap:4px;background:rgba(255,107,53,0.2);
|
| 41 |
-
border:1px solid rgba(255,107,53,0.4);color:#FFAD8E;
|
| 42 |
-
padding:5px 10px;border-radius:50px;font-size:0.76rem;font-weight:700;cursor:pointer}
|
| 43 |
-
.streak-badge.active{background:rgba(255,107,53,0.35);color:#FF8C5A}
|
| 44 |
-
|
| 45 |
-
/* ── TABS ── */
|
| 46 |
-
.tab-pages{flex:1;overflow:hidden;position:relative}
|
| 47 |
-
.tab-page{position:absolute;inset:0;overflow-y:auto;overflow-x:hidden;
|
| 48 |
-
padding:16px 16px 88px;display:none}
|
| 49 |
-
.tab-page.active{display:block}
|
| 50 |
-
|
| 51 |
-
/* ── BOTTOM NAV ── */
|
| 52 |
-
.bottom-nav{height:var(--nav-h);background:var(--white);
|
| 53 |
-
border-top:1px solid var(--whisper);display:flex;flex-shrink:0;z-index:20}
|
| 54 |
-
.nav-item{flex:1;display:flex;flex-direction:column;align-items:center;
|
| 55 |
-
justify-content:center;gap:3px;cursor:pointer;font-size:0.63rem;
|
| 56 |
-
font-weight:700;letter-spacing:0.5px;text-transform:uppercase;color:var(--mist);transition:color 0.2s}
|
| 57 |
-
.nav-item i{font-size:1.05rem}
|
| 58 |
-
.nav-item.active{color:var(--forest)}
|
| 59 |
-
.nav-item.active i{transform:scale(1.15)}
|
| 60 |
-
|
| 61 |
-
/* ── SHARED ── */
|
| 62 |
-
.section-label{font-size:0.67rem;font-weight:700;letter-spacing:2px;
|
| 63 |
-
text-transform:uppercase;color:var(--sage);margin-bottom:10px}
|
| 64 |
-
.chip-row{display:flex;gap:8px;overflow-x:auto;padding-bottom:3px;scrollbar-width:none}
|
| 65 |
-
.chip-row::-webkit-scrollbar{display:none}
|
| 66 |
-
.chip{flex-shrink:0;padding:7px 14px;background:var(--white);border-radius:50px;
|
| 67 |
-
border:1.5px solid var(--whisper);font-size:0.78rem;font-weight:600;
|
| 68 |
-
cursor:pointer;color:var(--mist);transition:all 0.2s;font-family:'DM Sans',sans-serif}
|
| 69 |
-
.chip.active{background:var(--forest);color:var(--cream);border-color:var(--forest)}
|
| 70 |
-
.card{background:var(--white);border-radius:var(--radius);border:1.5px solid var(--whisper);
|
| 71 |
-
padding:16px;box-shadow:var(--shadow)}
|
| 72 |
-
.btn-primary{width:100%;background:linear-gradient(135deg,var(--forest),var(--moss));
|
| 73 |
-
color:var(--cream);padding:15px;border-radius:var(--radius-sm);
|
| 74 |
-
font-weight:700;font-size:0.9rem;border:none;cursor:pointer;
|
| 75 |
-
font-family:'DM Sans',sans-serif;transition:opacity 0.2s;
|
| 76 |
-
box-shadow:0 4px 14px rgba(30,58,47,0.28);margin-top:12px}
|
| 77 |
-
.btn-primary:active{opacity:0.85}
|
| 78 |
-
.btn-ghost{width:100%;background:transparent;color:var(--mist);padding:11px;
|
| 79 |
-
border:none;font-weight:600;cursor:pointer;font-size:0.82rem;
|
| 80 |
-
font-family:'DM Sans',sans-serif;margin-top:4px}
|
| 81 |
-
|
| 82 |
-
/* ── STREAK PANEL ── */
|
| 83 |
-
.streak-panel{background:linear-gradient(135deg,#2D1B00,#4A2C00);
|
| 84 |
-
border-radius:var(--radius);padding:16px;margin-bottom:16px;
|
| 85 |
-
border:1px solid rgba(255,107,53,0.3)}
|
| 86 |
-
.streak-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
|
| 87 |
-
.streak-title{font-family:'Playfair Display',serif;color:#FFAD8E;font-size:1rem}
|
| 88 |
-
.streak-flame{font-size:1.6rem;animation:pulse 2s ease infinite}
|
| 89 |
-
@keyframes pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.12)}}
|
| 90 |
-
.streak-stats{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}
|
| 91 |
-
.s-stat{background:rgba(255,255,255,0.08);border-radius:10px;padding:10px;text-align:center}
|
| 92 |
-
.s-num{font-family:'Playfair Display',serif;font-size:1.5rem;color:#FF8C5A}
|
| 93 |
-
.s-lbl{font-size:0.62rem;color:#FFAD8E;font-weight:600;text-transform:uppercase;letter-spacing:0.5px;margin-top:2px}
|
| 94 |
-
.badge-row{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
|
| 95 |
-
.badge-pill{background:rgba(255,107,53,0.2);border:1px solid rgba(255,107,53,0.3);
|
| 96 |
-
color:#FFAD8E;padding:4px 10px;border-radius:50px;font-size:0.72rem;font-weight:600}
|
| 97 |
-
|
| 98 |
-
/* ── CHALLENGE CARD ── */
|
| 99 |
-
.challenge-card{background:var(--white);border-radius:var(--radius);
|
| 100 |
-
border:1.5px solid var(--whisper);padding:14px;margin-bottom:16px;
|
| 101 |
-
box-shadow:var(--shadow)}
|
| 102 |
-
.challenge-header{display:flex;align-items:center;gap:10px;margin-bottom:8px}
|
| 103 |
-
.challenge-emoji{font-size:1.6rem}
|
| 104 |
-
.challenge-title{font-weight:700;font-size:0.9rem;color:var(--forest)}
|
| 105 |
-
.challenge-week{font-size:0.7rem;color:var(--mist);margin-top:1px}
|
| 106 |
-
.challenge-desc{font-size:0.8rem;color:var(--mist);line-height:1.5;margin-bottom:10px}
|
| 107 |
-
.challenge-progress-wrap{background:var(--parchment);border-radius:6px;height:8px;overflow:hidden;margin-bottom:6px}
|
| 108 |
-
.challenge-progress-bar{height:100%;border-radius:6px;background:linear-gradient(90deg,var(--sage),var(--gold));transition:width 0.6s ease}
|
| 109 |
-
.challenge-meta{display:flex;justify-content:space-between;font-size:0.7rem;color:var(--mist)}
|
| 110 |
-
.challenge-reward{font-size:0.72rem;color:var(--gold);font-weight:600;margin-top:4px}
|
| 111 |
-
|
| 112 |
-
/* ── BARCODE SCANNER ── */
|
| 113 |
-
.barcode-scan-btn{width:100%;display:flex;align-items:center;justify-content:center;gap:10px;
|
| 114 |
-
padding:13px;background:var(--white);border:1.5px dashed var(--sage);
|
| 115 |
-
border-radius:var(--radius-sm);cursor:pointer;margin-bottom:14px;
|
| 116 |
-
font-family:'DM Sans',sans-serif;font-size:0.86rem;font-weight:600;
|
| 117 |
-
color:var(--forest);transition:all 0.2s}
|
| 118 |
-
.barcode-scan-btn:active{background:var(--parchment)}
|
| 119 |
-
.barcode-scan-btn .bs-icon{width:36px;height:36px;background:linear-gradient(135deg,var(--forest),var(--sage));
|
| 120 |
-
border-radius:10px;display:flex;align-items:center;justify-content:center;
|
| 121 |
-
color:white;font-size:1rem;flex-shrink:0}
|
| 122 |
-
#barcode-overlay{position:fixed;inset:0;z-index:550;background:#000;
|
| 123 |
-
display:none;flex-direction:column;align-items:center;justify-content:center}
|
| 124 |
-
#barcode-overlay.active{display:flex}
|
| 125 |
-
#barcode-video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
|
| 126 |
-
.bc-ui{position:relative;z-index:1;display:flex;flex-direction:column;
|
| 127 |
-
align-items:center;justify-content:center;height:100%;width:100%}
|
| 128 |
-
.bc-frame-wrap{position:relative;margin-bottom:24px}
|
| 129 |
-
.bc-frame{width:72vw;max-width:300px;height:120px;border-radius:14px;
|
| 130 |
-
border:3px solid rgba(255,255,255,0.9);
|
| 131 |
-
box-shadow:0 0 0 3000px rgba(0,0,0,0.55)}
|
| 132 |
-
.bc-laser{position:absolute;top:50%;left:8px;right:8px;height:2px;
|
| 133 |
-
background:linear-gradient(90deg,transparent,#FF6B35,transparent);
|
| 134 |
-
animation:laser 1.6s ease-in-out infinite}
|
| 135 |
-
@keyframes laser{0%,100%{top:20%}50%{top:80%}}
|
| 136 |
-
.bc-hint{color:rgba(255,255,255,0.9);font-size:0.8rem;font-weight:600;
|
| 137 |
-
text-align:center;margin-top:12px;max-width:260px;line-height:1.5}
|
| 138 |
-
.bc-detected{color:#4ADE80;font-size:0.88rem;font-weight:700;margin-top:8px;display:none}
|
| 139 |
-
.bc-close{position:absolute;top:52px;right:20px;width:40px;height:40px;
|
| 140 |
-
background:rgba(255,255,255,0.15);border-radius:50%;border:none;
|
| 141 |
-
color:white;font-size:1rem;cursor:pointer;display:flex;align-items:center;justify-content:center}
|
| 142 |
-
.bc-status{position:absolute;bottom:60px;left:50%;transform:translateX(-50%);
|
| 143 |
-
background:rgba(0,0,0,0.7);color:white;padding:8px 20px;border-radius:50px;
|
| 144 |
-
font-size:0.78rem;font-weight:600;white-space:nowrap}
|
| 145 |
-
#barcode-canvas{display:none}
|
| 146 |
-
|
| 147 |
-
/* ── SCAN CARDS ── */
|
| 148 |
-
.action-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:16px}
|
| 149 |
-
.scan-card{background:var(--white);padding:20px 12px;border-radius:var(--radius);
|
| 150 |
-
border:1.5px solid var(--whisper);box-shadow:var(--shadow);
|
| 151 |
-
cursor:pointer;display:flex;flex-direction:column;align-items:center;gap:9px;transition:all 0.2s}
|
| 152 |
-
.scan-card:active{transform:scale(0.96);border-color:var(--sage)}
|
| 153 |
-
.scan-icon{width:48px;height:48px;border-radius:13px;
|
| 154 |
-
background:linear-gradient(135deg,var(--forest),var(--sage));
|
| 155 |
-
display:flex;align-items:center;justify-content:center;color:white;font-size:1.2rem}
|
| 156 |
-
.scan-card h3{font-size:0.86rem;font-weight:700;color:var(--forest)}
|
| 157 |
-
.scan-card p{font-size:0.68rem;color:var(--mist)}
|
| 158 |
-
|
| 159 |
-
/* ── PREVIEW ── */
|
| 160 |
-
#preview-area{display:none;margin-bottom:4px}
|
| 161 |
-
#preview-img{width:100%;height:220px;object-fit:cover;border-radius:var(--radius);
|
| 162 |
-
border:3px solid var(--white);box-shadow:var(--shadow);margin-bottom:8px;transition:opacity 0.3s}
|
| 163 |
-
.upload-progress{width:100%;height:4px;background:var(--whisper);border-radius:2px;overflow:hidden;margin-bottom:8px;display:none}
|
| 164 |
-
.upload-progress-bar{height:100%;width:0%;background:linear-gradient(90deg,var(--sage),var(--gold));border-radius:2px;transition:width 0.4s ease}
|
| 165 |
-
.img-state-row{display:flex;align-items:center;gap:8px;padding:8px 12px;
|
| 166 |
-
border-radius:var(--radius-sm);margin-bottom:10px;font-size:0.8rem;font-weight:600}
|
| 167 |
-
.img-state-row.checking{background:#F0F4FF;color:#3730A3;border:1.5px solid #C7D2FE}
|
| 168 |
-
.img-state-row.good{background:#ECFDF5;color:var(--good);border:1.5px solid #A7F3D0}
|
| 169 |
-
.img-state-row.fair{background:#FFFBEB;color:var(--moderate);border:1.5px solid #FDE68A}
|
| 170 |
-
.img-state-row.poor{background:#FEF2F2;color:var(--caution);border:1.5px solid #FECACA}
|
| 171 |
-
.state-tip{font-size:0.7rem;color:var(--mist);font-weight:400;margin-top:1px}
|
| 172 |
-
|
| 173 |
-
/* ── UPLOAD HINT ── */
|
| 174 |
-
.upload-hint{background:var(--white);border:1.5px solid var(--whisper);
|
| 175 |
-
border-radius:var(--radius-sm);padding:12px 14px;
|
| 176 |
-
display:flex;align-items:flex-start;gap:10px;margin-bottom:14px}
|
| 177 |
-
.upload-hint-icon{font-size:1.25rem;flex-shrink:0;margin-top:1px}
|
| 178 |
-
.upload-hint-text{font-size:0.77rem;color:var(--mist);line-height:1.5}
|
| 179 |
-
.upload-hint-text strong{color:var(--forest)}
|
| 180 |
-
|
| 181 |
-
/* ── BARCODE RESULT BANNER ── */
|
| 182 |
-
.barcode-result{background:var(--white);border:1.5px solid #A7F3D0;
|
| 183 |
-
border-radius:var(--radius-sm);padding:13px 15px;
|
| 184 |
-
margin-bottom:12px;display:none}
|
| 185 |
-
.barcode-result-header{display:flex;align-items:center;gap:8px;margin-bottom:6px}
|
| 186 |
-
.barcode-nutriscore{display:inline-block;padding:2px 9px;border-radius:6px;
|
| 187 |
-
font-weight:800;font-size:0.85rem;letter-spacing:1px}
|
| 188 |
-
.ns-a{background:#038141;color:white} .ns-b{background:#85BB2F;color:white}
|
| 189 |
-
.ns-c{background:#FFCC00;color:#333} .ns-d{background:#FF6600;color:white}
|
| 190 |
-
.ns-e{background:#FF0000;color:white} .ns-n{background:#999;color:white}
|
| 191 |
-
|
| 192 |
-
/* ── ERROR CARDS ── */
|
| 193 |
-
.error-card{border-radius:var(--radius-sm);padding:0;display:none;
|
| 194 |
-
margin-bottom:12px;overflow:hidden;border:1.5px solid #FECACA}
|
| 195 |
-
.error-card-inner{padding:16px;text-align:center}
|
| 196 |
-
.error-card.no-label{border-color:#FDE68A;background:#FFFBEB}
|
| 197 |
-
.error-card.no-label .error-card-inner{background:#FFFBEB}
|
| 198 |
-
.flip-illustration{display:flex;align-items:center;justify-content:center;
|
| 199 |
-
gap:10px;margin:10px 0;padding:12px;
|
| 200 |
-
background:rgba(255,255,255,0.7);border-radius:10px}
|
| 201 |
-
.flip-box{width:50px;height:65px;border-radius:8px;display:flex;align-items:center;
|
| 202 |
-
justify-content:center;flex-direction:column;gap:3px;
|
| 203 |
-
font-size:0.58rem;font-weight:700;letter-spacing:0.3px}
|
| 204 |
-
.flip-box.front{background:#FEE2E2;color:#991B1B;border:2px solid #FECACA}
|
| 205 |
-
.flip-box.back{background:#DCFCE7;color:#166534;border:2px dashed #86EFAC}
|
| 206 |
-
.flip-box .fb-icon{font-size:1.3rem}
|
| 207 |
-
.flip-arrow{font-size:1.3rem;color:var(--mist)}
|
| 208 |
-
.error-card .err-icon{font-size:1.9rem;margin-bottom:6px;display:block}
|
| 209 |
-
.error-card .err-title{font-weight:700;color:#991B1B;margin-bottom:4px;font-size:0.9rem}
|
| 210 |
-
.error-card.no-label .err-title{color:#92400E}
|
| 211 |
-
.error-card .err-msg{font-size:0.8rem;color:#7F1D1D;line-height:1.5}
|
| 212 |
-
.error-card.no-label .err-msg{color:#78350F}
|
| 213 |
-
.err-retry-btn{width:100%;margin-top:12px;padding:11px;background:var(--forest);
|
| 214 |
-
color:var(--cream);border:none;border-radius:var(--radius-sm);font-weight:700;
|
| 215 |
-
font-size:0.82rem;cursor:pointer;font-family:"DM Sans",sans-serif}
|
| 216 |
-
.err-secondary-btn{width:100%;margin-top:8px;padding:9px;background:transparent;color:var(--mist);
|
| 217 |
-
border:1.5px solid var(--whisper);border-radius:var(--radius-sm);
|
| 218 |
-
font-weight:600;font-size:0.78rem;cursor:pointer;font-family:"DM Sans",sans-serif}
|
| 219 |
-
|
| 220 |
-
/* ── BLUR NOTICE ── */
|
| 221 |
-
.blur-notice{display:none;border-radius:var(--radius-sm);border:1.5px solid #FCD34D;
|
| 222 |
-
background:#FFFBEB;padding:12px 14px;margin-bottom:12px}
|
| 223 |
-
.blur-notice.visible{display:block}
|
| 224 |
-
.blur-notice-header{display:flex;align-items:center;gap:8px;font-weight:700;font-size:0.84rem;color:#92400E;margin-bottom:4px}
|
| 225 |
-
.blur-notice-body{font-size:0.77rem;color:#78350F;line-height:1.5}
|
| 226 |
-
.blur-notice-methods{margin-top:6px;font-size:0.68rem;color:#A16207;
|
| 227 |
-
background:rgba(251,191,36,0.15);padding:5px 9px;
|
| 228 |
-
border-radius:6px;font-family:monospace;word-break:break-all}
|
| 229 |
-
.severity-pill{display:inline-block;padding:2px 8px;border-radius:50px;
|
| 230 |
-
font-size:0.66rem;font-weight:700;letter-spacing:0.5px;text-transform:uppercase;margin-left:6px}
|
| 231 |
-
.severity-pill.severe{background:#FEE2E2;color:#991B1B}
|
| 232 |
-
.severity-pill.moderate{background:#FEF3C7;color:#92400E}
|
| 233 |
-
.severity-pill.mild{background:#ECFDF5;color:#065F46}
|
| 234 |
-
|
| 235 |
-
/* ── HISTORY ── */
|
| 236 |
-
.history-empty{text-align:center;padding:40px 20px;color:var(--mist)}
|
| 237 |
-
.history-empty i{font-size:2.4rem;opacity:0.3;display:block;margin-bottom:12px}
|
| 238 |
-
.history-card{background:var(--white);border-radius:var(--radius-sm);
|
| 239 |
-
border:1.5px solid var(--whisper);padding:14px 16px;
|
| 240 |
-
margin-bottom:10px;display:flex;align-items:center;gap:12px;
|
| 241 |
-
cursor:pointer;transition:border-color 0.2s}
|
| 242 |
-
.history-card:hover{border-color:var(--sage)}
|
| 243 |
-
.h-score-ring{width:44px;height:44px;border-radius:50%;flex-shrink:0;
|
| 244 |
-
display:flex;align-items:center;justify-content:center;font-weight:800;font-size:0.95rem}
|
| 245 |
-
.h-name{font-weight:700;font-size:0.86rem;color:var(--forest)}
|
| 246 |
-
.h-meta{font-size:0.7rem;color:var(--mist);margin-top:2px}
|
| 247 |
-
.h-del{margin-left:auto;color:#CBD5E1;padding:6px;cursor:pointer;font-size:0.84rem}
|
| 248 |
-
.h-del:hover{color:var(--coral)}
|
| 249 |
-
.history-clear-btn{width:100%;padding:11px;border:1.5px solid var(--whisper);
|
| 250 |
-
border-radius:var(--radius-sm);background:transparent;color:var(--mist);
|
| 251 |
-
font-weight:600;font-size:0.8rem;cursor:pointer;font-family:'DM Sans',sans-serif;margin-top:8px}
|
| 252 |
-
.history-clear-btn:hover{border-color:var(--coral);color:var(--coral)}
|
| 253 |
-
|
| 254 |
-
/* ── PROFILE ── */
|
| 255 |
-
.profile-avatar{width:78px;height:78px;border-radius:50%;
|
| 256 |
-
background:linear-gradient(135deg,var(--forest),var(--sage));
|
| 257 |
-
display:flex;align-items:center;justify-content:center;
|
| 258 |
-
font-size:1.9rem;margin:0 auto 10px;color:white}
|
| 259 |
-
.profile-name{font-family:'Playfair Display',serif;font-size:1.25rem;
|
| 260 |
-
text-align:center;color:var(--forest);margin-bottom:4px}
|
| 261 |
-
.profile-sub{text-align:center;font-size:0.8rem;color:var(--mist);margin-bottom:20px}
|
| 262 |
-
.profile-section{margin-bottom:16px}
|
| 263 |
-
.profile-row{display:flex;align-items:center;justify-content:space-between;
|
| 264 |
-
padding:14px 16px;background:var(--white);border-radius:var(--radius-sm);
|
| 265 |
-
border:1.5px solid var(--whisper);margin-bottom:8px}
|
| 266 |
-
.profile-row-left{display:flex;align-items:center;gap:12px}
|
| 267 |
-
.profile-row-icon{width:34px;height:34px;border-radius:10px;background:var(--parchment);
|
| 268 |
-
display:flex;align-items:center;justify-content:center;font-size:0.92rem}
|
| 269 |
-
.profile-row-label{font-weight:600;font-size:0.85rem;color:var(--forest)}
|
| 270 |
-
.profile-row-value{font-size:0.76rem;color:var(--mist)}
|
| 271 |
-
.toggle-switch{width:42px;height:24px;background:var(--whisper);
|
| 272 |
-
border-radius:12px;position:relative;cursor:pointer;transition:background 0.2s}
|
| 273 |
-
.toggle-switch.on{background:var(--sage)}
|
| 274 |
-
.toggle-knob{position:absolute;top:3px;left:3px;width:18px;height:18px;
|
| 275 |
-
border-radius:50%;background:white;transition:transform 0.2s;box-shadow:0 1px 4px rgba(0,0,0,0.2)}
|
| 276 |
-
.toggle-switch.on .toggle-knob{transform:translateX(18px)}
|
| 277 |
-
.profile-select{border:none;background:transparent;font-family:'DM Sans',sans-serif;
|
| 278 |
-
font-size:0.8rem;color:var(--mist);cursor:pointer;text-align:right}
|
| 279 |
-
.stat-row{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;margin-bottom:16px}
|
| 280 |
-
.stat-box{background:var(--white);border-radius:var(--radius-sm);
|
| 281 |
-
border:1.5px solid var(--whisper);padding:13px;text-align:center}
|
| 282 |
-
.stat-num{font-family:'Playfair Display',serif;font-size:1.5rem;color:var(--forest)}
|
| 283 |
-
.stat-lbl{font-size:0.66rem;color:var(--mist);font-weight:600;letter-spacing:0.5px;margin-top:2px}
|
| 284 |
-
|
| 285 |
-
/* ── LOADER ── */
|
| 286 |
-
#loader{position:fixed;inset:0;background:rgba(250,246,238,0.95);
|
| 287 |
-
backdrop-filter:blur(8px);z-index:600;display:none;
|
| 288 |
-
flex-direction:column;align-items:center;justify-content:center;gap:16px}
|
| 289 |
-
.loader-ring{width:56px;height:56px;border:4px solid var(--whisper);
|
| 290 |
-
border-top-color:var(--forest);border-radius:50%;animation:spin 0.9s linear infinite}
|
| 291 |
-
@keyframes spin{to{transform:rotate(360deg)}}
|
| 292 |
-
.loader-text{font-family:'Playfair Display',serif;font-size:1rem;color:var(--forest)}
|
| 293 |
-
.loader-step{font-size:0.76rem;color:var(--mist);text-align:center;max-width:230px}
|
| 294 |
-
.loader-hint{font-size:0.68rem;color:#aab;text-align:center}
|
| 295 |
-
.loader-cancel-btn{margin-top:16px;padding:9px 24px;background:transparent;
|
| 296 |
-
border:1.5px solid var(--whisper);border-radius:50px;
|
| 297 |
-
color:var(--mist);font-size:0.8rem;font-weight:600;cursor:pointer;font-family:'DM Sans',sans-serif}
|
| 298 |
-
|
| 299 |
-
/* ── CAMERA ── */
|
| 300 |
-
#cam-overlay{position:fixed;inset:0;z-index:500;background:#000;display:none;flex-direction:column}
|
| 301 |
-
#cam-overlay.active{display:flex}
|
| 302 |
-
#video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
|
| 303 |
-
.cam-ui{position:relative;z-index:1;display:flex;flex-direction:column;height:100%;pointer-events:none}
|
| 304 |
-
.cam-guide{flex:1;display:flex;align-items:center;justify-content:center}
|
| 305 |
-
.cam-frame{width:75vw;max-width:320px;aspect-ratio:1.6/1;
|
| 306 |
-
border:3px solid rgba(255,255,255,0.8);border-radius:14px;
|
| 307 |
-
box-shadow:0 0 0 3000px rgba(0,0,0,0.35)}
|
| 308 |
-
.cam-hint{color:rgba(255,255,255,0.9);text-align:center;margin-top:12px;
|
| 309 |
-
font-size:0.78rem;font-weight:600}
|
| 310 |
-
.cam-controls{padding:24px 32px 40px;display:flex;align-items:center;
|
| 311 |
-
justify-content:space-between;pointer-events:all}
|
| 312 |
-
.cam-cancel{color:white;font-size:0.9rem;font-weight:600;cursor:pointer;padding:8px}
|
| 313 |
-
.shutter{width:66px;height:66px;border-radius:50%;background:white;cursor:pointer;
|
| 314 |
-
border:4px solid rgba(255,255,255,0.4);box-shadow:0 2px 12px rgba(0,0,0,0.3);transition:transform 0.1s}
|
| 315 |
-
.shutter:active{transform:scale(0.9)}
|
| 316 |
-
|
| 317 |
-
/* ── REPORT PANEL ── */
|
| 318 |
-
#report{position:fixed;inset:0;z-index:400;background:var(--cream);
|
| 319 |
-
transform:translateY(100%);transition:transform 0.4s cubic-bezier(0.32,0.72,0,1);
|
| 320 |
-
display:flex;flex-direction:column}
|
| 321 |
-
#report.open{transform:translateY(0)}
|
| 322 |
-
.report-scroll{flex:1;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain}
|
| 323 |
-
.report-hero{background:linear-gradient(160deg,var(--forest) 0%,var(--moss) 100%);padding:16px 16px 22px}
|
| 324 |
-
.report-topbar{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}
|
| 325 |
-
.back-btn{width:36px;height:36px;background:rgba(255,255,255,0.15);border-radius:50%;
|
| 326 |
-
display:flex;align-items:center;justify-content:center;color:white;cursor:pointer;font-size:0.9rem}
|
| 327 |
-
.verdict-badge{padding:5px 14px;background:rgba(255,255,255,0.18);
|
| 328 |
-
border-radius:50px;color:white;font-weight:700;font-size:0.8rem;border:1px solid rgba(255,255,255,0.25)}
|
| 329 |
-
.hero-row{display:flex;gap:16px;align-items:flex-start}
|
| 330 |
-
.score-col{flex-shrink:0}
|
| 331 |
-
.score-ring-wrap{position:relative;width:110px;height:110px}
|
| 332 |
-
.score-ring-center{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center}
|
| 333 |
-
.score-num{font-family:'Playfair Display',serif;font-size:2.1rem;color:white;font-weight:900;line-height:1}
|
| 334 |
-
.score-sub{font-size:0.68rem;color:rgba(255,255,255,0.7);margin-top:1px}
|
| 335 |
-
.pie-legend{margin-top:8px}
|
| 336 |
-
.pie-legend-item{display:flex;align-items:center;gap:5px;font-size:0.65rem;color:rgba(255,255,255,0.75);margin-bottom:3px}
|
| 337 |
-
.pie-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0}
|
| 338 |
-
.info-col{flex:1;min-width:0}
|
| 339 |
-
.product-cat-tag{display:inline-flex;align-items:center;gap:5px;
|
| 340 |
-
background:rgba(255,255,255,0.15);border-radius:50px;
|
| 341 |
-
padding:3px 10px;font-size:0.68rem;color:rgba(255,255,255,0.8);
|
| 342 |
-
font-weight:600;margin-bottom:7px}
|
| 343 |
-
.product-name{font-family:'Playfair Display',serif;font-size:1.1rem;color:white;
|
| 344 |
-
font-weight:700;line-height:1.2;margin-bottom:7px;word-break:break-word}
|
| 345 |
-
.summary-text{font-size:0.8rem;color:rgba(255,255,255,0.82);line-height:1.55}
|
| 346 |
-
.report-body{padding:14px 14px 0}
|
| 347 |
-
.r-section{background:var(--white);border-radius:var(--radius);border:1.5px solid var(--whisper);
|
| 348 |
-
margin-bottom:12px;padding:14px;box-shadow:var(--shadow)}
|
| 349 |
-
.r-title{font-size:0.68rem;font-weight:700;letter-spacing:1.5px;text-transform:uppercase;
|
| 350 |
-
color:var(--sage);margin-bottom:10px}
|
| 351 |
-
.disclaimer-box{background:#F0F4FF;border:1.5px solid #C7D2FE;border-radius:var(--radius-sm);
|
| 352 |
-
padding:11px 13px;font-size:0.74rem;color:#3730A3;line-height:1.5;
|
| 353 |
-
margin-bottom:12px}
|
| 354 |
-
.disclaimer-box strong{display:block;margin-bottom:3px}
|
| 355 |
-
|
| 356 |
-
/* ── ELI5 ── */
|
| 357 |
-
.eli5-box{background:var(--parchment);border-radius:var(--radius-sm);
|
| 358 |
-
padding:13px;font-size:0.84rem;line-height:1.6;color:var(--ink)}
|
| 359 |
-
|
| 360 |
-
/* ── NUTRIENTS ── */
|
| 361 |
-
.nutrient-item{margin-bottom:10px}
|
| 362 |
-
.nutrient-row{display:flex;align-items:center;gap:10px}
|
| 363 |
-
.n-name{font-size:0.78rem;font-weight:600;color:var(--forest);width:74px;flex-shrink:0}
|
| 364 |
-
.n-bar-wrap{flex:1;height:7px;background:var(--parchment);border-radius:10px;overflow:hidden}
|
| 365 |
-
.n-bar{height:100%;border-radius:10px;width:0%;transition:width 0.9s ease}
|
| 366 |
-
.n-val{font-size:0.71rem;color:var(--mist);font-weight:600;width:44px;text-align:right;flex-shrink:0}
|
| 367 |
-
.n-impact{font-size:0.68rem;color:var(--mist);line-height:1.4;margin-top:2px;padding-left:84px}
|
| 368 |
-
.bar-good{background:linear-gradient(90deg,#4CAF7D,#2D9B5A)}
|
| 369 |
-
.bar-moderate{background:linear-gradient(90deg,#F5A623,#E8902A)}
|
| 370 |
-
.bar-caution{background:linear-gradient(90deg,#FF7043,#E53935)}
|
| 371 |
-
.bar-bad{background:linear-gradient(90deg,#C62828,#8B0000)}
|
| 372 |
-
|
| 373 |
-
/* ── PROS / CONS ── */
|
| 374 |
-
.pc-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
|
| 375 |
-
.pc-label{font-size:0.66rem;font-weight:700;letter-spacing:1.5px;text-transform:uppercase;margin-bottom:8px}
|
| 376 |
-
.pc-label.p{color:var(--good)} .pc-label.c{color:var(--caution)}
|
| 377 |
-
.pc-item{font-size:0.76rem;line-height:1.5;padding:5px 0;border-bottom:1px solid var(--whisper);display:flex;gap:6px}
|
| 378 |
-
.pc-item:last-child{border:none}
|
| 379 |
-
.pc-dot{width:5px;height:5px;border-radius:50%;flex-shrink:0;margin-top:8px}
|
| 380 |
-
.pc-dot.p{background:var(--good)} .pc-dot.c{background:var(--caution)}
|
| 381 |
-
|
| 382 |
-
/* ── AGE WARNINGS ── */
|
| 383 |
-
.age-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
|
| 384 |
-
.age-card{padding:11px;border-radius:var(--radius-sm);border:1.5px solid}
|
| 385 |
-
.age-card.good{background:#ECFDF5;border-color:#A7F3D0}
|
| 386 |
-
.age-card.caution{background:#FFFBEB;border-color:#FCD34D}
|
| 387 |
-
.age-card.warning{background:#FEF2F2;border-color:#FECACA}
|
| 388 |
-
.age-emoji{font-size:1.25rem}
|
| 389 |
-
.age-grp{font-size:0.68rem;font-weight:700;letter-spacing:0.5px;margin-top:2px}
|
| 390 |
-
.age-card.good .age-grp{color:#065F46}
|
| 391 |
-
.age-card.caution .age-grp{color:#92400E}
|
| 392 |
-
.age-card.warning .age-grp{color:#991B1B}
|
| 393 |
-
.age-msg{font-size:0.71rem;line-height:1.4;margin-top:4px;color:var(--ink)}
|
| 394 |
-
|
| 395 |
-
/* ── PARAGRAPHS ── */
|
| 396 |
-
.para-text{font-size:0.84rem;line-height:1.7;color:var(--ink)}
|
| 397 |
-
|
| 398 |
-
/* ── MOLECULAR ── */
|
| 399 |
-
.mol-box{background:#F8F4FF;border:1.5px solid #DDD6FE;border-radius:var(--radius-sm);
|
| 400 |
-
padding:13px;font-size:0.82rem;line-height:1.6;color:#3B1E7A}
|
| 401 |
-
|
| 402 |
-
/* ── ALTERNATIVE ── */
|
| 403 |
-
.alt-box{background:linear-gradient(135deg,var(--forest),var(--moss));
|
| 404 |
-
border-radius:var(--radius-sm);padding:15px;display:flex;align-items:flex-start;gap:10px}
|
| 405 |
-
.alt-icon{font-size:1.35rem;flex-shrink:0}
|
| 406 |
-
.alt-lbl{font-size:0.66rem;font-weight:700;letter-spacing:1px;text-transform:uppercase;color:var(--mint);margin-bottom:3px}
|
| 407 |
-
.alt-text{font-size:0.81rem;color:var(--cream);line-height:1.5}
|
| 408 |
-
|
| 409 |
-
/* ── CONFIDENCE BADGE ── */
|
| 410 |
-
.confidence-badge{display:inline-flex;align-items:center;gap:5px;
|
| 411 |
-
padding:3px 10px;border-radius:50px;font-size:0.7rem;font-weight:700;margin-top:8px}
|
| 412 |
-
.confidence-badge.high{background:#ECFDF5;color:#065F46;border:1px solid #A7F3D0}
|
| 413 |
-
.confidence-badge.medium{background:#FFFBEB;color:#92400E;border:1px solid #FCD34D}
|
| 414 |
-
.confidence-badge.low{background:#FEF2F2;color:#991B1B;border:1px solid #FECACA}
|
| 415 |
-
|
| 416 |
-
/* ── STREAK IN REPORT ── */
|
| 417 |
-
.report-streak-row{display:flex;align-items:center;gap:8px;
|
| 418 |
-
background:#2D1B00;border-radius:var(--radius-sm);padding:10px 14px;margin-bottom:12px}
|
| 419 |
-
.report-streak-fire{font-size:1.3rem}
|
| 420 |
-
.report-streak-text{font-size:0.8rem;color:#FFAD8E;font-weight:600}
|
| 421 |
-
|
| 422 |
-
/* ── SHARE BAR ── */
|
| 423 |
-
.report-share-bar{position:fixed;bottom:0;left:0;right:0;padding:12px 14px 24px;
|
| 424 |
-
background:var(--cream);border-top:1px solid var(--whisper);
|
| 425 |
-
display:none;gap:10px;z-index:420;align-items:center}
|
| 426 |
-
.report-share-bar.visible{display:flex}
|
| 427 |
-
.share-btn{flex:1;padding:13px;border-radius:var(--radius-sm);font-weight:700;
|
| 428 |
-
font-size:0.82rem;border:none;cursor:pointer;font-family:'DM Sans',sans-serif;transition:opacity 0.2s}
|
| 429 |
-
.share-btn.p{background:var(--forest);color:var(--cream)}
|
| 430 |
-
.share-btn.s{background:var(--white);color:var(--forest);border:1.5px solid var(--whisper)}
|
| 431 |
-
|
| 432 |
-
/* ── CONFETTI ── */
|
| 433 |
-
.confetti-piece{position:fixed;width:10px;height:10px;border-radius:2px;
|
| 434 |
-
pointer-events:none;z-index:9999;animation:confettiFall 2.5s ease-out forwards}
|
| 435 |
-
@keyframes confettiFall{
|
| 436 |
-
0%{transform:translateY(-20px) rotate(0deg);opacity:1}
|
| 437 |
-
100%{transform:translateY(100vh) rotate(720deg);opacity:0}
|
| 438 |
-
}
|
| 439 |
-
|
| 440 |
-
/* ── LANG MODAL ── */
|
| 441 |
-
#lang-modal{position:fixed;inset:0;z-index:700;display:none;align-items:flex-end;justify-content:center}
|
| 442 |
-
#lang-modal.open{display:flex}
|
| 443 |
-
.lang-backdrop{position:absolute;inset:0;background:rgba(0,0,0,0.4);backdrop-filter:blur(4px)}
|
| 444 |
-
.lang-sheet{position:relative;z-index:1;background:var(--cream);
|
| 445 |
-
border-radius:22px 22px 0 0;padding:18px 16px 36px;width:100%;max-width:460px}
|
| 446 |
-
.lang-handle{width:36px;height:4px;background:var(--whisper);border-radius:2px;margin:0 auto 16px}
|
| 447 |
-
.lang-title{font-family:'Playfair Display',serif;font-size:1.15rem;color:var(--forest);margin-bottom:14px}
|
| 448 |
-
.lang-option{display:flex;align-items:center;gap:12px;padding:12px 14px;
|
| 449 |
-
border-radius:var(--radius-sm);cursor:pointer;transition:background 0.15s;font-weight:500;font-size:0.86rem}
|
| 450 |
-
.lang-option:hover{background:var(--parchment)}
|
| 451 |
-
.lang-option.active{background:var(--forest);color:white}
|
| 452 |
-
.lang-flag{font-size:1.25rem}
|
| 453 |
-
|
| 454 |
-
/* ── TOAST ── */
|
| 455 |
-
.toast{position:fixed;bottom:90px;left:50%;transform:translateX(-50%) translateY(16px);
|
| 456 |
-
background:var(--forest);color:white;padding:8px 20px;border-radius:50px;
|
| 457 |
-
font-size:0.78rem;font-weight:600;opacity:0;transition:all 0.3s;z-index:800;white-space:nowrap}
|
| 458 |
-
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
|
| 459 |
-
|
| 460 |
-
/* ── DEBLUR ELEMENTS ── */
|
| 461 |
-
.deblur-report-badge{display:inline-flex;align-items:center;gap:5px;padding:4px 10px;
|
| 462 |
-
border-radius:50px;background:#FEF3C7;border:1px solid #FCD34D;
|
| 463 |
-
font-size:0.7rem;font-weight:700;color:#92400E;margin-bottom:10px}
|
| 464 |
-
.deblur-img-wrap{border-radius:var(--radius-sm);overflow:hidden;border:2px solid #FCD34D;margin-bottom:10px}
|
| 465 |
-
.deblur-img-wrap img{width:100%;display:block}
|
| 466 |
-
</style>
|
| 467 |
-
</head>
|
| 468 |
-
<body>
|
| 469 |
-
|
| 470 |
-
<!-- HEADER -->
|
| 471 |
-
<div class="header">
|
| 472 |
-
<div class="logo">Eat<em>lytic</em></div>
|
| 473 |
-
<div class="header-right">
|
| 474 |
-
<div class="streak-badge" id="streak-badge" onclick="switchTab('profile')">🔥 <span id="streak-count">0</span></div>
|
| 475 |
-
<button class="hdr-btn" onclick="openLang()"><i class="fas fa-globe"></i> <span id="lang-display">EN</span></button>
|
| 476 |
-
</div>
|
| 477 |
-
</div>
|
| 478 |
-
|
| 479 |
-
<!-- TAB PAGES -->
|
| 480 |
-
<div class="tab-pages">
|
| 481 |
-
|
| 482 |
-
<!-- ══ HOME TAB ══ -->
|
| 483 |
-
<div class="tab-page active" id="page-home">
|
| 484 |
-
|
| 485 |
-
<!-- Streak Panel (visible once user has scanned) -->
|
| 486 |
-
<div class="streak-panel" id="streak-panel" style="display:none">
|
| 487 |
-
<div class="streak-top">
|
| 488 |
-
<div class="streak-title">Your Streak 🔥</div>
|
| 489 |
-
<div class="streak-flame" id="streak-panel-flame">🔥</div>
|
| 490 |
-
</div>
|
| 491 |
-
<div class="streak-stats">
|
| 492 |
-
<div class="s-stat"><div class="s-num" id="sp-current">0</div><div class="s-lbl">Day Streak</div></div>
|
| 493 |
-
<div class="s-stat"><div class="s-num" id="sp-best">0</div><div class="s-lbl">Best</div></div>
|
| 494 |
-
<div class="s-stat"><div class="s-num" id="sp-total">0</div><div class="s-lbl">Total Scans</div></div>
|
| 495 |
-
</div>
|
| 496 |
-
<div class="badge-row" id="sp-badges"></div>
|
| 497 |
-
</div>
|
| 498 |
-
|
| 499 |
-
<!-- Weekly Challenge -->
|
| 500 |
-
<div class="challenge-card" id="challenge-card" style="display:none">
|
| 501 |
-
<div class="challenge-header">
|
| 502 |
-
<div class="challenge-emoji" id="ch-emoji">🥗</div>
|
| 503 |
-
<div>
|
| 504 |
-
<div class="challenge-title" id="ch-title">Weekly Challenge</div>
|
| 505 |
-
<div class="challenge-week" id="ch-week">Week —</div>
|
| 506 |
-
</div>
|
| 507 |
-
</div>
|
| 508 |
-
<div class="challenge-desc" id="ch-desc">Loading challenge...</div>
|
| 509 |
-
<div class="challenge-progress-wrap">
|
| 510 |
-
<div class="challenge-progress-bar" id="ch-progress-bar" style="width:0%"></div>
|
| 511 |
-
</div>
|
| 512 |
-
<div class="challenge-meta">
|
| 513 |
-
<span id="ch-progress-text">0 / 0 scans</span>
|
| 514 |
-
<span class="challenge-reward" id="ch-reward"></span>
|
| 515 |
-
</div>
|
| 516 |
-
</div>
|
| 517 |
-
|
| 518 |
-
<!-- Persona -->
|
| 519 |
-
<div style="margin-bottom:16px">
|
| 520 |
-
<div class="section-label">Eating profile</div>
|
| 521 |
-
<div class="chip-row" id="persona-row">
|
| 522 |
-
<div class="chip active" onclick="setChip(this,'persona','General')">🏠 General</div>
|
| 523 |
-
<div class="chip" onclick="setChip(this,'persona','Gym')">💪 Gym</div>
|
| 524 |
-
<div class="chip" onclick="setChip(this,'persona','Baby')">👶 Baby</div>
|
| 525 |
-
<div class="chip" onclick="setChip(this,'persona','Skin')">✨ Skin</div>
|
| 526 |
-
<div class="chip" onclick="setChip(this,'persona','Keto')">🥑 Keto</div>
|
| 527 |
-
<div class="chip" onclick="setChip(this,'persona','Heart')">❤️ Heart</div>
|
| 528 |
-
<div class="chip" onclick="setChip(this,'persona','Diabetic')">🩸 Diabetic</div>
|
| 529 |
-
</div>
|
| 530 |
-
</div>
|
| 531 |
-
|
| 532 |
-
<!-- Category -->
|
| 533 |
-
<div style="margin-bottom:16px">
|
| 534 |
-
<div class="section-label">Product type</div>
|
| 535 |
-
<div class="chip-row" id="cat-row">
|
| 536 |
-
<div class="chip active" onclick="setChip(this,'cat','general')">All</div>
|
| 537 |
-
<div class="chip" onclick="setChip(this,'cat','snack')">🍿 Snack</div>
|
| 538 |
-
<div class="chip" onclick="setChip(this,'cat','dairy')">🥛 Dairy</div>
|
| 539 |
-
<div class="chip" onclick="setChip(this,'cat','beverage')">🧃 Beverage</div>
|
| 540 |
-
<div class="chip" onclick="setChip(this,'cat','supplement')">💊 Supplement</div>
|
| 541 |
-
<div class="chip" onclick="setChip(this,'cat','frozen')">🧊 Frozen</div>
|
| 542 |
-
</div>
|
| 543 |
-
</div>
|
| 544 |
-
|
| 545 |
-
<!-- Barcode Camera Scanner -->
|
| 546 |
-
<div class="section-label">Barcode scanner</div>
|
| 547 |
-
<div class="barcode-scan-btn" onclick="startBarcodeScanner()">
|
| 548 |
-
<div class="bs-icon"><i class="fas fa-barcode"></i></div>
|
| 549 |
-
<span>Scan Barcode — Instant Label Fetch</span>
|
| 550 |
-
<i class="fas fa-camera" style="margin-left:auto;color:var(--sage)"></i>
|
| 551 |
-
</div>
|
| 552 |
-
<div class="barcode-result" id="barcode-result"></div>
|
| 553 |
-
|
| 554 |
-
<!-- Errors & blur notice -->
|
| 555 |
-
<div class="blur-notice" id="blur-notice">
|
| 556 |
-
<div class="blur-notice-header">
|
| 557 |
-
<span>🔧</span>
|
| 558 |
-
<span id="bn-title">Blur Detected & Corrected</span>
|
| 559 |
-
<span class="severity-pill" id="bn-severity-pill"></span>
|
| 560 |
-
</div>
|
| 561 |
-
<div class="blur-notice-body" id="bn-body"></div>
|
| 562 |
-
<div class="blur-notice-methods" id="bn-methods" style="display:none"></div>
|
| 563 |
-
</div>
|
| 564 |
-
<div class="error-card" id="error-card">
|
| 565 |
-
<div class="error-card-inner" id="error-card-inner">
|
| 566 |
-
<span class="err-icon" id="err-icon">📷</span>
|
| 567 |
-
<div class="err-title" id="err-title">Image Issue</div>
|
| 568 |
-
<div class="err-msg" id="err-msg">Please retake your photo.</div>
|
| 569 |
-
<div id="err-flip-illustration" style="display:none">
|
| 570 |
-
<div class="flip-illustration">
|
| 571 |
-
<div class="flip-box front"><div class="fb-icon">🏷️</div><span>FRONT</span></div>
|
| 572 |
-
<div class="flip-arrow">→</div>
|
| 573 |
-
<div class="flip-box back"><div class="fb-icon">📋</div><span>BACK ✓</span></div>
|
| 574 |
-
</div>
|
| 575 |
-
</div>
|
| 576 |
-
<button class="err-retry-btn" id="err-retry-btn" onclick="triggerRetake()">
|
| 577 |
-
<i class="fas fa-camera" style="margin-right:6px"></i>Retake Photo
|
| 578 |
-
</button>
|
| 579 |
-
<button class="err-secondary-btn" id="err-upload-btn"
|
| 580 |
-
onclick="document.getElementById('fileInput').click()" style="display:none">
|
| 581 |
-
<i class="fas fa-image" style="margin-right:6px"></i>Upload Different Image
|
| 582 |
-
</button>
|
| 583 |
-
</div>
|
| 584 |
-
</div>
|
| 585 |
-
|
| 586 |
-
<!-- Landing UI -->
|
| 587 |
-
<div id="landing-ui">
|
| 588 |
-
<div class="upload-hint">
|
| 589 |
-
<div class="upload-hint-icon">💡</div>
|
| 590 |
-
<div class="upload-hint-text">
|
| 591 |
-
<strong>Scan the back label</strong> — point at the ingredients & nutrition facts side,
|
| 592 |
-
not the front of the package.
|
| 593 |
-
</div>
|
| 594 |
-
</div>
|
| 595 |
-
<div class="action-grid">
|
| 596 |
-
<div class="scan-card" onclick="startCamera()">
|
| 597 |
-
<div class="scan-icon"><i class="fas fa-camera"></i></div>
|
| 598 |
-
<h3>Camera</h3><p>Scan live label</p>
|
| 599 |
-
</div>
|
| 600 |
-
<div class="scan-card" id="upload-drop-card"
|
| 601 |
-
onclick="document.getElementById('fileInput').click()"
|
| 602 |
-
ondragover="handleDragOver(event)" ondragleave="handleDragLeave(event)" ondrop="handleDrop(event)">
|
| 603 |
-
<div class="scan-icon"><i class="fas fa-image"></i></div>
|
| 604 |
-
<h3>Upload</h3><p>Tap or drag photo</p>
|
| 605 |
-
</div>
|
| 606 |
-
</div>
|
| 607 |
-
</div>
|
| 608 |
-
|
| 609 |
-
<!-- Preview -->
|
| 610 |
-
<div id="preview-area">
|
| 611 |
-
<img id="preview-img" src="" alt="Preview">
|
| 612 |
-
<div class="upload-progress" id="upload-progress">
|
| 613 |
-
<div class="upload-progress-bar" id="upload-progress-bar"></div>
|
| 614 |
-
</div>
|
| 615 |
-
<div id="img-state-badge" class="img-state-row checking" style="display:none">
|
| 616 |
-
<div class="state-icon" id="state-icon">⏳</div>
|
| 617 |
-
<div>
|
| 618 |
-
<div class="state-text" id="state-text">Checking image...</div>
|
| 619 |
-
<div class="state-tip" id="state-tip"></div>
|
| 620 |
-
</div>
|
| 621 |
-
</div>
|
| 622 |
-
<button class="btn-primary" id="analyze-main-btn" onclick="analyze()" style="display:none">
|
| 623 |
-
<i class="fas fa-microscope" style="margin-right:8px"></i>
|
| 624 |
-
<span id="analyze-btn-text">Analyze Label</span>
|
| 625 |
-
</button>
|
| 626 |
-
<button class="btn-ghost" onclick="resetHome()">↩ Choose different image</button>
|
| 627 |
-
</div>
|
| 628 |
-
</div><!-- end home tab -->
|
| 629 |
-
|
| 630 |
-
<!-- ══ HISTORY TAB ══ -->
|
| 631 |
-
<div class="tab-page" id="page-history">
|
| 632 |
-
<div class="section-label" style="margin-bottom:14px">Scan History</div>
|
| 633 |
-
<div id="history-list"></div>
|
| 634 |
-
</div>
|
| 635 |
-
|
| 636 |
-
<!-- ══ PROFILE TAB ══ -->
|
| 637 |
-
<div class="tab-page" id="page-profile">
|
| 638 |
-
<div class="card" style="margin-bottom:16px;text-align:center;padding:24px 16px">
|
| 639 |
-
<div class="profile-avatar" id="prof-avatar">🌿</div>
|
| 640 |
-
<div class="profile-name" id="prof-name">My Profile</div>
|
| 641 |
-
<div class="profile-sub" id="prof-sub">General · English</div>
|
| 642 |
-
</div>
|
| 643 |
-
<div class="stat-row">
|
| 644 |
-
<div class="stat-box"><div class="stat-num" id="stat-scans">0</div><div class="stat-lbl">Scans</div></div>
|
| 645 |
-
<div class="stat-box"><div class="stat-num" id="stat-avg">—</div><div class="stat-lbl">Avg Score</div></div>
|
| 646 |
-
<div class="stat-box"><div class="stat-num" id="stat-best">—</div><div class="stat-lbl">Best</div></div>
|
| 647 |
-
</div>
|
| 648 |
-
<!-- Streak stats on profile -->
|
| 649 |
-
<div class="card" style="margin-bottom:16px" id="profile-streak-card">
|
| 650 |
-
<div class="r-title">🔥 Streak & Badges</div>
|
| 651 |
-
<div class="stat-row" style="margin-bottom:8px">
|
| 652 |
-
<div class="stat-box"><div class="stat-num" id="ps-current">0</div><div class="stat-lbl">Current</div></div>
|
| 653 |
-
<div class="stat-box"><div class="stat-num" id="ps-longest">0</div><div class="stat-lbl">Best</div></div>
|
| 654 |
-
<div class="stat-box"><div class="stat-num" id="ps-total">0</div><div class="stat-lbl">Total</div></div>
|
| 655 |
-
</div>
|
| 656 |
-
<div class="badge-row" id="ps-badges"></div>
|
| 657 |
-
</div>
|
| 658 |
-
<div class="profile-section">
|
| 659 |
-
<div class="section-label">Preferences</div>
|
| 660 |
-
<div class="profile-row">
|
| 661 |
-
<div class="profile-row-left">
|
| 662 |
-
<div class="profile-row-icon">🌐</div>
|
| 663 |
-
<div><div class="profile-row-label">Language</div><div class="profile-row-value" id="pref-lang-val">English</div></div>
|
| 664 |
-
</div>
|
| 665 |
-
<button onclick="openLang()" style="background:var(--parchment);border:none;padding:6px 12px;border-radius:8px;font-size:0.76rem;font-weight:600;cursor:pointer;color:var(--forest)">Change</button>
|
| 666 |
-
</div>
|
| 667 |
-
<div class="profile-row">
|
| 668 |
-
<div class="profile-row-left">
|
| 669 |
-
<div class="profile-row-icon">👤</div>
|
| 670 |
-
<div><div class="profile-row-label">Default Persona</div><div class="profile-row-value" id="pref-persona-val">General</div></div>
|
| 671 |
-
</div>
|
| 672 |
-
<select class="profile-select" id="pref-persona-sel" onchange="savePersonaPref(this.value)">
|
| 673 |
-
<option>General</option><option>Gym</option><option>Baby</option>
|
| 674 |
-
<option>Skin</option><option>Keto</option><option>Heart</option><option>Diabetic</option>
|
| 675 |
-
</select>
|
| 676 |
-
</div>
|
| 677 |
-
<div class="profile-row">
|
| 678 |
-
<div class="profile-row-left">
|
| 679 |
-
<div class="profile-row-icon">🔔</div>
|
| 680 |
-
<div><div class="profile-row-label">Save scan history</div><div class="profile-row-value">Stored locally on device</div></div>
|
| 681 |
-
</div>
|
| 682 |
-
<div class="toggle-switch on" id="history-toggle" onclick="toggleHistorySave()"><div class="toggle-knob"></div></div>
|
| 683 |
-
</div>
|
| 684 |
-
</div>
|
| 685 |
-
<div class="profile-section">
|
| 686 |
-
<div class="section-label">Data & Privacy</div>
|
| 687 |
-
<div style="background:var(--white);border-radius:var(--radius-sm);border:1.5px solid var(--whisper);padding:13px;margin-bottom:8px;font-size:0.78rem;color:var(--mist);line-height:1.5">
|
| 688 |
-
🔒 Your scan images are processed server-side for OCR and AI analysis only. No health data is sold or shared with advertisers. All history is stored locally on your device.
|
| 689 |
-
</div>
|
| 690 |
-
<button class="history-clear-btn" onclick="clearAllHistory()">🗑 Clear All Scan History</button>
|
| 691 |
-
</div>
|
| 692 |
-
</div>
|
| 693 |
-
|
| 694 |
-
</div><!-- end tab-pages -->
|
| 695 |
-
|
| 696 |
-
<!-- BOTTOM NAV -->
|
| 697 |
-
<div class="bottom-nav">
|
| 698 |
-
<div class="nav-item active" id="nav-home" onclick="switchTab('home')"><i class="fas fa-home"></i>Home</div>
|
| 699 |
-
<div class="nav-item" id="nav-history" onclick="switchTab('history')"><i class="fas fa-history"></i>History</div>
|
| 700 |
-
<div class="nav-item" id="nav-profile" onclick="switchTab('profile')"><i class="fas fa-user"></i>Profile</div>
|
| 701 |
-
</div>
|
| 702 |
-
|
| 703 |
-
<!-- LOADER -->
|
| 704 |
-
<div id="loader">
|
| 705 |
-
<div class="loader-ring"></div>
|
| 706 |
-
<div class="loader-text">Analyzing your food...</div>
|
| 707 |
-
<div class="loader-step" id="loader-step">Preparing...</div>
|
| 708 |
-
<div class="loader-hint">First run may take ~30s while AI models load</div>
|
| 709 |
-
<button class="loader-cancel-btn" onclick="cancelAnalysis()">Cancel</button>
|
| 710 |
-
</div>
|
| 711 |
-
|
| 712 |
-
<!-- CAMERA -->
|
| 713 |
-
<div id="cam-overlay">
|
| 714 |
-
<video id="video" autoplay playsinline></video>
|
| 715 |
-
<div class="cam-ui">
|
| 716 |
-
<div class="cam-guide">
|
| 717 |
-
<div>
|
| 718 |
-
<div class="cam-frame"></div>
|
| 719 |
-
<div class="cam-hint">📦 Align the back label inside the frame</div>
|
| 720 |
-
</div>
|
| 721 |
-
</div>
|
| 722 |
-
<div class="cam-controls">
|
| 723 |
-
<div class="cam-cancel" onclick="stopCamera()">Cancel</div>
|
| 724 |
-
<div class="shutter" onclick="capture()"></div>
|
| 725 |
-
<div style="width:48px"></div>
|
| 726 |
-
</div>
|
| 727 |
-
</div>
|
| 728 |
-
</div>
|
| 729 |
-
<canvas id="canvas" style="display:none"></canvas>
|
| 730 |
-
|
| 731 |
-
<!-- LANGUAGE MODAL -->
|
| 732 |
-
<div id="lang-modal" onclick="closeLangBackdrop(event)">
|
| 733 |
-
<div class="lang-backdrop"></div>
|
| 734 |
-
<div class="lang-sheet">
|
| 735 |
-
<div class="lang-handle"></div>
|
| 736 |
-
<div class="lang-title">Select Language</div>
|
| 737 |
-
<div id="lang-options"></div>
|
| 738 |
-
</div>
|
| 739 |
-
</div>
|
| 740 |
-
|
| 741 |
-
<!-- REPORT PANEL -->
|
| 742 |
-
<div id="report">
|
| 743 |
-
<div class="report-scroll">
|
| 744 |
-
<div class="report-hero">
|
| 745 |
-
<div class="report-topbar">
|
| 746 |
-
<div class="back-btn" onclick="closeReport()"><i class="fas fa-chevron-down"></i></div>
|
| 747 |
-
<div class="verdict-badge" id="r-verdict">—</div>
|
| 748 |
-
</div>
|
| 749 |
-
<div class="hero-row">
|
| 750 |
-
<div class="score-col">
|
| 751 |
-
<div class="score-ring-wrap">
|
| 752 |
-
<canvas id="safetyChart" width="110" height="110"></canvas>
|
| 753 |
-
<div class="score-ring-center">
|
| 754 |
-
<div class="score-num" id="r-score">—</div>
|
| 755 |
-
<div class="score-sub">/ 10</div>
|
| 756 |
-
</div>
|
| 757 |
-
</div>
|
| 758 |
-
<div class="pie-legend">
|
| 759 |
-
<div class="pie-legend-item"><div class="pie-dot" style="background:#2D7A4F"></div><span>Safe</span></div>
|
| 760 |
-
<div class="pie-legend-item"><div class="pie-dot" style="background:#C9A84C"></div><span>Moderate</span></div>
|
| 761 |
-
<div class="pie-legend-item"><div class="pie-dot" style="background:#D96B47"></div><span>Risky</span></div>
|
| 762 |
-
</div>
|
| 763 |
-
</div>
|
| 764 |
-
<div class="info-col">
|
| 765 |
-
<div class="product-cat-tag" id="r-cat"><i class="fas fa-tag"></i> <span>—</span></div>
|
| 766 |
-
<div class="product-name" id="r-name">—</div>
|
| 767 |
-
<div class="summary-text" id="r-summary">—</div>
|
| 768 |
-
</div>
|
| 769 |
-
</div>
|
| 770 |
-
</div>
|
| 771 |
-
<div class="report-body" id="report-body"></div>
|
| 772 |
-
<div style="height:80px"></div>
|
| 773 |
-
</div>
|
| 774 |
-
</div>
|
| 775 |
-
|
| 776 |
-
<!-- SHARE BAR -->
|
| 777 |
-
<div class="report-share-bar" id="report-share-bar">
|
| 778 |
-
<button class="share-btn s" onclick="closeReport()"><i class="fas fa-camera" style="margin-right:6px"></i>New Scan</button>
|
| 779 |
-
<button class="share-btn p" onclick="shareReport()"><i class="fas fa-share-alt" style="margin-right:6px"></i>Share</button>
|
| 780 |
-
</div>
|
| 781 |
-
|
| 782 |
-
<div class="toast" id="toast">✅ Done!</div>
|
| 783 |
-
<input type="file" id="fileInput" accept="image/*" style="display:none" onchange="handleFile(this.files[0])">
|
| 784 |
-
|
| 785 |
-
<!-- BARCODE CAMERA OVERLAY -->
|
| 786 |
-
<div id="barcode-overlay">
|
| 787 |
-
<video id="barcode-video" autoplay playsinline muted></video>
|
| 788 |
-
<canvas id="barcode-canvas"></canvas>
|
| 789 |
-
<button class="bc-close" onclick="stopBarcodeScanner()"><i class="fas fa-times"></i></button>
|
| 790 |
-
<div class="bc-ui">
|
| 791 |
-
<div class="bc-frame-wrap">
|
| 792 |
-
<div class="bc-frame"></div>
|
| 793 |
-
<div class="bc-laser"></div>
|
| 794 |
-
</div>
|
| 795 |
-
<div class="bc-hint">Point at any barcode on the product<br>Label data fetches automatically</div>
|
| 796 |
-
<div class="bc-detected" id="bc-detected">✅ Barcode detected!</div>
|
| 797 |
-
</div>
|
| 798 |
-
<div class="bc-status" id="bc-status">Scanning...</div>
|
| 799 |
-
</div>
|
| 800 |
-
|
| 801 |
-
<script>
|
| 802 |
-
// ═════════════════════��═════════════════════════════
|
| 803 |
-
// STATE
|
| 804 |
-
// ═══════════════════════════════════════════════════
|
| 805 |
-
const API = '';
|
| 806 |
-
let currentPersona = 'General';
|
| 807 |
-
let currentCat = 'general';
|
| 808 |
-
let currentLang = 'en';
|
| 809 |
-
let blob = null;
|
| 810 |
-
let lastResult = null;
|
| 811 |
-
let myChart = null;
|
| 812 |
-
let scanHistory = [];
|
| 813 |
-
let saveHistory = true;
|
| 814 |
-
let currentAbortCtrl = null;
|
| 815 |
-
let streakData = { current: 0, longest: 0, total_scans: 0, badges: [] };
|
| 816 |
-
let challengeData = null;
|
| 817 |
-
let challengeProgress = 0;
|
| 818 |
-
|
| 819 |
-
const LANGUAGES = [
|
| 820 |
-
{ code:'en', label:'English', flag:'🇬🇧' },
|
| 821 |
-
{ code:'zh', label:'简体中文', flag:'🇨🇳' },
|
| 822 |
-
{ code:'es', label:'Español', flag:'🇪🇸' },
|
| 823 |
-
{ code:'ar', label:'العربية', flag:'🇸🇦' },
|
| 824 |
-
{ code:'fr', label:'Français', flag:'🇫🇷' },
|
| 825 |
-
{ code:'hi', label:'हिन्दी', flag:'🇮🇳' },
|
| 826 |
-
{ code:'pt', label:'Português', flag:'🇧🇷' },
|
| 827 |
-
{ code:'de', label:'Deutsch', flag:'🇩🇪' },
|
| 828 |
-
];
|
| 829 |
-
const LANG_NAMES = { en:'English', zh:'Chinese', es:'Spanish', ar:'Arabic', fr:'French', hi:'Hindi', pt:'Portuguese', de:'German' };
|
| 830 |
-
|
| 831 |
-
// ═══════════════════════════════════════════════════
|
| 832 |
-
// INIT
|
| 833 |
-
// ═══════════════════════════════════════════════════
|
| 834 |
-
window.onload = async () => {
|
| 835 |
-
try { scanHistory = JSON.parse(localStorage.getItem('eatlytic_v3') || '[]'); } catch { scanHistory = []; }
|
| 836 |
-
try { saveHistory = JSON.parse(localStorage.getItem('eatlytic_save_hist') ?? 'true'); } catch { saveHistory = true; }
|
| 837 |
-
try { streakData = JSON.parse(localStorage.getItem('eatlytic_streak') || '{}'); } catch {}
|
| 838 |
-
try { challengeProgress = parseInt(localStorage.getItem('eatlytic_ch_progress') || '0'); } catch {}
|
| 839 |
-
|
| 840 |
-
const savedLang = localStorage.getItem('eatlytic_lang') || 'en';
|
| 841 |
-
const savedPersona = localStorage.getItem('eatlytic_persona') || 'General';
|
| 842 |
-
setLang(savedLang, false);
|
| 843 |
-
currentPersona = savedPersona;
|
| 844 |
-
document.querySelectorAll('#persona-row .chip').forEach(c => {
|
| 845 |
-
if (c.textContent.includes(savedPersona)) { c.classList.add('active'); }
|
| 846 |
-
else c.classList.remove('active');
|
| 847 |
-
});
|
| 848 |
-
renderLangOptions();
|
| 849 |
-
updateStreakUI();
|
| 850 |
-
updateProfileStats();
|
| 851 |
-
loadChallenge();
|
| 852 |
-
};
|
| 853 |
-
|
| 854 |
-
// ═══════════════════════════════════════════════════
|
| 855 |
-
// TABS
|
| 856 |
-
// ═══════════════════════════════════════════════════
|
| 857 |
-
function switchTab(tab) {
|
| 858 |
-
document.querySelectorAll('.tab-page').forEach(p => p.classList.remove('active'));
|
| 859 |
-
document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active'));
|
| 860 |
-
document.getElementById('page-' + tab).classList.add('active');
|
| 861 |
-
document.getElementById('nav-' + tab).classList.add('active');
|
| 862 |
-
if (tab === 'history') renderHistory();
|
| 863 |
-
if (tab === 'profile') updateProfileStats();
|
| 864 |
-
}
|
| 865 |
-
|
| 866 |
-
// ═══════════════════════════════════════════════════
|
| 867 |
-
// CHIPS
|
| 868 |
-
// ═══════════════════════════════════════════════════
|
| 869 |
-
function setChip(el, type, value) {
|
| 870 |
-
const rowId = type === 'persona' ? 'persona-row' : 'cat-row';
|
| 871 |
-
document.querySelectorAll('#' + rowId + ' .chip').forEach(c => c.classList.remove('active'));
|
| 872 |
-
el.classList.add('active');
|
| 873 |
-
if (type === 'persona') { currentPersona = value; localStorage.setItem('eatlytic_persona', value); }
|
| 874 |
-
else currentCat = value;
|
| 875 |
-
}
|
| 876 |
-
|
| 877 |
-
// ═══════════════════════════════════════════════════
|
| 878 |
-
// CHALLENGE LOADER
|
| 879 |
-
// ═══════════════════════════════════════════════════
|
| 880 |
-
async function loadChallenge() {
|
| 881 |
-
try {
|
| 882 |
-
const r = await fetch(`${API}/challenges`);
|
| 883 |
-
if (!r.ok) return;
|
| 884 |
-
const data = await r.json();
|
| 885 |
-
challengeData = data.challenge;
|
| 886 |
-
const card = document.getElementById('challenge-card');
|
| 887 |
-
card.style.display = 'block';
|
| 888 |
-
document.getElementById('ch-emoji').textContent = challengeData.emoji;
|
| 889 |
-
document.getElementById('ch-title').textContent = challengeData.title;
|
| 890 |
-
document.getElementById('ch-week').textContent = `Week ${data.week}`;
|
| 891 |
-
document.getElementById('ch-desc').textContent = challengeData.description;
|
| 892 |
-
document.getElementById('ch-reward').textContent = '🏆 ' + challengeData.reward;
|
| 893 |
-
updateChallengeProgress();
|
| 894 |
-
} catch { /* silently fail if /challenges not reachable */ }
|
| 895 |
-
}
|
| 896 |
-
|
| 897 |
-
function updateChallengeProgress() {
|
| 898 |
-
if (!challengeData) return;
|
| 899 |
-
const goal = challengeData.goal || 1;
|
| 900 |
-
const pct = Math.min(100, Math.round(challengeProgress / goal * 100));
|
| 901 |
-
document.getElementById('ch-progress-bar').style.width = pct + '%';
|
| 902 |
-
document.getElementById('ch-progress-text').textContent = `${challengeProgress} / ${goal} scans`;
|
| 903 |
-
}
|
| 904 |
-
|
| 905 |
-
// ═══════════════════════════════════════════════════
|
| 906 |
-
// BARCODE CAMERA SCANNER
|
| 907 |
-
// ═══════════════════════════════════════════════════
|
| 908 |
-
let barcodeStream = null;
|
| 909 |
-
let barcodeTimer = null;
|
| 910 |
-
let barcodeDetector = null;
|
| 911 |
-
let lastScannedCode = null;
|
| 912 |
-
|
| 913 |
-
async function startBarcodeScanner() {
|
| 914 |
-
// Check for native BarcodeDetector (Chrome Android, Chrome Desktop)
|
| 915 |
-
const hasNative = ('BarcodeDetector' in window);
|
| 916 |
-
if (!hasNative) {
|
| 917 |
-
// Dynamically load ZXing as fallback
|
| 918 |
-
if (!window.ZXing) {
|
| 919 |
-
await loadScript('https://cdn.jsdelivr.net/npm/@zxing/browser@0.1.4/umd/index.min.js');
|
| 920 |
-
}
|
| 921 |
-
}
|
| 922 |
-
|
| 923 |
-
try {
|
| 924 |
-
barcodeStream = await navigator.mediaDevices.getUserMedia({
|
| 925 |
-
video: { facingMode: 'environment', width: { ideal: 1920 }, height: { ideal: 1080 } }
|
| 926 |
-
});
|
| 927 |
-
} catch {
|
| 928 |
-
showToast('📷 Camera permission denied. Please allow camera access.');
|
| 929 |
-
return;
|
| 930 |
-
}
|
| 931 |
-
|
| 932 |
-
const video = document.getElementById('barcode-video');
|
| 933 |
-
video.srcObject = barcodeStream;
|
| 934 |
-
await video.play();
|
| 935 |
-
|
| 936 |
-
document.getElementById('barcode-overlay').classList.add('active');
|
| 937 |
-
document.getElementById('bc-status').textContent = 'Scanning...';
|
| 938 |
-
document.getElementById('bc-detected').style.display = 'none';
|
| 939 |
-
lastScannedCode = null;
|
| 940 |
-
|
| 941 |
-
if (hasNative) {
|
| 942 |
-
startNativeDetection(video);
|
| 943 |
-
} else {
|
| 944 |
-
startZXingDetection(video);
|
| 945 |
-
}
|
| 946 |
-
}
|
| 947 |
-
|
| 948 |
-
function loadScript(src) {
|
| 949 |
-
return new Promise((resolve, reject) => {
|
| 950 |
-
const s = document.createElement('script');
|
| 951 |
-
s.src = src; s.onload = resolve; s.onerror = reject;
|
| 952 |
-
document.head.appendChild(s);
|
| 953 |
-
});
|
| 954 |
-
}
|
| 955 |
-
|
| 956 |
-
// ── Native BarcodeDetector (Chrome/Android) ──────────────────────
|
| 957 |
-
function startNativeDetection(video) {
|
| 958 |
-
const supported = ['ean_13','ean_8','upc_a','upc_e','code_128','code_39','qr_code','data_matrix'];
|
| 959 |
-
try {
|
| 960 |
-
barcodeDetector = new BarcodeDetector({ formats: supported });
|
| 961 |
-
} catch {
|
| 962 |
-
barcodeDetector = new BarcodeDetector();
|
| 963 |
-
}
|
| 964 |
-
|
| 965 |
-
async function detectFrame() {
|
| 966 |
-
if (!document.getElementById('barcode-overlay').classList.contains('active')) return;
|
| 967 |
-
try {
|
| 968 |
-
const barcodes = await barcodeDetector.detect(video);
|
| 969 |
-
if (barcodes.length > 0) {
|
| 970 |
-
const code = barcodes[0].rawValue;
|
| 971 |
-
if (code && code !== lastScannedCode) {
|
| 972 |
-
lastScannedCode = code;
|
| 973 |
-
onBarcodeDetected(code);
|
| 974 |
-
return;
|
| 975 |
-
}
|
| 976 |
-
}
|
| 977 |
-
} catch {}
|
| 978 |
-
barcodeTimer = requestAnimationFrame(detectFrame);
|
| 979 |
-
}
|
| 980 |
-
barcodeTimer = requestAnimationFrame(detectFrame);
|
| 981 |
-
}
|
| 982 |
-
|
| 983 |
-
// ── ZXing fallback ────────────────────────────────────────────────
|
| 984 |
-
function startZXingDetection(video) {
|
| 985 |
-
const canvas = document.getElementById('barcode-canvas');
|
| 986 |
-
const ctx = canvas.getContext('2d');
|
| 987 |
-
|
| 988 |
-
async function detectFrame() {
|
| 989 |
-
if (!document.getElementById('barcode-overlay').classList.contains('active')) return;
|
| 990 |
-
if (video.readyState === video.HAVE_ENOUGH_DATA) {
|
| 991 |
-
canvas.width = video.videoWidth;
|
| 992 |
-
canvas.height = video.videoHeight;
|
| 993 |
-
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
| 994 |
-
try {
|
| 995 |
-
const hints = new Map();
|
| 996 |
-
const reader = new ZXing.MultiFormatReader();
|
| 997 |
-
reader.setHints(hints);
|
| 998 |
-
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
| 999 |
-
const luminanceSource = new ZXing.RGBLuminanceSource(imageData.data, canvas.width, canvas.height);
|
| 1000 |
-
const binaryBitmap = new ZXing.BinaryBitmap(new ZXing.HybridBinarizer(luminanceSource));
|
| 1001 |
-
const result = reader.decode(binaryBitmap);
|
| 1002 |
-
if (result && result.getText() !== lastScannedCode) {
|
| 1003 |
-
lastScannedCode = result.getText();
|
| 1004 |
-
onBarcodeDetected(result.getText());
|
| 1005 |
-
return;
|
| 1006 |
-
}
|
| 1007 |
-
} catch {}
|
| 1008 |
-
}
|
| 1009 |
-
barcodeTimer = requestAnimationFrame(detectFrame);
|
| 1010 |
-
}
|
| 1011 |
-
barcodeTimer = requestAnimationFrame(detectFrame);
|
| 1012 |
-
}
|
| 1013 |
-
|
| 1014 |
-
function stopBarcodeScanner() {
|
| 1015 |
-
if (barcodeTimer) { cancelAnimationFrame(barcodeTimer); barcodeTimer = null; }
|
| 1016 |
-
if (barcodeStream) { barcodeStream.getTracks().forEach(t => t.stop()); barcodeStream = null; }
|
| 1017 |
-
document.getElementById('barcode-overlay').classList.remove('active');
|
| 1018 |
-
}
|
| 1019 |
-
|
| 1020 |
-
// ── On a barcode being detected ───────────────────────────────────
|
| 1021 |
-
async function onBarcodeDetected(code) {
|
| 1022 |
-
// Haptic feedback
|
| 1023 |
-
if (navigator.vibrate) navigator.vibrate([60, 30, 60]);
|
| 1024 |
-
|
| 1025 |
-
// Visual feedback
|
| 1026 |
-
const detectedEl = document.getElementById('bc-detected');
|
| 1027 |
-
detectedEl.textContent = `✅ ${code}`;
|
| 1028 |
-
detectedEl.style.display = 'block';
|
| 1029 |
-
document.getElementById('bc-status').textContent = 'Fetching label data...';
|
| 1030 |
-
|
| 1031 |
-
// Pause scanning
|
| 1032 |
-
if (barcodeTimer) { cancelAnimationFrame(barcodeTimer); barcodeTimer = null; }
|
| 1033 |
-
|
| 1034 |
-
await fetchBarcodeLabel(code);
|
| 1035 |
-
stopBarcodeScanner();
|
| 1036 |
-
}
|
| 1037 |
-
|
| 1038 |
-
// ── Fetch label data from Open Food Facts via backend ─────────────
|
| 1039 |
-
async function fetchBarcodeLabel(code) {
|
| 1040 |
-
const resultDiv = document.getElementById('barcode-result');
|
| 1041 |
-
resultDiv.style.display = 'block';
|
| 1042 |
-
resultDiv.innerHTML = `<span style="color:var(--mist);font-size:0.8rem">⏳ Fetching label for <strong>${escHtml(code)}</strong>...</span>`;
|
| 1043 |
-
|
| 1044 |
-
try {
|
| 1045 |
-
const r = await fetch(\`\${API}/barcode/\${code}\`);
|
| 1046 |
-
const d = await r.json();
|
| 1047 |
-
|
| 1048 |
-
if (!d.found) {
|
| 1049 |
-
resultDiv.innerHTML = \`
|
| 1050 |
-
<div style="font-size:0.8rem;color:var(--mist);padding:8px 0">
|
| 1051 |
-
❌ Barcode <strong>\${escHtml(code)}</strong> not found in database.
|
| 1052 |
-
<br><span style="font-size:0.75rem">Scan the label directly for a full AI analysis.</span>
|
| 1053 |
-
</div>\`;
|
| 1054 |
-
return;
|
| 1055 |
-
}
|
| 1056 |
-
|
| 1057 |
-
const ns = (d.nutriscore || '').toUpperCase() || 'N/A';
|
| 1058 |
-
const nsClass = 'ns-' + (d.nutriscore || 'n').toLowerCase();
|
| 1059 |
-
const nova = d.nova_group
|
| 1060 |
-
? \`<span style="background:#F0F9FF;border:1px solid #BAE6FD;color:#0369A1;padding:2px 8px;border-radius:50px;font-size:0.7rem;font-weight:700">NOVA \${d.nova_group}</span>\`
|
| 1061 |
-
: '';
|
| 1062 |
-
const imgTag = d.image_url
|
| 1063 |
-
? \`<img src="\${d.image_url}" style="width:60px;height:60px;object-fit:contain;border-radius:8px;flex-shrink:0;border:1px solid var(--whisper)">\`
|
| 1064 |
-
: \`<div style="width:60px;height:60px;background:var(--parchment);border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:1.6rem">📦</div>\`;
|
| 1065 |
-
|
| 1066 |
-
resultDiv.innerHTML = \`
|
| 1067 |
-
<div style="display:flex;gap:12px;align-items:flex-start;margin-bottom:10px">
|
| 1068 |
-
\${imgTag}
|
| 1069 |
-
<div style="flex:1;min-width:0">
|
| 1070 |
-
<div style="font-weight:700;font-size:0.9rem;color:var(--forest);margin-bottom:4px">\${escHtml(d.product_name)}</div>
|
| 1071 |
-
<div style="font-size:0.73rem;color:var(--mist);margin-bottom:6px">\${escHtml(d.brands || '')}</div>
|
| 1072 |
-
<div style="display:flex;gap:6px;flex-wrap:wrap">
|
| 1073 |
-
<span class="barcode-nutriscore \${nsClass}">NutriScore \${ns}</span>
|
| 1074 |
-
\${nova}
|
| 1075 |
-
</div>
|
| 1076 |
-
</div>
|
| 1077 |
-
</div>
|
| 1078 |
-
<div style="display:grid;grid-template-columns:repeat(5,1fr);gap:6px;margin-bottom:10px">
|
| 1079 |
-
\${[
|
| 1080 |
-
['Calories', d.nutrients.energy_kcal, 'kcal'],
|
| 1081 |
-
['Protein', d.nutrients.proteins_g, 'g'],
|
| 1082 |
-
['Carbs', d.nutrients.carbs_g, 'g'],
|
| 1083 |
-
['Fat', d.nutrients.fat_g, 'g'],
|
| 1084 |
-
['Sodium', d.nutrients.sodium_mg, 'mg'],
|
| 1085 |
-
].map(([lbl,val,unit]) => \`
|
| 1086 |
-
<div style="background:var(--parchment);border-radius:8px;padding:8px 4px;text-align:center">
|
| 1087 |
-
<div style="font-size:0.78rem;font-weight:700;color:var(--forest)">\${val ?? '?'}<span style="font-size:0.6rem;color:var(--mist)">\${unit}</span></div>
|
| 1088 |
-
<div style="font-size:0.62rem;color:var(--mist);margin-top:2px">\${lbl}</div>
|
| 1089 |
-
</div>\`).join('')}
|
| 1090 |
-
</div>
|
| 1091 |
-
<button onclick="document.getElementById('fileInput').click()" style="
|
| 1092 |
-
width:100%;padding:11px;background:var(--forest);color:var(--cream);
|
| 1093 |
-
border:none;border-radius:var(--radius-sm);font-weight:700;font-size:0.82rem;
|
| 1094 |
-
cursor:pointer;font-family:'DM Sans',sans-serif;display:flex;align-items:center;justify-content:center;gap:8px">
|
| 1095 |
-
<i class="fas fa-microscope"></i> Scan Label for Full AI Analysis
|
| 1096 |
-
</button>\`;
|
| 1097 |
-
} catch {
|
| 1098 |
-
resultDiv.innerHTML = '<div style="font-size:0.78rem;color:var(--caution);padding:6px 0">⚠️ Could not fetch label data. Check your connection.</div>';
|
| 1099 |
-
}
|
| 1100 |
-
}
|
| 1101 |
-
|
| 1102 |
-
// ═══════════════════════════════════════════════════
|
| 1103 |
-
// FILE / CAMERA HANDLING
|
| 1104 |
-
// ═══════════════════════════════════════════════════
|
| 1105 |
-
function handleDragOver(e) {
|
| 1106 |
-
e.preventDefault();
|
| 1107 |
-
document.getElementById('upload-drop-card').style.borderColor = 'var(--sage)';
|
| 1108 |
-
}
|
| 1109 |
-
function handleDragLeave() {
|
| 1110 |
-
document.getElementById('upload-drop-card').style.borderColor = '';
|
| 1111 |
-
}
|
| 1112 |
-
function handleDrop(e) {
|
| 1113 |
-
e.preventDefault();
|
| 1114 |
-
document.getElementById('upload-drop-card').style.borderColor = '';
|
| 1115 |
-
const file = e.dataTransfer.files[0];
|
| 1116 |
-
if (file && file.type.startsWith('image/')) handleFile(file);
|
| 1117 |
-
else showContextualError('generic', '📄', 'Unsupported File', 'Please upload a photo (JPG, PNG, HEIC).');
|
| 1118 |
-
}
|
| 1119 |
-
|
| 1120 |
-
async function handleFile(file) {
|
| 1121 |
-
if (!file) return;
|
| 1122 |
-
blob = file;
|
| 1123 |
-
hideError();
|
| 1124 |
-
document.getElementById('landing-ui').style.display = 'none';
|
| 1125 |
-
document.getElementById('preview-img').src = URL.createObjectURL(file);
|
| 1126 |
-
document.getElementById('preview-area').style.display = 'block';
|
| 1127 |
-
document.getElementById('analyze-btn-text').textContent = 'Analyze Label';
|
| 1128 |
-
document.getElementById('analyze-main-btn').style.display = 'none';
|
| 1129 |
-
runImageAssessment(file);
|
| 1130 |
-
}
|
| 1131 |
-
|
| 1132 |
-
function setImgState(type, icon, text, tip) {
|
| 1133 |
-
const badge = document.getElementById('img-state-badge');
|
| 1134 |
-
badge.className = 'img-state-row ' + type;
|
| 1135 |
-
badge.style.display = 'flex';
|
| 1136 |
-
document.getElementById('state-icon').textContent = icon;
|
| 1137 |
-
document.getElementById('state-text').textContent = text;
|
| 1138 |
-
document.getElementById('state-tip').textContent = tip || '';
|
| 1139 |
-
}
|
| 1140 |
-
|
| 1141 |
-
async function runImageAssessment(file) {
|
| 1142 |
-
const progress = document.getElementById('upload-progress');
|
| 1143 |
-
const bar = document.getElementById('upload-progress-bar');
|
| 1144 |
-
progress.style.display = 'block';
|
| 1145 |
-
setImgState('checking', '⏳', 'Checking image quality...', '');
|
| 1146 |
-
await animateBar(bar, 0, 60, 400);
|
| 1147 |
-
const variance = await getImageVariance(file);
|
| 1148 |
-
await animateBar(bar, 60, 100, 300);
|
| 1149 |
-
setTimeout(() => { progress.style.display = 'none'; bar.style.width = '0%'; }, 400);
|
| 1150 |
-
if (variance < 200) setImgState('poor', '⚠️', 'Low contrast — consider retaking', 'Move closer, improve lighting');
|
| 1151 |
-
else if (variance < 600) setImgState('fair', '🔆', 'Fair quality — results may vary', 'Clearer photos give better results');
|
| 1152 |
-
else setImgState('good', '✅', 'Good image quality', 'Label looks clear and readable');
|
| 1153 |
-
document.getElementById('analyze-main-btn').style.display = 'block';
|
| 1154 |
-
}
|
| 1155 |
-
|
| 1156 |
-
function animateBar(bar, from, to, ms) {
|
| 1157 |
-
return new Promise(resolve => {
|
| 1158 |
-
bar.style.transition = 'none';
|
| 1159 |
-
bar.style.width = from + '%';
|
| 1160 |
-
requestAnimationFrame(() => {
|
| 1161 |
-
bar.style.transition = `width ${ms}ms ease`;
|
| 1162 |
-
bar.style.width = to + '%';
|
| 1163 |
-
setTimeout(resolve, ms);
|
| 1164 |
-
});
|
| 1165 |
-
});
|
| 1166 |
-
}
|
| 1167 |
-
|
| 1168 |
-
function getImageVariance(file) {
|
| 1169 |
-
return new Promise(resolve => {
|
| 1170 |
-
const img = new Image();
|
| 1171 |
-
img.onload = () => {
|
| 1172 |
-
const c = document.createElement('canvas');
|
| 1173 |
-
c.width = Math.min(img.width, 400);
|
| 1174 |
-
c.height = Math.round(img.height * c.width / img.width);
|
| 1175 |
-
const ctx = c.getContext('2d');
|
| 1176 |
-
ctx.drawImage(img, 0, 0, c.width, c.height);
|
| 1177 |
-
const d = ctx.getImageData(0, 0, c.width, c.height).data;
|
| 1178 |
-
let vals = [];
|
| 1179 |
-
for (let i = 0; i < d.length; i += 32) vals.push(0.299*d[i] + 0.587*d[i+1] + 0.114*d[i+2]);
|
| 1180 |
-
const mean = vals.reduce((a,b)=>a+b,0)/vals.length;
|
| 1181 |
-
resolve(vals.reduce((a,b)=>a+(b-mean)*(b-mean),0)/vals.length);
|
| 1182 |
-
};
|
| 1183 |
-
img.onerror = () => resolve(999);
|
| 1184 |
-
img.src = URL.createObjectURL(file);
|
| 1185 |
-
});
|
| 1186 |
-
}
|
| 1187 |
-
|
| 1188 |
-
async function startCamera() {
|
| 1189 |
-
try {
|
| 1190 |
-
const s = await navigator.mediaDevices.getUserMedia({ video: { facingMode:'environment', width:{ideal:1920} }});
|
| 1191 |
-
document.getElementById('video').srcObject = s;
|
| 1192 |
-
document.getElementById('cam-overlay').classList.add('active');
|
| 1193 |
-
} catch { showToast('📷 Camera permission denied.'); }
|
| 1194 |
-
}
|
| 1195 |
-
function stopCamera() {
|
| 1196 |
-
const s = document.getElementById('video').srcObject;
|
| 1197 |
-
if (s) s.getTracks().forEach(t => t.stop());
|
| 1198 |
-
document.getElementById('cam-overlay').classList.remove('active');
|
| 1199 |
-
}
|
| 1200 |
-
function capture() {
|
| 1201 |
-
const v = document.getElementById('video');
|
| 1202 |
-
const c = document.getElementById('canvas');
|
| 1203 |
-
c.width = v.videoWidth; c.height = v.videoHeight;
|
| 1204 |
-
c.getContext('2d').drawImage(v, 0, 0);
|
| 1205 |
-
c.toBlob(b => { stopCamera(); handleFile(b); }, 'image/jpeg', 0.95);
|
| 1206 |
-
}
|
| 1207 |
-
function resetHome() {
|
| 1208 |
-
blob = null;
|
| 1209 |
-
document.getElementById('preview-area').style.display = 'none';
|
| 1210 |
-
document.getElementById('landing-ui').style.display = 'block';
|
| 1211 |
-
hideError();
|
| 1212 |
-
document.getElementById('blur-notice').classList.remove('visible');
|
| 1213 |
-
document.getElementById('fileInput').value = '';
|
| 1214 |
-
const br = document.getElementById('barcode-result');
|
| 1215 |
-
if (br) br.style.display = 'none';
|
| 1216 |
-
}
|
| 1217 |
-
|
| 1218 |
-
// ═══════════════════════════════════════════════════
|
| 1219 |
-
// ERRORS
|
| 1220 |
-
// ═══════════════════════════════════════════════════
|
| 1221 |
-
function showContextualError(type, icon, title, msg) {
|
| 1222 |
-
blob = null;
|
| 1223 |
-
document.getElementById('preview-area').style.display = 'none';
|
| 1224 |
-
document.getElementById('landing-ui').style.display = 'block';
|
| 1225 |
-
const card = document.getElementById('error-card');
|
| 1226 |
-
const flipIllus = document.getElementById('err-flip-illustration');
|
| 1227 |
-
const retryBtn = document.getElementById('err-retry-btn');
|
| 1228 |
-
const uploadBtn = document.getElementById('err-upload-btn');
|
| 1229 |
-
card.className = 'error-card';
|
| 1230 |
-
flipIllus.style.display = 'none';
|
| 1231 |
-
retryBtn.style.display = 'block';
|
| 1232 |
-
uploadBtn.style.display = 'none';
|
| 1233 |
-
document.getElementById('err-icon').textContent = icon;
|
| 1234 |
-
document.getElementById('err-title').textContent = title;
|
| 1235 |
-
document.getElementById('err-msg').textContent = msg;
|
| 1236 |
-
if (type === 'wrong_side') {
|
| 1237 |
-
card.classList.add('no-label');
|
| 1238 |
-
flipIllus.style.display = 'block';
|
| 1239 |
-
retryBtn.innerHTML = '<i class="fas fa-sync-alt" style="margin-right:6px"></i>Scan the Back Label';
|
| 1240 |
-
uploadBtn.style.display = 'block';
|
| 1241 |
-
uploadBtn.innerHTML = '<i class="fas fa-image" style="margin-right:6px"></i>Upload Different Image';
|
| 1242 |
-
} else {
|
| 1243 |
-
retryBtn.innerHTML = '<i class="fas fa-camera" style="margin-right:6px"></i>Retake Photo';
|
| 1244 |
-
uploadBtn.style.display = 'block';
|
| 1245 |
-
uploadBtn.innerHTML = '<i class="fas fa-image" style="margin-right:6px"></i>Upload from Gallery';
|
| 1246 |
-
}
|
| 1247 |
-
card.style.display = 'block';
|
| 1248 |
-
}
|
| 1249 |
-
function hideError() { document.getElementById('error-card').style.display = 'none'; document.getElementById('error-card').classList.remove('no-label'); }
|
| 1250 |
-
function triggerRetake() { hideError(); startCamera(); }
|
| 1251 |
-
|
| 1252 |
-
// ═══════════════════════════════════════════════════
|
| 1253 |
-
// ANALYZE
|
| 1254 |
-
// ═══════════════════════════════════════════════════
|
| 1255 |
-
function cancelAnalysis() { if (currentAbortCtrl) currentAbortCtrl.abort(); }
|
| 1256 |
-
|
| 1257 |
-
function handleBlurNotice(blurInfo) {
|
| 1258 |
-
const notice = document.getElementById('blur-notice');
|
| 1259 |
-
if (!blurInfo || !blurInfo.detected) { notice.classList.remove('visible'); return; }
|
| 1260 |
-
const sev = blurInfo.severity || 'moderate';
|
| 1261 |
-
document.getElementById('bn-severity-pill').textContent = sev.toUpperCase();
|
| 1262 |
-
document.getElementById('bn-severity-pill').className = `severity-pill ${sev}`;
|
| 1263 |
-
if (blurInfo.deblurred) {
|
| 1264 |
-
document.getElementById('bn-title').textContent = '🔧 Blur Detected & Corrected';
|
| 1265 |
-
document.getElementById('bn-body').textContent = `${sev} blur detected. Deblurring applied. Score: ${blurInfo.score}/100.`;
|
| 1266 |
-
if (blurInfo.method_log) { document.getElementById('bn-methods').textContent = 'Pipeline: ' + blurInfo.method_log; document.getElementById('bn-methods').style.display = 'block'; }
|
| 1267 |
-
} else {
|
| 1268 |
-
document.getElementById('bn-title').textContent = '⚠️ Blur Detected — Using Original';
|
| 1269 |
-
document.getElementById('bn-body').textContent = `Blur detected (severity: ${sev}, score: ${blurInfo.score}/100). Consider retaking with better lighting.`;
|
| 1270 |
-
document.getElementById('bn-methods').style.display = 'none';
|
| 1271 |
-
}
|
| 1272 |
-
notice.classList.add('visible');
|
| 1273 |
-
}
|
| 1274 |
-
|
| 1275 |
-
async function analyze() {
|
| 1276 |
-
if (!blob) return;
|
| 1277 |
-
hideError();
|
| 1278 |
-
const loader = document.getElementById('loader');
|
| 1279 |
-
const stepEl = document.getElementById('loader-step');
|
| 1280 |
-
loader.style.display = 'flex';
|
| 1281 |
-
const steps = [
|
| 1282 |
-
'📷 Checking image quality...', '🔧 Detecting & correcting blur...',
|
| 1283 |
-
'🔍 Reading label text (OCR)...', '🌐 Searching trusted health sources...',
|
| 1284 |
-
'🧠 Running AI analysis...', '📊 Validating & building report...',
|
| 1285 |
-
];
|
| 1286 |
-
let si = 0;
|
| 1287 |
-
stepEl.textContent = steps[0];
|
| 1288 |
-
const stepTimer = setInterval(() => { si = Math.min(si+1, steps.length-1); stepEl.textContent = steps[si]; }, 2800);
|
| 1289 |
-
|
| 1290 |
-
currentAbortCtrl = new AbortController();
|
| 1291 |
-
try {
|
| 1292 |
-
const fd = new FormData();
|
| 1293 |
-
fd.append('image', blob);
|
| 1294 |
-
fd.append('persona', currentPersona);
|
| 1295 |
-
fd.append('age_group', 'adult');
|
| 1296 |
-
fd.append('product_category', currentCat);
|
| 1297 |
-
fd.append('language', currentLang);
|
| 1298 |
-
fd.append('user_id', 'default');
|
| 1299 |
-
|
| 1300 |
-
const resp = await fetch(`${API}/analyze`, { method:'POST', body:fd, signal: currentAbortCtrl.signal });
|
| 1301 |
-
clearInterval(stepTimer);
|
| 1302 |
-
loader.style.display = 'none';
|
| 1303 |
-
const d = await resp.json();
|
| 1304 |
-
|
| 1305 |
-
if (d.error) {
|
| 1306 |
-
const errorMap = {
|
| 1307 |
-
no_text: { type:'generic', icon:'📷', title:'No Text Found', msg:'No text found on this image. Flip the product and scan the back label.' },
|
| 1308 |
-
no_label: { type:'wrong_side', icon:'📋', title:'Back Label Needed', msg: d.message || 'Please scan the back label with nutrition facts.' },
|
| 1309 |
-
low_confidence:{ type:'blurry', icon:'🔆', title:'Image Too Unclear', msg: d.message || 'Not enough readable text found. Try better lighting.' },
|
| 1310 |
-
};
|
| 1311 |
-
const err = errorMap[d.error] || { type:'generic', icon:'⚠️', title:'Analysis Failed', msg: d.error };
|
| 1312 |
-
showContextualError(err.type, err.icon, err.title, err.msg);
|
| 1313 |
-
return;
|
| 1314 |
-
}
|
| 1315 |
-
|
| 1316 |
-
lastResult = d;
|
| 1317 |
-
handleBlurNotice(d.blur_info);
|
| 1318 |
-
|
| 1319 |
-
// Update streak locally
|
| 1320 |
-
if (d.streak) {
|
| 1321 |
-
streakData = d.streak;
|
| 1322 |
-
try { localStorage.setItem('eatlytic_streak', JSON.stringify(streakData)); } catch {}
|
| 1323 |
-
updateStreakUI();
|
| 1324 |
-
}
|
| 1325 |
-
|
| 1326 |
-
// Update challenge progress
|
| 1327 |
-
challengeProgress = Math.min((challengeProgress || 0) + 1, challengeData?.goal || 999);
|
| 1328 |
-
try { localStorage.setItem('eatlytic_ch_progress', String(challengeProgress)); } catch {}
|
| 1329 |
-
updateChallengeProgress();
|
| 1330 |
-
|
| 1331 |
-
if (saveHistory) addToHistory(d);
|
| 1332 |
-
renderReport(d);
|
| 1333 |
-
|
| 1334 |
-
// Confetti for great scores
|
| 1335 |
-
if ((d.score || 0) >= 8) triggerConfetti();
|
| 1336 |
-
|
| 1337 |
-
} catch (err) {
|
| 1338 |
-
clearInterval(stepTimer);
|
| 1339 |
-
loader.style.display = 'none';
|
| 1340 |
-
if (err.name === 'AbortError') return;
|
| 1341 |
-
showContextualError('generic', '🌐', 'Connection Failed', 'Could not reach the server. Check your internet connection and try again.');
|
| 1342 |
-
}
|
| 1343 |
-
}
|
| 1344 |
-
|
| 1345 |
-
// ═══════════════════════════════════════════════════
|
| 1346 |
-
// CONFETTI
|
| 1347 |
-
// ═══════════════════════════════════════════════════
|
| 1348 |
-
function triggerConfetti() {
|
| 1349 |
-
const colors = ['#1E3A2F','#C9A84C','#4A7C59','#D96B47','#7FB896','#2D7A4F'];
|
| 1350 |
-
for (let i = 0; i < 40; i++) {
|
| 1351 |
-
const p = document.createElement('div');
|
| 1352 |
-
p.className = 'confetti-piece';
|
| 1353 |
-
p.style.cssText = `
|
| 1354 |
-
left:${Math.random()*100}%;
|
| 1355 |
-
top:-10px;
|
| 1356 |
-
background:${colors[Math.floor(Math.random()*colors.length)]};
|
| 1357 |
-
width:${6+Math.random()*8}px;height:${6+Math.random()*8}px;
|
| 1358 |
-
animation-delay:${Math.random()*0.6}s;
|
| 1359 |
-
animation-duration:${2+Math.random()*1}s;
|
| 1360 |
-
border-radius:${Math.random()>0.5?'50%':'2px'}`;
|
| 1361 |
-
document.body.appendChild(p);
|
| 1362 |
-
setTimeout(() => p.remove(), 3500);
|
| 1363 |
-
}
|
| 1364 |
-
}
|
| 1365 |
-
|
| 1366 |
-
// ═══════════════════════════════════════════════════
|
| 1367 |
-
// STREAK UI
|
| 1368 |
-
// ═══════════════════════════════════════════════════
|
| 1369 |
-
function updateStreakUI() {
|
| 1370 |
-
const current = streakData.current || 0;
|
| 1371 |
-
const longest = streakData.longest || 0;
|
| 1372 |
-
const total = streakData.total_scans || 0;
|
| 1373 |
-
const badges = streakData.badges || [];
|
| 1374 |
-
|
| 1375 |
-
// Header badge
|
| 1376 |
-
document.getElementById('streak-count').textContent = current;
|
| 1377 |
-
document.getElementById('streak-badge').classList.toggle('active', current > 0);
|
| 1378 |
-
|
| 1379 |
-
// Home panel
|
| 1380 |
-
const panel = document.getElementById('streak-panel');
|
| 1381 |
-
if (total > 0) {
|
| 1382 |
-
panel.style.display = 'block';
|
| 1383 |
-
document.getElementById('sp-current').textContent = current;
|
| 1384 |
-
document.getElementById('sp-best').textContent = longest;
|
| 1385 |
-
document.getElementById('sp-total').textContent = total;
|
| 1386 |
-
document.getElementById('streak-panel-flame').textContent = current >= 7 ? '🔥🔥🔥' : current >= 3 ? '🔥🔥' : '🔥';
|
| 1387 |
-
document.getElementById('sp-badges').innerHTML = badges.map(b => `<div class="badge-pill">${b}</div>`).join('');
|
| 1388 |
-
}
|
| 1389 |
-
// Profile
|
| 1390 |
-
document.getElementById('ps-current').textContent = current;
|
| 1391 |
-
document.getElementById('ps-longest').textContent = longest;
|
| 1392 |
-
document.getElementById('ps-total').textContent = total;
|
| 1393 |
-
document.getElementById('ps-badges').innerHTML = badges.length
|
| 1394 |
-
? badges.map(b => `<div class="badge-pill">${b}</div>`).join('')
|
| 1395 |
-
: '<div style="font-size:0.76rem;color:var(--mist)">Scan daily to earn badges 🏆</div>';
|
| 1396 |
-
}
|
| 1397 |
-
|
| 1398 |
-
// ═══════════════════════════════════════════════════
|
| 1399 |
-
// REPORT
|
| 1400 |
-
// ═══════════════════════════════════════════════════
|
| 1401 |
-
function renderReport(d) {
|
| 1402 |
-
// Hero
|
| 1403 |
-
document.getElementById('r-score').textContent = d.score ?? '?';
|
| 1404 |
-
document.getElementById('r-verdict').textContent = d.verdict || '';
|
| 1405 |
-
document.getElementById('r-name').textContent = d.product_name || 'Unknown Product';
|
| 1406 |
-
document.getElementById('r-summary').textContent = d.summary || '';
|
| 1407 |
-
const catSpan = document.getElementById('r-cat').querySelector('span');
|
| 1408 |
-
if (catSpan) catSpan.textContent = d.product_category || '—';
|
| 1409 |
-
|
| 1410 |
-
// Score ring
|
| 1411 |
-
const cd = (d.chart_data && d.chart_data.length === 3) ? d.chart_data : [50, 30, 20];
|
| 1412 |
-
if (myChart) myChart.destroy();
|
| 1413 |
-
myChart = new Chart(document.getElementById('safetyChart'), {
|
| 1414 |
-
type: 'doughnut',
|
| 1415 |
-
data: { datasets: [{ data: cd, backgroundColor:['#2D7A4F','#C9A84C','#D96B47'], borderWidth: 0 }] },
|
| 1416 |
-
options: { cutout:'72%', plugins:{ legend:{ display:false }, tooltip:{ enabled:false }}, animation:{ duration:800 }}
|
| 1417 |
-
});
|
| 1418 |
-
|
| 1419 |
-
// Body
|
| 1420 |
-
document.getElementById('report-body').innerHTML = buildReportBody(d);
|
| 1421 |
-
|
| 1422 |
-
// Animate nutrient bars
|
| 1423 |
-
setTimeout(() => {
|
| 1424 |
-
document.querySelectorAll('.n-bar').forEach(b => {
|
| 1425 |
-
const pct = b.dataset.pct || '0';
|
| 1426 |
-
b.style.width = pct + '%';
|
| 1427 |
-
});
|
| 1428 |
-
}, 120);
|
| 1429 |
-
|
| 1430 |
-
document.getElementById('report').classList.add('open');
|
| 1431 |
-
document.getElementById('report-share-bar').classList.add('visible');
|
| 1432 |
-
document.querySelector('#report .report-scroll').scrollTop = 0;
|
| 1433 |
-
}
|
| 1434 |
-
|
| 1435 |
-
function buildReportBody(d) {
|
| 1436 |
-
let h = '';
|
| 1437 |
-
const conf = d.confidence || 'medium';
|
| 1438 |
-
|
| 1439 |
-
// Disclaimer
|
| 1440 |
-
h += `<div class="disclaimer-box"><strong>⚕️ Health Information Disclaimer</strong>${escHtml(d.disclaimer || 'For educational purposes only. Not medical advice.')}</div>`;
|
| 1441 |
-
|
| 1442 |
-
// Streak row (if active)
|
| 1443 |
-
if (d.streak && d.streak.current > 0) {
|
| 1444 |
-
h += `<div class="report-streak-row"><div class="report-streak-fire">🔥</div><div class="report-streak-text">Day ${d.streak.current} streak — ${d.streak.total_scans} total scans!</div></div>`;
|
| 1445 |
-
}
|
| 1446 |
-
|
| 1447 |
-
// Confidence
|
| 1448 |
-
h += `<div style="margin-bottom:12px"><span class="confidence-badge ${conf}">` +
|
| 1449 |
-
(conf==='high'?'✅ High Confidence':conf==='medium'?'⚡ Medium Confidence':'⚠️ Low Confidence') + ` — AI analysis</span></div>`;
|
| 1450 |
-
|
| 1451 |
-
// 1. ELI5
|
| 1452 |
-
if (d.eli5_explanation) {
|
| 1453 |
-
h += `<div class="r-section"><div class="r-title">Simple Explanation 🧒</div><div class="eli5-box">${escHtml(d.eli5_explanation)}</div></div>`;
|
| 1454 |
-
}
|
| 1455 |
-
|
| 1456 |
-
// 2. Nutrient Breakdown
|
| 1457 |
-
if (d.nutrient_breakdown?.length) {
|
| 1458 |
-
const bars = d.nutrient_breakdown.map(n => {
|
| 1459 |
-
const maxMap = {protein:50,fat:30,sugar:30,sodium:3000,fiber:30,carbohydrate:100,calories:500,energy:500};
|
| 1460 |
-
const key = (n.name||'').toLowerCase().replace(/\s/g,'');
|
| 1461 |
-
const maxV = maxMap[key] || 100;
|
| 1462 |
-
const pct = Math.min(100, Math.round((n.value / maxV) * 100));
|
| 1463 |
-
const cls = `bar-${n.rating||'moderate'}`;
|
| 1464 |
-
return `<div class="nutrient-item">
|
| 1465 |
-
<div class="nutrient-row">
|
| 1466 |
-
<div class="n-name">${escHtml(n.name)}</div>
|
| 1467 |
-
<div class="n-bar-wrap"><div class="n-bar ${cls}" data-pct="${pct}"></div></div>
|
| 1468 |
-
<div class="n-val">${n.value}${n.unit}</div>
|
| 1469 |
-
</div>
|
| 1470 |
-
${n.impact ? `<div class="n-impact">${escHtml(n.impact)}</div>` : ''}
|
| 1471 |
-
</div>`;
|
| 1472 |
-
}).join('');
|
| 1473 |
-
h += `<div class="r-section"><div class="r-title">Nutrient Breakdown</div>${bars}</div>`;
|
| 1474 |
-
}
|
| 1475 |
-
|
| 1476 |
-
// 3. Pros & Cons
|
| 1477 |
-
if (d.pros?.length || d.cons?.length) {
|
| 1478 |
-
const pros = (d.pros||[]).map(p=>`<div class="pc-item"><div class="pc-dot p"></div>${escHtml(p)}</div>`).join('');
|
| 1479 |
-
const cons = (d.cons||[]).map(c=>`<div class="pc-item"><div class="pc-dot c"></div>${escHtml(c)}</div>`).join('');
|
| 1480 |
-
h += `<div class="r-section"><div class="r-title">Pros & Cons</div>
|
| 1481 |
-
<div class="pc-grid"><div><div class="pc-label p">✅ Benefits</div>${pros}</div>
|
| 1482 |
-
<div><div class="pc-label c">⚠️ Concerns</div>${cons}</div></div></div>`;
|
| 1483 |
-
}
|
| 1484 |
-
|
| 1485 |
-
// 4. Age Warnings
|
| 1486 |
-
if (d.age_warnings?.length) {
|
| 1487 |
-
const cards = d.age_warnings.map(w=>`
|
| 1488 |
-
<div class="age-card ${w.status||'caution'}">
|
| 1489 |
-
<div class="age-emoji">${w.emoji||''}</div>
|
| 1490 |
-
<div class="age-grp">${escHtml(w.group||'')}</div>
|
| 1491 |
-
<div class="age-msg">${escHtml(w.message||'')}</div>
|
| 1492 |
-
</div>`).join('');
|
| 1493 |
-
h += `<div class="r-section"><div class="r-title">Age & Health Group Warnings</div><div class="age-grid">${cards}</div></div>`;
|
| 1494 |
-
}
|
| 1495 |
-
|
| 1496 |
-
// 5. Benefits
|
| 1497 |
-
if (d.paragraph_benefits) {
|
| 1498 |
-
h += `<div class="r-section"><div class="r-title">Benefits & Nutritional Value</div><div class="para-text">${escHtml(d.paragraph_benefits)}</div></div>`;
|
| 1499 |
-
}
|
| 1500 |
-
|
| 1501 |
-
// 6. Uniqueness / Alternatives
|
| 1502 |
-
if (d.paragraph_uniqueness) {
|
| 1503 |
-
h += `<div class="r-section"><div class="r-title">${d.is_unique ? '⭐ What Makes It Unique' : '🔄 Similar & Better Options'}</div><div class="para-text">${escHtml(d.paragraph_uniqueness)}</div></div>`;
|
| 1504 |
-
}
|
| 1505 |
-
|
| 1506 |
-
// 7. Molecular Insight
|
| 1507 |
-
if (d.molecular_insight) {
|
| 1508 |
-
h += `<div class="r-section"><div class="r-title">Molecular Insight 🔬</div><div class="mol-box">🔬 ${escHtml(d.molecular_insight)}</div></div>`;
|
| 1509 |
-
}
|
| 1510 |
-
|
| 1511 |
-
// 8. Better Alternative
|
| 1512 |
-
if (d.better_alternative) {
|
| 1513 |
-
h += `<div class="r-section" style="padding:0;overflow:hidden">
|
| 1514 |
-
<div class="alt-box">
|
| 1515 |
-
<div class="alt-icon">💡</div>
|
| 1516 |
-
<div><div class="alt-lbl">Better Alternative</div>
|
| 1517 |
-
<div class="alt-text">${escHtml(d.better_alternative)}</div></div>
|
| 1518 |
-
</div></div>`;
|
| 1519 |
-
}
|
| 1520 |
-
|
| 1521 |
-
// 9. Deblur info
|
| 1522 |
-
if (d.blur_info?.deblurred && d.blur_info?.image_b64) {
|
| 1523 |
-
h += `<div class="r-section"><div class="r-title">Enhanced Image</div>
|
| 1524 |
-
<div class="deblur-report-badge">🔧 Deblurred Image Used for Analysis</div>
|
| 1525 |
-
<div class="deblur-img-wrap"><img src="${d.blur_info.image_b64}" alt="Enhanced"></div>
|
| 1526 |
-
<div style="font-size:0.72rem;color:var(--mist)">Pipeline: ${escHtml(d.blur_info.method_log||'')}</div>
|
| 1527 |
-
</div>`;
|
| 1528 |
-
}
|
| 1529 |
-
|
| 1530 |
-
return h;
|
| 1531 |
-
}
|
| 1532 |
-
|
| 1533 |
-
function escHtml(str) {
|
| 1534 |
-
if (str == null) return '';
|
| 1535 |
-
return String(str).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
| 1536 |
-
}
|
| 1537 |
-
function closeReport() {
|
| 1538 |
-
document.getElementById('report').classList.remove('open');
|
| 1539 |
-
document.getElementById('report-share-bar').classList.remove('visible');
|
| 1540 |
-
document.querySelector('#report .report-scroll').scrollTop = 0;
|
| 1541 |
-
}
|
| 1542 |
-
|
| 1543 |
-
// ═══════════════════════════════════════════════════
|
| 1544 |
-
// HISTORY
|
| 1545 |
-
// ═══════════════════════════════════════════════════
|
| 1546 |
-
function addToHistory(data) {
|
| 1547 |
-
if (!saveHistory) return;
|
| 1548 |
-
const item = { id: Date.now(), date: new Date().toLocaleDateString(), lang: currentLang, data };
|
| 1549 |
-
scanHistory.unshift(item);
|
| 1550 |
-
if (scanHistory.length > 30) scanHistory.pop();
|
| 1551 |
-
try { localStorage.setItem('eatlytic_v3', JSON.stringify(scanHistory)); } catch {}
|
| 1552 |
-
}
|
| 1553 |
-
function renderHistory() {
|
| 1554 |
-
const div = document.getElementById('history-list');
|
| 1555 |
-
if (!scanHistory.length) {
|
| 1556 |
-
div.innerHTML = `<div class="history-empty"><i class="fas fa-history"></i>No scans yet.<br>Go to Home and scan a label to get started.</div>`;
|
| 1557 |
-
return;
|
| 1558 |
-
}
|
| 1559 |
-
div.innerHTML = scanHistory.map(item => {
|
| 1560 |
-
const sc = item.data.score ?? 0;
|
| 1561 |
-
const col = sc>=7?'#2D7A4F':sc>=4?'#B07D22':'#C94B1E';
|
| 1562 |
-
const bg = sc>=7?'#ECFDF5':sc>=4?'#FFFBEB':'#FEF2F2';
|
| 1563 |
-
return `<div class="history-card" onclick="loadScan(${item.id})">
|
| 1564 |
-
<div class="h-score-ring" style="background:${bg};color:${col}">${sc}</div>
|
| 1565 |
-
<div style="flex:1">
|
| 1566 |
-
<div class="h-name">${escHtml(item.data.product_name||'Unknown')}</div>
|
| 1567 |
-
<div class="h-meta">${escHtml(item.data.verdict||'')} · ${item.date}</div>
|
| 1568 |
-
</div>
|
| 1569 |
-
<i class="fas fa-trash h-del" onclick="deleteScan(${item.id},event)"></i>
|
| 1570 |
-
</div>`;
|
| 1571 |
-
}).join('') +
|
| 1572 |
-
(scanHistory.length>1?`<button class="history-clear-btn" onclick="clearAllHistory()">🗑 Clear All History</button>`:'');
|
| 1573 |
-
}
|
| 1574 |
-
function loadScan(id) {
|
| 1575 |
-
const item = scanHistory.find(i=>i.id===id);
|
| 1576 |
-
if (!item) return;
|
| 1577 |
-
lastResult = item.data;
|
| 1578 |
-
switchTab('home');
|
| 1579 |
-
renderReport(item.data);
|
| 1580 |
-
}
|
| 1581 |
-
function deleteScan(id, e) {
|
| 1582 |
-
e.stopPropagation();
|
| 1583 |
-
scanHistory = scanHistory.filter(i=>i.id!==id);
|
| 1584 |
-
try { localStorage.setItem('eatlytic_v3', JSON.stringify(scanHistory)); } catch {}
|
| 1585 |
-
renderHistory();
|
| 1586 |
-
}
|
| 1587 |
-
function clearAllHistory() {
|
| 1588 |
-
if (!confirm('Delete all scan history?')) return;
|
| 1589 |
-
scanHistory = [];
|
| 1590 |
-
try { localStorage.removeItem('eatlytic_v3'); } catch {}
|
| 1591 |
-
renderHistory();
|
| 1592 |
-
updateProfileStats();
|
| 1593 |
-
}
|
| 1594 |
-
|
| 1595 |
-
// ═══════════════════════════════════════════════════
|
| 1596 |
-
// PROFILE
|
| 1597 |
-
// ═══════════════════════════════════════════════════
|
| 1598 |
-
function updateProfileStats() {
|
| 1599 |
-
document.getElementById('stat-scans').textContent = scanHistory.length;
|
| 1600 |
-
const scores = scanHistory.map(i=>i.data.score).filter(s=>s!=null);
|
| 1601 |
-
document.getElementById('stat-avg').textContent = scores.length ? Math.round(scores.reduce((a,b)=>a+b,0)/scores.length) : '—';
|
| 1602 |
-
document.getElementById('stat-best').textContent = scores.length ? Math.max(...scores) : '—';
|
| 1603 |
-
document.getElementById('pref-lang-val').textContent = LANG_NAMES[currentLang] || 'English';
|
| 1604 |
-
document.getElementById('pref-persona-val').textContent = currentPersona;
|
| 1605 |
-
document.getElementById('pref-persona-sel').value = currentPersona;
|
| 1606 |
-
document.getElementById('prof-sub').textContent = `${currentPersona} · ${LANG_NAMES[currentLang]||'English'}`;
|
| 1607 |
-
document.getElementById('history-toggle').className = 'toggle-switch ' + (saveHistory?'on':'');
|
| 1608 |
-
updateStreakUI();
|
| 1609 |
-
}
|
| 1610 |
-
function savePersonaPref(val) {
|
| 1611 |
-
currentPersona = val;
|
| 1612 |
-
document.querySelectorAll('#persona-row .chip').forEach(c => { c.classList.toggle('active', c.textContent.includes(val)); });
|
| 1613 |
-
localStorage.setItem('eatlytic_persona', val);
|
| 1614 |
-
updateProfileStats();
|
| 1615 |
-
}
|
| 1616 |
-
function toggleHistorySave() {
|
| 1617 |
-
saveHistory = !saveHistory;
|
| 1618 |
-
try { localStorage.setItem('eatlytic_save_hist', JSON.stringify(saveHistory)); } catch {}
|
| 1619 |
-
updateProfileStats();
|
| 1620 |
-
}
|
| 1621 |
-
|
| 1622 |
-
// ═══════════════════════════════════════════════════
|
| 1623 |
-
// LANGUAGE
|
| 1624 |
-
// ═══════════════════════════════════════════════════
|
| 1625 |
-
function openLang() { document.getElementById('lang-modal').classList.add('open'); }
|
| 1626 |
-
function closeLangBackdrop(e) {
|
| 1627 |
-
if (e.target.classList.contains('lang-backdrop')||e.target.id==='lang-modal')
|
| 1628 |
-
document.getElementById('lang-modal').classList.remove('open');
|
| 1629 |
-
}
|
| 1630 |
-
function renderLangOptions() {
|
| 1631 |
-
document.getElementById('lang-options').innerHTML = LANGUAGES.map(l=>`
|
| 1632 |
-
<div class="lang-option ${l.code===currentLang?'active':''}" onclick="setLang('${l.code}')">
|
| 1633 |
-
<span class="lang-flag">${l.flag}</span><span>${l.label}</span>
|
| 1634 |
-
</div>`).join('');
|
| 1635 |
-
}
|
| 1636 |
-
function setLang(code, save=true) {
|
| 1637 |
-
currentLang = code;
|
| 1638 |
-
document.getElementById('lang-display').textContent = code.toUpperCase();
|
| 1639 |
-
document.getElementById('lang-modal').classList.remove('open');
|
| 1640 |
-
if (save) try { localStorage.setItem('eatlytic_lang', code); } catch {}
|
| 1641 |
-
renderLangOptions();
|
| 1642 |
-
updateProfileStats();
|
| 1643 |
-
}
|
| 1644 |
-
|
| 1645 |
-
// ═══════════════════════════════════════════════════
|
| 1646 |
-
// SHARE
|
| 1647 |
-
// ═══════════════════════════════════════════════════
|
| 1648 |
-
async function shareReport() {
|
| 1649 |
-
if (!lastResult) return;
|
| 1650 |
-
try {
|
| 1651 |
-
const resp = await fetch(`${API}/share-card`, {
|
| 1652 |
-
method: 'POST',
|
| 1653 |
-
headers: { 'Content-Type': 'application/json' },
|
| 1654 |
-
body: JSON.stringify({ ...lastResult, persona: currentPersona })
|
| 1655 |
-
});
|
| 1656 |
-
if (resp.ok) {
|
| 1657 |
-
const { card } = await resp.json();
|
| 1658 |
-
if (navigator.share) {
|
| 1659 |
-
await navigator.share({ title: 'Eatlytic Food Report', text: card });
|
| 1660 |
-
} else {
|
| 1661 |
-
await navigator.clipboard.writeText(card);
|
| 1662 |
-
showToast('📋 Report copied to clipboard!');
|
| 1663 |
-
}
|
| 1664 |
-
return;
|
| 1665 |
-
}
|
| 1666 |
-
} catch { /* fallback below */ }
|
| 1667 |
-
const text = `🌿 Eatlytic Food Report\n\n${lastResult.product_name}\nScore: ${lastResult.score}/10 — ${lastResult.verdict}\n\n${lastResult.summary}`;
|
| 1668 |
-
try {
|
| 1669 |
-
if (navigator.share) await navigator.share({ title:'Eatlytic Report', text });
|
| 1670 |
-
else { await navigator.clipboard.writeText(text); showToast('📋 Copied to clipboard!'); }
|
| 1671 |
-
} catch { showToast('📋 Report copied!'); }
|
| 1672 |
-
}
|
| 1673 |
-
|
| 1674 |
-
function showToast(msg='✅ Done!') {
|
| 1675 |
-
const t = document.getElementById('toast');
|
| 1676 |
-
t.textContent = msg;
|
| 1677 |
-
t.classList.add('show');
|
| 1678 |
-
setTimeout(()=>t.classList.remove('show'), 2800);
|
| 1679 |
-
}
|
| 1680 |
-
</script>
|
| 1681 |
-
</body>
|
| 1682 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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