Commented + Tidying Up
This commit is contained in:
@@ -9,6 +9,8 @@ let filters = {
|
||||
sports: []
|
||||
}
|
||||
|
||||
// smartly removes one of the feeds when the window is too narrow for both feeds to be shown properly
|
||||
// it will swap between the "recent" and "filtered" feeds depending on if a filter is active
|
||||
function showFeeds() {
|
||||
if ($(window).width() < 1280) {
|
||||
if(filters.sports.length === 0 && filters.blockedWords.length === 0 && filters.searchedWords.length === 0 && (filters.sorted == "time" && filters.order == "desc")) {
|
||||
@@ -24,6 +26,7 @@ function showFeeds() {
|
||||
}
|
||||
}
|
||||
|
||||
// outputs HTML of a tweet based on the tweet that gets given as input
|
||||
function tweetCell(tweet) {
|
||||
const date = new Date(tweet.created_at);
|
||||
let minutes = date.getMinutes();
|
||||
@@ -65,6 +68,7 @@ function tweetCell(tweet) {
|
||||
return cell
|
||||
}
|
||||
|
||||
// applies all filters to a list of tweets
|
||||
function filterTweets(tweets, bannedWords=[], searchWords=[], sorted, order) {
|
||||
if(bannedWords.length == 1 && bannedWords[0] == ""){
|
||||
bannedWords = []
|
||||
@@ -83,6 +87,7 @@ function filterTweets(tweets, bannedWords=[], searchWords=[], sorted, order) {
|
||||
return tweets
|
||||
}
|
||||
|
||||
// iterates through each tweet in the list and removes any tweets that contain any of the given words in their text
|
||||
function filterBannedWords(bannedWords, tweets){
|
||||
for (let i = 0; i < tweets.length; i++) {
|
||||
var tweet = tweets[i]
|
||||
@@ -96,6 +101,7 @@ function filterBannedWords(bannedWords, tweets){
|
||||
return tweets
|
||||
}
|
||||
|
||||
// iterates through each tweet in the list and removes any tweets that do not contain any of the given words in their text
|
||||
function searchForWords(searchWords, tweets){
|
||||
var filteredTweets = []
|
||||
for (let i = 0; i < tweets.length; i++) {
|
||||
@@ -112,6 +118,7 @@ function searchForWords(searchWords, tweets){
|
||||
return filteredTweets.reverse()
|
||||
}
|
||||
|
||||
// sorts through a list of tweets based on an array with options (sort)
|
||||
function sortTweets(tweets, sort){
|
||||
if(typeof sort.sortby == 'undefined'){
|
||||
return tweets
|
||||
|
||||
Reference in New Issue
Block a user