From 557703e0d869cbfc3554afc33da99fed7516f15a Mon Sep 17 00:00:00 2001 From: ali asaria Date: Sat, 13 Sep 2014 02:04:27 -0400 Subject: [PATCH] change spacing --- client/script.js | 1122 ++++++++++++++++++++++------------------------ 1 file changed, 541 insertions(+), 581 deletions(-) diff --git a/client/script.js b/client/script.js index af66863..5963111 100644 --- a/client/script.js +++ b/client/script.js @@ -9,332 +9,331 @@ var socket = io.connect(); //an action has happened, send it to the //server -function sendAction(a, d) -{ - //console.log('--> ' + a); +function sendAction(a, d) { + //console.log('--> ' + a); - var message = { - action: a, - data: d - }; + var message = { + action: a, + data: d + }; - socket.json.send ( message ); + socket.json.send(message); } -socket.on('connect', function(){ - //console.log('successful socket.io connect'); +socket.on('connect', function() { + //console.log('successful socket.io connect'); - //let the path be the room name - var path = location.pathname; + //let the path be the room name + var path = location.pathname; - //imediately join the room which will trigger the initializations - sendAction('joinRoom', path); + //imediately join the room which will trigger the initializations + sendAction('joinRoom', path); }); -socket.on('disconnect', function(){ - blockUI("Server disconnected. Refresh page to try and reconnect..."); - //$('.blockOverlay').click($.unblockUI); +socket.on('disconnect', function() { + blockUI("Server disconnected. Refresh page to try and reconnect..."); + //$('.blockOverlay').click($.unblockUI); }); -socket.on('message', function(data){ - getMessage(data); +socket.on('message', function(data) { + getMessage(data); }); -function unblockUI() -{ - $.unblockUI(); +function unblockUI() { + $.unblockUI(); } -function blockUI(message) -{ - message = message || 'Waiting...'; +function blockUI(message) { + message = message || 'Waiting...'; - $.blockUI({ - message: message, + $.blockUI({ + message: message, - css: { - border: 'none', - padding: '15px', - backgroundColor: '#000', - '-webkit-border-radius': '10px', - '-moz-border-radius': '10px', - opacity: 0.5, - color: '#fff', - fontSize: '20px' - } - }); + css: { + border: 'none', + padding: '15px', + backgroundColor: '#000', + '-webkit-border-radius': '10px', + '-moz-border-radius': '10px', + opacity: 0.5, + color: '#fff', + fontSize: '20px' + } + }); } //respond to an action event -function getMessage( m ) -{ - var message = m; //JSON.parse(m); - var action = message.action; - var data = message.data; +function getMessage(m) { + var message = m; //JSON.parse(m); + var action = message.action; + var data = message.data; - //console.log('<-- ' + action); + //console.log('<-- ' + action); - switch (action) - { - case 'roomAccept': - //okay we're accepted, then request initialization - //(this is a bit of unnessary back and forth but that's okay for now) - sendAction('initializeMe', null); - break; + switch (action) { + case 'roomAccept': + //okay we're accepted, then request initialization + //(this is a bit of unnessary back and forth but that's okay for now) + sendAction('initializeMe', null); + break; - case 'roomDeny': - //this doesn't happen yet - break; + case 'roomDeny': + //this doesn't happen yet + break; - case 'moveCard': - moveCard($("#" + data.id), data.position); - break; + case 'moveCard': + moveCard($("#" + data.id), data.position); + break; - case 'initCards': - initCards(data); - break; + case 'initCards': + initCards(data); + break; - case 'createCard': - //console.log(data); - drawNewCard(data.id, data.text, data.x, data.y, data.rot, data.colour, null); - break; + case 'createCard': + //console.log(data); + drawNewCard(data.id, data.text, data.x, data.y, data.rot, data.colour, + null); + break; - case 'deleteCard': - $("#" + data.id).fadeOut(500, - function() {$(this).remove();} - ); - break; + case 'deleteCard': + $("#" + data.id).fadeOut(500, + function() { + $(this).remove(); + } + ); + break; - case 'editCard': - $("#" + data.id).children('.content:first').text(data.value); - break; + case 'editCard': + $("#" + data.id).children('.content:first').text(data.value); + break; - case 'initColumns': - initColumns(data); - break; + case 'initColumns': + initColumns(data); + break; - case 'updateColumns': - initColumns(data); - break; + case 'updateColumns': + initColumns(data); + break; - case 'changeTheme': - changeThemeTo(data); - break; + case 'changeTheme': + changeThemeTo(data); + break; - case 'join-announce': - displayUserJoined(data.sid, data.user_name); - break; + case 'join-announce': + displayUserJoined(data.sid, data.user_name); + break; - case 'leave-announce': - displayUserLeft(data.sid); - break; + case 'leave-announce': + displayUserLeft(data.sid); + break; - case 'initialUsers': - displayInitialUsers(data); - break; + case 'initialUsers': + displayInitialUsers(data); + break; - case 'nameChangeAnnounce': - updateName( message.data.sid, message.data.user_name ); - break; + case 'nameChangeAnnounce': + updateName(message.data.sid, message.data.user_name); + break; - case 'addSticker': - addSticker( message.data.cardId, message.data.stickerId ); - break; + case 'addSticker': + addSticker(message.data.cardId, message.data.stickerId); + break; - case 'setBoardSize': - resizeBoard( message.data ); - break; + case 'setBoardSize': + resizeBoard(message.data); + break; - default: - //unknown message - alert('unknown action: ' + JSON.stringify(message)); - break; - } + default: + //unknown message + alert('unknown action: ' + JSON.stringify(message)); + break; + } } $(document).bind('keyup', function(event) { - keyTrap = event.which; + keyTrap = event.which; }); -function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed) -{ - //cards[id] = {id: id, text: text, x: x, y: y, rot: rot, colour: colour}; +function drawNewCard(id, text, x, y, rot, colour, sticker, animationspeed) { + //cards[id] = {id: id, text: text, x: x, y: y, rot: rot, colour: colour}; - var h = '
\ \ - \ -
' + - text + '
\ + \ +
' + + text + '
\
'; - var card = $(h); - card.appendTo('#board'); + var card = $(h); + card.appendTo('#board'); - //@TODO - //Draggable has a bug which prevents blur event - //http://bugs.jqueryui.com/ticket/4261 - //So we have to blur all the cards and editable areas when - //we click on a card - //The following doesn't work so we will do the bug - //fix recommended in the above bug report - // card.click( function() { - // $(this).focus(); - // } ); + //@TODO + //Draggable has a bug which prevents blur event + //http://bugs.jqueryui.com/ticket/4261 + //So we have to blur all the cards and editable areas when + //we click on a card + //The following doesn't work so we will do the bug + //fix recommended in the above bug report + // card.click( function() { + // $(this).focus(); + // } ); - card.draggable( - { - snap: false, - snapTolerance: 5, - containment: [0,0,2000,2000], - stack: ".card", - start: function (event, ui) { - keyTrap = null; - }, - drag: function (event, ui) { - if (keyTrap == 27) { - ui.helper.css(ui.originalPosition); - return false; - } - } - } - ); + card.draggable({ + snap: false, + snapTolerance: 5, + containment: [0, 0, 2000, 2000], + stack: ".card", + start: function(event, ui) { + keyTrap = null; + }, + drag: function(event, ui) { + if (keyTrap == 27) { + ui.helper.css(ui.originalPosition); + return false; + } + } + }); - //After a drag: - card.bind( "dragstop", function(event, ui) { - if (keyTrap == 27) { - keyTrap = null; - return; - } + //After a drag: + card.bind("dragstop", function(event, ui) { + if (keyTrap == 27) { + keyTrap = null; + return; + } - var data = { - id: this.id, - position: ui.position, - oldposition: ui.originalPosition, - }; + var data = { + id: this.id, + position: ui.position, + oldposition: ui.originalPosition, + }; - sendAction('moveCard', data); - }); + sendAction('moveCard', data); + }); - card.children(".droppable").droppable( - { - accept: '.sticker', - drop: function( event, ui ) { - var stickerId = ui.draggable.attr("id"); - var cardId = $(this).parent().attr('id'); + card.children(".droppable").droppable({ + accept: '.sticker', + drop: function(event, ui) { + var stickerId = ui.draggable.attr("id"); + var cardId = $(this).parent().attr('id'); - addSticker( cardId, stickerId ); + addSticker(cardId, stickerId); - var data = { cardId: cardId, stickerId: stickerId }; - sendAction('addSticker', data); + var data = { + cardId: cardId, + stickerId: stickerId + }; + sendAction('addSticker', data); - //remove hover state to everything on the board to prevent - //a jquery bug where it gets left around - $('.card-hover-draggable').removeClass('card-hover-draggable'); - }, - hoverClass: 'card-hover-draggable' - } - ); + //remove hover state to everything on the board to prevent + //a jquery bug where it gets left around + $('.card-hover-draggable').removeClass('card-hover-draggable'); + }, + hoverClass: 'card-hover-draggable' + }); - var speed = Math.floor(Math.random() * 1000); - if (typeof(animationspeed) != 'undefined') speed = animationspeed; + var speed = Math.floor(Math.random() * 1000); + if (typeof(animationspeed) != 'undefined') speed = animationspeed; - var startPosition = $("#create-card").position(); + var startPosition = $("#create-card").position(); - card.css( 'top' , startPosition.top - card.height() * 0.5 ); - card.css('left', startPosition.left - card.width() * 0.5 ); + card.css('top', startPosition.top - card.height() * 0.5); + card.css('left', startPosition.left - card.width() * 0.5); - card.animate({ - left: x + "px", - top: y + "px" - }, speed); + card.animate({ + left: x + "px", + top: y + "px" + }, speed); - card.hover( - function(){ - $(this).addClass('hover'); - $(this).children('.card-icon').fadeIn(10); - }, - function(){ - $(this).removeClass('hover'); - $(this).children('.card-icon').fadeOut(150); - } - ); + card.hover( + function() { + $(this).addClass('hover'); + $(this).children('.card-icon').fadeIn(10); + }, + function() { + $(this).removeClass('hover'); + $(this).children('.card-icon').fadeOut(150); + } + ); - card.children('.card-icon').hover( - function(){ - $(this).addClass('card-icon-hover'); - }, - function(){ - $(this).removeClass('card-icon-hover'); - } - ); + card.children('.card-icon').hover( + function() { + $(this).addClass('card-icon-hover'); + }, + function() { + $(this).removeClass('card-icon-hover'); + } + ); - card.children('.delete-card-icon').click( - function(){ - $("#" + id).remove(); - //notify server of delete - sendAction( 'deleteCard' , { 'id': id }); - } - ); + card.children('.delete-card-icon').click( + function() { + $("#" + id).remove(); + //notify server of delete + sendAction('deleteCard', { + 'id': id + }); + } + ); - card.children('.content').editable(function(value, settings) { - onCardChange( id, value ); - return(value); - }, { - type : 'textarea', - submit : 'OK', - style : 'inherit', - cssclass : 'card-edit-form', - placeholder : 'Double Click to Edit.', - onblur: 'submit', - event: 'dblclick', //event: 'mouseover' - }); + card.children('.content').editable(function(value, settings) { + onCardChange(id, value); + return (value); + }, { + type: 'textarea', + submit: 'OK', + style: 'inherit', + cssclass: 'card-edit-form', + placeholder: 'Double Click to Edit.', + onblur: 'submit', + event: 'dblclick', //event: 'mouseover' + }); - //add applicable sticker - if (sticker !== null) - addSticker( id, sticker ); + //add applicable sticker + if (sticker !== null) + addSticker(id, sticker); } -function onCardChange( id, text ) -{ - sendAction('editCard', { id: id, value: text }); +function onCardChange(id, text) { + sendAction('editCard', { + id: id, + value: text + }); } function moveCard(card, position) { - card.animate({ - left: position.left+"px", - top: position.top+"px" - }, 500); + card.animate({ + left: position.left + "px", + top: position.top + "px" + }, 500); } -function addSticker ( cardId , stickerId ) -{ +function addSticker(cardId, stickerId) { - stickerContainer = $('#' + cardId + ' .filler'); + stickerContainer = $('#' + cardId + ' .filler'); - if (stickerId === "nosticker") - { - stickerContainer.html(""); - return; - } + if (stickerId === "nosticker") { + stickerContainer.html(""); + return; + } - if ( Array.isArray( stickerId ) ) - { - for (var i in stickerId) - { - stickerContainer.prepend(''); - } - } - else - { - if ( stickerContainer.html().indexOf(stickerId) < 0 ) - stickerContainer.prepend(''); - } + if (Array.isArray(stickerId)) { + for (var i in stickerId) { + stickerContainer.prepend(''); + } + } else { + if (stickerContainer.html().indexOf(stickerId) < 0) + stickerContainer.prepend(''); + } } @@ -342,59 +341,55 @@ function addSticker ( cardId , stickerId ) //---------------------------------- // cards //---------------------------------- -function createCard( id, text, x, y, rot, colour ) -{ - drawNewCard(id, text, x, y, rot, colour, null); +function createCard(id, text, x, y, rot, colour) { + drawNewCard(id, text, x, y, rot, colour, null); - var action = "createCard"; + var action = "createCard"; - var data = { - id: id, - text: text, - x: x, - y: y, - rot: rot, - colour: colour - }; + var data = { + id: id, + text: text, + x: x, + y: y, + rot: rot, + colour: colour + }; - sendAction(action, data); + sendAction(action, data); } -function randomCardColour() -{ - var colours = ['yellow', 'green', 'blue', 'white']; +function randomCardColour() { + var colours = ['yellow', 'green', 'blue', 'white']; - var i = Math.floor(Math.random() * colours.length); + var i = Math.floor(Math.random() * colours.length); - return colours[i]; + return colours[i]; } -function initCards( cardArray ) -{ - //first delete any cards that exist - $('.card').remove(); +function initCards(cardArray) { + //first delete any cards that exist + $('.card').remove(); - cards = cardArray; + cards = cardArray; - for (var i in cardArray) - { - card = cardArray[i]; + for (var i in cardArray) { + card = cardArray[i]; - drawNewCard( - card.id, - card.text, - card.x, - card.y, - card.rot, - card.colour, - card.sticker - ); - } + drawNewCard( + card.id, + card.text, + card.x, + card.y, + card.rot, + card.colour, + card.sticker + ); + } - boardInitialized = true; - unblockUI(); + boardInitialized = true; + unblockUI(); } @@ -402,142 +397,130 @@ function initCards( cardArray ) // cols //---------------------------------- -function drawNewColumn (columnName) -{ - var cls = "col"; - if (totalcolumns === 0) - { - cls = "col first"; - } +function drawNewColumn(columnName) { + var cls = "col"; + if (totalcolumns === 0) { + cls = "col first"; + } - $('#icon-col').before('

' + columnName + '

'); + $('#icon-col').before('

' + columnName + '

'); - $('.editable').editable(function(value, settings) { - onColumnChange( this.id, value ); - return(value); - }, { - style : 'inherit', - cssclass : 'card-edit-form', - type : 'textarea', - placeholder : 'New', - onblur: 'submit', - width: '', - height: '', - xindicator: '', - event: 'dblclick', //event: 'mouseover' - }); + $('.editable').editable(function(value, settings) { + onColumnChange(this.id, value); + return (value); + }, { + style: 'inherit', + cssclass: 'card-edit-form', + type: 'textarea', + placeholder: 'New', + onblur: 'submit', + width: '', + height: '', + xindicator: '', + event: 'dblclick', //event: 'mouseover' + }); - $('.col:last').fadeIn(1500); + $('.col:last').fadeIn(1500); - totalcolumns ++; + totalcolumns++; } -function onColumnChange( id, text ) -{ - var names = Array(); +function onColumnChange(id, text) { + var names = Array(); - //console.log(id + " " + text ); + //console.log(id + " " + text ); - //Get the names of all the columns right from the DOM - $('.col').each(function() { + //Get the names of all the columns right from the DOM + $('.col').each(function() { - //get ID of current column we are traversing over - var thisID = $(this).children("h2").attr('id'); + //get ID of current column we are traversing over + var thisID = $(this).children("h2").attr('id'); - if (id == thisID) - { - names.push( text ); - } - else - { - names.push( $(this).text() ); - } + if (id == thisID) { + names.push(text); + } else { + names.push($(this).text()); + } - }); + }); - updateColumns(names); + updateColumns(names); } -function displayRemoveColumn() -{ - if (totalcolumns <= 0) return false; +function displayRemoveColumn() { + if (totalcolumns <= 0) return false; - $('.col:last').fadeOut( 150, - function() { - $(this).remove(); - } - ); + $('.col:last').fadeOut(150, + function() { + $(this).remove(); + } + ); - totalcolumns --; + totalcolumns--; } -function createColumn( name ) -{ - if (totalcolumns >= 8) return false; +function createColumn(name) { + if (totalcolumns >= 8) return false; - drawNewColumn( name ); - columns.push(name); + drawNewColumn(name); + columns.push(name); - var action = "updateColumns"; + var action = "updateColumns"; - var data = columns; + var data = columns; - sendAction(action, data); + sendAction(action, data); } -function deleteColumn() -{ - if (totalcolumns <= 0) return false; +function deleteColumn() { + if (totalcolumns <= 0) return false; - displayRemoveColumn(); - columns.pop(); + displayRemoveColumn(); + columns.pop(); - var action = "updateColumns"; + var action = "updateColumns"; - var data = columns; + var data = columns; - sendAction(action, data); + sendAction(action, data); } -function updateColumns( c ) -{ - columns = c; +function updateColumns(c) { + columns = c; - var action = "updateColumns"; + var action = "updateColumns"; - var data = columns; + var data = columns; - sendAction(action, data); + sendAction(action, data); } -function deleteColumns( next ) -{ - //delete all existing columns: - $('.col').fadeOut( 'slow', next() ); +function deleteColumns(next) { + //delete all existing columns: + $('.col').fadeOut('slow', next()); } -function initColumns( columnArray ) -{ - totalcolumns = 0; - columns = columnArray; +function initColumns(columnArray) { + totalcolumns = 0; + columns = columnArray; - $('.col').remove(); + $('.col').remove(); - for (var i in columnArray) - { - column = columnArray[i]; + for (var i in columnArray) { + column = columnArray[i]; - drawNewColumn( - column - ); - } + drawNewColumn( + column + ); + } } -function changeThemeTo( theme ) -{ - currentTheme = theme; - $("link[title=cardsize]").attr("href", "/css/" + theme + ".css"); +function changeThemeTo(theme) { + currentTheme = theme; + $("link[title=cardsize]").attr("href", "/css/" + theme + ".css"); } @@ -547,116 +530,107 @@ function changeThemeTo( theme ) -function setCookie(c_name,value,exdays) -{ - var exdate=new Date(); - exdate.setDate(exdate.getDate() + exdays); - var c_value=escape(value) + ((exdays===null) ? "" : "; expires="+exdate.toUTCString()); - document.cookie=c_name + "=" + c_value; +function setCookie(c_name, value, exdays) { + var exdate = new Date(); + exdate.setDate(exdate.getDate() + exdays); + var c_value = escape(value) + ((exdays === null) ? "" : "; expires=" + + exdate.toUTCString()); + document.cookie = c_name + "=" + c_value; } -function getCookie(c_name) -{ - var i,x,y,ARRcookies=document.cookie.split(";"); - for (i=0;i' + name + ''); + $('#names-ul').append('
  • ' + name + '
  • '); } -function displayUserLeft ( sid ) -{ - name = ''; - if (name) - name = user_name; - else - name = sid; +function displayUserLeft(sid) { + name = ''; + if (name) + name = user_name; + else + name = sid; - var id = '#user-' + sid.toString(); + var id = '#user-' + sid.toString(); - $('#names-ul').children(id).fadeOut( 1000 , function() { - $(this).remove(); - }); + $('#names-ul').children(id).fadeOut(1000, function() { + $(this).remove(); + }); } -function updateName ( sid, name ) -{ - var id = '#user-' + sid.toString(); +function updateName(sid, name) { + var id = '#user-' + sid.toString(); - $('#names-ul').children(id).text( name ); + $('#names-ul').children(id).text(name); } ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// -function boardResizeHappened(event, ui) -{ - var newsize = ui.size; +function boardResizeHappened(event, ui) { + var newsize = ui.size; - sendAction( 'setBoardSize', newsize); + sendAction('setBoardSize', newsize); } -function resizeBoard (size) { - $( ".board-outline" ).animate( { - height: size.height, - width: size.width - } ); +function resizeBoard(size) { + $(".board-outline").animate({ + height: size.height, + width: size.width + }); } ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// function calcCardOffset() { - var offsets = {}; - $(".card").each(function() { - var card = $(this); - $(".col").each(function(i) { - var col = $(this); - if(col.offset().left + col.outerWidth() > card.offset().left + card.outerWidth() || i === $(".col").size() - 1) { - offsets[card.attr('id')] = { - col: col, - x: ( (card.offset().left - col.offset().left) / col.outerWidth() ) - }; - return false; - } - }); - }); - return offsets; + var offsets = {}; + $(".card").each(function() { + var card = $(this); + $(".col").each(function(i) { + var col = $(this); + if (col.offset().left + col.outerWidth() > card.offset().left + + card.outerWidth() || i === $(".col").size() - 1) { + offsets[card.attr('id')] = { + col: col, + x: ((card.offset().left - col.offset().left) / col.outerWidth()) + }; + return false; + } + }); + }); + return offsets; } @@ -701,176 +675,162 @@ function adjustCard(offsets, doSync) { $(function() { - if (boardInitialized === false) - blockUI(''); + if (boardInitialized === false) + blockUI(''); - //setTimeout($.unblockUI, 2000); + //setTimeout($.unblockUI, 2000); - $( "#create-card" ) - .click(function() { - var rotation = Math.random() * 10 - 5; //add a bit of random rotation (+/- 10deg) - uniqueID = Math.round(Math.random()*99999999); //is this big enough to assure uniqueness? - //alert(uniqueID); - createCard( - 'card' + uniqueID, - '', - 58, $('div.board-outline').height(),// hack - not a great way to get the new card coordinates, but most consistant ATM - rotation, - randomCardColour()); - }); + $("#create-card") + .click(function() { + var rotation = Math.random() * 10 - 5; //add a bit of random rotation (+/- 10deg) + uniqueID = Math.round(Math.random() * 99999999); //is this big enough to assure uniqueness? + //alert(uniqueID); + createCard( + 'card' + uniqueID, + '', + 58, $('div.board-outline').height(), // hack - not a great way to get the new card coordinates, but most consistant ATM + rotation, + randomCardColour()); + }); - - // Style changer - $("#smallify").click(function(){ - if (currentTheme == "bigcards") - { - changeThemeTo('smallcards'); - } - else if (currentTheme == "smallcards") - { - changeThemeTo('bigcards'); - } - /*else if (currentTheme == "nocards") + // Style changer + $("#smallify").click(function() { + if (currentTheme == "bigcards") { + changeThemeTo('smallcards'); + } else if (currentTheme == "smallcards") { + changeThemeTo('bigcards'); + } + /*else if (currentTheme == "nocards") { currentTheme = "bigcards"; $("link[title=cardsize]").attr("href", "css/bigcards.css"); }*/ - sendAction('changeTheme', currentTheme); + sendAction('changeTheme', currentTheme); - return false; - }); + return false; + }); - $('#icon-col').hover( - function() { - $('.col-icon').fadeIn(10); - }, - function() { - $('.col-icon').fadeOut(150); - } - ); + $('#icon-col').hover( + function() { + $('.col-icon').fadeIn(10); + }, + function() { + $('.col-icon').fadeOut(150); + } + ); - $('#add-col').click( - function(){ - createColumn('New'); - return false; - } - ); + $('#add-col').click( + function() { + createColumn('New'); + return false; + } + ); - $('#delete-col').click( - function(){ - deleteColumn(); - return false; - } - ); + $('#delete-col').click( + function() { + deleteColumn(); + return false; + } + ); - // $('#cog-button').click( function(){ - // $('#config-dropdown').fadeToggle(); - // } ); + // $('#cog-button').click( function(){ + // $('#config-dropdown').fadeToggle(); + // } ); - // $('#config-dropdown').hover( - // function(){ /*$('#config-dropdown').fadeIn()*/ }, - // function(){ $('#config-dropdown').fadeOut() } - // ); - // + // $('#config-dropdown').hover( + // function(){ /*$('#config-dropdown').fadeIn()*/ }, + // function(){ $('#config-dropdown').fadeOut() } + // ); + // - var user_name = getCookie('scrumscrum-username'); + var user_name = getCookie('scrumscrum-username'); - $("#yourname-input").focus(function() - { - if ($(this).val() == 'unknown') - { - $(this).val(""); - } + $("#yourname-input").focus(function() { + if ($(this).val() == 'unknown') { + $(this).val(""); + } - $(this).addClass('focused'); + $(this).addClass('focused'); - }); + }); - $("#yourname-input").blur(function() - { - if ($(this).val() === "") - { - $(this).val('unknown'); - } - $(this).removeClass('focused'); + $("#yourname-input").blur(function() { + if ($(this).val() === "") { + $(this).val('unknown'); + } + $(this).removeClass('focused'); - setName($(this).val()); - }); + setName($(this).val()); + }); - $("#yourname-input").val(user_name); - $("#yourname-input").blur(); + $("#yourname-input").val(user_name); + $("#yourname-input").blur(); - $("#yourname-li").hide(); + $("#yourname-li").hide(); - $("#yourname-input").keypress(function(e) - { - code= (e.keyCode ? e.keyCode : e.which); - if (code == 10 || code == 13) - { - $(this).blur(); - } - }); + $("#yourname-input").keypress(function(e) { + code = (e.keyCode ? e.keyCode : e.which); + if (code == 10 || code == 13) { + $(this).blur(); + } + }); -$( ".sticker" ).draggable({ - revert: true, - zIndex: 1000 -}); + $(".sticker").draggable({ + revert: true, + zIndex: 1000 + }); -$( ".board-outline" ).resizable( { - ghost: false, - minWidth: 700, - minHeight: 400 , - maxWidth: 3200, - maxHeight: 1800, -} ); + $(".board-outline").resizable({ + ghost: false, + minWidth: 700, + minHeight: 400, + maxWidth: 3200, + maxHeight: 1800, + }); -//A new scope for precalculating -(function() { - var offsets; + //A new scope for precalculating + (function() { + var offsets; - $(".board-outline").bind("resizestart", function() { - offsets = calcCardOffset(); - }); - $(".board-outline").bind("resize", function(event, ui) { - adjustCard(offsets, false); - }); - $(".board-outline").bind("resizestop", function(event, ui) { - boardResizeHappened(event, ui); - adjustCard(offsets, true); - }); -})(); + $(".board-outline").bind("resizestart", function() { + offsets = calcCardOffset(); + }); + $(".board-outline").bind("resize", function(event, ui) { + adjustCard(offsets, false); + }); + $(".board-outline").bind("resizestop", function(event, ui) { + boardResizeHappened(event, ui); + adjustCard(offsets, true); + }); + })(); -$('#marker').draggable( - { - axis: 'x', - containment: 'parent' - } -); + $('#marker').draggable({ + axis: 'x', + containment: 'parent' + }); -$('#eraser').draggable( - { - axis: 'x', - containment: 'parent' - } -); + $('#eraser').draggable({ + axis: 'x', + containment: 'parent' + }); -//disable image dragging -//window.ondragstart = function() { return false; }; + //disable image dragging + //window.ondragstart = function() { return false; }; });