()
| 673 | // Storage may be unavailable in hardened browser modes. |
| 674 | } |
| 675 | link.removeAttribute("aria-disabled"); |
| 676 | showToast(error.message || "GitHub sign-in is unavailable."); |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | function createLoginDialog() { |
| 681 | if (loginDialog) { |
| 682 | return loginDialog; |
| 683 | } |
| 684 | |
| 685 | const dialog = document.createElement("dialog"); |
| 686 | dialog.className = "login-dialog"; |
| 687 | dialog.setAttribute("aria-labelledby", "vote-login-title"); |
| 688 | |
| 689 | const panel = document.createElement("div"); |
| 690 | panel.className = "login-dialog-panel"; |
| 691 | const eyebrow = document.createElement("p"); |
| 692 | eyebrow.className = "eyebrow"; |
| 693 | eyebrow.textContent = "Community voting"; |
| 694 | const title = document.createElement("h2"); |
| 695 | title.id = "vote-login-title"; |
| 696 | title.textContent = "Sign in to vote"; |
| 697 | const explanation = document.createElement("p"); |
| 698 | explanation.textContent = |
| 699 | "Use GitHub. One account gets one vote per loop, and you can change it anytime."; |
| 700 | const providers = document.createElement("div"); |
| 701 | providers.className = "login-providers"; |
| 702 | |
| 703 | const githubLink = document.createElement("a"); |
| 704 | githubLink.className = "login-provider login-provider-github"; |
| 705 | githubLink.href = voteLoginUrl("github"); |
| 706 | githubLink.textContent = "Continue with GitHub"; |
| 707 | githubLink.addEventListener("click", (event) => { |
| 708 | event.preventDefault(); |
| 709 | if (githubLink.getAttribute("aria-disabled") === "true") return; |
| 710 | githubLink.setAttribute("aria-disabled", "true"); |
| 711 | beginGithubLogin(githubLink); |
| 712 | }); |
| 713 | providers.append(githubLink); |
| 714 | |
| 715 | const cancel = document.createElement("button"); |
| 716 | cancel.className = "login-cancel"; |
| 717 | cancel.type = "button"; |
| 718 | cancel.textContent = "Not now"; |
| 719 | cancel.addEventListener("click", () => dialog.close()); |
| 720 | dialog.addEventListener("click", (event) => { |
| 721 | if (event.target === dialog) dialog.close(); |
| 722 | }); |
| 723 | |
| 724 | panel.append(eyebrow, title, explanation, providers, cancel); |
| 725 | dialog.append(panel); |
| 726 | document.body.append(dialog); |
| 727 | loginDialog = dialog; |
no test coverage detected