|
4 | 4 |
|
5 | 5 | <template shadowrootmode=open> |
6 | 6 |
|
| 7 | + |
7 | 8 | <style> |
8 | 9 |
|
9 | 10 | #user-root |
|
26 | 27 |
|
27 | 28 | </style> |
28 | 29 |
|
| 30 | + |
29 | 31 | <section id=user-root> |
30 | 32 |
|
31 | 33 | <div id=info> |
|
59 | 61 |
|
60 | 62 | </section> |
61 | 63 |
|
| 64 | + |
62 | 65 | </template> |
63 | 66 |
|
| 67 | + |
64 | 68 | <script> |
65 | 69 |
|
66 | 70 | (function({mod,host}){ |
|
70 | 74 | var df=true,did='chat-room-tmp'; |
71 | 75 |
|
72 | 76 |
|
73 | | - var debug |
| 77 | + var debug,$ |
74 | 78 | ; |
75 | 79 |
|
76 | 80 | obj.initmod = function(params){ |
77 | 81 |
|
78 | 82 | debug = mod.rd(params,'debug',debug); |
| 83 | + $ = mod.rd(params,'$',$); |
79 | 84 |
|
80 | 85 | }//initmod |
81 | 86 |
|
82 | 87 |
|
83 | 88 | //: |
84 | 89 |
|
85 | | - var ui = {}; |
| 90 | + var ui = {}; |
| 91 | + |
86 | 92 |
|
| 93 | + var btn = {}; |
| 94 | + var kd = {}; |
87 | 95 |
|
| 96 | + //: |
| 97 | + |
| 98 | + |
88 | 99 | obj.init = async function(){ |
89 | 100 | debug=eval(debug.mod); |
90 | 101 | debug('init'); |
91 | 102 | }//init |
92 | 103 |
|
93 | 104 |
|
| 105 | + //: |
| 106 | + |
| 107 | + |
94 | 108 | obj.initdom = async function(){ |
95 | 109 |
|
96 | 110 | var info = $(shadow,'#info'); |
|
108 | 122 | }//initdom |
109 | 123 |
|
110 | 124 |
|
111 | | - |
112 | 125 | //: |
113 | 126 |
|
114 | 127 |
|
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 | + |
116 | 187 | }) |
117 | 188 |
|
| 189 | + </script> |
| 190 | + |
| 191 | + |
118 | 192 | </chat-room-tmp> |
119 | 193 |
|
120 | 194 |
|
|
0 commit comments