Skip to content

Commit

Permalink
Display each state's score on the home page
Browse files Browse the repository at this point in the history
Towards #32.
  • Loading branch information
waldoj committed Mar 21, 2016
1 parent 31e2782 commit e9ed56a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions public/grid/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ <h2 class="text-center">
<script id="state-template" type="text/x-handlebars-template">
<tr>
<td> <a href="{{stateHref}}"> {{state}} </a> </td>
<td> {{state_score}} </td>
{{#each this.datasets}}
<td class="grade grade-{{grade}}">
<a href="{{datasetHref}}">
Expand All @@ -86,6 +87,7 @@ <h2 class="text-center">
<script id="dataset-template" type="text/x-handlebars-template">
<tr>
<th>State</th>
<th>Score</th>
{{#each this}}
<th><span><a href="{{datatypeHref}}">{{datatype}}</a></span></th>
{{/each}} </tr>
Expand Down
10 changes: 8 additions & 2 deletions public/grid/js/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,19 @@ function mapInfo(data, tabletop) {

setupDatatypes(allTypes);

/* Reverse the state abbreviations' keys and values. */
reversed = {};
for(var key in state_abbreviations){
reversed[state_abbreviations[key]] = key;
}
state_abbreviations = reversed;

var rows = _.chain(rawData)
.groupBy("State")
.map(function(datasets, state) {
var row = {
state: state,
state_score: place_scores[state_abbreviations[state]] + "%",
state: datasets[0]["State"],
stateHref: URI().filename("datasets.html").search({
"state": state
Expand Down Expand Up @@ -201,9 +209,7 @@ function mapInfo(data, tabletop) {
var html = stateTemplate(row);
$("#states").append(html);
})

.value();

$('[data-toggle="tooltip"]').tooltip()
}

Expand Down

0 comments on commit e9ed56a

Please sign in to comment.