- commit
- 5804bfc1f454deb651197898693abacd3ca5ef25
- parent
- 23ea2032db1c428371288a5e0fe6f4bd08a32709
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-05-05 17:39
set readonly when offline
Diffstat
M | index.html | 2 | +- |
M | static/index.js | 3 | +++ |
M | static/style.css | 4 | ++++ |
3 files changed, 8 insertions, 1 deletions
diff --git a/index.html b/index.html
@@ -8,7 +8,7 @@ 8 8 <link rel="stylesheet" href="/static/style.css"> 9 9 </head> 10 10 <body>11 -1 <textarea autocomplete="off" autofocus placeholder="Collaborative editor-1 11 <textarea autocomplete="off" readonly autofocus placeholder="Collaborative editor 12 12 13 13 Warning: All text is deleted when the last person leaves."></textarea> 14 14 <script type="module" src="/static/index.js"></script>
diff --git a/static/index.js b/static/index.js
@@ -41,12 +41,15 @@ signal.listen(room, function(msg) { 41 41 return; 42 42 } else if (msg.type === 'open') { 43 43 signal.send(room, {sender: id, type: 'request'}); -1 44 } else if (msg.type === 'error') { -1 45 el.readOnly = true; 44 46 } else if (msg.type === 'changes') { 45 47 applyChanges(msg.data); 46 48 } else if (msg.type === 'request') { 47 49 signal.send(room, {sender: id, type: 'text', data: el.value}); 48 50 } else if (msg.type === 'text' && !el.value) { 49 51 setText(msg.data, 0, 0); -1 52 el.readOnly = false; 50 53 } 51 54 }); 52 55
diff --git a/static/style.css b/static/style.css
@@ -14,3 +14,7 @@ textarea { 14 14 box-sizing: border-box; 15 15 font-size: 120%; 16 16 } -1 17 -1 18 textarea[readonly] { -1 19 background: #eee; -1 20 }