Skip to content

Commit daa8643

Browse files
committed
Minor update
1 parent f4cd592 commit daa8643

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</div>
4747
<div class="col-auto">
4848
<div class="input-group">
49-
<input type="text" disabled class="form-control" id="nameInput"></div>
49+
<a id="nameAnchor"><input type="text" disabled class="form-control" id="nameInput"></a>
5050
</div>
5151
</div>
5252
</div>

index.ts

+24-8
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,18 @@ function readProblemUrl(): string {
3232
return input.value ? input.value : defaultUrl;
3333
}
3434

35-
function writeProblemName(name: string): void {
35+
function writeProblemName(name: string | null): void {
3636
const input = document.getElementById("nameInput") as HTMLInputElement;
37-
input.value = name;
37+
if (name === null) {
38+
input.value = "error";
39+
} else {
40+
input.value = name;
41+
}
42+
}
43+
44+
function writeProblemUrl(url: string): void {
45+
const anchor = document.getElementById("nameAnchor") as HTMLAnchorElement;
46+
anchor.href = url;
3847
}
3948

4049
function writeGeneratedCode(result: string, lang: string) {
@@ -89,22 +98,29 @@ function update(): void {
8998
const data = loadPrecomputedDataWithCache();
9099
const url = readProblemUrl();
91100

92-
const problem = lookupProblemFromUrl(url, data);
93101
try {
94102
new URL(url);
95103
} catch (err) {
96-
writeProblemName("error");
104+
writeProblemName(null);
97105
writeGeneratedCode("not a URL: " + JSON.stringify(url) + "\n", "plaintext");
106+
return;
98107
}
108+
writeProblemUrl(url);
109+
110+
const problem = lookupProblemFromUrl(url, data);
99111
if (problem === null) {
100-
writeProblemName("error");
112+
writeProblemName(null);
101113
let message =
102114
"Please use the command-line version instead: https://github.com/online-judge-tools/template-generator";
103115
if (
104-
!url.match(/\batcoder\b/) &&
105-
!url.match(/\bcodeforces\b/) &&
106-
!url.match(/\byosupo\b/)
116+
url.match(/\batcoder\b/) ||
117+
url.match(/\bcodeforces\b/) ||
118+
url.match(/\byosupo\b/)
107119
) {
120+
message =
121+
"Probably the data for your problem is not pre-computed yet. This web-interface only supports old problems.\n" +
122+
message;
123+
} else {
108124
message =
109125
"Currently this web-interface only supports problems of AtCoder (atcoder.jp), Codeforces (codeforces.com), and Library-Checker (judge.yosupo.jp).\n" +
110126
message;

0 commit comments

Comments
 (0)