@@ -32,9 +32,18 @@ function readProblemUrl(): string {
32
32
return input . value ? input . value : defaultUrl ;
33
33
}
34
34
35
- function writeProblemName ( name : string ) : void {
35
+ function writeProblemName ( name : string | null ) : void {
36
36
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 ;
38
47
}
39
48
40
49
function writeGeneratedCode ( result : string , lang : string ) {
@@ -89,22 +98,29 @@ function update(): void {
89
98
const data = loadPrecomputedDataWithCache ( ) ;
90
99
const url = readProblemUrl ( ) ;
91
100
92
- const problem = lookupProblemFromUrl ( url , data ) ;
93
101
try {
94
102
new URL ( url ) ;
95
103
} catch ( err ) {
96
- writeProblemName ( "error" ) ;
104
+ writeProblemName ( null ) ;
97
105
writeGeneratedCode ( "not a URL: " + JSON . stringify ( url ) + "\n" , "plaintext" ) ;
106
+ return ;
98
107
}
108
+ writeProblemUrl ( url ) ;
109
+
110
+ const problem = lookupProblemFromUrl ( url , data ) ;
99
111
if ( problem === null ) {
100
- writeProblemName ( "error" ) ;
112
+ writeProblemName ( null ) ;
101
113
let message =
102
114
"Please use the command-line version instead: https://github.com/online-judge-tools/template-generator" ;
103
115
if (
104
- ! url . match ( / \b a t c o d e r \b / ) &&
105
- ! url . match ( / \b c o d e f o r c e s \b / ) &&
106
- ! url . match ( / \b y o s u p o \b / )
116
+ url . match ( / \b a t c o d e r \b / ) ||
117
+ url . match ( / \b c o d e f o r c e s \b / ) ||
118
+ url . match ( / \b y o s u p o \b / )
107
119
) {
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 {
108
124
message =
109
125
"Currently this web-interface only supports problems of AtCoder (atcoder.jp), Codeforces (codeforces.com), and Library-Checker (judge.yosupo.jp).\n" +
110
126
message ;
0 commit comments