| 17 | let logConnected = false; |
| 18 | |
| 19 | function dateToStr(ts: number): string { |
| 20 | const dt = new Date(1000 * ts); |
| 21 | const year = dt.getFullYear(); |
| 22 | const mo = String(dt.getMonth() + 1).padStart(2, '0'); |
| 23 | const day = String(dt.getDate()).padStart(2, '0'); |
| 24 | const hour = String(dt.getHours()).padStart(2, '0'); |
| 25 | const min = String(dt.getMinutes()).padStart(2, '0'); |
| 26 | const sec = String(dt.getSeconds()).padStart(2, '0'); |
| 27 | const ms = String(dt.getMilliseconds()).padStart(3, '0'); |
| 28 | const s = `${year}-${mo}-${day} ${hour}:${min}:${sec}.${ms}`; |
| 29 | return s; |
| 30 | } |
| 31 | |
| 32 | function htmlEscape(text: string): string { |
| 33 | return text.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>'); |