diff --git a/public/js/main.js b/public/js/main.js index 844544e..af7b26f 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -1,6 +1,7 @@ -var whiteboardId = "myNewWhiteboard"; -var myUsername = "Default"; - +var whiteboardId = getQueryVariable("whiteboardid"); +whiteboardId = whiteboardId || "myNewWhiteboard"; +var myUsername = getQueryVariable("username"); +myUsername = myUsername || "unkonwn"; var io = signaling_socket = io(); io.on('connect', function () { @@ -9,6 +10,10 @@ io.on('connect', function () { signaling_socket.on('drawToWhiteboard', function (content) { whiteboard.handleEventsAndData(content, true); }); + + signaling_socket.on('refreshUserBadges', function () { + whiteboard.refreshUserBadges(); + }); }); $(document).ready(function() { @@ -246,4 +251,16 @@ window.addEventListener("paste", function(e) { //Even do copy & paste from clipb } } } -}); \ No newline at end of file +}); + +function getQueryVariable(variable) { + var query = window.location.search.substring(1); + var vars = query.split("&"); + for (var i=0;i=1) { _this.cursorContainer.find("."+content["username"]).css({"left":data[0]+"px","top":data[1]+"px" }); } else { - _this.cursorContainer.append('
'+ + _this.cursorContainer.append('
'+ '
'+ content["username"]+'
'); } @@ -623,6 +623,9 @@ var whiteboard = { userLeftWhiteboard(username) { this.cursorContainer.find("."+username).remove(); }, + refreshUserBadges() { + this.cursorContainer.find(".userbadge").remove(); + }, getImageDataBase64() { _this = this; var width = this.mouseOverlay.width(); diff --git a/server.js b/server.js index 7c85b6b..66e1048 100644 --- a/server.js +++ b/server.js @@ -71,6 +71,10 @@ function progressUploadFormData(formData) { } io.on('connection', function(socket){ + socket.on('disconnect', function () { + socket.broadcast.emit('refreshUserBadges', null); + }); + socket.on('drawToWhiteboard', function(content) { socket.broadcast.emit('drawToWhiteboard', content); s_whiteboard.handleEventsAndData(content); //save whiteboardchanges on the server