shailens commited on
Commit
dbb8aa7
·
1 Parent(s): 790638a

Landing: swap "Get API key" for "Go to demos" once the key validates

Browse files

Progressive-enhancement script in index.html. When #key-status reaches
data-state="ok" (key validated for decisions+chat), hide the "Get API key"
link and show a "Go to demos" button that smooth-scrolls to #demos-title.
Reverts if the key is forgotten or invalid. No-op without JS; does not touch
the built bundle.

Files changed (1) hide show
  1. landing/index.html +55 -0
landing/index.html CHANGED
@@ -31,5 +31,60 @@
31
  </head>
32
  <body>
33
  <div id="root"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  </body>
35
  </html>
 
31
  </head>
32
  <body>
33
  <div id="root"></div>
34
+ <script>
35
+ // Progressive enhancement: once the API key validates (#key-status[data-state="ok"]),
36
+ // the "Get API key" link has done its job, so swap it for a "Go to demos" button that
37
+ // smooth-scrolls to the live demos section. Reverts if the key is forgotten / invalid.
38
+ // Pure DOM add-on over the built bundle; no behaviour changes when JS is disabled.
39
+ (function () {
40
+ var KEY_HREF = "https://app.vllm-sr.ai/#key";
41
+ var jump = null;
42
+ function keyLink() { return document.querySelector('a[href^="' + KEY_HREF + '"]'); }
43
+ function keyOk() {
44
+ var k = document.getElementById("key-status");
45
+ return !!k && k.getAttribute("data-state") === "ok";
46
+ }
47
+ function ensureJump(link) {
48
+ if (jump && jump.isConnected) return jump;
49
+ jump = document.createElement("a");
50
+ jump.id = "go-to-demos-link";
51
+ jump.className = link.className; // match the key link's styling exactly
52
+ jump.href = "#demos-title";
53
+ jump.style.display = "none";
54
+ jump.innerHTML =
55
+ '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"' +
56
+ ' fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round"' +
57
+ ' stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14"/><path d="m19 12-7 7-7-7"/></svg>' +
58
+ " Go to demos";
59
+ jump.addEventListener("click", function (e) {
60
+ e.preventDefault();
61
+ var t = document.getElementById("demos-title") || document.getElementById("demo-receipt");
62
+ if (t) t.scrollIntoView({ behavior: "smooth", block: "start" });
63
+ });
64
+ link.parentNode.insertBefore(jump, link.nextSibling);
65
+ return jump;
66
+ }
67
+ function apply() {
68
+ var link = keyLink();
69
+ if (!link) return;
70
+ var j = ensureJump(link), on = keyOk();
71
+ link.style.display = on ? "none" : "";
72
+ j.style.display = on ? "" : "none";
73
+ }
74
+ function start() {
75
+ var obs = new MutationObserver(apply);
76
+ obs.observe(document.body, {
77
+ subtree: true, childList: true,
78
+ attributes: true, attributeFilter: ["data-state"]
79
+ });
80
+ apply();
81
+ }
82
+ if (document.readyState === "loading") {
83
+ document.addEventListener("DOMContentLoaded", start);
84
+ } else {
85
+ start();
86
+ }
87
+ })();
88
+ </script>
89
  </body>
90
  </html>