Skip to content

Commit

Permalink
First merge for #31
Browse files Browse the repository at this point in the history
Thanks a lot and congratulations to @finnboeger and @rdbeach !
  • Loading branch information
lovasoa committed Apr 26, 2020
2 parents fc51f0d + f63301b commit f23926b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ npm-debug.log
# Openode
.openode
wbo-backup.zip

# Jetbrains
.idea/
59 changes: 44 additions & 15 deletions client-data/js/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,43 @@ Tools.i18n = (function i18n() {

Tools.board = document.getElementById("board");
Tools.svg = document.getElementById("canvas");
Tools.socket = io.connect('', {
"reconnectionDelay": 100, //Make the xhr connections as fast as possible
"timeout": 1000 * 60 * 20 // Timeout after 20 minutes
});

//Initialization
Tools.curTool = null;

Tools.socket = null;
Tools.connect = function() {
var self = this;

// Destroy socket if one already exists
if (self.socket) {
self.socket.destroy();
delete self.socket;
self.socket = null;
}


this.socket = io.connect('', {
"reconnection": true,
"reconnectionDelay": 100, //Make the xhr connections as fast as possible
"timeout": 1000 * 60 * 20 // Timeout after 20 minutes
});

//Receive draw instructions from the server
this.socket.on("broadcast", function (msg) {
handleMessage(msg).finally(function afterload() {
var loadingEl = document.getElementById("loadingMessage");
loadingEl.classList.add("hidden");
});
});

this.socket.on("reconnect", function onReconnection() {
Tools.socket.emit('joinboard', Tools.boardName);
});
};

Tools.connect();

Tools.boardName = (function () {
var path = window.location.pathname.split("/");
return decodeURIComponent(path[path.length - 1]);
Expand Down Expand Up @@ -150,6 +182,14 @@ Tools.change = function (toolName) {

var newtool = Tools.list[toolName];

if (newtool === Tools.curTool) {
if(newtool.toggle){
var elem = document.getElementById("toolID-" + newtool.name);
newtool.toggle(elem);
}
return;
}

//Update the GUI
var curToolName = (Tools.curTool) ? Tools.curTool.name : "";
try {
Expand Down Expand Up @@ -248,17 +288,6 @@ function handleMessage(message) {
else return Promise.resolve();
}

//Receive draw instructions from the server
Tools.socket.on("broadcast", function (msg) {
handleMessage(msg).finally(function afterload() {
var loadingEl = document.getElementById("loadingMessage");
loadingEl.classList.add("hidden");
});
});
Tools.socket.on("reconnect", function onReconnection() {
Tools.socket.emit('joinboard', Tools.boardName);
});

Tools.unreadMessagesCount = 0;
Tools.newUnreadMessage = function () {
Tools.unreadMessagesCount++;
Expand Down

0 comments on commit f23926b

Please sign in to comment.