Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jokecamp committed Aug 24, 2014
0 parents commit a0422af
Show file tree
Hide file tree
Showing 19 changed files with 576 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "app/bower_components"
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
logs/*
!.gitkeep
node_modules/
bower_components/
tmp
.DS_Store
.idea
6 changes: 6 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"globalstrict": true,
"globals": {
"angular": false
}
}
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: node_js
node_js:
- "0.10"

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm start > /dev/null &
- npm run update-webdriver
- sleep 1 # give server time to start

script:
- node_modules/.bin/karma start test/karma.conf.js --no-auto-watch --single-run --reporters=dots --browsers=Firefox
- node_modules/.bin/protractor test/protractor-conf.js --browser=firefox
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License

Copyright (c) 2010-2014 Google, Inc. http://angularjs.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# English Premier League Fantasy Stats for Geeks

By Joe Kampschmidt

## About

I've will try to update the stats every week after the matches. However, since its open source feel free to update the stats yourself.

Also pull requests highly recommended.

Please use this project/page to crush your friends in fantasy football.

## Technology

- Angular JS
- nodejs for the local development server

## To Run

To install all dependencies and run a local web server run `npm start`
60 changes: 60 additions & 0 deletions app/css/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* app css stylesheet */
body { padding:10px; font-size:12px; }

.menu {
list-style: none;
border-bottom: 0.1em solid black;
margin-bottom: 2em;
padding: 0 0 0.5em;
}

.menu:before {
content: "[";
}

.menu:after {
content: "]";
}

.menu > li {
display: inline;
}

.menu > li:before {
content: "|";
padding-right: 0.3em;
}

.menu > li:nth-child(1):before {
content: "";
padding: 0;
}

.center { text-align:center; }
.right { text-align:right; }

ul li { display:inline; margin:0 4px;}
table { margin:0; padding:0; }
th { background:#35700F; color:#FFF; text-align:center; }
th a { color:#FFF; text-decoration:none; }
td, th { border:solid 1px #CCC; padding:0 5px; }

tr:nth-child(even) {background: #EEE;}

.status { font-weight:bold; padding:1px 2px; }
.warn { background:#CC0000; color:#FFF; }
.doubt { background:#FF5C26; color:#FFF; }
.doubt25 { background:#FF5C26; color:#FFF; }
.doubt50 { background:#FFAA33; }
.doubt75 { background:#FFE463; }

.positive { color:green; }
.negative { color:#CC0000; }

.points { font-weight:bold; }
.dream { font-weight:bold; text-align:center; }

.filterForm { padding:6px 0; }
.filterForm .form-group { padding-right:10px; }

.footer { padding:10px 0; }
58 changes: 58 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>English Premier League 2014-15 Fantasy Stats for Geeks</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

<link rel="stylesheet" href="css/app.css"/>

<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

</head>
<body>
<ul class="menu">
<li><a href="#/players">All Players</a></li>
<li><a href="#/all">Raw Data</a></li>
<li>Stats Last Updated: 8/24/14 5:29 PM EST</li>
</ul>

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">English Premier League Fantasy Stats for Geeks</a>
</div>
<ul class="nav navbar-nav">
<li><a href="#/players">All Players</a></li>
<li><a href="#/all">Raw Data</a></li>
</ul>
</div>
</div>

<div ng-view></div>

<div class="footer">
Created by Joe Kampschmidt - 2014 <a href="http://www.jokecamp.com">www.jokecamp.com</a>
</div>

<script src="bower_components/lodash/dist/lodash.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers/rawDataCtrl.js"></script>
<script src="js/controllers/playersCtrl.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
<script src="js/data-svc.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions app/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';


// Declare app level module which depends on filters, and services
angular.module('myApp', [
'ngRoute',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/all', {templateUrl: 'partials/raw.html', controller: 'rawDataCtrl'});
$routeProvider.when('/players', {templateUrl: 'partials/players.html', controller: 'playersCtrl'});
$routeProvider.otherwise({redirectTo: '/players'});
}]);
46 changes: 46 additions & 0 deletions app/js/controllers/playersCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';

/* Controllers */

angular.module('myApp.controllers')
.controller('playersCtrl', ['$scope', 'Data', function($scope, data) {

$scope.reverse = false;
$scope.predicate = '';
$scope.search = { };
$scope.search.minMinutes = 1;

$scope.sort = function(col) {

if ($scope.predicate == col)
$scope.reverse = !$scope.reverse;
else
$scope.predicate = col;
};

data.getJson().then(function(resp) {

$scope.teams = data.teams(resp);
$scope.roster = data.roster(resp);
$scope.stat = data.stats(resp);
$scope.allPlayers = data.players(resp);

$scope.columns = ['web_name', 'team'];
$scope.players = data.cleanData($scope.allPlayers, $scope.teams, $scope.stat);

});

$scope.searchFilter = function(player) {

// alias
var s = $scope.search;

var name = s.web_name == undefined || player.web_name.toUpperCase().indexOf(s.web_name.toUpperCase()) > -1;
var team = s.team == undefined || player.team.indexOf(s.team.toUpperCase()) > -1;
var minutes = s.minMinutes == undefined || s.minMinutes < 0 || (player.minutes >= s.minMinutes);
var posn = s.position == undefined || s.position == '' || s.position.toUpperCase() == player.position.toUpperCase();

return name && team && minutes && posn;
};

}]);
20 changes: 20 additions & 0 deletions app/js/controllers/rawDataCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

/* Controllers */

angular.module('myApp.controllers', [])
.controller('rawDataCtrl', ['$scope', '$http', 'Data', function($scope, $http, data) {

data.getJson().then(function(resp) {

$scope.teams = data.teams(resp);
$scope.roster = data.roster(resp);
$scope.stat = data.stats(resp);
$scope.allPlayers = data.players(resp);

$scope.columns = Object.keys($scope.stat);
$scope.players = data.cleanData($scope.allPlayers, $scope.teams, $scope.stat);

});

}]);
60 changes: 60 additions & 0 deletions app/js/data-svc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

angular.module('myApp.services', [])
.factory('Data', ['$http', '$filter', function ($http, $filter) {

var cleanData = function(items, teams, stat) {

var players = _.map(items, function(p) {
if (p == null) p = {};

var x = {};
angular.extend(x, stat);

_.forOwn(x, function(value, key) {
x[key] = p[value];
});

// custom data
if (x.team_id > 0) x.team = _.find(teams, function(t) { return t.id == x.team_id; }).short_name;
x.position = $filter('pos')(x.element_type_id);
x.transfer_diff = x.transfers_in_event - x.transfers_out_event;

return x;

});

return _.where(players, function (p) { return p.id > 0; } );
};

var getTeams = function(data) {
return data.eiwteams;
};

var getRoster = function(data) {
return data.elements;
};

var getStatColumns = function(data) {
return data.elStat;
};

var getPlayers = function(data) {
return data.elInfo;
};

var getJson = function(){
return $http.get('js/data.json').then(function(res){
return res.data;
});
};

return {
getJson: getJson,
cleanData: cleanData,
players: getPlayers,
teams: getTeams,
roster: getRoster,
stats: getStatColumns
};

}]);
1 change: 1 addition & 0 deletions app/js/data.json

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions app/js/directives.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

/* Directives */


angular.module('myApp.directives', []);
Loading

0 comments on commit a0422af

Please sign in to comment.