|
136 | 136 | versionButton.textContent = '13.3'; |
137 | 137 | } else if (path.includes('/13.0/')) { |
138 | 138 | versionButton.textContent = '13.0'; |
139 | | - } |
140 | | - else if (path.includes('/25.05/')) { |
141 | | - versionButton.textContent = '25.05'; |
142 | | - } else if (path.includes('/24.10/')) { |
143 | | - versionButton.textContent = '24.10'; |
144 | | - } else if (path.includes('/24.04/')) { |
145 | | - versionButton.textContent = '24.04'; |
146 | | - } else if (path.includes('/23.10/')) { |
147 | | - versionButton.textContent = '23.10'; |
148 | | - } else if (path.includes('/22.12/')) { |
149 | | - versionButton.textContent = 'Archive'; |
150 | | - } else { |
151 | | - // Default version if no specific path is matched |
152 | | - versionButton.textContent = '25.05'; |
153 | | - } |
154 | | - versionUpdated = true; |
155 | | - } else if (path.includes('/truecommand/')) { |
156 | | - productButton.innerHTML = 'TrueCommand <i class="fa fa-angle-down"></i>'; |
157 | | - if (path.includes('/3.0/')) { |
158 | | - versionButton.textContent = '3.0'; |
| 139 | + } else { |
| 140 | + versionButton.textContent = 'Nightly'; |
159 | 141 | } |
160 | | - versionUpdated = true; |
161 | | - } else if (path.includes('/hardware/')) { |
162 | | - productButton.innerHTML = 'TrueNAS Systems <i class="fa fa-angle-down"></i>'; |
163 | | - if (!versionUpdated) { |
164 | | - versionButton.textContent = '---'; |
165 | | - versionUpdated = true; |
166 | | - } |
167 | | - } else if (path.includes('/truenasapps/')) { |
168 | | - productButton.innerHTML = 'TrueNAS Apps <i class="fa fa-angle-down"></i>'; |
169 | | - if (!versionUpdated) { |
170 | | - versionButton.textContent = '---'; |
171 | | - versionUpdated = true; |
172 | | - } |
| 142 | + versionUpdated = true; |
| 143 | + } else if (path.includes('/scale/')) { |
| 144 | + productButton.innerHTML = 'TrueNAS SCALE <i class="fa fa-angle-down"></i>'; |
| 145 | + if (path.includes('/24.10/')) { |
| 146 | + versionButton.textContent = '24.10'; |
| 147 | + } else if (path.includes('/24.04/')) { |
| 148 | + versionButton.textContent = '24.04'; |
| 149 | + } else if (path.includes('/23.10/')) { |
| 150 | + versionButton.textContent = '23.10'; |
| 151 | + } else if (path.includes('/22.12/')) { |
| 152 | + versionButton.textContent = 'Archive'; |
173 | 153 | } else { |
174 | | - productButton.innerHTML = 'Product <i class="fa fa-angle-down"></i>'; |
| 154 | + versionButton.textContent = '25.04'; |
| 155 | + } |
| 156 | + versionUpdated = true; |
| 157 | + } else if (path.includes('/truecommand/')) { |
| 158 | + productButton.innerHTML = 'TrueCommand <i class="fa fa-angle-down"></i>'; |
| 159 | + if (path.includes('/3.0/')) { |
| 160 | + versionButton.textContent = '3.0'; |
| 161 | + } else if (path.includes('/2.3/')) { |
| 162 | + versionButton.textContent = 'Archive'; |
| 163 | + } else { |
| 164 | + versionButton.textContent = 'Nightly'; |
| 165 | + } |
| 166 | + versionUpdated = true; |
| 167 | + } else if (path.includes('/hardware/')) { |
| 168 | + productButton.innerHTML = 'TrueNAS Systems <i class="fa fa-angle-down"></i>'; |
| 169 | + if (!versionUpdated) { |
| 170 | + versionButton.textContent = '---'; |
| 171 | + versionUpdated = true; |
175 | 172 | } |
176 | | - |
| 173 | + } else if (path.includes('/truenasapps/')) { |
| 174 | + productButton.innerHTML = 'TrueNAS Apps <i class="fa fa-angle-down"></i>'; |
177 | 175 | if (!versionUpdated) { |
178 | | - versionButton.innerHTML = 'Version <i class="fa fa-angle-down"></i>'; |
| 176 | + versionButton.textContent = '---'; |
| 177 | + versionUpdated = true; |
| 178 | + } |
| 179 | + } else { |
| 180 | + productButton.innerHTML = 'Product <i class="fa fa-angle-down"></i>'; |
| 181 | + } |
| 182 | + |
| 183 | + if (!versionUpdated) { |
| 184 | + versionButton.innerHTML = 'Version <i class="fa fa-angle-down"></i>'; |
| 185 | + } |
| 186 | + |
| 187 | + versionDropdown.textContent = 'Choose a Product'; |
| 188 | +} |
| 189 | + |
| 190 | +updateDropdownPlaceholderText(); |
| 191 | + |
| 192 | + function selectProduct(product) { |
| 193 | + var productButton = document.getElementById('productButton'); |
| 194 | + var versionButton = document.getElementById('versionButton'); |
| 195 | + var versionDropdown = document.getElementById('versionDropdown'); |
| 196 | + |
| 197 | + versionButton.innerHTML = 'Version <i class="fa fa-angle-down"></i>'; |
| 198 | + versionButton.dataset.versionId = ''; |
| 199 | + |
| 200 | + productButton.innerHTML = product + ' <i class="fa fa-angle-down"></i>'; |
| 201 | + productButton.dataset.productId = product.toLowerCase().replace(/\s/g, ''); // Store the selected product ID |
| 202 | + |
| 203 | + var docsnavIntro = document.getElementById('docsnav-intro'); |
| 204 | + docsnavIntro.textContent = 'Product and Version:'; |
| 205 | + |
| 206 | + if (product === 'TrueNAS Systems') { |
| 207 | + window.location.href = 'https://www.truenas.com/docs/hardware'; |
| 208 | + return; |
| 209 | + } else if (product === 'TrueNAS Apps') { |
| 210 | + window.location.href = 'https://www.truenas.com/docs/truenasapps'; |
| 211 | + return; |
179 | 212 | } |
180 | 213 |
|
181 | | - versionDropdown.textContent = 'Choose a Product'; |
| 214 | + versionButton.disabled = false; |
| 215 | + versionDropdown.style.display = 'none'; |
| 216 | + versionDropdown.innerHTML = ''; |
| 217 | + |
| 218 | + if (product === 'TrueNAS CORE') { |
| 219 | + versionDropdown.innerHTML = ` |
| 220 | + <div class="truenas-dropdown-item" onclick="selectVersion('13.3')" id="13.3">13.3</div> |
| 221 | + <div class="truenas-dropdown-item" onclick="selectVersion('13.0')" id="13">13.0</div> |
| 222 | + <div class="truenas-dropdown-item" onclick="selectVersion('Archive')" id="Archive">Archive</div> |
| 223 | + `; |
| 224 | + } else if (product === 'TrueNAS SCALE') { |
| 225 | + versionDropdown.innerHTML = ` |
| 226 | + <div class="truenas-dropdown-item" onclick="selectVersion('scale-nightly')" id="scale-nightly">25.04</div> |
| 227 | + <div class="truenas-dropdown-item" onclick="selectVersion('24.10')" id="2410">24.10</div> |
| 228 | + <div class="truenas-dropdown-item" onclick="selectVersion('24.04')" id="2404">24.04</div> |
| 229 | + <div class="truenas-dropdown-item" onclick="selectVersion('23.10')" id="2310">23.10</div> |
| 230 | + <div class="truenas-dropdown-item" onclick="selectVersion('Archive')" id="Archive">Archive</div> |
| 231 | + `; |
| 232 | + } else if (product === 'TrueCommand') { |
| 233 | + versionDropdown.innerHTML = ` |
| 234 | + <div class="truenas-dropdown-item" onclick="selectVersion('3.0')" id="30">3.0</div> |
| 235 | + <div class="truenas-dropdown-item" onclick="selectVersion('Archive')" id="Archive">Archive</div> |
| 236 | + `; |
| 237 | + } |
| 238 | + |
| 239 | + versionDropdown.style.display = 'block'; |
| 240 | + |
| 241 | + var productDropdown = document.getElementById('productDropdown'); |
| 242 | + productDropdown.style.display = 'none'; |
182 | 243 | } |
| 244 | + |
| 245 | + function selectVersion(version) { |
| 246 | + var versionButton = document.getElementById('versionButton'); |
| 247 | + versionButton.dataset.versionId = version.toLowerCase().replace(/\s/g, ''); |
183 | 248 |
|
184 | | - updateDropdownPlaceholderText(); |
| 249 | + // Modify the version text if it's nightly |
| 250 | + var displayVersion = version.toLowerCase().includes('nightly') ? 'Nightly' : version; |
185 | 251 |
|
186 | | - function selectProduct(product) { |
187 | | - var productButton = document.getElementById('productButton'); |
188 | | - var versionButton = document.getElementById('versionButton'); |
189 | | - var versionDropdown = document.getElementById('versionDropdown'); |
190 | | - |
191 | | - versionButton.innerHTML = 'Version <i class="fa fa-angle-down"></i>'; |
192 | | - versionButton.dataset.versionId = ''; |
193 | | - |
194 | | - productButton.innerHTML = product + ' <i class="fa fa-angle-down"></i>'; |
195 | | - productButton.dataset.productId = product.toLowerCase().replace(/\s/g, ''); // Store the selected product ID |
196 | | - |
197 | | - var docsnavIntro = document.getElementById('docsnav-intro'); |
198 | | - docsnavIntro.textContent = 'Product and Version:'; |
199 | | - |
200 | | - if (product === 'TrueNAS Systems') { |
201 | | - window.location.href = 'https://www.truenas.com/docs/hardware'; |
202 | | - return; |
203 | | - } else if (product === 'TrueNAS Apps') { |
204 | | - window.location.href = 'https://www.truenas.com/docs/truenasapps'; |
205 | | - return; |
206 | | - } |
207 | | - |
208 | | - versionButton.disabled = false; |
209 | | - versionDropdown.style.display = 'none'; |
210 | | - versionDropdown.innerHTML = ''; |
| 252 | + versionButton.textContent = displayVersion; |
211 | 253 |
|
212 | | - if (product === 'TrueNAS') { |
213 | | - versionDropdown.innerHTML = ` |
214 | | - <div class="truenas-dropdown-item" onclick="selectVersion('scale-nightly')" id="scale-nightly">25.04</div> |
215 | | - <div class="truenas-dropdown-item" onclick="selectVersion('24.10')" id="2410">24.10</div> |
216 | | - <div class="truenas-dropdown-item" onclick="selectVersion('24.04')" id="2404">24.04</div> |
217 | | - <div class="truenas-dropdown-item" onclick="selectVersion('23.10')" id="2310">23.10</div> |
218 | | - <div class="truenas-dropdown-item" onclick="selectVersion('13.3')" id="13.3">13.3</div> |
219 | | - <div class="truenas-dropdown-item" onclick="selectVersion('13.0')" id="13">13.0</div> |
220 | | - <div class="truenas-dropdown-item" onclick="selectVersion('Archive')" id="Archive">Archive</div> |
221 | | - `; |
222 | | - } else if (product === 'TrueCommand') { |
223 | | - versionDropdown.innerHTML = ` |
224 | | - <div class="truenas-dropdown-item" onclick="selectVersion('3.0')" id="30">3.0</div> |
225 | | - <div class="truenas-dropdown-item" onclick="selectVersion('Archive')" id="Archive">Archive</div> |
226 | | - `; |
227 | | - } |
228 | | - |
229 | | - versionDropdown.style.display = 'block'; |
| 254 | + var base_url = 'https://www.truenas.com'; |
| 255 | + var currentPath = getCurrentPath(); |
230 | 256 |
|
231 | | - var productDropdown = document.getElementById('productDropdown'); |
232 | | - productDropdown.style.display = 'none'; |
| 257 | + function getProductFromPath(path) { |
| 258 | + if (path.includes('/core/')) return 'TrueNAS CORE'; |
| 259 | + if (path.includes('/scale/')) return 'TrueNAS SCALE'; |
| 260 | + if (path.includes('/truecommand/')) return 'TrueCommand'; |
| 261 | + return ''; |
233 | 262 | } |
234 | 263 |
|
235 | | - function selectVersion(version) { |
236 | | - var versionButton = document.getElementById('versionButton'); |
237 | | - versionButton.dataset.versionId = version.toLowerCase().replace(/\s/g, ''); |
238 | | - var displayVersion = version.toLowerCase().includes('nightly') ? 'Nightly' : version; |
239 | | - versionButton.textContent = displayVersion; |
240 | | - |
241 | | - var base_url = 'https://www.truenas.com'; |
242 | | - var currentPath = getCurrentPath(); |
243 | | - |
244 | | - // Add this section for the redirection from scale 24.04 apps tutorials |
245 | | - if (currentPath.startsWith('/docs/scale/24.04/scaletutorials/apps/') && version !== '24.04') { |
246 | | - var newPath = currentPath.replace('/scale/24.04/scaletutorials/apps/', '/truenasapps/'); |
247 | | - window.location.href = base_url + newPath; |
248 | | - return; // Exit the function after redirection |
249 | | - } |
250 | | - |
251 | | - function getProductFromPath(path) { |
252 | | - if (path.includes('/core/') || path.includes('/scale/')) { |
253 | | - return 'TrueNAS'; |
254 | | - } |
255 | | - if (path.includes('/truecommand/')) return 'TrueCommand'; |
256 | | - return ''; |
257 | | - } |
258 | | - |
259 | | - var currentProduct = getProductFromPath(currentPath); |
260 | | - var selectedProduct = document.getElementById('productButton').textContent.trim().toLowerCase(); |
| 264 | + var currentProduct = getProductFromPath(currentPath); |
| 265 | + var selectedProduct = document.getElementById('productButton').textContent.trim().toLowerCase(); |
| 266 | + |
| 267 | + function handleRedirect(newPath, fallbackUrl) { |
| 268 | + var attemptedUrl = base_url + newPath; |
261 | 269 |
|
262 | | - function handleRedirect(newPath, fallbackUrl) { |
263 | | - var attemptedUrl = base_url + newPath; |
264 | | - fetch(attemptedUrl, { method: 'HEAD' }) |
265 | | - .then(response => { |
266 | | - if (response.ok) { |
267 | | - window.location.href = attemptedUrl; |
268 | | - } else { |
269 | | - console.log(`Fetch request failed for URL: ${attemptedUrl}`); |
270 | | - showRedirectModal(product, version, attemptedUrl); // Show modal before redirecting |
271 | | - setTimeout(() => { |
| 270 | + fetch(attemptedUrl, { method: 'HEAD' }) |
| 271 | + .then(response => { |
| 272 | + if (response.ok) { |
| 273 | + window.location.href = attemptedUrl; |
| 274 | + } else { |
| 275 | + console.log(`Fetch request failed for URL: ${attemptedUrl}`); |
| 276 | + showRedirectModal(product, version, attemptedUrl); // Show modal before redirecting |
| 277 | + setTimeout(() => { |
272 | 278 | console.log(`Redirecting to fallback URL: ${fallbackUrl}`); |
273 | 279 | window.location.href = fallbackUrl; |
274 | 280 | }, 5000); // Wait 5 seconds before redirecting |
|
0 commit comments