generated from ultralytics/template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Multi-page demo #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
glenn-jocher
wants to merge
1
commit into
main
Choose a base branch
from
mult-page-demo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+576
−398
Open
Multi-page demo #53
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| <!-- Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license --> | ||
|
|
||
| <html lang="en" data-theme="light"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta | ||
| name="viewport" | ||
| content="width=device-width, initial-scale=1.0, viewport-fit=cover, interactive-widget=overlays-content" | ||
| /> | ||
| <meta name="apple-mobile-web-app-capable" content="yes" /> | ||
| <meta name="apple-mobile-web-app-status-bar-style" content="default" /> | ||
| <meta name="mobile-web-app-capable" content="yes" /> | ||
| <meta name="format-detection" content="telephone=no, address=no, email=no" /> | ||
| <meta | ||
| name="description" | ||
| content="Ultralytics Chat Widget Multi-Page Demo - keep the chat pill visible across navigations" | ||
| /> | ||
| <meta name="color-scheme" content="light dark" /> | ||
| <meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)" /> | ||
| <meta name="theme-color" content="#0a0a0b" media="(prefers-color-scheme: dark)" /> | ||
| <title>Ultralytics Chat — Multi-Page Demo</title> | ||
| <link | ||
| rel="icon" | ||
| type="image/png" | ||
| href="https://raw.githubusercontent.com/ultralytics/assets/refs/heads/main/logo/favicon-yolo.png" | ||
| /> | ||
| <link rel="stylesheet" href="demo.css" /> | ||
| </head> | ||
| <body> | ||
| <!-- Top bar --> | ||
| <header class="topbar"> | ||
| <div class="topbar-inner"> | ||
| <div class="brand"> | ||
| <a href="https://www.ultralytics.com" target="_blank" rel="noopener"> | ||
| <img | ||
| src="https://cdn.prod.website-files.com/680a070c3b99253410dd3dcf/68e4eb1e9893320b26cc02c3_Ultralytics%20Logo.png.svg" | ||
| alt="Ultralytics" | ||
| loading="lazy" | ||
| decoding="async" | ||
| /> | ||
| </a> | ||
| </div> | ||
| <div class="toolbar"> | ||
| <a class="btn primary" href="demo.html">Single-page demo</a> | ||
| </div> | ||
| </div> | ||
| </header> | ||
|
|
||
| <main class="page"> | ||
| <aside class="sidebar" aria-label="Multi-page navigation"> | ||
| <div class="nav-title">Jump between pages</div> | ||
| <ul class="nav"> | ||
| <li><a href="demo-multi.html">Multi-page demo (you are here)</a></li> | ||
| <li><a href="demo.html">Original demo</a></li> | ||
| </ul> | ||
| </aside> | ||
| <section class="content"> | ||
| <div class="hero" id="intro"> | ||
| <h1>Multi-page navigation test</h1> | ||
| <p class="lead"> | ||
| Navigate between this page and the original demo while the chat pill remains visible. This shows how the | ||
| widget survives DOM swaps. | ||
| </p> | ||
| <div class="toolbar"> | ||
| <button class="btn" onclick="openChat()" aria-label="Open chat">Open Chat</button> | ||
| <span class="btn" style="pointer-events: none; opacity: 0.72">Press ⌘ + K to open</span> | ||
| <a class="btn primary" href="demo.html">Back to single-page demo</a> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="card"> | ||
| <h3>Multi-page steps</h3> | ||
| <ol> | ||
| <li>Open the chat with the <strong>Open Chat</strong> button.</li> | ||
| <li>Switch to <a href="demo.html">the original demo</a> (same domain, different page).</li> | ||
| <li>Watch for the pill/modal—they should stay visible without rebuilding the DOM elements.</li> | ||
| <li> | ||
| Go back to this page and open the chat again to confirm the session persisted via | ||
| <code>localStorage</code>. | ||
| </li> | ||
| </ol> | ||
| </div> | ||
|
|
||
| <div class="card"> | ||
| <h3>Why this demo exists</h3> | ||
| <p> | ||
| Some frameworks replace the <code><body></code> and <code><head></code> on each navigation. The | ||
| chat widget now marks its elements as permanent and watches for missing parents so the UI never flashes | ||
| away. | ||
| </p> | ||
| <p class="lead"> | ||
| Feel free to script rapid navigation between these pages to reproduce the bug you observed. | ||
| </p> | ||
| </div> | ||
| </section> | ||
| </main> | ||
|
|
||
| <footer class="footer"> | ||
| <span>Need help?</span> | ||
| <a href="#" onclick="openChat();return false;">Ask Ultralytics AI</a> | ||
| </footer> | ||
|
|
||
| <!-- Chat client --> | ||
| <script src="../../js/chat.js"></script> | ||
| <script> | ||
| let chatInstance; | ||
|
|
||
| function applySystemTheme() { | ||
| const dark = window.matchMedia("(prefers-color-scheme: dark)").matches; | ||
| const theme = dark ? "dark" : "light"; | ||
| document.documentElement.setAttribute("data-theme", theme); | ||
| } | ||
|
|
||
| (function bindSystemThemeListener() { | ||
| const mql = window.matchMedia("(prefers-color-scheme: dark)"); | ||
| try { | ||
| mql.addEventListener("change", applySystemTheme); | ||
| } catch { | ||
| mql.addListener(applySystemTheme); | ||
| } | ||
| })(); | ||
|
|
||
| function openChat() { | ||
| if (chatInstance) chatInstance.toggle(true, "chat"); | ||
| } | ||
| function openSearch() { | ||
| if (chatInstance) chatInstance.toggle(true, "search"); | ||
| } | ||
|
|
||
| document.addEventListener( | ||
| "touchmove", | ||
| (e) => { | ||
| const el = e.target.closest("pre, table, .sidebar"); | ||
| if (el) return; | ||
| }, | ||
| { passive: true }, | ||
| ); | ||
|
|
||
| window.addEventListener("DOMContentLoaded", () => { | ||
| applySystemTheme(); | ||
| chatInstance = new UltralyticsChat({ | ||
| branding: { | ||
| name: "Ultralytics AI", | ||
| tagline: "Ask anything about Ultralytics, YOLO, and more", | ||
| logo: "https://cdn.prod.website-files.com/680a070c3b99253410dd3dcf/68e4eb1e9893320b26cc02c3_Ultralytics%20Logo.png.svg", | ||
| logomark: | ||
| "https://storage.googleapis.com/organization-image-assets/ultralytics-botAvatarSrcUrl-1729379860806.svg", | ||
| pillText: "Ask AI", | ||
| }, | ||
| theme: { | ||
| primary: "#042AFF", | ||
| dark: "#111F68", | ||
| yellow: "#E1FF25", | ||
| text: "#0b0b0f", | ||
| }, | ||
| welcome: { | ||
| title: "Hello 👋", | ||
| message: "I'm an AI assistant trained on Ultralytics documentation - ask me anything!", | ||
| chatExamples: [ | ||
| "What's new in SAM 3?", | ||
| "How do I get started with YOLO?", | ||
| "Tell me about Enterprise Licensing", | ||
| ], | ||
| searchExamples: ["YOLO quickstart", "model training parameters", "export formats", "dataset configuration"], | ||
| }, | ||
| ui: { | ||
| placeholder: "Ask anything…", | ||
| copyText: "Copy thread", | ||
| downloadText: "Download thread", | ||
| clearText: "New chat", | ||
| }, | ||
| }); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<!DOCTYPE html>declaration. Without it, browsers can fall back to quirks mode, which causes inconsistent layout/box-model behavior compared to the single-page demo. Add the HTML5 DOCTYPE before the opening<html>tag so both demos render in standards mode.