|
480 | 480 | if (backPartner) showInstallScreen("picker"); |
481 | 481 | }); |
482 | 482 |
|
483 | | - const installBody = $("#install-body"); |
484 | | - if (installBody) { |
485 | | - installBody.addEventListener("click", (e) => { |
486 | | - const tile = e.target.closest("[data-provider-id]"); |
487 | | - if (!tile) return; |
488 | | - const id = tile.getAttribute("data-provider-id"); |
489 | | - if (!id) return; |
490 | | - e.preventDefault(); |
491 | | - if (id === "nvidia") { |
492 | | - showInstallScreen("nvidia"); |
493 | | - apiKeyInput.focus(); |
494 | | - if (!installTriggered && !installFailed) triggerInstall(); |
495 | | - } else { |
496 | | - showInstallScreen("partner", id); |
497 | | - } |
498 | | - }); |
499 | | - installBody.addEventListener("keydown", (e) => { |
500 | | - if (e.key !== "Enter" && e.key !== " ") return; |
501 | | - const tile = e.target.closest("[data-provider-id]"); |
502 | | - if (!tile) return; |
503 | | - const id = tile.getAttribute("data-provider-id"); |
504 | | - if (!id) return; |
505 | | - e.preventDefault(); |
506 | | - if (id === "nvidia") { |
507 | | - showInstallScreen("nvidia"); |
508 | | - apiKeyInput.focus(); |
509 | | - if (!installTriggered && !installFailed) triggerInstall(); |
510 | | - } else { |
511 | | - showInstallScreen("partner", id); |
512 | | - } |
513 | | - }); |
| 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 | + } |
514 | 522 | } |
515 | 523 |
|
516 | 524 | closeOnBackdrop(overlayInstall); |
|
0 commit comments