Skip to content
Open
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
75 changes: 35 additions & 40 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,44 +46,45 @@
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Single Page Application</title>

<style>
<head>
<title>Single Page Application</title>

<style>
body {
margin: 0px;
padding: 0px;
}

.app-container {
width: 400px;
margin: 0 auto 0 auto;
}

.image {
width: 100px;
height: 100px;
}

.list-container {
width: 100%;
border: 1px solid black;
}
</style>
</head>
<body>
<!-- Container for our application -->
<div id="app"></div>
</style>
</head>

<body>
<!-- Container for our application -->
<div id="app"></div>

<!-- 3rd Party Scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>

<!-- 3rd Party Scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js"></script>

<!-- Our Application Logic -->
<script>

<!-- Our Application Logic -->
<script>
/*==================================================

API
Expand All @@ -101,19 +102,13 @@
* ...
* ]
*/
function getPersonList() {
return new Promise((resolve, reject) => {
fetch('https://willowtreeapps.com/api/v1.0/profiles')
.then(response => {
if (response.status !== 200) {
reject(new Error("Error!"));
}

response.json().then(imageList => {
resolve(imageList);
});
});
});

function getPersonList() {
return fetch('https://willowtreeapps.com/api/v1.0/profiles')
.then(response => response.json())
.then(imageList => { return imageList })
.catch(error => console.log('error', error))
}


Expand All @@ -128,13 +123,14 @@
return person.lastName;
}

const getFirstName = (person) => {
function getFirstName(person) {
return person.firstName;
};


// headshot URLs are scheme relative //
// prepend http: to prevent invalid schemes like file:// or uri://
const getImageUrl = (person) => {
function getImageUrl(person) {
return `http:${person.headshot.url}`;
};

Expand All @@ -143,15 +139,14 @@
*/
function shuffleList(list) {
// Make a copy & don't mutate the passed in list
let result = list.slice(1);

let result = Array.from(list);
let tmp, j, i = list.length - 1

for (; i > 0; i -= 1) {
j = Math.floor(Math.random() * (i + 1));
tmp = list[i];
list[i] = list[j];
list[j] = tmp;
[tmp, list[i]] = [list[i], tmp];
[list[i], list[j]] = [list[j], list[i]];
[list[j], tmp] = [tmp, list[j]]
}

return result;
Expand Down Expand Up @@ -186,7 +181,7 @@
*
*/
function sortObjListByProp(prop) {
return function(objList) {
return function (objList) {
// Make a copy & don't mutate the passed in list
let result = objList.slice(1);

Expand All @@ -208,7 +203,7 @@

const sortByFirstName = sortObjListByProp('firstName');

const sortByLastName = (personList) => sortByFirstName(personList).reverse();
const sortByLastName = sortObjListByProp('lastName');


/*==================================================
Expand Down Expand Up @@ -300,7 +295,7 @@
React.createElement(App),
document.getElementById('app')
);
</script>
</body>

</script>
</body>
</html>
</html>