Initialization
$(document).ready(function () { ... });
Initializes the document when ready and sets up event listeners, loads data, and handles pagination.
Properties
posts
The array holding all posts data.
Type: Array
searchTerm
The search term used to filter posts.
Type: string
currentPage
The current page number in pagination.
Type: number
postsPerPage
The number of posts displayed per page.
Type: number
filteredPosts
The array holding the filtered posts data.
Type: Array
totalPages
The total number of pages after filtering.
Type: number
Methods
populatePosts(postsToPopulate)
Populates the posts container with the given posts.
Parameters: postsToPopulate
(Array) - The posts to populate in the container.
filterBySearchTerm(posts)
Filters posts by search term.
Parameters: posts
(Array) - The posts to filter.
Returns: Array
- The filtered posts.
filterByDate(posts, startDate, endDate)
Filters posts by date range.
Parameters: posts
(Array) - The posts to filter. startDate
(string) - The start date of the range. endDate
(string) - The end date of the range.
Returns: Array
- The filtered posts.
filterPostsByDateAndSearch(posts, startDate, endDate, searchTerm)
Filters posts by date range and search term.
Parameters: posts
(Array) - The posts to filter. startDate
(string) - The start date of the range. endDate
(string) - The end date of the range. searchTerm
(string) - The search term to filter by.
Returns: Array
- The filtered posts.
goToPage(page)
Goes to the specified page of posts.
Parameters: page
(number) - The page number to go to.
updatePagination(currentPage)
Updates the pagination links.
Parameters: currentPage
(number) - The current page number.
updatePaginationLinks(currentPage)
Updates the pagination links for navigating between pages.
Parameters: currentPage
(number) - The current page number.
formatDate(date)
Formats a date to the YYYY-MM-DD format.
Parameters: date
(string) - The date to format.
Returns: string
- The formatted date.
SetDates()
Sets the default start and end dates for the date inputs.
filterByDateRange(posts, startDate, endDate)
Filters posts by date range, adjusting the range if no posts are found.
Parameters: posts
(Array) - The posts to filter. startDate
(string) - The start date of the range. endDate
(string) - The end date of the range.
Returns: Array
- The filtered posts.
Video Tutorials
How to Add a Post
How to Update a Post
How to Delete a Post
How to add a new sheet
Steps to Manage Posts
Add a Post
Follow these steps to add a new post:
- Navigate to the posts google sheet.
- Fill in the required fields such as content, picture URL, and date.
- Head back to the WorldWide Wildcats page to see the changes(remember to refresh the page incase the changes are not showing).
Update a Post
Follow these steps to update an existing post:
- Navigate to the posts google sheet.
- Select the post you want to update.
- Make the necessary changes in the form.
- Head back to the WorldWide Wildcats page to see the changes(remember to refresh the page incase the changes are not showing).
Delete a Post
Follow these steps to delete a post:
- Navigate to the posts google sheet.
- Select the row of the post you want to delete.
- Left Click the "Delete Row" button.
- Head back to the WorldWide Wildcats page to see the changes(remember to refresh the page incase the changes are not showing).
Add a new sheet
Follow these steps to delete a post:
- Navigate to the posts google sheet.
- Select the "+" at the bottom right.
- Rename the new sheet to be "posts_{current Year}.
- Head to the WorldWide Wildcats Source Code and click the "Edit" tab.
- Find "const sheets" and add the name of the new sheet.
- Click save and publish.
- Head back to the WorldWide Wildcats page to see the changes(remember to refresh the page incase the changes are not showing).