File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change 44
55{% block head %}
66 < title > Generation in Progress</ title >
7- < meta http-equiv ="refresh " content ="1 ">
7+ < noscript >
8+ < meta http-equiv ="refresh " content ="1 ">
9+ </ noscript >
810 < link rel ="stylesheet " type ="text/css " href ="{{ url_for('static', filename= "styles /waitSeed.css") }}"/>
911{% endblock %}
1012
@@ -16,4 +18,34 @@ <h1>Generation in Progress</h1>
1618 Waiting for game to generate, this page auto-refreshes to check.
1719 </ div >
1820 </ div >
21+ < script >
22+ const waitSeedDiv = document . getElementById ( "wait-seed" ) ;
23+ async function checkStatus ( ) {
24+ try {
25+ const response = await fetch ( "{{ url_for('api.wait_seed_api', seed=seed_id) }}" ) ;
26+ if ( response . status !== 202 ) {
27+ // Seed is ready; reload page to load seed page.
28+ location . reload ( ) ;
29+ return ;
30+ }
31+
32+ const data = await response . json ( ) ;
33+ waitSeedDiv . innerHTML = `
34+ <h1>Generation in Progress</h1>
35+ <p>${ data . text } </p>
36+ ` ;
37+
38+ setTimeout ( checkStatus , 1000 ) ; // Continue polling.
39+ } catch ( error ) {
40+ waitSeedDiv . innerHTML = `
41+ <h1>Progress Unknown</h1>
42+ <p>${ error . message } <br />(Last checked: ${ new Date ( ) . toLocaleTimeString ( ) } )</p>
43+ ` ;
44+
45+ setTimeout ( checkStatus , 1000 ) ;
46+ }
47+ }
48+
49+ setTimeout ( checkStatus , 1000 ) ;
50+ </ script >
1951{% endblock %}
You can’t perform that action at this time.
0 commit comments