From e6a56390e3ae93b38c3957f840cc987c90b3a4ac Mon Sep 17 00:00:00 2001 From: Robert Beach Date: Sun, 26 Apr 2020 15:13:39 +0200 Subject: [PATCH 01/13] Added document tool --- client-data/board.html | 1 + client-data/tools/document/document.js | 74 ++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 client-data/tools/document/document.js diff --git a/client-data/board.html b/client-data/board.html index d4dc8ce6..76f31e54 100644 --- a/client-data/board.html +++ b/client-data/board.html @@ -88,6 +88,7 @@ + diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js new file mode 100644 index 00000000..eabc286f --- /dev/null +++ b/client-data/tools/document/document.js @@ -0,0 +1,74 @@ +(function documents() { //Code isolation + + +// This isn't an HTML5 canvas, it's an old svg hack, (the code is _that_ old!) + + var xlinkNS = "http://www.w3.org/1999/xlink"; + var imgCount = 1; + function onstart() { + const fileInput = document.createElement("input"); + fileInput.type = "file"; + fileInput.accept = "image/*"; + fileInput.click(); + fileInput.addEventListener("change", () => { + var reader = new FileReader(); + reader.readAsDataURL(fileInput.files[0]); + + reader.onload = function (e) { + var image = new Image(); + image.src = e.target.result; + image.onload = function () { + + var uid = Tools.generateUID("doc"); // doc for document + console.log(image.src.toString().length); + + var msg = { + id: uid, + type:"doc", + data: image.src, + w: this.width || 300, + h: this.height || 300, + x: (100+document.documentElement.scrollLeft)/Tools.scale+10*imgCount, + y: (100+document.documentElement.scrollTop)/Tools.scale + 10*imgCount + //fileType: fileInput.files[0].type + }; + draw(msg); + Tools.send(msg,"Document"); + imgCount++; + }; + }; + // Tools.change(Tools.prevToolName); + }); + } + + function draw(msg) { + //const file = self ? msg.data : new Blob([msg.data], { type: msg.fileType }); + //const fileURL = URL.createObjectURL(file); + + // fakeCanvas.style.background = `url("${fileURL}") 170px 0px no-repeat`; + //fakeCanvas.style.backgroundSize = "400px 500px"; + var aspect = msg.w/msg.h + var img = Tools.createSVGElement("image"); + img.id=msg.id; + img.setAttribute("class", "layer-"+Tools.layer); + img.setAttributeNS(xlinkNS, "href", msg.data); + img.x.baseVal.value = msg['x']; + img.y.baseVal.value = msg['y']; + img.setAttribute("width", 400*aspect); + img.setAttribute("height", 400); + if(msg.transform) + img.setAttribute("transform",msg.transform); + Tools.group.appendChild(img); + + } + + Tools.add({ + "name": "Document", + "icon": "🖼️", + //"shortcut": "", + "draw": draw, + "onstart": onstart, + "oneTouch":true + }); + +})(); //End of code isolation \ No newline at end of file From 6a4c9bd0bddad69c0422c987ae0efc68bb6a060e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sun, 26 Apr 2020 15:23:58 +0200 Subject: [PATCH 02/13] Added Document icon. Author: Dave Gandy (https://fontawesome.com), License: CC BY 4.0 --- client-data/tools/document/icon.svg | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 client-data/tools/document/icon.svg diff --git a/client-data/tools/document/icon.svg b/client-data/tools/document/icon.svg new file mode 100644 index 00000000..ce64b0db --- /dev/null +++ b/client-data/tools/document/icon.svg @@ -0,0 +1,17 @@ + + + + + + + + From 4b1ee6eea346856147af69c1224a40602c28497f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sun, 26 Apr 2020 15:24:34 +0200 Subject: [PATCH 03/13] change icon to fit new structure --- client-data/tools/document/document.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index eabc286f..c61d8891 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -64,11 +64,11 @@ Tools.add({ "name": "Document", - "icon": "🖼️", //"shortcut": "", "draw": draw, "onstart": onstart, - "oneTouch":true + "oneTouch":true, + "icon": "/tools/document/icon.svg", }); })(); //End of code isolation \ No newline at end of file From 9f210b3289c843a28fd0bb60ca324c726614a0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sun, 26 Apr 2020 15:26:58 +0200 Subject: [PATCH 04/13] ignore group/layers for now --- client-data/tools/document/document.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index c61d8891..7dc647d2 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -47,7 +47,7 @@ // fakeCanvas.style.background = `url("${fileURL}") 170px 0px no-repeat`; //fakeCanvas.style.backgroundSize = "400px 500px"; - var aspect = msg.w/msg.h + var aspect = msg.w/msg.h; var img = Tools.createSVGElement("image"); img.id=msg.id; img.setAttribute("class", "layer-"+Tools.layer); @@ -58,7 +58,7 @@ img.setAttribute("height", 400); if(msg.transform) img.setAttribute("transform",msg.transform); - Tools.group.appendChild(img); + Tools.svg.appendChild(img); } From 38bebf3e777f15bdafdccf2e28c3ebe8ccd4ee53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sun, 26 Apr 2020 18:52:11 +0200 Subject: [PATCH 05/13] Added checks for maximum filesize and amount of concurrent documents --- client-data/tools/document/document.js | 32 ++++++++++++++++++-------- server/configuration.js | 6 +++++ server/sockets.js | 26 ++++++++++++++++++++- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index 7dc647d2..6a625fba 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -3,33 +3,47 @@ // This isn't an HTML5 canvas, it's an old svg hack, (the code is _that_ old!) - var xlinkNS = "http://www.w3.org/1999/xlink"; - var imgCount = 1; + const xlinkNS = "http://www.w3.org/1999/xlink"; + let imgCount = 1; + function onstart() { const fileInput = document.createElement("input"); fileInput.type = "file"; fileInput.accept = "image/*"; fileInput.click(); fileInput.addEventListener("change", () => { - var reader = new FileReader(); + const reader = new FileReader(); reader.readAsDataURL(fileInput.files[0]); reader.onload = function (e) { - var image = new Image(); + const image = new Image(); image.src = e.target.result; image.onload = function () { var uid = Tools.generateUID("doc"); // doc for document - console.log(image.src.toString().length); - var msg = { + // File size as data url, approximately 1/3 larger than as bytestream + //TODO: internationalization + let size = image.src.toString().length; + if (size > 1048576) { //TODO: get correct size from config + alert("File too large"); + throw new Error("File too large"); + } + + if (Tools.svg.querySelectorAll("image").length > 5) { //TODO: get correct amount from config + alert("Too many documents exist already"); + throw new Error("Too many documents exist already"); + } + + const msg = { id: uid, - type:"doc", + type: "doc", data: image.src, + size: image.src.toString().length, w: this.width || 300, h: this.height || 300, - x: (100+document.documentElement.scrollLeft)/Tools.scale+10*imgCount, - y: (100+document.documentElement.scrollTop)/Tools.scale + 10*imgCount + x: (100 + document.documentElement.scrollLeft) / Tools.scale + 10 * imgCount, + y: (100 + document.documentElement.scrollTop) / Tools.scale + 10 * imgCount //fileType: fileInput.files[0].type }; draw(msg); diff --git a/server/configuration.js b/server/configuration.js index 62e95b07..8e579883 100644 --- a/server/configuration.js +++ b/server/configuration.js @@ -25,4 +25,10 @@ module.exports = { /** Maximum value for any x or y on the board */ MAX_BOARD_SIZE: parseInt(process.env['WBO_MAX_BOARD_SIZE']) || 65536, + + /** Maximum size of uploaded documents default 1MB */ + MAX_DOUMENT_SIZE: parseInt(process.env['WBO_MAX_DOCUMENT_SIZE']) || 1048576, + + /** Maximum number of documents allowed */ + MAX_DOCUMENTS: parseInt(process.env['WBO_MAX_DOCUMENTS']) || 5, }; \ No newline at end of file diff --git a/server/sockets.js b/server/sockets.js index ebfc96c2..f782f7fd 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -1,6 +1,7 @@ var iolib = require('socket.io') , log = require("./log.js").log - , BoardData = require("./boardData.js").BoardData; + , BoardData = require("./boardData.js").BoardData + , config = require("./configuration"); var MAX_EMIT_COUNT = 64; // Maximum number of draw operations before getting banned var MAX_EMIT_COUNT_PERIOD = 5000; // Duration (in ms) after which the emit count is reset @@ -51,6 +52,9 @@ function socketConnection(socket) { var board = await getBoard(name); board.users.add(socket.id); log('board joined', { 'board': board.name, 'users': board.users.size }); + + console.log(board); + return board; } @@ -96,6 +100,26 @@ function socketConnection(socket) { return; } + if (message.data.type === "doc") { + getBoard(boardName).then(boardData => { + let existingDocuments = 0; + for (key in boardData.board) { + if (boardData.board[key].type === "doc") { + existingDocuments += 1; + } + if (existingDocuments >= config.MAX_DOCUMENTS) { + console.warn("Received too many documents"); + return; + } + } + }); + + if (!message.data.size || message.data.size > config.MAX_DOUMENT_SIZE) { + console.warn("Received too large file"); + return; + } + } + //Send data to all other users connected on the same board socket.broadcast.to(boardName).emit('broadcast', data); From 52478537a5fce621f94bad4446f78967f80d0a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sat, 2 May 2020 18:51:26 +0200 Subject: [PATCH 06/13] pass through configuration from server --- client-data/tools/document/document.js | 4 ++-- server/client_configuration.js | 2 ++ server/configuration.js | 5 +++-- server/sockets.js | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index 6a625fba..59668076 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -25,12 +25,12 @@ // File size as data url, approximately 1/3 larger than as bytestream //TODO: internationalization let size = image.src.toString().length; - if (size > 1048576) { //TODO: get correct size from config + if (size > Tools.server_config.MAX_DOCUMENT_SIZE) { alert("File too large"); throw new Error("File too large"); } - if (Tools.svg.querySelectorAll("image").length > 5) { //TODO: get correct amount from config + if (Tools.svg.querySelectorAll("image").length > Tools.server_config.MAX_DOCUMENT_COUNT) { alert("Too many documents exist already"); throw new Error("Too many documents exist already"); } diff --git a/server/client_configuration.js b/server/client_configuration.js index 495775e3..9c0a1ad1 100644 --- a/server/client_configuration.js +++ b/server/client_configuration.js @@ -2,6 +2,8 @@ const config = require("./configuration"); /** Settings that should be handed through to the clients */ module.exports = { + "MAX_DOCUMENT_SIZE": config.MAX_DOCUMENT_SIZE, + "MAX_DOCUMENT_COUNT": config.MAX_DOCUMENT_COUNT, "MAX_BOARD_SIZE": config.MAX_BOARD_SIZE, "MAX_EMIT_COUNT": config.MAX_EMIT_COUNT, "MAX_EMIT_COUNT_PERIOD": config.MAX_EMIT_COUNT_PERIOD, diff --git a/server/configuration.js b/server/configuration.js index 1c1b90be..0df1beac 100644 --- a/server/configuration.js +++ b/server/configuration.js @@ -27,10 +27,11 @@ module.exports = { MAX_BOARD_SIZE: parseInt(process.env['WBO_MAX_BOARD_SIZE']) || 65536, /** Maximum size of uploaded documents default 1MB */ - MAX_DOUMENT_SIZE: parseInt(process.env['WBO_MAX_DOCUMENT_SIZE']) || 1048576, + MAX_DOCUMENT_SIZE: parseInt(process.env['WBO_MAX_DOCUMENT_SIZE']) || 1048576, /** Maximum number of documents allowed */ - MAX_DOCUMENTS: parseInt(process.env['WBO_MAX_DOCUMENTS']) || 5, + MAX_DOCUMENT_COUNT: parseInt(process.env['WBO_MAX_DOCUMENT_COUNT']) || 5, + /** Maximum messages per user over the given time period before banning them */ MAX_EMIT_COUNT: parseInt(process.env['WBO_MAX_EMIT_COUNT']) || 128, diff --git a/server/sockets.js b/server/sockets.js index dd671d36..0e780a4d 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -113,7 +113,7 @@ function socketConnection(socket) { } }); - if (!message.data.size || message.data.size > config.MAX_DOUMENT_SIZE) { + if (!message.data.size || message.data.size > config.MAX_DOCUMENT_SIZE) { console.warn("Received too large file"); return; } From 0a99ad2c2b8e170573fcced2ca6e1ef4980b86e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sun, 3 May 2020 12:30:33 +0200 Subject: [PATCH 07/13] remove debug logging --- server/sockets.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/sockets.js b/server/sockets.js index 0e780a4d..d8d84ffa 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -50,8 +50,6 @@ function socketConnection(socket) { board.users.add(socket.id); log('board joined', { 'board': board.name, 'users': board.users.size }); - console.log(board); - return board; } From 061f84d12661f8ac78e3f4309db0943323bf6368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sun, 3 May 2020 12:41:27 +0200 Subject: [PATCH 08/13] append to drawing area instead of svg root --- client-data/tools/document/document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index 59668076..d80044b8 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -72,7 +72,7 @@ img.setAttribute("height", 400); if(msg.transform) img.setAttribute("transform",msg.transform); - Tools.svg.appendChild(img); + Tools.drawingArea.appendChild(img); } From bc0e1e90551b7863ff7f8a4f93b4d271c16cf040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sun, 3 May 2020 15:44:39 +0200 Subject: [PATCH 09/13] compress image until it is small enough for upload --- client-data/tools/document/document.js | 72 +++++++++++++++----------- 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index d80044b8..730f1266 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -1,51 +1,72 @@ (function documents() { //Code isolation -// This isn't an HTML5 canvas, it's an old svg hack, (the code is _that_ old!) + var xlinkNS = "http://www.w3.org/1999/xlink"; + var imgCount = 1; - const xlinkNS = "http://www.w3.org/1999/xlink"; - let imgCount = 1; + function assert_count() { + if (Tools.svg.querySelectorAll("image").length > Tools.server_config.MAX_DOCUMENT_COUNT) { + alert("Too many documents exist already"); + throw new Error("Too many documents exist already"); + } + } function onstart() { - const fileInput = document.createElement("input"); + var fileInput = document.createElement("input"); fileInput.type = "file"; fileInput.accept = "image/*"; fileInput.click(); fileInput.addEventListener("change", () => { - const reader = new FileReader(); + assert_count(); + + var reader = new FileReader(); reader.readAsDataURL(fileInput.files[0]); reader.onload = function (e) { - const image = new Image(); + // use canvas to compress image + var image = new Image(); image.src = e.target.result; image.onload = function () { + assert_count(); + var uid = Tools.generateUID("doc"); // doc for document - // File size as data url, approximately 1/3 larger than as bytestream - //TODO: internationalization - let size = image.src.toString().length; - if (size > Tools.server_config.MAX_DOCUMENT_SIZE) { - alert("File too large"); - throw new Error("File too large"); - } + var ctx, size; + var scale = 1; + + do { + ctx = document.createElement("canvas").getContext("2d"); + ctx.canvas.width = image.width * scale; + ctx.canvas.height = image.height * scale; + ctx.drawImage(image, 0, 0, image.width * scale, image.height * scale); + var dataURL = ctx.canvas.toDataURL("image/webp", 0.7); - if (Tools.svg.querySelectorAll("image").length > Tools.server_config.MAX_DOCUMENT_COUNT) { - alert("Too many documents exist already"); - throw new Error("Too many documents exist already"); - } + // Compressed file size as data url, approximately 1/3 larger than as bytestream + size = dataURL.length; - const msg = { + console.log(size, scale); + // attempt again with an image that is at least 10% smaller + scale = scale * Math.sqrt(Math.min( + 0.9, + Tools.server_config.MAX_DOCUMENT_SIZE / size + )); + } while (size > Tools.server_config.MAX_DOCUMENT_SIZE); + + var msg = { id: uid, type: "doc", - data: image.src, - size: image.src.toString().length, - w: this.width || 300, - h: this.height || 300, + data: dataURL, + size: size, + w: this.width * scale || 300, + h: this.height * scale || 300, x: (100 + document.documentElement.scrollLeft) / Tools.scale + 10 * imgCount, y: (100 + document.documentElement.scrollTop) / Tools.scale + 10 * imgCount //fileType: fileInput.files[0].type }; + + assert_count(); + draw(msg); Tools.send(msg,"Document"); imgCount++; @@ -56,11 +77,6 @@ } function draw(msg) { - //const file = self ? msg.data : new Blob([msg.data], { type: msg.fileType }); - //const fileURL = URL.createObjectURL(file); - - // fakeCanvas.style.background = `url("${fileURL}") 170px 0px no-repeat`; - //fakeCanvas.style.backgroundSize = "400px 500px"; var aspect = msg.w/msg.h; var img = Tools.createSVGElement("image"); img.id=msg.id; @@ -70,8 +86,6 @@ img.y.baseVal.value = msg['y']; img.setAttribute("width", 400*aspect); img.setAttribute("height", 400); - if(msg.transform) - img.setAttribute("transform",msg.transform); Tools.drawingArea.appendChild(img); } From b1b875a8695965185a7befc33130dc6cf8855a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Sun, 3 May 2020 17:57:55 +0200 Subject: [PATCH 10/13] actually verify size --- server/sockets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/sockets.js b/server/sockets.js index d8d84ffa..4c1d2d75 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -111,7 +111,7 @@ function socketConnection(socket) { } }); - if (!message.data.size || message.data.size > config.MAX_DOCUMENT_SIZE) { + if (message.data.data.length > config.MAX_DOCUMENT_SIZE) { console.warn("Received too large file"); return; } From 4e258c0132a87099a931fcb4f3ed5efb644223c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Finn=20B=C3=B6ger?= Date: Mon, 4 May 2020 17:39:58 +0200 Subject: [PATCH 11/13] compute existing document count only on board load on the server side --- client-data/tools/document/document.js | 5 +++-- server/boardData.js | 6 +++++- server/sockets.js | 29 ++++++++++++++------------ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index 730f1266..e1d61b27 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -5,7 +5,7 @@ var imgCount = 1; function assert_count() { - if (Tools.svg.querySelectorAll("image").length > Tools.server_config.MAX_DOCUMENT_COUNT) { + if (Tools.svg.querySelectorAll("image").length >= Tools.server_config.MAX_DOCUMENT_COUNT) { alert("Too many documents exist already"); throw new Error("Too many documents exist already"); } @@ -36,6 +36,8 @@ var scale = 1; do { + // Todo give feedback of processing effort + ctx = document.createElement("canvas").getContext("2d"); ctx.canvas.width = image.width * scale; ctx.canvas.height = image.height * scale; @@ -45,7 +47,6 @@ // Compressed file size as data url, approximately 1/3 larger than as bytestream size = dataURL.length; - console.log(size, scale); // attempt again with an image that is at least 10% smaller scale = scale * Math.sqrt(Math.min( 0.9, diff --git a/server/boardData.js b/server/boardData.js index 5d354880..cb7ac038 100644 --- a/server/boardData.js +++ b/server/boardData.js @@ -228,7 +228,11 @@ BoardData.load = async function loadBoard(name) { try { data = await fs.promises.readFile(boardData.file); boardData.board = JSON.parse(data); - for (id in boardData.board) boardData.validate(boardData.board[id]); + boardData.existingDocuments = 0; + for (id in boardData.board) { + boardData.validate(boardData.board[id]); + if (boardData.board[id].type === "doc") existingDocuments += 1; + } log('disk load', { 'board': boardData.name }); } catch (e) { log('empty board creation', { diff --git a/server/sockets.js b/server/sockets.js index 4c1d2d75..c2f5261c 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -67,7 +67,7 @@ function socketConnection(socket) { var lastEmitSecond = Date.now() / config.MAX_EMIT_COUNT_PERIOD | 0; var emitCount = 0; - socket.on('broadcast', noFail(function onBroadcast(message) { + socket.on('broadcast', noFail(async function onBroadcast(message) { var currentSecond = Date.now() / config.MAX_EMIT_COUNT_PERIOD | 0; if (currentSecond === lastEmitSecond) { emitCount++; @@ -97,24 +97,27 @@ function socketConnection(socket) { return; } + var boardData; if (message.data.type === "doc") { - getBoard(boardName).then(boardData => { - let existingDocuments = 0; - for (key in boardData.board) { - if (boardData.board[key].type === "doc") { - existingDocuments += 1; - } - if (existingDocuments >= config.MAX_DOCUMENTS) { - console.warn("Received too many documents"); - return; - } - } - }); + boardData = await getBoard(boardName); + + if (boardData.existingDocuments >= config.MAX_DOCUMENT_COUNT) { + console.warn("Received too many documents"); + return; + } if (message.data.data.length > config.MAX_DOCUMENT_SIZE) { console.warn("Received too large file"); return; } + + boardData.existingDocuments += 1; + } else if (message.data.type === "delete") { + boardData = await getBoard(boardName); + + if (boardData.board[message.data.id].type === "doc") { + boardData.existingDocuments -= 1; + } } // Save the message in the board From 006739970d153e9d9bee18f1f334d2d5020eb39b Mon Sep 17 00:00:00 2001 From: finnboeger Date: Tue, 5 May 2020 20:18:26 +0200 Subject: [PATCH 12/13] remove es6 Co-authored-by: Ophir LOJKINE --- client-data/tools/document/document.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client-data/tools/document/document.js b/client-data/tools/document/document.js index e1d61b27..77fc532a 100644 --- a/client-data/tools/document/document.js +++ b/client-data/tools/document/document.js @@ -16,7 +16,7 @@ fileInput.type = "file"; fileInput.accept = "image/*"; fileInput.click(); - fileInput.addEventListener("change", () => { + fileInput.addEventListener("change", function () { assert_count(); var reader = new FileReader(); @@ -100,4 +100,4 @@ "icon": "/tools/document/icon.svg", }); -})(); //End of code isolation \ No newline at end of file +})(); //End of code isolation From 8aefd41be3c2c15495ed60584e42b81f0b9e9578 Mon Sep 17 00:00:00 2001 From: Ophir LOJKINE Date: Thu, 1 Oct 2020 14:12:52 +0200 Subject: [PATCH 13/13] Update sockets.js --- server/sockets.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/sockets.js b/server/sockets.js index af680809..f152c41a 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -97,7 +97,7 @@ function socketConnection(socket) { return; } - if (!message.data.tool || config.BLOCKED_TOOLS.includes(message.data.tool)) { + if (!message.data.tool || config.BLOCKED_TOOLS.includes(message.data.tool)) { log('BLOCKED MESSAGE', message.data); return; } @@ -122,6 +122,7 @@ function socketConnection(socket) { if (boardData.board[message.data.id].type === "doc") { boardData.existingDocuments -= 1; + } } // Save the message in the board