This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Exclude items with forbidden words | |
| const filterItems = (items, forbiddenWords) => { | |
| return items.filter((item) => { | |
| return forbiddenWords.reduce((acceptable, term) => { | |
| return ( | |
| (item.title + item.description + item.author).toLowerCase().indexOf(term) == -1 && acceptable | |
| ); | |
| }, true); | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('spider', function() { | |
| describe('filterItems()', function() { | |
| it('should remove the second item, cause it has a forbidden word', function() { | |
| items = [ | |
| { | |
| title: 'Redux rules', | |
| description: 'Redux is the best, you might not need it tho', | |
| author: 'Dan Abramov' | |
| }, | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Exclude items with forbidden words | |
| const filterItems = (items) => { | |
| items.forEach((item, i) => { | |
| config.forbiddenTerms.forEach((term) => { | |
| if((item.title + item.description + item.author).toLowerCase().indexOf(term) != -1){ | |
| // contains forbidden word | |
| items.splice(i, 1); | |
| } | |
| }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Static resources server | |
| app.use(express.static(__dirname + '/www')); | |
| var server = app.listen(8082, function () { | |
| var port = server.address().port; | |
| console.log('Server running at port %s', port); | |
| }); | |
| var io = require('socket.io')(server); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setInterval(function(){ | |
| g.mainLoop(); | |
| }, INTERVAL); | |
| mainLoop: function(){ | |
| if(this.localTank != undefined){ | |
| this.sendData(); //send data to server about local tank | |
| } | |
| if(this.localTank != undefined){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| client.on('joinGame', function(tank){ | |
| console.log(tank.id + ' joined the game'); | |
| var initX = getRandomInt(40, 900); | |
| var initY = getRandomInt(40, 500); | |
| client.emit('addTank', { id: tank.id, type: tank.type, isLocal: true, x: initX, y: initY, hp: TANK_INIT_HP }); | |
| client.broadcast.emit('addTank', { id: tank.id, type: tank.type, isLocal: false, x: initX, y: initY, hp: TANK_INIT_HP} ); | |
| game.addTank({ id: tank.id, type: tank.type, hp: TANK_INIT_HP}); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $("#form-id").dirrty("isDirty"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="../js/jquery.dirrty.js"></script> | |
| <script> | |
| $("#my-form").dirrty({ | |
| onDirty: function(){ | |
| $("#status").html("dirty"); | |
| $("#save").removeAttr("disabled"); | |
| $("#status").removeClass("clean"); | |
| }, | |
| onClean: function(){ | |
| $("#status").html("clean"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Cubeman | |
| */ | |
| #cubeman{ | |
| margin-top:100px; | |
| } | |
| #spiderman{ | |
| margin-top:200px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //BASE: | |
| @head-width:50px; | |
| @head-height:60px; | |
| @head-depth:50px; | |
| @body-width:25px; | |
| @body-height:40px; | |
| @body-depth:25px; |