pad

minimal etherpad alternative  https://pad.ce9e.org
git clone https://git.ce9e.org/pad.git

commit
23ea2032db1c428371288a5e0fe6f4bd08a32709
parent
42d5fd8ecb357e5e26d2cee41ca1d34277ef62c3
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-05-05 17:37
signal: add open/error messages

Diffstat

M static/index.js 4 ++--
M static/signal.js 2 ++

2 files changed, 4 insertions, 2 deletions


diff --git a/static/index.js b/static/index.js

@@ -39,6 +39,8 @@ el.addEventListener('input', function() {
   39    39 signal.listen(room, function(msg) {
   40    40 	if (msg.sender === id) {
   41    41 		return;
   -1    42 	} else if (msg.type === 'open') {
   -1    43 		signal.send(room, {sender: id, type: 'request'});
   42    44 	} else if (msg.type === 'changes') {
   43    45 		applyChanges(msg.data);
   44    46 	} else if (msg.type === 'request') {
@@ -60,5 +62,3 @@ setInterval(function() {
   60    62 		});
   61    63 	}
   62    64 }, 500);
   63    -1 
   64    -1 signal.send(room, {sender: id, type: 'request'});

diff --git a/static/signal.js b/static/signal.js

@@ -17,6 +17,8 @@ export var send = function(key, data) {
   17    17 export var listen = function(key, fn) {
   18    18 	var evtSource = new EventSource(baseUrl + 'msg/' + key);
   19    19 	evtSource.onmessage = msg => fn(JSON.parse(msg.data));
   -1    20 	evtSource.onopen = () => fn({type: 'open'});
   -1    21 	evtSource.onerror = () => fn({type: 'error'});
   20    22 };
   21    23 
   22    24 export var store = function(key, data) {