|
|
| const applyAutoTheme = () => {
|
|
|
| const prefersLight = window.matchMedia("(prefers-color-scheme: light)").matches;
|
| const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
|
|
|
| if (prefersLight) {
|
| document.body.setAttribute("data-md-color-scheme", "default");
|
| document.body.setAttribute("data-md-color-primary", "indigo");
|
| } else if (prefersDark) {
|
| document.body.setAttribute("data-md-color-scheme", "slate");
|
| document.body.setAttribute("data-md-color-primary", "black");
|
| }
|
| };
|
|
|
|
|
| function checkAutoTheme() {
|
|
|
| const supportedLangCodes = ["en", "zh", "ko", "ja", "ru", "de", "fr", "es", "pt", "it", "tr", "vi", "nl"];
|
|
|
| const path = window.location.pathname;
|
|
|
| const langCode = path.split("/")[1];
|
|
|
| const isValidLangCode = supportedLangCodes.includes(langCode);
|
|
|
| const localStorageKey = isValidLangCode ? `/${langCode}/.__palette` : "/.__palette";
|
|
|
| const palette = localStorage.getItem(localStorageKey);
|
| if (palette) {
|
|
|
| const paletteObj = JSON.parse(palette);
|
| if (paletteObj && paletteObj.index === 0) {
|
| applyAutoTheme();
|
| }
|
| }
|
| }
|
|
|
|
|
| checkAutoTheme();
|
|
|
|
|
| window.matchMedia("(prefers-color-scheme: light)").addEventListener("change", checkAutoTheme);
|
| window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", checkAutoTheme);
|
|
|
|
|
|
|
|
|
|
|
| var autoThemeInput = document.getElementById("__palette_1");
|
| if (autoThemeInput) {
|
|
|
| autoThemeInput.addEventListener("click", function () {
|
|
|
| if (autoThemeInput.checked) {
|
|
|
| setTimeout(applyAutoTheme);
|
| }
|
| });
|
| }
|
|
|
|
|
| window.onhashchange = function() {
|
| window.parent.postMessage({
|
| type: 'navigation',
|
| hash: window.location.pathname + window.location.search + window.location.hash
|
| }, '*');
|
| };
|
|
|
|
|
| document.addEventListener("DOMContentLoaded", () => {
|
| const inkeepScript = document.createElement("script");
|
| inkeepScript.src = "https://unpkg.com/@inkeep/uikit-js@0.3.11/dist/embed.js";
|
| inkeepScript.type = "module";
|
| inkeepScript.defer = true;
|
| document.head.appendChild(inkeepScript);
|
|
|
|
|
| const addInkeepWidget = () => {
|
| const inkeepWidget = Inkeep().embed({
|
| componentType: "ChatButton",
|
| colorModeSync: {
|
| observedElement: document.documentElement,
|
| isDarkModeCallback: (el) => {
|
| const currentTheme = el.getAttribute("data-color-mode");
|
| return currentTheme === "dark";
|
| },
|
| colorModeAttribute: "data-color-mode",
|
| },
|
| properties: {
|
| chatButtonType: "PILL",
|
| fixedPositionXOffset: "1rem",
|
| fixedPositionYOffset: "3rem",
|
| chatButtonBgColor: "#E1FF25",
|
| baseSettings: {
|
| apiKey: "13dfec2e75982bc9bae3199a08e13b86b5fbacd64e9b2f89",
|
| integrationId: "cm1shscmm00y26sj83lgxzvkw",
|
| organizationId: "org_e3869az6hQZ0mXdF",
|
| primaryBrandColor: "#E1FF25",
|
| organizationDisplayName: "Ultralytics",
|
| theme: {
|
| stylesheetUrls: ["/stylesheets/style.css"],
|
| },
|
|
|
| },
|
| modalSettings: {
|
|
|
| },
|
| searchSettings: {
|
|
|
| },
|
| aiChatSettings: {
|
| chatSubjectName: "Ultralytics",
|
| botAvatarSrcUrl: "https://storage.googleapis.com/organization-image-assets/ultralytics-botAvatarSrcUrl-1727908259285.png",
|
| botAvatarDarkSrcUrl: "https://storage.googleapis.com/organization-image-assets/ultralytics-botAvatarDarkSrcUrl-1727908258478.png",
|
| quickQuestions: [
|
| "What's new in Ultralytics YOLO11?",
|
| "How can I get started with Ultralytics HUB?",
|
| "How does Ultralytics Enterprise Licensing work?"
|
| ],
|
| getHelpCallToActions: [
|
| {
|
| name: "Ask on Ultralytics GitHub",
|
| url: "https://github.com/ultralytics/ultralytics",
|
| icon: {
|
| builtIn: "FaGithub"
|
| }
|
| },
|
| {
|
| name: "Ask on Ultralytics Discourse",
|
| url: "https://community.ultralytics.com/",
|
| icon: {
|
| builtIn: "FaDiscourse"
|
| }
|
| },
|
| {
|
| name: "Ask on Ultralytics Discord",
|
| url: "https://discord.com/invite/ultralytics",
|
| icon: {
|
| builtIn: "FaDiscord"
|
| }
|
| }
|
| ],
|
| },
|
| },
|
| });
|
| };
|
| inkeepScript.addEventListener("load", () => {
|
| addInkeepWidget();
|
| });
|
| });
|
|
|