Update index.html
Browse files- index.html +143 -119
index.html
CHANGED
|
@@ -1,129 +1,153 @@
|
|
| 1 |
-
<!
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
-
<meta charset="
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
-
<
|
| 7 |
-
<meta name="theme-color" content="#0c0c0d">
|
| 8 |
-
<title>Pure Body Transformation — Stop Starting Again</title>
|
| 9 |
<style>
|
| 10 |
-
:root{
|
| 11 |
-
--
|
| 12 |
-
--
|
| 13 |
-
--
|
| 14 |
-
--
|
|
|
|
|
|
|
|
|
|
| 15 |
}
|
| 16 |
-
*{box-sizing:border-box
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
.
|
| 20 |
-
.
|
| 21 |
-
|
| 22 |
-
.
|
| 23 |
-
.
|
| 24 |
-
.
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
.path{background:var(--paper)}.path-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:15px;margin-top:44px}.path-card{border:1px solid var(--line);background:#fff;padding:25px;border-radius:20px}.path-card.featured{background:var(--ink);border-color:var(--ink);color:#fff}.path-card .round{width:33px;height:33px;display:grid;place-items:center;border-radius:50%;background:var(--red-soft);color:var(--red);font-size:12px;font-weight:950}.path-card.featured .round{background:var(--lime);color:#111}.path-card h3{font-size:24px;letter-spacing:-.06em;margin:34px 0 9px;line-height:1}.path-card p{font-size:13px;color:var(--muted);margin:0}.path-card.featured p{color:#cac5c3}.path-line{margin-top:31px;border-top:1px dashed #cfcac6;position:relative;height:1px}.path-line:before{content:"";position:absolute;top:-4px;left:0;width:7px;height:7px;border-radius:50%;background:var(--red)}.path-card .mini-link{display:inline-flex;color:var(--red);font-size:12px;font-weight:900;margin-top:22px}.path-card.featured .mini-link{color:var(--lime)}
|
| 31 |
-
.programme{background:#eae7e2}.programme-grid{margin-top:43px;display:grid;grid-template-columns:1fr 1.05fr;gap:18px;align-items:stretch}.plan{border:1px solid var(--line);border-radius:26px;padding:30px;background:#fff;display:flex;flex-direction:column}.plan.hot{background:var(--ink);border-color:var(--ink);color:#fff;box-shadow:var(--shadow);position:relative}.plan-top{display:flex;justify-content:space-between;align-items:center;gap:10px}.plan-label{font-size:10px;letter-spacing:.13em;text-transform:uppercase;color:var(--red);font-weight:950}.plan.hot .plan-label{color:#ff9ba4}.popular{background:var(--lime);padding:6px 10px;border-radius:99px;color:#111;font-size:10px;font-weight:950;text-transform:uppercase}.plan h3{font-size:38px;letter-spacing:-.07em;line-height:1;margin:26px 0 10px}.plan .intro{font-size:14px;color:var(--muted);max-width:410px}.plan.hot .intro{color:#d3cecb}.price{font-size:38px;line-height:1;font-weight:950;letter-spacing:-.07em;margin:25px 0 3px}.price small{font-size:14px;font-weight:800;letter-spacing:0}.price-note{font-size:11px;color:var(--muted);margin-bottom:21px}.plan.hot .price-note{color:#a8a29f}.plan ul{list-style:none;padding:0;margin:0 0 24px;display:grid;gap:11px;flex:1}.plan li{font-size:13px;padding-left:23px;position:relative}.plan li:before{content:"✓";position:absolute;left:0;color:var(--red);font-weight:950}.plan.hot li:before{color:var(--lime)}.plan .btn{width:100%}
|
| 32 |
-
.about{background:#fff}.about-grid{display:grid;grid-template-columns:.9fr 1.1fr;gap:74px;align-items:center}.about-mark{min-height:420px;border-radius:30px;background:var(--ink);position:relative;overflow:hidden;display:flex;align-items:flex-end;padding:34px}.about-mark:before{content:"PBT";font-size:135px;letter-spacing:-.16em;color:var(--red);line-height:1;font-weight:950;position:absolute;left:0;top:64px}.about-mark:after{content:"";position:absolute;width:385px;height:385px;border:1px solid rgba(255,255,255,.28);border-radius:50%;left:-112px;top:-100px}.about-mark span{position:relative;color:#fff;font-size:24px;line-height:1.08;letter-spacing:-.05em;font-weight:900;max-width:220px}.about-mark i{position:absolute;right:35px;bottom:36px;width:74px;height:74px;border-radius:50%;background:var(--lime);display:grid;place-items:center;color:#111;font-size:32px;font-style:normal}.about-copy p{color:var(--muted);font-size:15px;max-width:580px}.credentials{display:flex;flex-wrap:wrap;gap:8px;margin-top:25px}.credential{font-size:11px;font-weight:800;background:var(--cloud);border-radius:99px;padding:9px 12px}
|
| 33 |
-
.faq-section{background:var(--cloud)}.faq-grid{display:grid;grid-template-columns:.74fr 1.26fr;gap:70px}.faq-list{border-top:1px solid var(--line)}.faq-item{border-bottom:1px solid var(--line)}.faq-q{background:transparent;border:0;width:100%;padding:21px 0;display:flex;text-align:left;align-items:center;justify-content:space-between;gap:25px;color:var(--ink);font-size:16px;font-weight:850}.faq-q span:last-child{font-size:25px;font-weight:400;color:var(--red);transition:transform .2s}.faq-a{display:grid;grid-template-rows:0fr;transition:grid-template-rows .25s}.faq-a>div{overflow:hidden}.faq-a p{color:var(--muted);font-size:14px;line-height:1.6;margin:0 0 20px;max-width:600px}.faq-item.open .faq-a{grid-template-rows:1fr}.faq-item.open .faq-q span:last-child{transform:rotate(45deg)}
|
| 34 |
-
.final{padding:80px 0;background:var(--paper)}.final-box{border-radius:32px;background:linear-gradient(130deg,#0c0c0d,#222022);color:#fff;padding:55px 6%;position:relative;overflow:hidden;text-align:center}.final-box:after{content:"";position:absolute;top:-195px;right:-120px;width:430px;height:430px;border-radius:50%;border:60px solid rgba(237,38,57,.55)}.final-box>*{position:relative;z-index:1}.final-box .section-kicker{color:#ffa8b0}.final-box .section-title{max-width:700px;margin-left:auto;margin-right:auto}.final-box p{max-width:590px;margin:0 auto;color:#d9d4d1}.form-grid{max-width:680px;margin:30px auto 0;display:grid;grid-template-columns:1fr 1fr auto;gap:9px}.form-grid input{border:1px solid transparent;border-radius:99px;min-width:0;padding:0 17px;height:48px;outline:none;color:#111}.form-grid input:focus{border-color:var(--red);box-shadow:0 0 0 3px rgba(237,38,57,.2)}.form-grid .btn{height:48px}.form-note{font-size:11px;color:#a7a19e;margin-top:14px}.footer{background:#080809;color:#aaa;padding:30px 0}.footer .wrap{display:flex;align-items:center;justify-content:space-between;gap:20px}.footer .brand{color:#fff}.footer p{font-size:11px;margin:0;text-align:right}
|
| 35 |
-
.modal{display:none;position:fixed;z-index:100;inset:0;padding:20px;background:rgba(6,6,7,.72);backdrop-filter:blur(9px)}.modal.open{display:flex;align-items:center;justify-content:center}.modal-box{width:min(980px,100%);height:min(890px,calc(100dvh - 40px));position:relative;border-radius:24px;overflow:hidden;background:#fff;box-shadow:0 32px 100px rgba(0,0,0,.4)}.modal-top{height:55px;display:flex;align-items:center;justify-content:space-between;padding:0 15px 0 22px;background:#111;color:#fff}.modal-title{font-size:12px;font-weight:850;letter-spacing:.08em;text-transform:uppercase}.modal-close{border:0;border-radius:50%;background:#fff;color:#111;width:33px;height:33px;font-size:22px;line-height:1}.modal iframe{width:100%;height:calc(100% - 55px);border:0;display:block;background:#fff}.toast{visibility:hidden;opacity:0;position:fixed;z-index:300;left:50%;bottom:92px;transform:translate(-50%,15px);background:#fff;color:#151515;padding:14px 18px;border-radius:13px;box-shadow:var(--shadow);font-size:13px;font-weight:750;transition:.25s}.toast.show{visibility:visible;opacity:1;transform:translate(-50%,0)}
|
| 36 |
-
.reveal{opacity:0;transform:translateY(18px);transition:opacity .55s ease,transform .55s ease}.reveal.visible{opacity:1;transform:none}@keyframes float{50%{transform:translateY(-10px)}}@keyframes spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}*,*:before,*:after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}
|
| 37 |
-
@media(max-width:980px){.nav-links>a:not(.btn){display:none}.hero-grid,.intro-grid,.about-grid,.faq-grid{grid-template-columns:1fr;gap:35px}.hero-grid{padding:64px 0 70px}.hero-visual{max-width:600px;width:100%;justify-self:center;min-height:440px}.trust-strip .wrap{grid-template-columns:repeat(3,1fr)}.trust-heading{grid-column:1/-1;text-align:center}.system-grid{grid-template-columns:repeat(2,1fr)}.results-grid{grid-template-columns:1fr;gap:30px}.results-aside{display:grid;grid-template-columns:1fr auto;gap:20px;align-items:end}.results-aside .btn{margin:0}.about-grid{gap:44px}.about-mark{max-width:540px;min-height:320px}.about-mark:before{font-size:105px}.faq-grid{gap:25px}.tool-grid{gap:14px}.programme-grid{grid-template-columns:1fr 1fr}}
|
| 38 |
-
@media(max-width:650px){.wrap{width:min(100% - 34px,var(--wrap))}.topline{font-size:10px}.nav{height:64px}.menu-button{display:block}.nav-links{display:none}.brand{font-size:14px}.hero-grid{padding:48px 0 55px}.hero h1{font-size:48px}.hero-copy{font-size:16px}.hero-actions{display:grid;grid-template-columns:1fr;margin-top:27px}.hero-actions .btn{width:100%}.hero-visual{min-height:350px;margin-top:10px}.hero-photo{inset:25px 7% 0 13%}.trust-strip .wrap{grid-template-columns:1fr 1fr;gap:18px}.stat{border-left:0;padding-left:0}.stat b{font-size:19px}section{padding:74px 0}.section-title{font-size:39px}.intro-grid{gap:30px}.quote-card{padding:26px}.quote-card blockquote{font-size:26px}.system-grid{grid-template-columns:1fr 1fr;gap:9px;margin-top:31px}.system-card{min-height:215px;padding:16px}.system-card h3{font-size:19px;margin-top:33px}.system-card p{font-size:12px}.results-aside{display:block}.results-aside .btn{margin-top:23px}.tools-head{display:block}.tool-grid,.programme-grid,.path-grid{grid-template-columns:1fr}.tool-card{min-height:310px;padding:26px}.tool-card h3{font-size:27px}.path-grid{margin-top:31px}.path-card h3{margin-top:27px}.about-mark{min-height:280px}.about-mark:before{font-size:92px}.about-mark span{font-size:21px}.faq-q{font-size:15px}.final{padding:55px 0}.final-box{padding:42px 18px}.form-grid{grid-template-columns:1fr}.form-grid input{width:100%}.footer .wrap{display:block}.footer p{text-align:left;margin-top:16px}.modal{padding:8px}.modal-box{height:calc(100dvh - 16px);border-radius:16px}.modal-top{height:50px;padding-left:15px}.modal iframe{height:calc(100% - 50px)}.modal-title{font-size:10px}.toast{width:calc(100% - 34px);bottom:72px;text-align:center}.path-card.featured{order:-1}}
|
| 39 |
-
|
| 40 |
-
/* Image-first transformation treatment — no copy, gradients or labels ever sit over a before/after image. */
|
| 41 |
-
.hero-photo{border-radius:54px 54px 22px 22px;box-shadow:0 26px 65px rgba(0,0,0,.28);will-change:transform;transform:translate3d(0,var(--parallax,0px),0)}
|
| 42 |
-
.hero-photo:after{display:none}.hero-photo img{filter:none}
|
| 43 |
-
.gallery-shell{min-width:0}.result-gallery{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:15px;align-items:start}.gallery-column{display:grid;gap:15px;align-content:start}.gallery-tile{margin:0;overflow:hidden;border-radius:20px;background:#d9d6d2;box-shadow:0 14px 33px rgba(24,20,17,.11);will-change:transform;transform:translate3d(0,calc(var(--parallax,0px) + var(--hover-y,0px)),0);transition:transform .4s cubic-bezier(.2,.8,.2,1),box-shadow .4s ease}.gallery-tile:hover{--hover-y:-7px;box-shadow:0 22px 42px rgba(24,20,17,.17)}.gallery-tile img{width:100%;height:100%;object-fit:cover;border-radius:20px}.gallery-tile--portrait{height:345px}.gallery-tile--landscape{height:198px}.gallery-tile--square{height:255px}.gallery-tile--tall{height:405px}.gallery-tile--medium{height:280px}.results-disclaimer{max-width:580px}.results-gallery+ .results-disclaimer{margin-top:25px}
|
| 44 |
-
@media(max-width:980px){.result-gallery{max-width:690px}.gallery-tile--portrait{height:320px}.gallery-tile--landscape{height:185px}.gallery-tile--square{height:235px}.gallery-tile--tall{height:375px}.gallery-tile--medium{height:260px}}
|
| 45 |
-
@media(max-width:650px){.hero-photo{border-radius:40px 40px 18px 18px}.result-gallery{gap:9px}.gallery-column{gap:9px}.gallery-tile,.gallery-tile img{border-radius:15px}.gallery-tile--portrait{height:210px}.gallery-tile--landscape{height:120px}.gallery-tile--square{height:157px}.gallery-tile--tall{height:248px}.gallery-tile--medium{height:176px}}
|
| 46 |
</style>
|
| 47 |
</head>
|
| 48 |
<body>
|
| 49 |
-
<
|
| 50 |
-
<div
|
| 51 |
-
<div class="
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
<
|
| 56 |
-
<a class="btn btn-primary" href="#apply">Apply for a Fit Call <span class="arrow">→</span></a>
|
| 57 |
-
</div>
|
| 58 |
-
<button class="menu-button" id="menuButton" aria-label="Open menu" aria-expanded="false">☰</button>
|
| 59 |
-
</nav>
|
| 60 |
-
<div class="mobile-nav" id="mobileNav"><a href="#method">The Method</a><a href="#results">Results</a><a href="#tools">Free Tools</a><a href="#programmes">Programmes</a><a class="btn btn-primary" href="#apply">Apply for a Fit Call <span class="arrow">→</span></a></div>
|
| 61 |
-
</div>
|
| 62 |
-
<main id="main">
|
| 63 |
-
<header class="hero" id="top">
|
| 64 |
-
<div class="wrap hero-grid">
|
| 65 |
-
<div class="reveal">
|
| 66 |
-
<div class="eyebrow">For men & women ready for lasting change</div>
|
| 67 |
-
<h1>Stop starting <em>again.</em></h1>
|
| 68 |
-
<p class="hero-copy">Lose weight, get stronger and build a system that still works when work, weekends and real life get in the way.</p>
|
| 69 |
-
<div class="hero-actions"><a class="btn btn-primary" href="#apply">Apply for a PBT Fit Call <span class="arrow">→</span></a><a class="btn btn-outline" href="#method">See how it works</a></div>
|
| 70 |
-
<div class="hero-note">No pressure. An application does not commit you to joining.</div>
|
| 71 |
-
<div class="hero-proof"><div class="avatars"><span>J</span><span>S</span><span>M</span><span>+</span></div><div><b>Built around real lives, not perfect weeks.</b>Personal coaching. Practical systems. Sustainable change.</div></div>
|
| 72 |
-
</div>
|
| 73 |
-
<div class="hero-visual reveal" aria-label="PBT client transformation">
|
| 74 |
-
<div class="red-orbit"></div>
|
| 75 |
-
<div class="hero-photo parallax-item" data-speed="-0.025"><img src="assets/client-1.jpg" alt="PBT client before and after progress" fetchpriority="high"></div>
|
| 76 |
-
</div>
|
| 77 |
</div>
|
| 78 |
</header>
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
<
|
| 88 |
-
|
| 89 |
-
<
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
</body>
|
| 129 |
-
</html>
|
|
|
|
| 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" />
|
| 6 |
+
<title>OpenCode Zen - DeepSeek Chat</title>
|
|
|
|
|
|
|
| 7 |
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--bg-primary: #0f172a;
|
| 10 |
+
--bg-secondary: #1e293b;
|
| 11 |
+
--bg-bubble-ai: #273549;
|
| 12 |
+
--bg-bubble-user: #2563eb;
|
| 13 |
+
--text-main: #f8fafc;
|
| 14 |
+
--border-color: #334155;
|
| 15 |
+
--accent: #38bdf8;
|
| 16 |
}
|
| 17 |
+
* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, sans-serif; }
|
| 18 |
+
body { background-color: var(--bg-primary); color: var(--text-main); display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
|
| 19 |
+
header { background-color: var(--bg-secondary); border-bottom: 1px solid var(--border-color); padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
|
| 20 |
+
.config-group { display: flex; gap: 10px; align-items: center; font-size: 13px; }
|
| 21 |
+
.config-group input { background: var(--bg-primary); border: 1px solid var(--border-color); color: var(--text-main); padding: 6px 10px; border-radius: 6px; font-size: 13px; outline: none; }
|
| 22 |
+
#chat-window { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
|
| 23 |
+
.message { max-width: 80%; line-height: 1.5; padding: 12px 16px; border-radius: 12px; word-break: break-word; white-space: pre-wrap; }
|
| 24 |
+
.user-msg { background-color: var(--bg-bubble-user); align-self: flex-end; border-bottom-right-radius: 2px; }
|
| 25 |
+
.ai-msg { background-color: var(--bg-bubble-ai); align-self: flex-start; border-bottom-left-radius: 2px; border: 1px solid var(--border-color); }
|
| 26 |
+
.error-msg { background-color: #7f1d1d; color: #fecaca; align-self: center; font-size: 13px; }
|
| 27 |
+
#input-container { background-color: var(--bg-secondary); border-top: 1px solid var(--border-color); padding: 16px 20px; display: flex; gap: 12px; }
|
| 28 |
+
textarea { flex: 1; background: var(--bg-primary); color: var(--text-main); border: 1px solid var(--border-color); border-radius: 8px; padding: 10px 14px; resize: none; height: 50px; outline: none; font-size: 14px; }
|
| 29 |
+
button { background: var(--accent); color: #0f172a; border: none; font-weight: 600; padding: 0 20px; border-radius: 8px; cursor: pointer; }
|
| 30 |
+
button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
</style>
|
| 32 |
</head>
|
| 33 |
<body>
|
| 34 |
+
<header>
|
| 35 |
+
<div><strong>OpenCode Zen Chat</strong></div>
|
| 36 |
+
<div class="config-group">
|
| 37 |
+
<label>Model:</label>
|
| 38 |
+
<input type="text" id="model-input" value="deepseek-v4.1-flash-free" style="width: 220px;" />
|
| 39 |
+
<label>API Key:</label>
|
| 40 |
+
<input type="password" id="api-key" value="oc_sk_35b87025c3e1_wYnXQAjQFh5SahiJknEk7MRQdW3q7RaL" style="width: 170px;" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
</div>
|
| 42 |
</header>
|
| 43 |
+
|
| 44 |
+
<div id="chat-window">
|
| 45 |
+
<div class="message ai-msg">Connected to local proxy. Type a message to begin!</div>
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
<div id="input-container">
|
| 49 |
+
<textarea id="prompt-input" placeholder="Type your message... (Shift + Enter for new line)"></textarea>
|
| 50 |
+
<button id="send-btn" onclick="sendMessage()">Send</button>
|
| 51 |
+
</div>
|
| 52 |
+
|
| 53 |
+
<script>
|
| 54 |
+
const chatWindow = document.getElementById("chat-window");
|
| 55 |
+
const promptInput = document.getElementById("prompt-input");
|
| 56 |
+
const sendBtn = document.getElementById("send-btn");
|
| 57 |
+
const apiKeyInput = document.getElementById("api-key");
|
| 58 |
+
const modelInput = document.getElementById("model-input");
|
| 59 |
+
|
| 60 |
+
let messages = [{ role: "system", content: "You are a helpful coding and AI assistant." }];
|
| 61 |
+
|
| 62 |
+
promptInput.addEventListener("keydown", (e) => {
|
| 63 |
+
if (e.key === "Enter" && !e.shiftKey) {
|
| 64 |
+
e.preventDefault();
|
| 65 |
+
sendMessage();
|
| 66 |
+
}
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
function appendMessage(role, text) {
|
| 70 |
+
const msg = document.createElement("div");
|
| 71 |
+
msg.className = `message ${role === "user" ? "user-msg" : "ai-msg"}`;
|
| 72 |
+
msg.textContent = text;
|
| 73 |
+
chatWindow.appendChild(msg);
|
| 74 |
+
chatWindow.scrollTop = chatWindow.scrollHeight;
|
| 75 |
+
return msg;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
async function sendMessage() {
|
| 79 |
+
const text = promptInput.value.trim();
|
| 80 |
+
const apiKey = apiKeyInput.value.trim();
|
| 81 |
+
const model = modelInput.value.trim();
|
| 82 |
+
|
| 83 |
+
if (!text || !apiKey) return;
|
| 84 |
+
|
| 85 |
+
appendMessage("user", text);
|
| 86 |
+
messages.push({ role: "user", content: text });
|
| 87 |
+
promptInput.value = "";
|
| 88 |
+
|
| 89 |
+
const aiBubble = appendMessage("assistant", "...");
|
| 90 |
+
sendBtn.disabled = true;
|
| 91 |
+
|
| 92 |
+
try {
|
| 93 |
+
// Points to our local server proxy endpoint
|
| 94 |
+
const response = await fetch("/api/chat", {
|
| 95 |
+
method: "POST",
|
| 96 |
+
headers: {
|
| 97 |
+
"Content-Type": "application/json",
|
| 98 |
+
"Authorization": `Bearer ${apiKey}`
|
| 99 |
+
},
|
| 100 |
+
body: JSON.stringify({
|
| 101 |
+
model: model,
|
| 102 |
+
messages: messages,
|
| 103 |
+
stream: true
|
| 104 |
+
})
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
if (!response.ok) {
|
| 108 |
+
const err = await response.json().catch(() => ({}));
|
| 109 |
+
throw new Error(err.error?.message || `HTTP ${response.status}: ${response.statusText}`);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
aiBubble.textContent = "";
|
| 113 |
+
const reader = response.body.getReader();
|
| 114 |
+
const decoder = new TextDecoder();
|
| 115 |
+
let assistantReply = "";
|
| 116 |
+
let buffer = "";
|
| 117 |
+
|
| 118 |
+
while (true) {
|
| 119 |
+
const { done, value } = await reader.read();
|
| 120 |
+
if (done) break;
|
| 121 |
+
|
| 122 |
+
buffer += decoder.decode(value, { stream: true });
|
| 123 |
+
const lines = buffer.split("\n");
|
| 124 |
+
buffer = lines.pop();
|
| 125 |
+
|
| 126 |
+
for (const line of lines) {
|
| 127 |
+
const trimmed = line.trim();
|
| 128 |
+
if (!trimmed || trimmed.startsWith(":")) continue;
|
| 129 |
+
if (trimmed === "data: [DONE]") break;
|
| 130 |
+
if (trimmed.startsWith("data: ")) {
|
| 131 |
+
try {
|
| 132 |
+
const parsed = JSON.parse(trimmed.replace(/^data:\s*/, ""));
|
| 133 |
+
const delta = parsed.choices?.[0]?.delta?.content || "";
|
| 134 |
+
assistantReply += delta;
|
| 135 |
+
aiBubble.textContent = assistantReply;
|
| 136 |
+
chatWindow.scrollTop = chatWindow.scrollHeight;
|
| 137 |
+
} catch (_) {}
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
messages.push({ role: "assistant", content: assistantReply });
|
| 143 |
+
} catch (err) {
|
| 144 |
+
aiBubble.className = "message error-msg";
|
| 145 |
+
aiBubble.textContent = "Error: " + err.message;
|
| 146 |
+
} finally {
|
| 147 |
+
sendBtn.disabled = false;
|
| 148 |
+
promptInput.focus();
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
</script>
|
| 152 |
</body>
|
| 153 |
+
</html>
|