Download tasks/33/solution/site/implementation/clone/static/auth-dialog.js from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 2.14 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/33/solution/site/implementation/clone/static/auth-dialog.js
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench/tasks/33/solution/site/implementation/clone/static/auth-dialog.js
-
curl -L -o auth-dialog.js https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/33/solution/site/implementation/clone/static/auth-dialog.js
2.14 kB
| (() => { | |
| const dialog = document.querySelector('[data-login-dialog]'); | |
| if (dialog) { | |
| const form = dialog.querySelector('[data-login-form]'); | |
| const email = dialog.querySelector('[data-login-email]'); | |
| const error = dialog.querySelector('[data-login-error]'); | |
| const open = () => { | |
| if (!dialog.open) dialog.showModal(); | |
| email.focus(); | |
| }; | |
| document.querySelectorAll('[data-login-open]').forEach((control) => { | |
| control.addEventListener('click', open); | |
| }); | |
| dialog.querySelector('[data-login-close]').addEventListener('click', () => dialog.close()); | |
| dialog.addEventListener('click', (event) => { | |
| if (event.target === dialog) dialog.close(); | |
| }); | |
| form.addEventListener('submit', (event) => { | |
| if (form.querySelector('input[type="password"]')) return; | |
| event.preventDefault(); | |
| if (!email.checkValidity()) { | |
| error.textContent = 'Enter a valid email address.'; | |
| error.hidden = false; | |
| return; | |
| } | |
| error.hidden = true; | |
| email.readOnly = true; | |
| const label = document.createElement('label'); | |
| label.dataset.loginPassword = ''; | |
| label.textContent = 'Password '; | |
| const required = document.createElement('span'); | |
| required.setAttribute('aria-hidden', 'true'); | |
| required.textContent = '*'; | |
| const password = document.createElement('input'); | |
| password.type = 'password'; | |
| password.name = 'password'; | |
| password.placeholder = 'Enter your password'; | |
| password.required = true; | |
| label.append(required, password); | |
| form.querySelector('[data-login-continue]').before(label); | |
| password.focus(); | |
| }); | |
| if (dialog.dataset.openOnLoad === 'true') open(); | |
| } | |
| const signup = document.querySelector('[data-signup-dialog]'); | |
| if (signup) { | |
| const open = () => { if (!signup.open) signup.showModal(); }; | |
| signup.querySelector('[data-signup-close]').addEventListener('click', () => signup.close()); | |
| signup.addEventListener('click', (event) => { if (event.target === signup) signup.close(); }); | |
| if (signup.dataset.openOnLoad === 'true') open(); | |
| } | |
| })(); | |