pad

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

commit
b474d6176eed8555e17a0a70e5b3365caa8a8be8
parent
a0586d1c5d1127da54ecb57b668bd1dc0c3c601b
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-05-03 10:56
foo

Diffstat

M context.mjs 2 +-
R index.js -> index.mjs 18 +++++++++---------

2 files changed, 10 insertions, 10 deletions


diff --git a/context.mjs b/context.mjs

@@ -1,7 +1,7 @@
    1     1 import * as fuzzy from './fuzzy.mjs';
    2     2 
    3     3 var applyExact = function(text, [pos, before, after], selection) {
    4    -1 	if (text.slice(pos).startsWith(before)) {
   -1     4 	if (pos >= 0 && text.slice(pos).startsWith(before)) {
    5     5 		if (selection) {
    6     6 			if (pos < selection[0]) {
    7     7 				selection[0] += after.length - before.length;

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

@@ -16,6 +16,12 @@ el.addEventListener('input', function() {
   16    16 	old = el.value;
   17    17 });
   18    18 
   -1    19 signal.listen(room, function(msg) {
   -1    20 	if (msg.sender !== id && msg.changes) {
   -1    21 		remoteChanges = remoteChanges.concat(msg.changes);
   -1    22 	}
   -1    23 });
   -1    24 
   19    25 setInterval(function() {
   20    26 	if (localChanges.length) {
   21    27 		signal.post(room, {
@@ -30,16 +36,10 @@ setInterval(function() {
   30    36 	while (remoteChanges.length) {
   31    37 		text = context.apply(text, remoteChanges.shift(), selection);
   32    38 	}
   33    -1 	el.value = text;
   34    -1 	old = text;
   35    -1 	if (el.selectionStart !== selection[0] || el.selectionEnd !== selection[1]) {
   -1    39 	if (text !== el.value) {
   -1    40 		el.value = text;
   36    41 		el.selectionStart = selection[0];
   37    42 		el.selectionEnd = selection[1];
   -1    43 		old = text;
   38    44 	}
   39    45 }, 500);
   40    -1 
   41    -1 signal.listen(room, function(msg) {
   42    -1 	if (msg.sender !== id && msg.changes) {
   43    -1 		remoteChanges = remoteChanges.concat(msg.changes);
   44    -1 	}
   45    -1 });