Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

reset eslint rules, refactored code to fit

# This is the commit message Seneca-CDOT#2:

Added jQuery to eslint
  • Loading branch information
eekbatani committed Nov 11, 2019
1 parent 57eb25c commit f619052
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ module.exports = {
"env": {
"jest": true,
"browser": true,
"jquery": true
},
"plugins": [
"dollar-sign",
"jquery"
],
rules: {
/**
* Disallow the use of console
Expand All @@ -23,7 +28,5 @@ module.exports = {
*/
"func-names": "off",


'no-plusplus': 'off'
}
};
13 changes: 7 additions & 6 deletions pagination.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*eslint-env jquery*/
// Pagination Logic

// Counts nymber of blog posts
Expand All @@ -18,7 +19,7 @@ const totalPages = Math.ceil(numberOfItems / limitPerPage);
$('.pagination').append(`<li class='page-item active'><a class='page-link' href='#')'>${1}</a></li>`);

// Adds additional pages dynamically based on # of blog posts
for (let i = 2; i <= totalPages; i++) {
for (let i = 2; i <= totalPages; i += 1) {
// Insert page number into pagination tabs
$('.pagination').append(`<li class='page-item'><a class='page-link' href='#'>${i}</a></li>`);
}
Expand All @@ -42,7 +43,7 @@ $('.pagination li.page-item').on('click', function () {
const grandTotal = limitPerPage * currentPage;

// Loop through total items, selecting a new set of items based on page number
for (let i = grandTotal - limitPerPage; i < grandTotal; i++) {
for (let i = grandTotal - limitPerPage; i < grandTotal; i += 1) {
$(`#page .blogPost:eq(${i})`).show(); // Show items from the new page that was selected
}
return true;
Expand All @@ -55,14 +56,14 @@ $('#next-page').on('click', () => {
if (currentPage === totalPages) {
return false;
}
currentPage++; // Increment page by one
currentPage += 1; // Increment page by one
$('.pagination li').removeClass('active'); // Remove the 'activate' status class from the previous active page number
$('#page .blogPost').hide(); // Hide all items in the pagination loop
// Get the total number of items up to the page that was selected
const grandTotal = limitPerPage * currentPage;

// Loop through total items, selecting a new set of items based on page number
for (let i = grandTotal - limitPerPage; i < grandTotal; i++) {
for (let i = grandTotal - limitPerPage; i < grandTotal; i += 1) {
$(`#page .blogPost:eq(${i})`).show(); // Show items from the new page that was selected
}

Expand All @@ -78,14 +79,14 @@ $('#previous-page').on('click', () => {
if (currentPage === 1) {
return false; // Exit function if invalid
}
currentPage--; // Decrement page by one
currentPage -= 1; // Decrement page by one
$('.pagination li').removeClass('active'); // Remove the 'activate' status class from the previous active page number
$('#page .blogPost').hide(); // Hide all items in the pagination loop
// Get the total number of items up to the page that was selected
const grandTotal = limitPerPage * currentPage;

// Loop through total items, selecting a new set of items based on page number
for (let i = grandTotal - limitPerPage; i < grandTotal; i++) {
for (let i = grandTotal - limitPerPage; i < grandTotal; i += 1) {
$(`#page .blogPost:eq(${i})`).show(); // Show items from the new page that was selected
}

Expand Down

0 comments on commit f619052

Please sign in to comment.