Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added list of shelters to the main page #10

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions client/assets/api.js
Original file line number Diff line number Diff line change
@@ -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");
// }
// });

});
Loading