Index: lams_build/conf/whiteboard/config.default.yml =================================================================== diff -u -rb73d05cf773a739adb36cc867ad24eb73c207bf9 -r1cb71fb7cfd13ce1de802d0a069ebe849466a7fc --- lams_build/conf/whiteboard/config.default.yml (.../config.default.yml) (revision b73d05cf773a739adb36cc867ad24eb73c207bf9) +++ lams_build/conf/whiteboard/config.default.yml (.../config.default.yml) (revision 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc) @@ -34,7 +34,7 @@ # LAMS addition - URL prefix for uploaded images, without the trailing slash, for example # imageURL: "http://localhost:9003" # if it is blank, images will use relative path, for example "/uploads/.png" - imageURL : "" + imageURL: "" # draw the background grid to images on download ? (If True, even PNGs are also not transparent anymore) -- boolean drawBackgroundGrid: false Index: lams_build/conf/whiteboard/readme.txt =================================================================== diff -u -rfd658aaab63ae5e77711f5200d885d83ce330690 -r1cb71fb7cfd13ce1de802d0a069ebe849466a7fc --- lams_build/conf/whiteboard/readme.txt (.../readme.txt) (revision fd658aaab63ae5e77711f5200d885d83ce330690) +++ lams_build/conf/whiteboard/readme.txt (.../readme.txt) (revision 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc) @@ -2,7 +2,7 @@ 1. Get code from https://github.com/cracker0dks/whiteboard -Current version is 1.6 with all changes up to date 2021-05-19 +Current version is 1.6 with all changes up to date 2021-05-21 It requires Node.js version 16 as version 14 has a problem with image loading https://stackoverflow.com/questions/63610932/express-static-network-requests-stuck-on-pending @@ -22,8 +22,4 @@ 3.4 In s_whiteboard.js we introduce methods for copying and saving canvas contents. 3.5 In index.html we hide some buttons - In index.html and index.js we hide Whiteboard contents until everything loads, otherwise the UI looks messed up at first. - - 3.7 In config.default.yml, config-schema.json, ConfigService.js and whiteboard.js we introduce imageURL config property. - In vanilla Whiteboard all images are prefixed with current server URL. If we move Whiteboard or export & import data, it will not work. - Now images have relative URL prefixed with whatever is in imageURL. \ No newline at end of file + In index.html and index.js we hide Whiteboard contents until everything loads, otherwise the UI looks messed up at first. \ No newline at end of file Fisheye: Tag 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc refers to a dead (removed) revision in file `lams_build/conf/whiteboard/scripts/config/config-schema.json'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_build/conf/whiteboard/scripts/s_whiteboard.js =================================================================== diff -u -r77af7934c1b60274b5d2b534735179d56ea9b23b -r1cb71fb7cfd13ce1de802d0a069ebe849466a7fc --- lams_build/conf/whiteboard/scripts/s_whiteboard.js (.../s_whiteboard.js) (revision 77af7934c1b60274b5d2b534735179d56ea9b23b) +++ lams_build/conf/whiteboard/scripts/s_whiteboard.js (.../s_whiteboard.js) (revision 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc) @@ -6,12 +6,12 @@ var savedUndos = {}; var saveDelay = {}; -if (config.backend.enableFileDatabase){ - // make sure that folder with saved boards exists - fs.mkdirSync("savedBoards", { - // this option also mutes an error if path exists - recursive : true - }); +if (config.backend.enableFileDatabase) { + // make sure that folder with saved boards exists + fs.mkdirSync("savedBoards", { + // this option also mutes an error if path exists + recursive: true + }); } module.exports = { @@ -23,18 +23,18 @@ //Clear the whiteboard delete savedBoards[wid]; delete savedUndos[wid]; - // delete the corresponding file too - fs.unlink("savedBoards/" + wid + ".json", function(err) { - if (err) { - return console.log(err); - } - }); + // delete the corresponding file too + fs.unlink("savedBoards/" + wid + ".json", function (err) { + if (err) { + return console.log(err); + } + }); } else if (tool === "undo") { //Undo an action if (!savedUndos[wid]) { savedUndos[wid] = []; } - let savedBoard = this.loadStoredData(wid); + let savedBoard = this.loadStoredData(wid); if (savedBoard) { for (var i = savedBoards[wid].length - 1; i >= 0; i--) { if (savedBoards[wid][i]["username"] == username) { @@ -59,7 +59,7 @@ if (!savedUndos[wid]) { savedUndos[wid] = []; } - let savedBoard = this.loadStoredData(wid); + let savedBoard = this.loadStoredData(wid); for (var i = savedUndos[wid].length - 1; i >= 0; i--) { if (savedUndos[wid][i]["username"] == username) { var drawId = savedUndos[wid][i]["drawId"]; @@ -93,7 +93,7 @@ "setTextboxFontColor", ].includes(tool) ) { - let savedBoard = this.loadStoredData(wid); + let savedBoard = this.loadStoredData(wid); //Save all this actions delete content["wid"]; //Delete id from content so we don't store it twice if (tool === "setTextboxText") { @@ -109,61 +109,65 @@ } savedBoard.push(content); } - this.saveToDB(wid); + this.saveToDB(wid); }, - saveToDB : function(wid){ + saveToDB: function (wid) { if (config.backend.enableFileDatabase) { //Save whiteboard to file if (!saveDelay[wid]) { saveDelay[wid] = true; setTimeout(function () { saveDelay[wid] = false; - if (savedBoards[wid]) { - fs.writeFile("savedBoards/" + wid + ".json", JSON.stringify(savedBoards[wid]), (err) => { - if (err) { - return console.log(err); - } - }); - } + if (savedBoards[wid]) { + fs.writeFile( + "savedBoards/" + wid + ".json", + JSON.stringify(savedBoards[wid]), + (err) => { + if (err) { + return console.log(err); + } + } + ); + } }, 1000 * 10); //Save after 10 sec } } - }, - // Load saved whiteboard + }, + // Load saved whiteboard loadStoredData: function (wid) { - if (wid in savedBoards) { - return savedBoards[wid]; - } - - savedBoards[wid] = []; + if (wid in savedBoards) { + return savedBoards[wid]; + } - // try to load from DB - if (config.backend.enableFileDatabase) { - //read saved board from file - var filePath = "savedBoards/" + wid + ".json"; - if (fs.existsSync(filePath)) { - var data = fs.readFileSync(filePath); - if (data) { - savedBoards[wid] = JSON.parse(data); - } - } - } - - return savedBoards[wid]; + savedBoards[wid] = []; + + // try to load from DB + if (config.backend.enableFileDatabase) { + //read saved board from file + var filePath = "savedBoards/" + wid + ".json"; + if (fs.existsSync(filePath)) { + var data = fs.readFileSync(filePath); + if (data) { + savedBoards[wid] = JSON.parse(data); + } + } + } + + return savedBoards[wid]; }, - copyStoredData : function(sourceWid, targetWid) { - const sourceData = this.loadStoredData(sourceWid); - if (sourceData.length === 0 || this.loadStoredData(targetWid).lenght > 0) { - return; - } - savedBoards[targetWid] = sourceData.slice(); - this.saveToDB(targetWid); - }, + copyStoredData: function (sourceWid, targetWid) { + const sourceData = this.loadStoredData(sourceWid); + if (sourceData.length === 0 || this.loadStoredData(targetWid).lenght > 0) { + return; + } + savedBoards[targetWid] = sourceData.slice(); + this.saveToDB(targetWid); + }, saveData: function(wid, data, processEmbeddedImages) { - const existingData = this.loadStoredData(wid); - if (existingData.length > 0 || !data) { - return; - } + const existingData = this.loadStoredData(wid); + if (existingData.length > 0 || !data) { + return; + } let savedBoard = JSON.parse(data); // importing LAMS content which has base64 images embedded @@ -194,6 +198,6 @@ }); } savedBoards[wid] = savedBoard; - this.saveToDB(wid); - } + this.saveToDB(wid); + } }; Index: lams_build/conf/whiteboard/scripts/server-backend.js =================================================================== diff -u -rd25ffa6a2c7ec431af4b04d4b3909e2903342285 -r1cb71fb7cfd13ce1de802d0a069ebe849466a7fc --- lams_build/conf/whiteboard/scripts/server-backend.js (.../server-backend.js) (revision d25ffa6a2c7ec431af4b04d4b3909e2903342285) +++ lams_build/conf/whiteboard/scripts/server-backend.js (.../server-backend.js) (revision 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc) @@ -19,6 +19,7 @@ var s_whiteboard = require("./s_whiteboard.js"); var app = express(); + var server = require("http").Server(app); server.listen(port); var io = require("socket.io")(server, { path: "/ws-api" }); @@ -408,9 +409,8 @@ socket.emit("whiteboardConfig", { common: config.frontend, whiteboardSpecific: { - correspondingReadOnlyWid: ReadOnlyBackendService.getReadOnlyId( - whiteboardId - ), + correspondingReadOnlyWid: + ReadOnlyBackendService.getReadOnlyId(whiteboardId), isReadOnly: ReadOnlyBackendService.isReadOnly(whiteboardId), }, }); Index: lams_build/conf/whiteboard/src/index.html =================================================================== diff -u -rca0dfbeab89f5dc06f8de124ed208e57a968ee57 -r1cb71fb7cfd13ce1de802d0a069ebe849466a7fc --- lams_build/conf/whiteboard/src/index.html (.../index.html) (revision ca0dfbeab89f5dc06f8de124ed208e57a968ee57) +++ lams_build/conf/whiteboard/src/index.html (.../index.html) (revision 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc) @@ -6,8 +6,7 @@ - - +
@@ -178,7 +177,7 @@ class="fas fa-upload" > - + - + Fisheye: Tag 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc refers to a dead (removed) revision in file `lams_build/conf/whiteboard/src/js/index.js'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_build/conf/whiteboard/src/js/main.js =================================================================== diff -u -rf96b5eb0c971cce99b1ed8a12e080b890e0eb006 -r1cb71fb7cfd13ce1de802d0a069ebe849466a7fc --- lams_build/conf/whiteboard/src/js/main.js (.../main.js) (revision f96b5eb0c971cce99b1ed8a12e080b890e0eb006) +++ lams_build/conf/whiteboard/src/js/main.js (.../main.js) (revision 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc) @@ -1,5 +1,5 @@ import keymage from "keymage"; -import io from "socket.io-client"; +import { io } from "socket.io-client"; import whiteboard from "./whiteboard"; import keybinds from "./keybinds"; import Picker from "vanilla-picker"; @@ -174,24 +174,21 @@ function (data) { // modified for LAMS, force original data to be drawn and saved first if (copyfromwid && data.length == 0) { - // Copy from witheboard if current is empty and get parameter is given + //Copy from witheboard if current is empty and get parameter is given $.get(subdir + "/api/loadwhiteboard", { wid: copyfromwid, // needed for checking hash targetWid: whiteboardId, // this is not the main access token, but a special one just for this operation at: copyaccesstoken, }).done(function (originalData) { - console.log(originalData); - console.log(data); whiteboard.loadJsonData(originalData); - whiteboard.loadData(data); + whiteboard.loadData(data); }); } else { console.log(data); whiteboard.loadData(data); - } - + } } ); @@ -633,7 +630,6 @@ reader.readAsDataURL(blob); reader.onloadend = function () { const base64data = reader.result; - uploadImgAndAddToWhiteboard(base64data); }; } else if (isPDFFileName(filename)) { @@ -803,6 +799,8 @@ // In any case, if we are on read-only whiteboard we activate read-only mode if (ConfigService.isReadOnly) ReadOnlyService.activateReadOnlyMode(); + + $("body").show(); }); //Prevent site from changing tab on drag&drop @@ -823,7 +821,6 @@ false ); - function uploadImgAndAddToWhiteboard(base64data) { const date = +new Date(); $.ajax({ Fisheye: Tag 1cb71fb7cfd13ce1de802d0a069ebe849466a7fc refers to a dead (removed) revision in file `lams_build/conf/whiteboard/src/js/whiteboard.js'. Fisheye: No comparison available. Pass `N' to diff?