Skip to content

Commit

Permalink
with es5 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikkkkk committed Oct 30, 2018
1 parent 308fb44 commit c39c3d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build/js/script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 21 additions & 28 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@ $(document).ready(function() {
});

$('#select-section').on('change', function() {
loader();
let userinput = $(this).val();
getStories(userinput);
});

function loader() {
$('.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') {
function getStories(userinput) {
if (userinput === 'sections') {
alert('Not sure what you want to read? try Sports');
// console.log('hihi');
}
let url =
'https://api.nytimes.com/svc/topstories/v2/' + userinput + '.json';

let url = `https://api.nytimes.com/svc/topstories/v2/${userinput}.json`;
url +=
'?' +
$.param({
Expand Down Expand Up @@ -50,29 +52,20 @@ $(document).ready(function() {
// 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();

// $.each(filteredResults, function(key, value) {
for (let value of filteredResults) {
$('.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>'
`<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(userSelection) {
// if (userinput == 'sections') {
// alert('cannot make selection?');
// }
// }
}); // end doc ready
}
}); //end of doc ready

0 comments on commit c39c3d3

Please sign in to comment.