|
151 | 151 | if(error){ |
152 | 152 | value = def.username; |
153 | 153 | } |
154 | | - $(info,'#username').value = value; |
| 154 | + ui.username = $(info,'#username'); |
| 155 | + ui.username.value = value; |
155 | 156 |
|
156 | 157 | var {value,error} = ls.read['chat-simple-password']; |
157 | 158 | if(error){ |
158 | 159 | value = def.password; |
159 | 160 | } |
160 | | - $(info,'#password').value = value; |
| 161 | + ui.password = $(info,'#password'); |
| 162 | + ui.password.value = value; |
| 163 | + |
161 | 164 | $(info,'#show').onclick = btn.password; |
162 | 165 | var {value,error} = ls.read['chat-simple-password-show']; |
163 | 166 | if(error){ |
164 | 167 | value = def['password-show']; |
165 | 168 | } |
166 | 169 | set.password(value); |
167 | 170 |
|
168 | | - $(shadow,'#txt').onkeydown = kd.txt; |
169 | | - $(shadow,'#txt').focus(); |
| 171 | + ui.txt = $(shadow,'#txt'); |
| 172 | + ui.txt.onkeydown = kd.txt; |
170 | 173 |
|
171 | 174 | $(shadow,'[value=send]').onclick = btn.send; |
172 | 175 | ui.pause = $(shadow,'[value=pause]'); |
173 | 176 | ui.pause.onclick = btn.pause; |
174 | 177 |
|
175 | 178 |
|
| 179 | + ui.read(); |
| 180 | + |
176 | 181 | }//initdom |
177 | 182 |
|
178 | 183 |
|
| 184 | + //: |
| 185 | + |
| 186 | + |
| 187 | + ui.write = function(){ |
| 188 | + |
| 189 | + ls.write['chat-simple-username'] = ui.username.value; |
| 190 | + ls.write['chat-simple-password'] = ui.password.value; |
| 191 | + ls.write['chat-simple-password-show'] = (ui.password.getAttribute('type')==='password') |
| 192 | + |
| 193 | + }//write |
| 194 | + |
| 195 | + |
179 | 196 | //: |
180 | 197 |
|
181 | 198 |
|
|
186 | 203 | var node = $(shadow,'#password'); |
187 | 204 | if(node.getAttribute('type')=='password'){ |
188 | 205 | set.password(false); |
189 | | - ls.write['chat-simple-password-show'] = false; |
190 | 206 | }else{ |
191 | 207 | set.password(true); |
192 | | - ls.write['chat-simple-password-show'] = true; |
193 | 208 | } |
| 209 | + ui.write(); |
194 | 210 |
|
195 | 211 | }//password |
196 | 212 |
|
|
209 | 225 |
|
210 | 226 | kd.txt = function(e){ |
211 | 227 | //console.log(e.ctrlKey,e.key); |
| 228 | + var f = false; |
212 | 229 | if(e.ctrlKey && e.key=='Enter'){ |
213 | 230 | btn.send(); |
| 231 | + f = true; |
214 | 232 | } |
215 | 233 | if(e.ctrlKey && e.key==' '){ |
216 | 234 | btn.pause(); |
| 235 | + f = true; |
| 236 | + } |
| 237 | + |
| 238 | + if(f){ |
| 239 | + e.preventDefault(); |
217 | 240 | } |
218 | 241 |
|
219 | 242 | }//user |
220 | 243 |
|
221 | 244 |
|
222 | 245 | btn.send = function(){ |
223 | 246 |
|
224 | | - $(shadow,'#txt').focus(); |
| 247 | + ui.txt.focus(); |
| 248 | + ui.write(); |
225 | 249 |
|
226 | | - var txt = $(shadow,'#txt').value; |
227 | | - $(shadow,'#txt').value = ''; |
228 | | - var username = $(shadow,'#username').value; |
229 | | - ls.write.username = username; |
230 | | - var password = $(shadow,'#password').value; |
231 | | - ls.write.password = password; |
232 | | - var ts = display.last; |
| 250 | + var txt = ui.txt.value; |
| 251 | + ui.txt.value = ''; |
| 252 | + var username = ui.username.value; |
| 253 | + var password = ui.password.value; |
| 254 | + var ts = display.last; |
233 | 255 |
|
234 | 256 | send.msg({username,password,txt,ts}); |
235 | 257 |
|
|
239 | 261 | btn.pause = function(){ |
240 | 262 |
|
241 | 263 | $(shadow,'#txt').focus(); |
| 264 | + ui.write(); |
242 | 265 |
|
243 | 266 | if(poll.abort){ |
244 | 267 | ui.pause.value = 'pause'; |
|
0 commit comments