-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Daw
committed
Jul 18, 2017
1 parent
c54be33
commit 2005799
Showing
8 changed files
with
5,582 additions
and
4,952 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.table-green { | ||
color: #00bb00; | ||
} | ||
|
||
.table-red { | ||
color: #cc0000; | ||
} | ||
|
||
.table-grey { | ||
color: #aaaaaa; | ||
} | ||
|
||
.form-control { | ||
|
||
width: 75%; | ||
transition: none; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,36 @@ | ||
<template> | ||
majors | ||
</template> | ||
<require from="./majors-stats-styles.css"></require> | ||
<div class="col-lg-12" if.bind="poolies"> | ||
<h2><span style="margin-right: 20px">${season} Majors Stats</span><small>after week ${week - 1} / <span class="text-primary">${tournamentName}</span></small></h2> | ||
<div class="card-box"> | ||
<table id="majorstable" class="table"> | ||
<thead> | ||
<tr> | ||
<th>Rank</th> | ||
<th>Poolie</th> | ||
<th>Points</th> | ||
<th>Behind</th> | ||
<th>Wins</th> | ||
<th>Top 5s</th> | ||
<th>Top 10s</th> | ||
<th>Cuts</th> | ||
<th>+/-</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr repeat.for="poolie of poolies"> | ||
<td>${poolie.Rank}</td> | ||
<td>${poolie.LastFirst}</td> | ||
<td>${poolie.Points}</td> | ||
<td>${poolie.Behind}</td> | ||
<td class="${poolie.Wins === maxWins ? 'table-green' : ''}">${poolie.Wins}</td> | ||
<td class="${poolie.Top5 === maxTop5 ? 'table-green' : ''}">${poolie.Top5}</td> | ||
<td class="${poolie.Top10 === maxTop10 ? 'table-green' : ''}">${poolie.Top10}</td> | ||
<td class="${poolie.Cuts === 0 ? 'table-green' : ''}">${poolie.Cuts}</td> | ||
<td class="${poolie.PlusMinus === maxPlusMinus ? 'table-green' : ''}">${poolie.PlusMinus}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</template> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,102 @@ | ||
import { inject } from 'aurelia-framework'; | ||
import { StatsClient } from '../statsClient'; | ||
|
||
@inject(StatsClient) | ||
export class MajorsStatsCustomElement { | ||
|
||
} | ||
constructor(sc: StatsClient) { | ||
this.statsClient = sc; | ||
} | ||
|
||
private readonly statsClient: StatsClient; | ||
private poolies: Array<Object>; | ||
private season: number; | ||
private week: number; | ||
private tournamentName: string; | ||
|
||
private maxWins: number; | ||
private maxTop5: number; | ||
private maxTop10: number; | ||
private maxCuts: number; | ||
private maxPlusMinus: number; | ||
|
||
async attached() { | ||
await this.getData(); | ||
window.setTimeout(() => { | ||
(<any>$('#majorstable')).dataTable(this.getTableConfig()); | ||
(<any>$('input')).addClass("form-control input-sm"); | ||
}, 1000); | ||
} | ||
|
||
async getData() { | ||
let data = await this.statsClient.getMajorsStats(); | ||
this.week = <number>data["Week"]; | ||
this.season = <number>data["Season"]; | ||
this.tournamentName = <string>data["Tournament"] | ||
this.tournamentName = this.tournamentName.toLowerCase().startsWith("the ") ? this.tournamentName : `The ${this.tournamentName}`; | ||
this.poolies = <Array<Object>>data["Poolies"]; | ||
this.getMaxValues(); | ||
} | ||
|
||
getTableConfig(): Object { | ||
return { | ||
columnDefs: [ | ||
{ type: "num" }, | ||
{ type: "num" }, | ||
{ type: "string" }, | ||
{ type: "num" }, | ||
{ type: "num" }, | ||
{ type: "num" }, | ||
{ type: "num" }, | ||
{ type: "num" }, | ||
{ type: "num" }, | ||
{ type: "num" } | ||
], | ||
order: [[0, 'asc']], | ||
paging: false, | ||
info: false | ||
}; | ||
} | ||
|
||
getMaxValues() { | ||
let array = []; | ||
this.poolies.forEach(poolie => { | ||
if(poolie["Wins"]){ | ||
array.push(poolie["Wins"]); | ||
} | ||
}); | ||
this.maxWins = Math.max.apply(null, array); | ||
|
||
array = []; | ||
this.poolies.forEach(poolie => { | ||
if(poolie["Top5"]){ | ||
array.push(poolie["Top5"]); | ||
} | ||
}); | ||
this.maxTop5 = Math.max.apply(null, array); | ||
|
||
array = []; | ||
this.poolies.forEach(poolie => { | ||
if(poolie["Top10"]){ | ||
array.push(poolie["Top10"]); | ||
} | ||
}); | ||
this.maxTop10 = Math.max.apply(null, array); | ||
|
||
array = []; | ||
this.poolies.forEach(poolie => { | ||
if(poolie["Cuts"]){ | ||
array.push(poolie["Cuts"]); | ||
} | ||
}); | ||
this.maxCuts = Math.max.apply(null, array); | ||
|
||
array = []; | ||
this.poolies.forEach(poolie => { | ||
if(poolie["PlusMinus"]){ | ||
array.push(poolie["PlusMinus"]); | ||
} | ||
}); | ||
this.maxPlusMinus = Math.max.apply(null, array); | ||
|
||
} | ||
} |
This file contains 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
This file contains 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