mirror of https://git.tuxpa.in/a/code-server.git
Allow use of the enter key for password input for code-server (#479)
* Allow use of the enter key for password input for code-server * Remove function, make html form * Remove function and create html form * Handle form submit action * Remove button listener * Check if form exists
This commit is contained in:
parent
f7342ede69
commit
db57aa229f
|
@ -7,9 +7,10 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<form id="login-form">
|
||||||
<div class="login">
|
<div class="login">
|
||||||
<div class="back"> <- Back </div>
|
<div class="back">
|
||||||
<h4 class="title">code-server</h4>
|
<- Back </div> <h4 class="title">code-server</h4>
|
||||||
<h2 class="subtitle">
|
<h2 class="subtitle">
|
||||||
Enter server password
|
Enter server password
|
||||||
</h2>
|
</h2>
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
</button>
|
</button>
|
||||||
<div id="error-display"></div>
|
<div id="error-display"></div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
|
@ -20,11 +20,14 @@ window.addEventListener("message", (event) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const password = document.getElementById("password") as HTMLInputElement;
|
const password = document.getElementById("password") as HTMLInputElement;
|
||||||
const submit = document.getElementById("submit") as HTMLButtonElement;
|
const form = document.getElementById("login-form") as HTMLFormElement;
|
||||||
if (!submit) {
|
|
||||||
throw new Error("No submit button found");
|
if (!form) {
|
||||||
|
throw new Error("No password form found");
|
||||||
}
|
}
|
||||||
submit.addEventListener("click", () => {
|
|
||||||
|
form.addEventListener("submit", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
document.cookie = `password=${password.value}`;
|
document.cookie = `password=${password.value}`;
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue