]> git.example.dev Git - binbsis50.git/commitdiff
reduced indentation levels of the "joinAnonymously" function
authorLuigi Pinca <luigipinca@gmail.com>
Fri, 28 Dec 2012 21:01:32 +0000 (22:01 +0100)
committerLuigi Pinca <luigipinca@gmail.com>
Fri, 28 Dec 2012 21:01:32 +0000 (22:01 +0100)
package.json
public/js/app.js

index f2e491de0985dabc83261e3f3753acd1e3e2e478..4c94b7e28b2d4c22bbd09fee45eb715e55683688 100644 (file)
@@ -22,5 +22,5 @@
     "start": "app.js"
   },
   "subdomain": "binb",
-  "version": "0.3.5-3"
+  "version": "0.3.5-4"
 }
index 252da32de0405462c17c8bb04b9292581ce05a63..ebb4bf04f35f5433470ba4b6345eb56a8468a1b1 100644 (file)
         if (/nickname\s*\=/.test(document.cookie) && !msg) {
             var encodednickname = document.cookie.replace(/.*nickname\s*\=\s*([^;]*);?.*/, '$1');
             nickname = decodeURIComponent(encodednickname);
-            socket.emit('joinanonymously', nickname, roomname);
+            return socket.emit('joinanonymously', nickname, roomname);
         }
-        else {
-            if (!DOM.modal.hasClass('in')) {
-                var html = '<div class="modal-header">';
-                html += '<h3>You are joining the '+roomname+' room</h3></div>';
-                html += '<div class="modal-body"><p>'+(msg || "What's your name?")+'</p></div>';
-                html += '<div class="modal-footer relative">';
-                html += '<input id="login" class="" type="text" name="nickname" />';
-                html += '<button id="join" class="btn btn-success">';
-                html += '<i class="icon-user icon-white"></i> Join the game</button>';
-                html += '<span class="divider"><span>or</span></span>';
-                html += '<a class="btn btn-primary" href="/login?followup=/'+roomname+'">';
-                html += '<i class="icon-lock icon-white"></i> Login</a></div>';
-
-                $(html).appendTo(DOM.modal);
-                var login = $('#login');
-                var button = $('#join');
-
-                button.click(function() {
-                    var val = $.trim(login.val());
-                    if (val !== '') {
-                        nickname = val;
-                        socket.emit('joinanonymously', nickname, roomname);
-                    }
-                    else {
-                        var txt = 'Nickname can\'t be empty.';
-                        invalidNickName('<span class="label label-important">'+txt+'</span>');
-                    }
-                    login.val('');
-                });
 
-                login.keyup(function(event) {
-                    if (event.keyCode === 13) {
-                        button.click();
-                    }
-                });
+        if (DOM.modal.hasClass('in')) {
+            $('.modal-body p').html(msg);
+            return $('#login').focus();
+        }
 
-                DOM.modal.modal('show');
-                DOM.modal.on('shown', function() {
-                    login.focus();
-                });
+        var html = '<div class="modal-header">';
+        html += '<h3>You are joining the '+roomname+' room</h3></div>';
+        html += '<div class="modal-body"><p>'+(msg || "What's your name?")+'</p></div>';
+        html += '<div class="modal-footer relative">';
+        html += '<input id="login" class="" type="text" name="nickname" />';
+        html += '<button id="join" class="btn btn-success">';
+        html += '<i class="icon-user icon-white"></i> Join the game</button>';
+        html += '<span class="divider"><span>or</span></span>';
+        html += '<a class="btn btn-primary" href="/login?followup=/'+roomname+'">';
+        html += '<i class="icon-lock icon-white"></i> Login</a></div>';
+
+        $(html).appendTo(DOM.modal);
+        var login = $('#login');
+        var button = $('#join');
+
+        button.click(function() {
+            var val = $.trim(login.val());
+            if (val !== '') {
+                nickname = val;
+                socket.emit('joinanonymously', nickname, roomname);
             }
             else {
-                $('.modal-body p').html(msg);
-                $('#login').focus();
+                var txt = 'Nickname can\'t be empty.';
+                invalidNickName('<span class="label label-important">'+txt+'</span>');
             }
-        }
+            login.val('');
+        });
+
+        login.keyup(function(event) {
+            if (event.keyCode === 13) {
+                button.click();
+            }
+        });
+
+        DOM.modal.modal('show');
+        DOM.modal.on('shown', function() {
+            login.focus();
+        });
     };
 
     var jplayerReady = function() {