Skip to content

Commit 6c98128

Browse files
save file
1 parent 4fbf9ec commit 6c98128

1 file changed

Lines changed: 37 additions & 14 deletions

File tree

html/chat-room/html/chat-room-simple/chat-room-simple.html

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,31 +151,48 @@
151151
if(error){
152152
value = def.username;
153153
}
154-
$(info,'#username').value = value;
154+
ui.username = $(info,'#username');
155+
ui.username.value = value;
155156

156157
var {value,error} = ls.read['chat-simple-password'];
157158
if(error){
158159
value = def.password;
159160
}
160-
$(info,'#password').value = value;
161+
ui.password = $(info,'#password');
162+
ui.password.value = value;
163+
161164
$(info,'#show').onclick = btn.password;
162165
var {value,error} = ls.read['chat-simple-password-show'];
163166
if(error){
164167
value = def['password-show'];
165168
}
166169
set.password(value);
167170

168-
$(shadow,'#txt').onkeydown = kd.txt;
169-
$(shadow,'#txt').focus();
171+
ui.txt = $(shadow,'#txt');
172+
ui.txt.onkeydown = kd.txt;
170173

171174
$(shadow,'[value=send]').onclick = btn.send;
172175
ui.pause = $(shadow,'[value=pause]');
173176
ui.pause.onclick = btn.pause;
174177

175178

179+
ui.read();
180+
176181
}//initdom
177182

178183

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+
179196
//:
180197

181198

@@ -186,11 +203,10 @@
186203
var node = $(shadow,'#password');
187204
if(node.getAttribute('type')=='password'){
188205
set.password(false);
189-
ls.write['chat-simple-password-show'] = false;
190206
}else{
191207
set.password(true);
192-
ls.write['chat-simple-password-show'] = true;
193208
}
209+
ui.write();
194210

195211
}//password
196212

@@ -209,27 +225,33 @@
209225

210226
kd.txt = function(e){
211227
//console.log(e.ctrlKey,e.key);
228+
var f = false;
212229
if(e.ctrlKey && e.key=='Enter'){
213230
btn.send();
231+
f = true;
214232
}
215233
if(e.ctrlKey && e.key==' '){
216234
btn.pause();
235+
f = true;
236+
}
237+
238+
if(f){
239+
e.preventDefault();
217240
}
218241

219242
}//user
220243

221244

222245
btn.send = function(){
223246

224-
$(shadow,'#txt').focus();
247+
ui.txt.focus();
248+
ui.write();
225249

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;
233255

234256
send.msg({username,password,txt,ts});
235257

@@ -239,6 +261,7 @@
239261
btn.pause = function(){
240262

241263
$(shadow,'#txt').focus();
264+
ui.write();
242265

243266
if(poll.abort){
244267
ui.pause.value = 'pause';

0 commit comments

Comments
 (0)