Skip to content

Commit

Permalink
Added functionality to allow users to change the default view of the …
Browse files Browse the repository at this point in the history
…application to month, week, or day; shipped with week as default
  • Loading branch information
kingsman142 committed May 30, 2017
1 parent c7959d6 commit a928b28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ somewhere in the `body`.

In order to turn on or off default checkboxes, open up `map.js`, CTRL+F 'DEFAULT_CHECKS', and change a value to `false` to turn it off by default and `true` to turn it on by default.

In order to change the default view (currently shipped with weekly data as default) to the past month, week, or day, open `map.js`, CTRL+F 'DEFAULT_VIEW', and read the documentation. You can change the value to "month", "week", or "day"; anything else will default to weekly data.

## Getting started:
1. Fork the project
2. Add your name to `contributors.md`
Expand Down
25 changes: 21 additions & 4 deletions map.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
WPRDC_QUERY_SUFFIX,
PITT_LAUNDRY,
PITT_LABS,
DEFAULT_CHECKS;
DEFAULT_CHECKS,
DEFAULT_VIEW;

// await those values
window.addEventListener("dataready", function handler(event) {
Expand All @@ -28,6 +29,12 @@
// true = turned on by default; false = turned off by default
DEFAULT_CHECKS = { "library": true, "arrest": true, "police": true, "code violation": true, "non-traffic violation": true, "311": true, "labs": true, "laundry": true };

// choose the default data shown in the map; can hold 1 of 3 strings:
// "month" = show data from the previous 30 days
// "week" = show data from the previous 7 days
// "day" = show data from the previous day
DEFAULT_VIEW = "week";

// wait for these values before fetching dependant data
fetchAllData();

Expand Down Expand Up @@ -383,7 +390,6 @@

record.filtered = true;
if (filter.checked == true) {
record.pin.addTo(map);
record.filtered = false;
}

Expand Down Expand Up @@ -652,8 +658,19 @@
retryDiv.appendChild(retryButton);
});
}).then(() => {
//display past week map as default
displayPastWeek();
switch (DEFAULT_VIEW) {
case "month":
displayPastMonth();
break;
case "week":
displayPastWeek();
break;
case "day":
displayPastDay();
break;
default:
displayPastWeek();
}
displayMapMode();
generateDataTable();
});
Expand Down

0 comments on commit a928b28

Please sign in to comment.