Skip to content
Merged
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
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<div id="userFaves">
<form id="getFaves">
<label for="userName">Your Name</label>
<input type="text">
<input id="userInput" type="text">
<button id="view" type="submit">View</button>
</form>
</div>
Expand Down
37 changes: 13 additions & 24 deletions models/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ const API_URL = 'http://localhost:3000/api/v1';
}

Image.fetchFaves = () =>{

Image.all = [];
$.get(`${API_URL}/favorites`)
.then(Image.loadAll)
const user = {
user: $('#userInput').val()
}
$.get(`${API_URL}/favorites`, user)
.then(Image.loadFaves)
.fail(console.error);

console.log("this is in fetchFaves", Image.all);
Expand All @@ -48,38 +52,23 @@ const API_URL = 'http://localhost:3000/api/v1';

}
Image.loadFaves = (data) => {
Image.faves = data.map(obj => new Image(obj));
console.log(ImageFaves.all);
app.Image.faves.map(image => $('#favorites-wrapper').append(image.toHtml()));
Image.all = data.map(obj => new Image(obj));
console.log('this is in loadFaves', data);
console.log('this is image.all in loadFaves', Image.all)
$('#favorites-wrapper').empty();
app.Image.all.map(image => $('#favorites-wrapper').append(image.toHtml()));

}

Image.loadAll = (data) => {
Image.all = data.map(obj => new Image(obj));
console.log(Image.all);
console.log('this is in loadAll', Image.all);
app.imageView.append();
Image.all = [];


// app.imageView.initDiscoverPage();
}

Image.saveImage = (image) =>{
// const rover = $('#rover option:selected').text();
// const img_id = $(this).find('img').attr('id');
// const img_num = img_id.slice(1);
// const src = $(this).find('img').attr('src');


$.post(`${API_URL}/favorites`, image)
// {
// image_id: img_num,
// rover: rover,
// camera: $('#camera option:selected').text(),
// url: src,
// user: $('#user').val()

// })

}

Image.prototype.toHtml = function () {
Expand Down