Skip to content

Commit 2b847e7

Browse files
save file
1 parent e0243b8 commit 2b847e7

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

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

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,13 @@
204204

205205
$(shadow,'#txt').focus();
206206

207-
var txt = $(shadow,'#txt').value;
208-
$(shadow,'#txt').value = '';
209-
var username = $(shadow,'#username').value;
210-
var password = $(shadow,'#password').value;
207+
var txt = $(shadow,'#txt').value;
208+
$(shadow,'#txt').value = '';
209+
var username = $(shadow,'#username').value;
210+
var password = $(shadow,'#password').value;
211+
var ts = display.last;
211212

212-
send({username,password,txt});
213+
send.msg({username,password,txt,ts});
213214

214215
}//send
215216

@@ -280,6 +281,22 @@
280281

281282
return nmsg;
282283

284+
285+
function del(){
286+
287+
var name = $(shadow,'#username').value;
288+
if(username!==name){
289+
log.red('invalid username');
290+
return;
291+
}
292+
293+
var password = $(shadow,'#password').value;
294+
var del_id = msg_id;
295+
var ts = display.last;
296+
send.del({username,password,del_id,ts});
297+
298+
}//del
299+
283300
}//display
284301

285302

@@ -292,33 +309,22 @@
292309
}//delete
293310

294311

295-
async function del({username:m_username,msg_id}){
312+
//:
313+
314+
315+
send.del = async function({username,password,del_id,ts}){
296316

297-
var username = $(shadow,'#username').value;
298-
if(username!==m_username){
299-
log.red('invalid username');
300-
return;
301-
}
302-
303-
var password = $(shadow,'#password').value;
304-
var del_id = msg_id;
305-
var ts = display.last;
306-
307317
var result = await post('simple/del',{room_id,username,password,del_id,ts});
308-
console.log('del',result);
309318
if(!result)return;
310-
311319
display.result(result);
312320

313321
}//del
314322

315323

316-
async function send({username,password,txt}){
324+
send.msg = async function({username,password,txt,ts}){
317325
//console.log('post.msg');
318-
var ts = display.last;
319326
var result = await post('simple/msg',{room_id,username,password,txt,ts});
320327
if(!result)return;
321-
322328
display.result(result);
323329

324330
}//msg

0 commit comments

Comments
 (0)