diff --git a/client/assets/api.js b/client/assets/api.js index dd165a4..32e0370 100644 --- a/client/assets/api.js +++ b/client/assets/api.js @@ -1,10 +1,41 @@ -// all scripts for api calls with ajax -var api_url = 'CHANGE ME'; +$(function() { + // all scripts for api calls with ajax + var api_url = 'assets/test-data.json'; //TODO: CHANGE ME! -function getAllShelters(success, fail) { - console.log('function not implemented yet'); -} + function getAllShelters(success, fail) { + console.log('function not implemented yet'); + } -function getShelterById(id, success, fail) { - console.log('function not implemented yet'); -} + function getShelterById(id, success, fail) { + console.log('function not implemented yet'); + } + + function ShelterData(data) { + var self = this; + + self.originalShelters = data; + + //Not the prettiest way of doing it, but it works. + var columnLength = Math.floor(data.length / 3); + var column1 = data; + var column2 = data.splice(0, columnLength); + var column3 = data.splice(0, columnLength); + self.shelterGroups = ko.observableArray([column1, column2, column3]); + } + + ko.applyBindings(new ShelterData(ALL_SHELTERS)); + //TODO: when client can be run through a server and not the file system + // var shelterUrl = api_url; + // $.ajax({ + // url : shelterUrl, + // type: 'GET', + // success : function(data) { + // console.log("found data", data); + // ko.applyBindings(new ShelterData(data)); + + // $("#loading").addClass("hidden"); + // $("#shelter-list").removeClass("hidden"); + // } + // }); + +}); diff --git a/client/assets/test-data.js b/client/assets/test-data.js new file mode 100644 index 0000000..abcd61d --- /dev/null +++ b/client/assets/test-data.js @@ -0,0 +1,376 @@ +var ALL_SHELTERS = [ + { + "id": 1, + "lat": null, + "lng": null, + "address": "909 Andover Road", + "city": "Andover", + "description": "Police Department", + "created_at": "2016-10-23T15:45:08.085Z", + "updated_at": "2016-10-23T15:45:08.085Z", + "instructions": null + }, + { + "id": 2, + "lat": null, + "lng": null, + "address": "2100 N. Ohio", + "city": "Augusta", + "description": "Public safety building safe room", + "created_at": "2016-10-23T15:45:08.102Z", + "updated_at": "2016-10-23T15:45:08.102Z", + "instructions": null + }, + { + "id": 3, + "lat": null, + "lng": null, + "address": "516 N. Main", + "city": "Cheney", + "description": "Senior center", + "created_at": "2016-10-23T15:45:08.108Z", + "updated_at": "2016-10-23T15:45:08.108Z", + "instructions": null + }, + { + "id": 4, + "lat": null, + "lng": null, + "address": "1401 N. Rock Road", + "city": "Derby", + "description": "Fire Station No. 2", + "created_at": "2016-10-23T15:45:08.114Z", + "updated_at": "2016-10-23T15:45:08.114Z", + "instructions": null + }, + { + "id": 5, + "lat": null, + "lng": null, + "address": "1335 N. Buckner", + "city": "Derby", + "description": "Pleasant View Baptist Church", + "created_at": "2016-10-23T15:45:08.119Z", + "updated_at": "2016-10-23T15:45:08.119Z", + "instructions": null + }, + { + "id": 6, + "lat": null, + "lng": null, + "address": "914 E. First St.", + "city": "Douglass", + "description": "Middle school support facility", + "created_at": "2016-10-23T15:45:08.124Z", + "updated_at": "2016-10-23T15:45:08.124Z", + "instructions": null + }, + { + "id": 7, + "lat": null, + "lng": null, + "address": "220 E. 1st", + "city": "El Dorado", + "description": "City hall basement", + "created_at": "2016-10-23T15:45:08.130Z", + "updated_at": "2016-10-23T15:45:08.130Z", + "instructions": null + }, + { + "id": 8, + "lat": null, + "lng": null, + "address": "210 E. 2nd", + "city": "El Dorado", + "description": "senior center", + "created_at": "2016-10-23T15:45:08.136Z", + "updated_at": "2016-10-23T15:45:08.136Z", + "instructions": null + }, + { + "id": 9, + "lat": null, + "lng": null, + "address": "200 W. Grand", + "city": "Haysville", + "description": "City hall", + "created_at": "2016-10-23T15:45:08.141Z", + "updated_at": "2016-10-23T15:45:08.141Z", + "instructions": null + }, + { + "id": 10, + "lat": null, + "lng": null, + "address": "6110 N. Hydraulic", + "city": "Park City", + "description": "City hall", + "created_at": "2016-10-23T15:45:08.147Z", + "updated_at": "2016-10-23T15:45:08.147Z", + "instructions": null + }, + { + "id": 11, + "lat": null, + "lng": null, + "address": "401 S. Khedive", + "city": "Maize", + "description": "Community center", + "created_at": "2016-10-23T15:45:08.152Z", + "updated_at": "2016-10-23T15:45:08.152Z", + "instructions": null + }, + { + "id": 12, + "lat": null, + "lng": null, + "address": "10100 Grady Ave.", + "city": "Maize", + "description": "City hall", + "created_at": "2016-10-23T15:45:08.157Z", + "updated_at": "2016-10-23T15:45:08.157Z", + "instructions": "(use storm shelter entrance on front of building by flag pole)" + }, + { + "id": 13, + "lat": null, + "lng": null, + "address": "6110 N. Hydraulic", + "city": "Park City", + "description": "City hall", + "created_at": "2016-10-23T15:45:08.164Z", + "updated_at": "2016-10-23T15:45:08.164Z", + "instructions": null + }, + { + "id": 14, + "lat": null, + "lng": null, + "address": "211 N. 2nd", + "city": "Mulvane", + "description": "City Hall", + "created_at": "2016-10-23T15:45:08.169Z", + "updated_at": "2016-10-23T15:45:08.169Z", + "instructions": "(enter through the police department door on the east side)" + }, + { + "id": 15, + "lat": null, + "lng": null, + "address": "910 E. Main", + "city": "Mulvane", + "description": "EMS station", + "created_at": "2016-10-23T15:45:08.175Z", + "updated_at": "2016-10-23T15:45:08.175Z", + "instructions": null + }, + { + "id": 16, + "lat": null, + "lng": null, + "address": "314 N. Rose Hill Road", + "city": "Rose Hill", + "description": "Christian Church", + "created_at": "2016-10-23T15:45:08.181Z", + "updated_at": "2016-10-23T15:45:08.181Z", + "instructions": null + }, + { + "id": 17, + "lat": null, + "lng": null, + "address": "1206 N. Rose Hill Road", + "city": "Rose Hill", + "description": "First Baptist Church", + "created_at": "2016-10-23T15:45:08.186Z", + "updated_at": "2016-10-23T15:45:08.186Z", + "instructions": null + }, + { + "id": 18, + "lat": null, + "lng": null, + "address": "1410 N. Main", + "city": "Rose Hill", + "description": "Bible Church", + "created_at": "2016-10-23T15:45:08.193Z", + "updated_at": "2016-10-23T15:45:08.193Z", + "instructions": null + }, + { + "id": 19, + "lat": null, + "lng": null, + "address": "109 N. Main", + "city": "Rose Hill", + "description": "United Methodist Youth Center", + "created_at": "2016-10-23T15:45:08.198Z", + "updated_at": "2016-10-23T15:45:08.198Z", + "instructions": "use south door on Showalter" + }, + { + "id": 20, + "lat": null, + "lng": null, + "address": "125 W. Rosewood", + "city": "Rose Hill", + "description": "City Hall", + "created_at": "2016-10-23T15:45:08.204Z", + "updated_at": "2016-10-23T15:45:08.204Z", + "instructions": null + }, + { + "id": 21, + "lat": null, + "lng": null, + "address": "911 N. Rose Hill Road", + "city": "Rose Hill", + "description": "Butler County Fire Station", + "created_at": "2016-10-23T15:45:08.209Z", + "updated_at": "2016-10-23T15:45:08.209Z", + "instructions": null + }, + { + "id": 22, + "lat": null, + "lng": null, + "address": "560 N. Park", + "city": "Valley Center", + "description": "Methodist Church", + "created_at": "2016-10-23T15:45:08.215Z", + "updated_at": "2016-10-23T15:45:08.215Z", + "instructions": "has handicap lift" + }, + { + "id": 23, + "lat": null, + "lng": null, + "address": "400 S. Abilene", + "city": "Valley Center", + "description": "Life Point Assembly of God", + "created_at": "2016-10-23T15:45:08.220Z", + "updated_at": "2016-10-23T15:45:08.220Z", + "instructions": null + }, + { + "id": 24, + "lat": null, + "lng": null, + "address": "300 N. Ash", + "city": "Valley Center", + "description": "Grace Connections", + "created_at": "2016-10-23T15:45:08.226Z", + "updated_at": "2016-10-23T15:45:08.226Z", + "instructions": "has single handicap chair lift" + }, + { + "id": 25, + "lat": null, + "lng": null, + "address": "316 E. Clay", + "city": "Valley Center", + "description": "community building", + "created_at": "2016-10-23T15:45:08.232Z", + "updated_at": "2016-10-23T15:45:08.232Z", + "instructions": null + }, + { + "id": 26, + "lat": null, + "lng": null, + "address": "1323 N. A St.", + "city": "Wellington", + "description": "Sumner Regional Medical Center", + "created_at": "2016-10-23T15:45:08.239Z", + "updated_at": "2016-10-23T15:45:08.239Z", + "instructions": "use southeast basement entrance; accepts pets in carriers" + }, + { + "id": 27, + "lat": null, + "lng": null, + "address": "1600 W. 8th St.", + "city": "Wellington", + "description": "Sumner Care Center", + "created_at": "2016-10-23T15:45:08.245Z", + "updated_at": "2016-10-23T15:45:08.245Z", + "instructions": "(use rear entrance under carport)" + }, + { + "id": 28, + "lat": null, + "lng": null, + "address": " 311 North A St.", + "city": "Wellington", + "description": "old junior high school", + "created_at": "2016-10-23T15:45:08.250Z", + "updated_at": "2016-10-23T15:45:08.250Z", + "instructions": "use east entrance" + }, + { + "id": 29, + "lat": null, + "lng": null, + "address": "milepost 26", + "city": "Kansas Turnpike", + "description": null, + "created_at": "2016-10-23T15:45:08.256Z", + "updated_at": "2016-10-23T15:45:08.256Z", + "instructions": null + }, + { + "id": 30, + "lat": null, + "lng": null, + "address": "milepost, 65", + "city": "Kansas Turnpike", + "description": null, + "created_at": "2016-10-23T15:45:08.261Z", + "updated_at": "2016-10-23T15:45:08.261Z", + "instructions": null + }, + { + "id": 31, + "lat": null, + "lng": null, + "address": "milepost 97", + "city": "Kansas Turnpike", + "description": null, + "created_at": "2016-10-23T15:45:08.266Z", + "updated_at": "2016-10-23T15:45:08.266Z", + "instructions": null + }, + { + "id": 32, + "lat": null, + "lng": null, + "address": "milepost 132", + "city": "Kansas Turnpike", + "description": null, + "created_at": "2016-10-23T15:45:08.272Z", + "updated_at": "2016-10-23T15:45:08.272Z", + "instructions": null + }, + { + "id": 33, + "lat": null, + "lng": null, + "address": "milepost 188", + "city": "Kansas Turnpike", + "description": null, + "created_at": "2016-10-23T15:45:08.278Z", + "updated_at": "2016-10-23T15:45:08.278Z", + "instructions": null + }, + { + "id": 34, + "lat": null, + "lng": null, + "address": "milepost 209", + "city": "Kansas Turnpike", + "description": null, + "created_at": "2016-10-23T15:45:08.283Z", + "updated_at": "2016-10-23T15:45:08.283Z", + "instructions": null + } +]; \ No newline at end of file diff --git a/client/index.html b/client/index.html index d045bc8..1eca5e5 100644 --- a/client/index.html +++ b/client/index.html @@ -1,5 +1,7 @@ - + + + @@ -8,13 +10,35 @@ -
+
+ +
+ + +
+
+
+
+ + +
+
+

+

+
+
+
- - + + + + + - +