Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit db57aa2

Browse files
nol166code-asher
authored andcommitted
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
1 parent f7342ed commit db57aa2

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

‎packages/app/browser/src/app.html‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,24 @@
77
</head>
88

99
<body>
10-
<div class="login">
11-
<div class="back"> <- Back </div>
12-
<h4 class="title">code-server</h4>
13-
<h2 class="subtitle">
14-
Enter server password
15-
</h2>
16-
<div class="mdc-text-field">
17-
<input type="password" id="password" class="mdc-text-field__input" required>
18-
<label class="mdc-floating-label" for="password">Password</label>
19-
<div class="mdc-line-ripple"></div>
20-
</div>
21-
<button id="submit" class="mdc-button mdc-button--unelevated">
22-
<span class="mdc-button__label">Enter IDE</span>
23-
</button>
24-
<div id="error-display"></div>
25-
</div>
10+
<form id="login-form">
11+
<div class="login">
12+
<div class="back">
13+
<- Back </div> <h4 class="title">code-server</h4>
14+
<h2 class="subtitle">
15+
Enter server password
16+
</h2>
17+
<div class="mdc-text-field">
18+
<input type="password" id="password" class="mdc-text-field__input" required>
19+
<label class="mdc-floating-label" for="password">Password</label>
20+
<div class="mdc-line-ripple"></div>
21+
</div>
22+
<button id="submit" class="mdc-button mdc-button--unelevated">
23+
<span class="mdc-button__label">Enter IDE</span>
24+
</button>
25+
<div id="error-display"></div>
26+
</div>
27+
</form>
2628
</body>
2729

2830
</html>

‎packages/app/browser/src/app.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ window.addEventListener("message", (event) => {
2020
});
2121

2222
const password = document.getElementById("password") as HTMLInputElement;
23-
const submit = document.getElementById("submit") as HTMLButtonElement;
24-
if (!submit) {
25-
throw new Error("No submit button found");
23+
const form = document.getElementById("login-form") as HTMLFormElement;
24+
25+
if (!form) {
26+
throw new Error("No password form found");
2627
}
27-
submit.addEventListener("click", () => {
28+
29+
form.addEventListener("submit", (e) => {
30+
e.preventDefault();
2831
document.cookie = `password=${password.value}`;
2932
location.reload();
3033
});
@@ -38,4 +41,4 @@ const errorDisplay = document.getElementById("error-display") as HTMLDivElement;
3841

3942
if (document.referrer === document.location.href && matches) {
4043
errorDisplay.innerText = "Password is incorrect!";
41-
}
44+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /