-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
118 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
Instanews is a great way to look at news from the NEW York Times top stories API. | ||
# Project#2-Instanews | ||
|
||
Instanews is a great way to look at news from the NEW York Times top stories API. It will allow users to select from several news categories and display the top stories. Only 12 articles with a photo will be displayed at once. | ||
|
||
## Getting Started | ||
|
||
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. | ||
|
||
## Built With | ||
|
||
Javascript | ||
Jquery | ||
Ajax | ||
Scss | ||
|
||
## Author | ||
|
||
- Victor Guo | ||
|
||
## Acknowledgments | ||
|
||
- Everyone in WEBDEV_is_DOPE! |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
$(document).ready(function() { | ||
//Selectric | ||
$(function() { | ||
$('select').selectric(); | ||
}); | ||
|
||
$('#select-section').on('change', function() { | ||
$('.list').empty(); | ||
$('.load').append( | ||
'<img class="loadingIcon" src="./Images/assets/ajax-loader.gif">' | ||
); | ||
|
||
$('header').addClass('mininav'); | ||
|
||
let userinput = $(this).val(); | ||
console.log(userinput); | ||
|
||
sayHello(userinput); | ||
|
||
if (userinput == 'sections') { | ||
// alert('dont select home dumbass!'); | ||
// console.log('hihi'); | ||
} | ||
let url = | ||
'https://api.nytimes.com/svc/topstories/v2/' + userinput + '.json'; | ||
url += | ||
'?' + | ||
$.param({ | ||
'api-key': 'e9a1e979e8aa462e9143ac6fbdaa8557' | ||
}); | ||
|
||
$.ajax({ | ||
method: 'GET', | ||
url: url, | ||
dataType: 'JSON' | ||
}) | ||
|
||
.always(function() { | ||
$('.load').remove(); | ||
}) | ||
|
||
.done(function(data) { | ||
const filteredResults = data.results | ||
.filter(function(value) { | ||
// console.log(data.results.multimedia[4]); | ||
return value.multimedia.length > 1; | ||
}) | ||
.slice(0, 12); | ||
|
||
// filtering through the data.results Array, and if any object within calle multimedia has more than 0 items in it we | ||
// return that object. the slice is chained to it, saying we only want 12 results. | ||
|
||
$.each(filteredResults, function(key, value) { | ||
// console.log(); | ||
|
||
$('.list').append( | ||
' <li style="background-image: url(' + | ||
value.multimedia[4].url + | ||
');background-size:cover;background-position: 50%;"><a target="_blank" href="' + | ||
value.url + | ||
'"><p class="newstext">' + | ||
value.abstract + | ||
'</p></a></li>' | ||
); | ||
}); | ||
}) | ||
|
||
.fail(function() { | ||
console.log('fail'); | ||
}); | ||
}); | ||
|
||
function sayHello(cat) { | ||
alert(cat); | ||
} | ||
}); // end doc ready |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,3 +48,5 @@ | |
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,8 @@ | |
margin-top: 0; | ||
} | ||
@include desktop { | ||
width: 20%; | ||
width: 35%; | ||
margin-left: 0; | ||
} | ||
} | ||
} |