|
14 | 14 |
|
15 | 15 | // Install modal elements |
16 | 16 | const installMain = $("#install-main"); |
| 17 | + const installNvidiaKey = $("#install-nvidia-key"); |
| 18 | + const installProviderPicker = $("#install-provider-picker"); |
| 19 | + const installPartnerInstructions = $("#install-partner-instructions"); |
17 | 20 | const stepError = $("#install-step-error"); |
18 | 21 | const apiKeyInput = $("#api-key-input"); |
19 | 22 | const toggleKeyVis = $("#toggle-key-vis"); |
|
233 | 236 | stepError.hidden = true; |
234 | 237 | } |
235 | 238 |
|
| 239 | + // -- Install modal screens (picker / NVIDIA / partner) ----------------- |
| 240 | + |
| 241 | + function showInstallScreen(screen, providerId) { |
| 242 | + if (installProviderPicker) installProviderPicker.hidden = screen !== "picker"; |
| 243 | + if (installNvidiaKey) installNvidiaKey.hidden = screen !== "nvidia"; |
| 244 | + if (installPartnerInstructions) { |
| 245 | + installPartnerInstructions.hidden = screen !== "partner"; |
| 246 | + if (screen === "partner" && providerId) { |
| 247 | + const content = $("#partner-instructions-content"); |
| 248 | + if (content) { |
| 249 | + content.querySelectorAll("[id^=\"provider-instructions-\"]").forEach((el) => { |
| 250 | + el.hidden = el.id !== "provider-instructions-" + providerId; |
| 251 | + }); |
| 252 | + } |
| 253 | + } |
| 254 | + } |
| 255 | + } |
| 256 | + |
236 | 257 | function showError(msg) { |
237 | 258 | stopPolling(); |
238 | 259 | installMain.hidden = true; |
|
387 | 408 | updateButtonState(); |
388 | 409 |
|
389 | 410 | showOverlay(overlayInstall); |
| 411 | + showInstallScreen("nvidia"); |
390 | 412 | if (!keyInjected) { |
391 | 413 | startPolling(); |
392 | 414 | } |
|
398 | 420 | updateButtonState(); |
399 | 421 |
|
400 | 422 | showOverlay(overlayInstall); |
| 423 | + showInstallScreen("nvidia"); |
401 | 424 | startPolling(); |
402 | 425 | } |
403 | 426 | } catch { |
|
425 | 448 | showOverlay(overlayInstall); |
426 | 449 | if (installFailed) { |
427 | 450 | stepError.hidden = false; |
428 | | - installMain.hidden = true; |
| 451 | + if (installProviderPicker) installProviderPicker.hidden = true; |
| 452 | + if (installNvidiaKey) installNvidiaKey.hidden = true; |
| 453 | + if (installPartnerInstructions) installPartnerInstructions.hidden = true; |
429 | 454 | } else { |
430 | | - showMainView(); |
| 455 | + if (installProviderPicker) { |
| 456 | + showInstallScreen("picker"); |
| 457 | + } else { |
| 458 | + showInstallScreen("nvidia"); |
| 459 | + apiKeyInput.focus(); |
| 460 | + if (!installTriggered) triggerInstall(); |
| 461 | + } |
431 | 462 | } |
432 | | - apiKeyInput.focus(); |
433 | 463 | updateButtonState(); |
434 | | - if (!installTriggered && !installFailed) triggerInstall(); |
435 | 464 | }); |
436 | 465 |
|
437 | 466 | cardOther.addEventListener("click", () => { |
|
442 | 471 | closeInstall.addEventListener("click", () => hideOverlay(overlayInstall)); |
443 | 472 | closeInstr.addEventListener("click", () => hideOverlay(overlayInstr)); |
444 | 473 |
|
| 474 | + const backFromNvidia = $("#back-from-nvidia"); |
| 475 | + if (backFromNvidia) { |
| 476 | + backFromNvidia.addEventListener("click", () => showInstallScreen("picker")); |
| 477 | + } |
| 478 | + document.addEventListener("click", (e) => { |
| 479 | + const backPartner = e.target.closest("#back-from-partner"); |
| 480 | + if (backPartner) showInstallScreen("picker"); |
| 481 | + }); |
| 482 | + |
| 483 | + function handleProviderChoice(id) { |
| 484 | + if (id === "nvidia") { |
| 485 | + showInstallScreen("nvidia"); |
| 486 | + apiKeyInput.focus(); |
| 487 | + if (!installTriggered && !installFailed) triggerInstall(); |
| 488 | + } else { |
| 489 | + showInstallScreen("partner", id); |
| 490 | + } |
| 491 | + } |
| 492 | + |
| 493 | + function onProviderPickerClick(e) { |
| 494 | + const tile = e.target.closest("[data-provider-id]"); |
| 495 | + if (!tile) return; |
| 496 | + const id = tile.getAttribute("data-provider-id"); |
| 497 | + if (!id) return; |
| 498 | + e.preventDefault(); |
| 499 | + e.stopPropagation(); |
| 500 | + handleProviderChoice(id); |
| 501 | + } |
| 502 | + |
| 503 | + function onProviderPickerKeydown(e) { |
| 504 | + if (e.key !== "Enter" && e.key !== " ") return; |
| 505 | + const tile = e.target.closest("[data-provider-id]"); |
| 506 | + if (!tile) return; |
| 507 | + const id = tile.getAttribute("data-provider-id"); |
| 508 | + if (!id) return; |
| 509 | + e.preventDefault(); |
| 510 | + handleProviderChoice(id); |
| 511 | + } |
| 512 | + |
| 513 | + if (installProviderPicker) { |
| 514 | + installProviderPicker.addEventListener("click", onProviderPickerClick); |
| 515 | + installProviderPicker.addEventListener("keydown", onProviderPickerKeydown); |
| 516 | + } else { |
| 517 | + const installBody = $("#install-body"); |
| 518 | + if (installBody) { |
| 519 | + installBody.addEventListener("click", onProviderPickerClick); |
| 520 | + installBody.addEventListener("keydown", onProviderPickerKeydown); |
| 521 | + } |
| 522 | + } |
| 523 | + |
445 | 524 | closeOnBackdrop(overlayInstall); |
446 | 525 | closeOnBackdrop(overlayInstr); |
447 | 526 |
|
|
0 commit comments