serverConnect.js (1431B)
1 PNotify.prototype.options.styling = "bootstrap3"; 2 $("#menu-toggle").click(function(e) { 3 e.preventDefault(); 4 $("#wrapper").toggleClass("toggled"); 5 }); 6 var ws = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: ''); 7 var socket = io(ws); 8 $(document).off('click', '#restart').on('click', '#restart', function (e) { 9 console.log('restart fired'); 10 11 socket.emit('command', {command: 'restartgame'}); 12 e.preventDefault(); 13 }); 14 $(document).off('click', '#live_on').on('click', '#live_on', function (e) { 15 console.warn('LIVE!!!'); 16 17 socket.emit('command', {command: 'live_on'}); 18 e.preventDefault(); 19 }); 20 socket.on('alert', function (message) { 21 if (message.command === "live_on") { 22 PNotify.desktop.permission(); 23 (new PNotify({ 24 title: 'LIVE!!!', 25 text: "The game successfully started!", 26 type: 'success', 27 desktop: { 28 desktop: true 29 } 30 })).get().click(function(e) { 31 if ($('.ui-pnotify-closer, .ui-pnotify-sticker, .ui-pnotify-closer *, .ui-pnotify-sticker *').is(e.target)) return; 32 alert('Hey! You clicked the desktop notification!'); 33 }); 34 } 35 }); 36 socket.on('status_alert', function (message) { 37 console.warn(typeof message) 38 console.warn(message) 39 }); 40 $(document).off('click', '#check_status').on('click', '#check_status', function (e) { 41 console.log('Check Status'); 42 43 socket.emit('command', {command: 'status'}); 44 e.preventDefault(); 45 });