Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

extra.js 4.7 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  1. // Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
  2. // Apply theme colors based on dark/light mode
  3. const applyTheme = (isDark) => {
  4. document.body.setAttribute(
  5. "data-md-color-scheme",
  6. isDark ? "slate" : "default",
  7. );
  8. document.body.setAttribute(
  9. "data-md-color-primary",
  10. isDark ? "black" : "indigo",
  11. );
  12. };
  13. // Check and apply appropriate theme based on system/user preference
  14. const checkTheme = () => {
  15. const palette = JSON.parse(localStorage.getItem(".__palette") || "{}");
  16. if (palette.index === 0) {
  17. // Auto mode is selected
  18. applyTheme(window.matchMedia("(prefers-color-scheme: dark)").matches);
  19. }
  20. };
  21. // Watch for system theme changes
  22. window
  23. .matchMedia("(prefers-color-scheme: dark)")
  24. .addEventListener("change", checkTheme);
  25. // Initialize theme handling on page load
  26. document.addEventListener("DOMContentLoaded", () => {
  27. // Watch for theme toggle changes
  28. document
  29. .getElementById("__palette_1")
  30. ?.addEventListener(
  31. "change",
  32. (e) => e.target.checked && setTimeout(checkTheme),
  33. );
  34. // Initial theme check
  35. checkTheme();
  36. });
  37. // Inkeep --------------------------------------------------------------------------------------------------------------
  38. document.addEventListener("DOMContentLoaded", () => {
  39. const enableSearchBar = true;
  40. const inkeepScript = document.createElement("script");
  41. inkeepScript.src = "https://unpkg.com/@inkeep/uikit-js@0.3.18/dist/embed.js";
  42. inkeepScript.type = "module";
  43. inkeepScript.defer = true;
  44. document.head.appendChild(inkeepScript);
  45. if (enableSearchBar) {
  46. const containerDiv = document.createElement("div");
  47. containerDiv.style.transform = "scale(0.7)";
  48. containerDiv.style.transformOrigin = "left center";
  49. const inkeepDiv = document.createElement("div");
  50. inkeepDiv.id = "inkeepSearchBar";
  51. containerDiv.appendChild(inkeepDiv);
  52. const headerElement = document.querySelector(".md-header__inner");
  53. const searchContainer = headerElement.querySelector(".md-header__source");
  54. if (headerElement && searchContainer) {
  55. headerElement.insertBefore(containerDiv, searchContainer);
  56. }
  57. }
  58. // configure and initialize the widget
  59. const addInkeepWidget = (componentType, targetElementId) => {
  60. const inkeepWidget = Inkeep().embed({
  61. componentType,
  62. ...(componentType !== "ChatButton"
  63. ? { targetElement: targetElementId }
  64. : {}),
  65. colorModeSync: {
  66. observedElement: document.documentElement,
  67. isDarkModeCallback: (el) => {
  68. const currentTheme = el.getAttribute("data-color-mode");
  69. return currentTheme === "dark";
  70. },
  71. colorModeAttribute: "data-color-mode-scheme",
  72. },
  73. properties: {
  74. chatButtonType: "PILL",
  75. fixedPositionXOffset: "1rem",
  76. fixedPositionYOffset: "3rem",
  77. chatButtonBgColor: "#E1FF25",
  78. baseSettings: {
  79. apiKey: "13dfec2e75982bc9bae3199a08e13b86b5fbacd64e9b2f89",
  80. integrationId: "cm1shscmm00y26sj83lgxzvkw",
  81. organizationId: "org_e3869az6hQZ0mXdF",
  82. primaryBrandColor: "#E1FF25",
  83. organizationDisplayName: "Ultralytics",
  84. theme: {
  85. stylesheetUrls: ["/stylesheets/style.css"],
  86. },
  87. },
  88. modalSettings: {
  89. // optional settings
  90. },
  91. searchSettings: {
  92. placeholder: "Search",
  93. },
  94. aiChatSettings: {
  95. chatSubjectName: "Ultralytics",
  96. botAvatarSrcUrl:
  97. "https://storage.googleapis.com/organization-image-assets/ultralytics-botAvatarSrcUrl-1729379860806.svg",
  98. quickQuestions: [
  99. "What's new in Ultralytics YOLO11?",
  100. "How can I get started with Ultralytics HUB?",
  101. "How does Ultralytics Enterprise Licensing work?",
  102. ],
  103. getHelpCallToActions: [
  104. {
  105. name: "Ask on Ultralytics GitHub",
  106. url: "https://github.com/ultralytics/ultralytics",
  107. icon: {
  108. builtIn: "FaGithub",
  109. },
  110. },
  111. {
  112. name: "Ask on Ultralytics Discourse",
  113. url: "https://community.ultralytics.com/",
  114. icon: {
  115. builtIn: "FaDiscourse",
  116. },
  117. },
  118. {
  119. name: "Ask on Ultralytics Discord",
  120. url: "https://discord.com/invite/ultralytics",
  121. icon: {
  122. builtIn: "FaDiscord",
  123. },
  124. },
  125. ],
  126. },
  127. },
  128. });
  129. };
  130. inkeepScript.addEventListener("load", () => {
  131. const widgetContainer = document.getElementById("inkeepSearchBar");
  132. addInkeepWidget("ChatButton");
  133. widgetContainer && addInkeepWidget("SearchBar", "#inkeepSearchBar");
  134. });
  135. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...