@@ -105,10 +105,9 @@ class Client {
105
105
gameVersion . innerText = version ;
106
106
107
107
const newsModal = document . querySelector ( "news-modal" ) as NewsModal ;
108
- if ( ! newsModal ) {
108
+ if ( ! newsModal || ! ( newsModal instanceof NewsModal ) ) {
109
109
console . warn ( "News modal element not found" ) ;
110
110
}
111
- newsModal instanceof NewsModal ;
112
111
const newsButton = document . querySelector ( "news-button" ) as NewsButton ;
113
112
if ( ! newsButton ) {
114
113
console . warn ( "News button element not found" ) ;
@@ -167,7 +166,9 @@ class Client {
167
166
const spModal = document . querySelector (
168
167
"single-player-modal" ,
169
168
) as SinglePlayerModal ;
170
- spModal instanceof SinglePlayerModal ;
169
+ if ( ! spModal || ! ( spModal instanceof SinglePlayerModal ) ) {
170
+ console . warn ( "Singleplayer modal element not found" ) ;
171
+ }
171
172
172
173
const singlePlayer = document . getElementById ( "single-player" ) ;
173
174
if ( singlePlayer === null ) throw new Error ( "Missing single-player" ) ;
@@ -184,7 +185,9 @@ class Client {
184
185
// });
185
186
186
187
const hlpModal = document . querySelector ( "help-modal" ) as HelpModal ;
187
- hlpModal instanceof HelpModal ;
188
+ if ( ! hlpModal || ! ( hlpModal instanceof HelpModal ) ) {
189
+ console . warn ( "Help modal element not found" ) ;
190
+ }
188
191
const helpButton = document . getElementById ( "help-button" ) ;
189
192
if ( helpButton === null ) throw new Error ( "Missing help-button" ) ;
190
193
helpButton . addEventListener ( "click" , ( ) => {
@@ -194,7 +197,10 @@ class Client {
194
197
const flagInputModal = document . querySelector (
195
198
"flag-input-modal" ,
196
199
) as FlagInputModal ;
197
- flagInputModal instanceof FlagInputModal ;
200
+ if ( ! flagInputModal || ! ( flagInputModal instanceof FlagInputModal ) ) {
201
+ console . warn ( "Flag input modal element not found" ) ;
202
+ }
203
+
198
204
const flgInput = document . getElementById ( "flag-input_" ) ;
199
205
if ( flgInput === null ) throw new Error ( "Missing flag-input_" ) ;
200
206
flgInput . addEventListener ( "click" , ( ) => {
@@ -204,10 +210,15 @@ class Client {
204
210
this . patternsModal = document . querySelector (
205
211
"territory-patterns-modal" ,
206
212
) as TerritoryPatternsModal ;
213
+ if (
214
+ ! this . patternsModal ||
215
+ ! ( this . patternsModal instanceof TerritoryPatternsModal )
216
+ ) {
217
+ console . warn ( "Territory patterns modal element not found" ) ;
218
+ }
207
219
const patternButton = document . getElementById (
208
220
"territory-patterns-input-preview-button" ,
209
221
) ;
210
- this . patternsModal instanceof TerritoryPatternsModal ;
211
222
if ( patternButton === null )
212
223
throw new Error ( "territory-patterns-input-preview-button" ) ;
213
224
this . patternsModal . previewButton = patternButton ;
@@ -219,7 +230,12 @@ class Client {
219
230
this . tokenLoginModal = document . querySelector (
220
231
"token-login" ,
221
232
) as TokenLoginModal ;
222
- this . tokenLoginModal instanceof TokenLoginModal ;
233
+ if (
234
+ ! this . tokenLoginModal ||
235
+ ! ( this . tokenLoginModal instanceof TokenLoginModal )
236
+ ) {
237
+ console . warn ( "Token login modal element not found" ) ;
238
+ }
223
239
224
240
const onUserMe = async ( userMeResponse : UserMeResponse | false ) => {
225
241
document . dispatchEvent (
@@ -330,7 +346,9 @@ class Client {
330
346
const settingsModal = document . querySelector (
331
347
"user-setting" ,
332
348
) as UserSettingModal ;
333
- settingsModal instanceof UserSettingModal ;
349
+ if ( ! settingsModal || ! ( settingsModal instanceof UserSettingModal ) ) {
350
+ console . warn ( "User settings modal element not found" ) ;
351
+ }
334
352
document
335
353
. getElementById ( "settings-button" )
336
354
?. addEventListener ( "click" , ( ) => {
@@ -340,7 +358,9 @@ class Client {
340
358
const hostModal = document . querySelector (
341
359
"host-lobby-modal" ,
342
360
) as HostPrivateLobbyModal ;
343
- hostModal instanceof HostPrivateLobbyModal ;
361
+ if ( ! hostModal || ! ( hostModal instanceof HostPrivateLobbyModal ) ) {
362
+ console . warn ( "Host private lobby modal element not found" ) ;
363
+ }
344
364
const hostLobbyButton = document . getElementById ( "host-lobby-button" ) ;
345
365
if ( hostLobbyButton === null ) throw new Error ( "Missing host-lobby-button" ) ;
346
366
hostLobbyButton . addEventListener ( "click" , ( ) => {
@@ -353,7 +373,9 @@ class Client {
353
373
this . joinModal = document . querySelector (
354
374
"join-private-lobby-modal" ,
355
375
) as JoinPrivateLobbyModal ;
356
- this . joinModal instanceof JoinPrivateLobbyModal ;
376
+ if ( ! this . joinModal || ! ( this . joinModal instanceof JoinPrivateLobbyModal ) ) {
377
+ console . warn ( "Join private lobby modal element not found" ) ;
378
+ }
357
379
const joinPrivateLobbyButton = document . getElementById (
358
380
"join-private-lobby-button" ,
359
381
) ;
@@ -550,8 +572,9 @@ class Client {
550
572
const startingModal = document . querySelector (
551
573
"game-starting-modal" ,
552
574
) as GameStartingModal ;
553
- startingModal instanceof GameStartingModal ;
554
- startingModal . show ( ) ;
575
+ if ( startingModal && startingModal instanceof GameStartingModal ) {
576
+ startingModal . show ( ) ;
577
+ }
555
578
} ,
556
579
( ) => {
557
580
this . joinModal . close ( ) ;
0 commit comments