Skip to content

Commit 0f6d53a

Browse files
save file
1 parent 1be6065 commit 0f6d53a

1 file changed

Lines changed: 78 additions & 4 deletions

File tree

html/chat-room/html/chat-room-tmp/chat-room-tmp.html

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<template shadowrootmode=open>
66

7+
78
<style>
89

910
#user-root
@@ -26,6 +27,7 @@
2627

2728
</style>
2829

30+
2931
<section id=user-root>
3032

3133
<div id=info>
@@ -59,8 +61,10 @@
5961

6062
</section>
6163

64+
6265
</template>
6366

67+
6468
<script>
6569

6670
(function({mod,host}){
@@ -70,27 +74,37 @@
7074
var df=true,did='chat-room-tmp';
7175

7276

73-
var debug
77+
var debug,$
7478
;
7579

7680
obj.initmod = function(params){
7781

7882
debug = mod.rd(params,'debug',debug);
83+
$ = mod.rd(params,'$',$);
7984

8085
}//initmod
8186

8287

8388
//:
8489

85-
var ui = {};
90+
var ui = {};
91+
8692

93+
var btn = {};
94+
var kd = {};
8795

96+
//:
97+
98+
8899
obj.init = async function(){
89100
debug=eval(debug.mod);
90101
debug('init');
91102
}//init
92103

93104

105+
//:
106+
107+
94108
obj.initdom = async function(){
95109

96110
var info = $(shadow,'#info');
@@ -108,13 +122,73 @@
108122
}//initdom
109123

110124

111-
112125
//:
113126

114127

115-
128+
btn.password = function(){
129+
130+
$(shadow,'#txt').focus();
131+
132+
var node = $(shadow,'#password');
133+
if(node.getAttribute('type')=='password'){
134+
node.removeAttribute('type');
135+
}else{
136+
node.setAttribute('type','password');
137+
}
138+
139+
}//password
140+
141+
142+
kd.user = function(e){
143+
144+
if(e.ctrlKey && e.key=='Enter'){
145+
btn.send();
146+
}
147+
if(e.ctrlKey && e.key=='Space'){
148+
btn.pause();
149+
}
150+
151+
}//user
152+
153+
154+
btn.send = function(){
155+
156+
$(shadow,'#txt').focus();
157+
158+
var txt = $(shadow,'#txt').value;
159+
$(shadow,'#txt').value = '';
160+
var user = $(shadow,'#user').value;
161+
var password = $(shadow,'#password').value;
162+
163+
post.msg({user,password,txt});
164+
165+
}//send
166+
167+
168+
btn.pause = function(){
169+
170+
$(shadow,'#txt').focus();
171+
172+
if(poll.abort){
173+
ui.pause.value = 'pause';
174+
poll.abort = false;
175+
poll.update.initial();
176+
}else{
177+
ui.pause.value = 'resume';
178+
poll.abort = true;
179+
}
180+
181+
}//pause
182+
183+
184+
185+
186+
116187
})
117188

189+
</script>
190+
191+
118192
</chat-room-tmp>
119193

120194

0 commit comments

Comments
 (0)