Added eslit and circle.yml

This commit is contained in:
AlexKvazos
2015-04-30 14:01:19 -05:00
parent 7794cbf56d
commit 48eb590c32
18 changed files with 67 additions and 41 deletions
+19
View File
@@ -0,0 +1,19 @@
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"rules": {
"quotes": [2, "single"],
"strict": [2, "never"],
"no-multi-spaces": false,
"no-alert": false,
"key-spacing": false,
"curly": false,
"no-octal-escape": false
},
"globals": {
"$": true
}
}
+5
View File
@@ -50,6 +50,10 @@ module.exports = function(grunt) {
watch: ['app/server'] watch: ['app/server']
} }
} }
},
eslint: {
src: ["app"]
} }
}); });
@@ -58,6 +62,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-nodemon'); grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-eslint');
grunt.registerTask('build', ['browserify:pro', 'uglify']); grunt.registerTask('build', ['browserify:pro', 'uglify']);
grunt.registerTask('debug', ['browserify:dev']); grunt.registerTask('debug', ['browserify:dev']);
+2
View File
@@ -1,3 +1,5 @@
var angular = angular;
// initialize angular application // initialize angular application
var app = angular.module('chat', []); var app = angular.module('chat', []);
+1 -3
View File
@@ -7,7 +7,7 @@ module.exports = function($scope, socket, servers) {
$scope.servers = servers.get(); $scope.servers = servers.get();
$scope.select = function(id) { $scope.select = function(id) {
$scope.ip = servers.select(id).ip; $scope.ip = servers.select(id).ip;
$scope.port = servers.select(id).port; $scope.port = servers.select(id).port;
if ($scope.username.length > 0 && $scope.password.length > 0) { if ($scope.username.length > 0 && $scope.password.length > 0) {
@@ -27,8 +27,6 @@ module.exports = function($scope, socket, servers) {
password: $scope.password, password: $scope.password,
hostname: $scope.ip, hostname: $scope.ip,
port: $scope.port || 25565 port: $scope.port || 25565
}, function(response) {
}); });
} else { } else {
+1 -1
View File
@@ -36,4 +36,4 @@ module.exports = function($scope, socket) {
}); });
}); });
}; };
+5 -15
View File
@@ -1,26 +1,16 @@
module.exports = function() { module.exports = function() {
// initialize servers store if doesn't exist // initialize servers store if doesn't exist
localStorage.servers = localStorage.servers || "[]"; localStorage.servers = localStorage.servers || '[]';
// function to save servers into localStorage
function save() {
localStorage.servers = JSON.stringify(servers);
}
// default servers
var defaultServers = [
{name: 'LattyCraft', ip: 'us.latty.info', port: 25565}
];
// load servers from localstorage // load servers from localstorage
var servers = JSON.parse(localStorage.servers); var servers = JSON.parse(localStorage.servers);
// if no servers are saved, load the default ones // function to save servers into localStorage
if (!servers || servers.length === 0) { function save() {
servers = defaultServers; localStorage.servers = JSON.stringify(servers);
save();
} }
@@ -41,4 +31,4 @@ module.exports = function() {
} }
}; };
}; };
+2
View File
@@ -4,6 +4,8 @@
module.exports = function() { module.exports = function() {
var io = io;
var socket = io(window.location.host); var socket = io(window.location.host);
return socket; return socket;
+4 -3
View File
@@ -1,9 +1,10 @@
module.exports = function() { module.exports = function() {
var connected = "connected"; var createjs = createjs;
var error = "error";
createjs.Sound.registerSound("/sounds/connected.mp3", connected); var connected = 'connected';
createjs.Sound.registerSound('/sounds/connected.mp3', connected);
return { return {
connected: function() { connected: function() {
+1 -1
View File
@@ -41,7 +41,7 @@ module.exports = function(socket) {
// format the buffer with the correct coloring // format the buffer with the correct coloring
buffer = buffer.replace(/§([0-9abcdef])([^§]*)/ig, function replace(regex, color, msg) { buffer = buffer.replace(/§([0-9abcdef])([^§]*)/ig, function replace(regex, color, msg) {
return '<span class="color-'+color+'">'+msg.replace(/ /g, '&nbsp;')+'</span>'; return '<span class="color-' + color + '">' + msg.replace(/ /g, '&nbsp;') + '</span>';
}); });
// send line back to the client // send line back to the client
+9 -7
View File
@@ -3,7 +3,7 @@ var parseExtra = require('../parsers/extra');
module.exports = function(jsonMsg) { module.exports = function(jsonMsg) {
var buffer = ''; var username, msg, sender, broadcast, connected, max, current, pages, player, victim, killer, achievement;
var color = stringToCode(jsonMsg.color); var color = stringToCode(jsonMsg.color);
switch (jsonMsg.translate) { switch (jsonMsg.translate) {
@@ -11,13 +11,13 @@ module.exports = function(jsonMsg) {
case 'chat.type.text': case 'chat.type.text':
username = jsonMsg.with[0].text; username = jsonMsg.with[0].text;
msg = jsonMsg.with[1]; msg = jsonMsg.with[1];
return '§' + color + '<'+username+'> ' + msg; return '§' + color + '<' + username + '> ' + msg;
case 'chat.type.announcement': case 'chat.type.announcement':
sender = jsonMsg.with[0]; sender = jsonMsg.with[0];
broadcast = parseExtra(jsonMsg.with[1].extra); broadcast = parseExtra(jsonMsg.with[1].extra);
return '§' + color + '['+sender+'] ' + broadcast; return '§' + color + '[' + sender + '] ' + broadcast;
case 'commands.generic.notFound': case 'commands.generic.notFound':
@@ -27,13 +27,13 @@ module.exports = function(jsonMsg) {
case 'commands.players.list': case 'commands.players.list':
connected = jsonMsg.with[0]; connected = jsonMsg.with[0];
max = jsonMsg.with[1]; max = jsonMsg.with[1];
return '§' + color + 'There are '+connected+'/'+max+' players online:'; return '§' + color + 'There are ' + connected + '/' + max + ' players online:';
case 'commands.help.header': case 'commands.help.header':
current = jsonMsg.with[0]; current = jsonMsg.with[0];
pages = jsonMsg.with[1]; pages = jsonMsg.with[1];
return '§' + color + '--- Showing help page '+current+' of '+pages+' (/help <page>) ---'; return '§' + color + '--- Showing help page ' + current + ' of ' + pages + ' (/help <page>) ---';
case 'commands.generic.usage': case 'commands.generic.usage':
@@ -81,7 +81,7 @@ module.exports = function(jsonMsg) {
case 'chat.type.achievement': case 'chat.type.achievement':
player = jsonMsg.with[0].text; player = jsonMsg.with[0].text;
achievement = jsonMsg.with[1].extra[0].translate; achievement = jsonMsg.with[1].extra[0].translate;
return '§' + color + player + ' has just earned the achievement ' + '§a['+parseAchievement(achievement)+']' ; return '§' + color + player + ' has just earned the achievement ' + '§a[' + parseAchievement(achievement) + ']';
} }
@@ -95,6 +95,8 @@ module.exports = function(jsonMsg) {
function parseAdmin(command) { function parseAdmin(command) {
var player, gamemode;
switch (command.translate) { switch (command.translate) {
case 'commands.downfall.success': case 'commands.downfall.success':
@@ -278,4 +280,4 @@ function parseCommandUsage(commandId) {
return commands[commandId] || 'Unknown command usage'; return commands[commandId] || 'Unknown command usage';
} }
+1 -1
View File
@@ -6,4 +6,4 @@ module.exports = function(socket) {
} }
}); });
}; };
+1 -1
View File
@@ -3,7 +3,7 @@ var events = require('../../bot');
module.exports = function(socket) { module.exports = function(socket) {
socket.on('server:connect', function(data, response) { socket.on('server:connect', function(data) {
if (socket.mcbot) { if (socket.mcbot) {
socket.emit('buffer:error', 'Pleae disconnect before connecting again'); socket.emit('buffer:error', 'Pleae disconnect before connecting again');
+1 -1
View File
@@ -17,4 +17,4 @@ module.exports = function(socket) {
}); });
}; };
+1 -1
View File
@@ -6,4 +6,4 @@ module.exports = function(socket) {
} }
}); });
}; };
+5 -5
View File
@@ -1,8 +1,8 @@
module.exports = function escapeHtml(unsafe) { module.exports = function escapeHtml(unsafe) {
return unsafe return unsafe
.replace(/&/g, "&amp;") .replace(/&/g, '&amp;')
.replace(/</g, "&lt;") .replace(/</g, '&lt;')
.replace(/>/g, "&gt;") .replace(/>/g, '&gt;')
.replace(/"/g, "&quot;") .replace(/"/g, '&quot;')
.replace(/'/g, "&#039;"); .replace(/'/g, '&#039;');
}; };
+1 -1
View File
@@ -1,2 +1,2 @@
exports.escapeHtml = require('./escapeHtml'); exports.escapeHtml = require('./escapeHtml');
exports.stringToCode = require('./stringToCode'); exports.stringToCode = require('./stringToCode');
+6
View File
@@ -0,0 +1,6 @@
machine:
node:
version: 0.10.32
dependencies:
pre:
- npm install grunt-cli -g
+2 -1
View File
@@ -9,6 +9,7 @@
"express": "^4.12.3", "express": "^4.12.3",
"grunt": "^0.4.5", "grunt": "^0.4.5",
"grunt-browserify": "^3.7.0", "grunt-browserify": "^3.7.0",
"grunt-contrib-eslint": "0.0.5",
"grunt-contrib-uglify": "^0.9.1", "grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "^0.6.1", "grunt-contrib-watch": "^0.6.1",
"grunt-nodemon": "^0.4.0", "grunt-nodemon": "^0.4.0",
@@ -18,7 +19,7 @@
}, },
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "grunt eslint",
"start": "node app/server" "start": "node app/server"
}, },
"repository": { "repository": {