Skip to content

Commit

Permalink
fixed jshint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Jan 10, 2015
1 parent 7c72680 commit 474d642
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 118 deletions.
114 changes: 60 additions & 54 deletions www/js/app.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,70 @@
// Ionic Starter App
//noinspection JSHint
(function(angular){
"use strict";

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
// Ionic Starter App

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])

.config(function($stateProvider, $urlRouterProvider) {
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
window.cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
window.StatusBar.styleDefault();
}
});
})

// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
.config(function($stateProvider, $urlRouterProvider) {

// setup an abstract state for the tabs directive
.state('tab', {
url: "/tab",
abstract: true,
templateUrl: "templates/tabs.html"
})
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider

// Each tab has its own nav history stack:
// setup an abstract state for the tabs directive
.state('tab', {
url: "/tab",
abstract: true,
templateUrl: "templates/tabs.html"
})

.state('tab.map', {
url: '/map',
views: {
'tab-map': {
templateUrl: 'templates/tab-map.html',
controller: 'MapCtrl'
}
}
})
// Each tab has its own nav history stack:

.state('tab.settings', {
url: '/settings',
views: {
'tab-settings': {
templateUrl: 'templates/tab-settings.html',
controller: 'SettingsCtrl'
}
}
});
.state('tab.map', {
url: '/map',
views: {
'tab-map': {
templateUrl: 'templates/tab-map.html',
controller: 'MapCtrl'
}
}
})

// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/map');
.state('tab.settings', {
url: '/settings',
views: {
'tab-settings': {
templateUrl: 'templates/tab-settings.html',
controller: 'SettingsCtrl'
}
}
});

});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/map');

});

})(angular);
1 change: 1 addition & 0 deletions www/js/catan/js/Position.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//noinspection JSHint
(function (Catan) {
"use strict";

Expand Down
12 changes: 7 additions & 5 deletions www/js/catan/js/generator/generator.harbor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//noinspection JSHint
(function(Catan) {
"use strict";

Catan.Generator.Harbor = {};

Expand All @@ -25,15 +27,15 @@

// put harbors on map and index
map.eachCoast(function (i, j) {
// set oceans and harboors
if (n++ % 2 != mod) {
map.get(i, j).land = Catan.T.Ocean;
} else {
// set oceans and harbors
if (n++ % 2 === mod) {
map.get(i, j).land = harbors.pop();

if (map.get(i, j).land != Catan.T.Empty) {
if (map.get(i, j).land !== Catan.T.Empty) {
harborCoords.push(new Catan.Position(i, j));
}
} else {
map.get(i, j).land = Catan.T.Ocean;
}
});

Expand Down
2 changes: 2 additions & 0 deletions www/js/catan/js/generator/generator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//noinspection JSHint
(function(Catan) {
"use strict";

Catan.Generator = {};

Expand Down
8 changes: 5 additions & 3 deletions www/js/catan/js/generator/generator.land.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//noinspection JSHint
(function(Catan) {
"use strict";

Catan.Generator.Land = {};

Expand All @@ -25,7 +27,7 @@
var a;
var b;
map.eachConsecutiveNeighbour(i, j, function (a, b) {
return (a.land == b.land && a.land != Catan.T.Empty && a.land !== undefined);
return (a.land === b.land && a.land !== Catan.T.Empty && a.land !== undefined);
}, function (ax, ay, bx, by) {
a = map.get(ax, ay);
b = map.get(bx, by);
Expand Down Expand Up @@ -56,10 +58,10 @@
var allLands;
var swapped = false;
var eachSwapFunction = function (i, j) {
if (!swapped && !(i == ex && j == ey) && Catan.Tools.contains(allowedLands, map.get(i, j).land)) {
if (!swapped && !(i === ex && j === ey) && Catan.Tools.contains(allowedLands, map.get(i, j).land)) {
var currentAllowedLands = map.getAllowedLands(i, j, allLands);
for (var t = 0; t < lands.length && !swapped; t++) {
if (map.get(i, j).land != lands[t] && Catan.Tools.contains(currentAllowedLands, lands[t])) {
if (map.get(i, j).land !== lands[t] && Catan.Tools.contains(currentAllowedLands, lands[t])) {
// set empty spot land to current.land
map.get(ex, ey).land = map.get(i, j).land;
// set current land to land[t]
Expand Down
13 changes: 6 additions & 7 deletions www/js/catan/js/generator/generator.number.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//noinspection JSHint
(function(Catan) {
"use strict";

Catan.Generator.Number = {};

Expand Down Expand Up @@ -29,7 +31,7 @@
var lowest;
for (j = 0; j < groupKeys.length; j++) {
// continue when size reached
if (groups[groupKeys[j]].numbers.length == groups[groupKeys[j]].size) {
if (groups[groupKeys[j]].numbers.length === groups[groupKeys[j]].size) {
continue;
}
// init lowest
Expand All @@ -49,7 +51,7 @@
// and index lands groups
map.each(function (i, j) {
var current = map.get(i, j);
if (current.land != Catan.T.Desert) {
if (current.land !== Catan.T.Desert) {
current.number = groups[current.land].numbers.pop();
groups[current.land].pos.push({x: i, y: j});
}
Expand All @@ -68,10 +70,6 @@
if (neighbour.number !== undefined && Catan.Tools.tdsc(neighbour.number) > max) {
max = neighbour.number;
}
// can't swap with this neighbour
if (maxNeighbourTdsc !== undefined && Catan.Tools.tdsc(neighbour.number) > maxNeighbourTdsc) {
return;
}
});
return max;
};
Expand All @@ -85,6 +83,7 @@
if (Catan.Tools.tdsc(map.get(coord.x, coord.y).number) < maxTdsc) {
max = getMax(coord.x, coord.y);
if (max !== undefined) {
//noinspection JSUnusedAssignment
if (min === undefined || max < min) {
min = max;
minCoord = coord;
Expand All @@ -107,7 +106,7 @@
coordinates.push(new Catan.Position(i, j));
};
var isCoupleValidFunction = function (a, b) {
return (a.land != Catan.T.Empty && b.land != Catan.T.Empty && a.number !== undefined && b.number !== undefined);
return (a.land != Catan.T.Empty && b.land !== Catan.T.Empty && a.number !== undefined && b.number !== undefined);
};
var doSwapFunction = function (ax, ay, bx, by) {
a = map.get(ax, ay);
Expand Down
3 changes: 2 additions & 1 deletion www/js/catan/js/map.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//noinspection JSHint
(function(Catan){
"use strict";

Expand Down Expand Up @@ -148,7 +149,7 @@
this.eachNeighbour(i, j, function (x, y) {
// remove neighbours lands from allowed lands
allowedLands = allowedLands.filter(function (element, index, array) {
return (map.get(x, y).land != element);
return (map.get(x, y).land !== element);
});
});
return allowedLands;
Expand Down
17 changes: 12 additions & 5 deletions www/js/catan/js/tools.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//noinspection JSHint
(function(Catan){
"use strict";

Expand All @@ -16,8 +17,10 @@
Catan.Tools.removeOne = function (a, o) {
var removed = false;
return a.filter(function (element, index, array) {
if (removed) return true;
if (element == o) {
if (removed) {
return true;
}
if (element === o) {
removed = true;
return false;
}
Expand All @@ -41,13 +44,17 @@
return sum;
};

Catan.Tools.rotate = function (a, inc) {
Catan.Tools.rotate = function (a, inc)
{
var l = a.length, i, x;
inc = Math.abs(inc) >= l && (inc %= l) ||
inc < 0 && (inc += l) ||
inc;
for (; inc; inc = (Math.ceil(l / inc) - 1) * inc - l + (l = inc))
for (i = l; i > inc; x = a[--i], a[i] = a[i - inc], a[i - inc] = x);
for (; inc; inc = (Math.ceil(l / inc) - 1) * inc - l + (l = inc)) {
for (i = l; i > inc; x = a[--i], a[i] = a[i - inc], a[i - inc] = x) {
// nothing
}
}
};

// the number of two dice combination with a sum equal to this number
Expand Down
1 change: 1 addition & 0 deletions www/js/catan/js/ui.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//noinspection JSHint
(function(Catan){
"use strict";

Expand Down
87 changes: 46 additions & 41 deletions www/js/controllers.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
angular.module('starter.controllers', [])
//noinspection JSHint
(function (angular, Catan) {
"use strict";

.controller('MapCtrl', function($scope, $ionicPlatform, Settings) {
$scope.generate = function() {
var canvas = document.querySelector('.canvas');
canvas.width = document.querySelector('.canvas-container').offsetWidth;
canvas.height = document.querySelector('.canvas-container').offsetHeight;
var map = Catan.Generator.Map.generate(Settings.getTileTrioScoreLimit(), Settings.getHarborGenerationStrategy());
Catan.UI.drawMap(map, canvas);
};
})
angular.module('starter.controllers', [])

.controller('SettingsCtrl', function($scope, Settings) {
$scope.tileTrioScoreLimitOptions = [
{id: 11, label: 'High (slower)'},
{id: 12, label: 'Normal'},
{id: 13, label: 'Low (faster)'}
];
var selectedTileTrioScoreLimitValue = Settings.getTileTrioScoreLimit();
$scope.selectedTileTrioScoreLimit = null;
for (var i = 0 ; i < $scope.tileTrioScoreLimitOptions.length ; i++) {
if ($scope.tileTrioScoreLimitOptions[i].id === selectedTileTrioScoreLimitValue) {
$scope.selectedTileTrioScoreLimit = $scope.tileTrioScoreLimitOptions[i];
}
}
$scope.updateTileTrioScoreLimit = function() {
Settings.setTileTrioScoreLimit(this.selectedTileTrioScoreLimit.id);
};
.controller('MapCtrl', function ($scope, $ionicPlatform, Settings) {
$scope.generate = function () {
var canvas = document.querySelector('.canvas');
canvas.width = document.querySelector('.canvas-container').offsetWidth;
canvas.height = document.querySelector('.canvas-container').offsetHeight;
var map = Catan.Generator.Map.generate(Settings.getTileTrioScoreLimit(), Settings.getHarborGenerationStrategy());
Catan.UI.drawMap(map, canvas);
};
})

.controller('SettingsCtrl', function ($scope, Settings) {
$scope.tileTrioScoreLimitOptions = [
{id: 11, label: 'High (slower)'},
{id: 12, label: 'Normal'},
{id: 13, label: 'Low (faster)'}
];
var selectedTileTrioScoreLimitValue = Settings.getTileTrioScoreLimit();
$scope.selectedTileTrioScoreLimit = null;
for (var i = 0; i < $scope.tileTrioScoreLimitOptions.length; i++) {
if ($scope.tileTrioScoreLimitOptions[i].id === selectedTileTrioScoreLimitValue) {
$scope.selectedTileTrioScoreLimit = $scope.tileTrioScoreLimitOptions[i];
}
}
$scope.updateTileTrioScoreLimit = function () {
Settings.setTileTrioScoreLimit(this.selectedTileTrioScoreLimit.id);
};


$scope.harborGenerationStrategyOptions = [
{id: 'separate-tiles', label: 'Separate Tiles'},
{id: 'coast-bars', label: 'Coast Bars'}
];
var selectedHarborGenerationStrategyValue = Settings.getHarborGenerationStrategy();
$scope.selectedHarborGenerationStrategy = null;
for (i = 0 ; i < $scope.harborGenerationStrategyOptions.length ; i++) {
if ($scope.harborGenerationStrategyOptions[i].id === selectedHarborGenerationStrategyValue) {
$scope.selectedHarborGenerationStrategy = $scope.harborGenerationStrategyOptions[i];
}
}
$scope.updateHarborGenerationStrategy = function() {
Settings.setHarborGenerationStrategy(this.selectedHarborGenerationStrategy.id);
};
});
$scope.harborGenerationStrategyOptions = [
{id: 'separate-tiles', label: 'Separate Tiles'},
{id: 'coast-bars', label: 'Coast Bars'}
];
var selectedHarborGenerationStrategyValue = Settings.getHarborGenerationStrategy();
$scope.selectedHarborGenerationStrategy = null;
for (i = 0; i < $scope.harborGenerationStrategyOptions.length; i++) {
if ($scope.harborGenerationStrategyOptions[i].id === selectedHarborGenerationStrategyValue) {
$scope.selectedHarborGenerationStrategy = $scope.harborGenerationStrategyOptions[i];
}
}
$scope.updateHarborGenerationStrategy = function () {
Settings.setHarborGenerationStrategy(this.selectedHarborGenerationStrategy.id);
};
});

})(angular, Catan);
Loading

0 comments on commit 474d642

Please sign in to comment.