mirror of
https://github.com/lovasoa/whitebophir
synced 2024-11-10 06:24:17 +00:00
First merge for #31
Thanks a lot and congratulations to @finnboeger and @rdbeach !
This commit is contained in:
commit
f23926bdef
2 changed files with 47 additions and 15 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -20,3 +20,6 @@ npm-debug.log
|
|||
# Openode
|
||||
.openode
|
||||
wbo-backup.zip
|
||||
|
||||
# Jetbrains
|
||||
.idea/
|
|
@ -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]);
|
||||
|
@ -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 {
|
||||
|
@ -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++;
|
||||
|
|
Loading…
Reference in a new issue