@@ -8,10 +8,12 @@ const cancelLink = document.getElementById("request_modal_cancel_button");
8
8
const timeoutCounter = document . getElementById ( "timeout_counter" ) ;
9
9
const timeoutBar = document . getElementById ( "timeout_bar" ) ;
10
10
const requestTimeoutAlert = document . getElementById ( "request_timeout_alert" ) ;
11
+ const requestNamelessAlert = document . getElementById ( "request_nameless_alert" ) ;
11
12
const requestAnswerAlert = document . getElementById ( "request_answer_alert" ) ;
12
13
const requestNvmAlert = document . getElementById ( "request_nvm_alert" ) ;
13
14
const timeoutDiv = document . getElementById ( "timeout_div" ) ;
14
15
const requestTitle = document . getElementById ( "request_modal_title" ) ;
16
+ const namelessTitle = document . getElementById ( "nameless_title" ) ;
15
17
16
18
// TODO: This feels janky.
17
19
// Sets up the event listeners for the various doors specified by the
@@ -27,8 +29,18 @@ function homePageSetup() {
27
29
}
28
30
29
31
function knockSocket ( location ) {
32
+ if ( nameInput . value === "" ) {
33
+ displayNameless ( ) ;
34
+ return ;
35
+ }
36
+ console . log ( location . protocol ) ;
37
+ // If we're http, then we'll use an unencrypted websocket (for development)
38
+ let socketProtocol = 'wss' ;
39
+ if ( location . protocol !== 'https:' ) {
40
+ socketProtocol = 'ws' ;
41
+ }
30
42
host = window . location . host ;
31
- url = `wss ://${ host } /knock/socket/${ location } ` ;
43
+ url = `${ socketProtocol } ://${ host } /knock/socket/${ location } ` ;
32
44
ws = new WebSocket ( url ) ;
33
45
34
46
ws . onopen = function ( ) {
@@ -70,6 +82,7 @@ function socketNevermind(ws, location) {
70
82
71
83
function displayAcknowledge ( ) {
72
84
requestAnswerAlert . hidden = false ;
85
+ requestNamelessAlert . hidden = true ;
73
86
timeoutDiv . hidden = true ;
74
87
homeLink . hidden = false ;
75
88
cancelLink . hidden = true ;
@@ -79,6 +92,21 @@ function displayTimeout() {
79
92
timeoutCounter . hidden = true ;
80
93
timeoutBar . hidden = true ;
81
94
requestTimeoutAlert . hidden = false ;
95
+ requestNamelessAlert . hidden = true ;
96
+ timeoutDiv . hidden = true ;
97
+ homeLink . hidden = false ;
98
+ cancelLink . hidden = true ;
99
+ }
100
+
101
+ function displayNameless ( ) {
102
+ requestTitle . hidden = true ;
103
+ namelessTitle . hidden = false ;
104
+ timeoutCounter . hidden = true ;
105
+ timeoutBar . hidden = true ;
106
+ requestTimeoutAlert . hidden = true ;
107
+ requestAnswerAlert . hidden = true ;
108
+ requestNvmAlert . hidden = true ;
109
+ requestNamelessAlert . hidden = false ;
82
110
timeoutDiv . hidden = true ;
83
111
homeLink . hidden = false ;
84
112
cancelLink . hidden = true ;
@@ -96,13 +124,15 @@ function resetRequestModal() {
96
124
// Stuff that should be hidden
97
125
homeLink . hidden = true ;
98
126
requestTimeoutAlert . hidden = true ;
127
+ requestNamelessAlert . hidden = true ;
99
128
requestAnswerAlert . hidden = true ;
100
129
requestNvmAlert . hidden = true ;
130
+ namelessTitle . hidden = true ;
101
131
102
132
// Stuff that should not be hidden
103
133
cancelLink . hidden = false ;
104
134
timeoutDiv . hidden = false ;
105
-
135
+ requestTitle . hidden = false ;
106
136
timeoutCounter . hidden = false ;
107
137
timeoutBar . hidden = false ;
108
138
0 commit comments