diff --git a/__pycache__/dashboard.cpython-310.pyc b/__pycache__/dashboard.cpython-310.pyc index ef5ec2f..4ea8c45 100644 Binary files a/__pycache__/dashboard.cpython-310.pyc and b/__pycache__/dashboard.cpython-310.pyc differ diff --git a/dashboard_static/js/code.js b/dashboard_static/js/code.js index 680796a..53e2b0c 100644 --- a/dashboard_static/js/code.js +++ b/dashboard_static/js/code.js @@ -32,6 +32,8 @@ function tweetCell(tweet) {
${tweet.user.name} @${tweet.user.screen_name} + +

${tweet.created_at}

${tweet.text}
@@ -54,7 +56,6 @@ function tweetCell(tweet) { } function filterTweets(tweets, bannedWords=[], searchWords=[], sorted, order) { - console.log(searchWords) if(bannedWords.length > 0){ tweets = filterBannedWords(bannedWords, tweets) } diff --git a/dashboard_static/js/events.js b/dashboard_static/js/events.js index 9000e11..7ed73fd 100644 --- a/dashboard_static/js/events.js +++ b/dashboard_static/js/events.js @@ -8,6 +8,10 @@ $(".sport").on("selected", function(e, selected, sports) { window.addEventListener('DOMContentLoaded', (event) => { window.sessionStorage.setItem('tweets', JSON.stringify([])); + // run code every 5 seconds + setInterval(function() { + $(window).trigger("filter"); + }, 1000); }); $(".sport").on("click", function() { @@ -66,19 +70,26 @@ $(".logo").on("click", function() { }) $(window).on("filter", function() { + console.log("called") var parent = document.querySelector("#filtered") parent.replaceChildren(); - console.debug(filters); + console.log(filters); tweets = window.sessionStorage.getItem('tweets'); tweets = JSON.parse(tweets); + console.log(tweets.length) tweets = filterTweets(tweets, filters.blockedWords, filters.searchedWords.concat(filters.sports), filters.sorted, filters.order); tweets = sortTweets(tweets); - for (i = 0; i < Math.min(tweets.length, 20); i++){ - parent.append(tweetCell(tweets[i])); + var displayTweets = tweets.reverse().slice(0, 20).reverse(); + for (i = 0; i < 19; i++){ + console.log("FDS") + parent.prepend(tweetCell(displayTweets[i])); + console.log("FDS 2") } }) + + $(".order-btn").on("click", function() { if($(this).html() == "arrow_downward") { // Descending to ascending $(this).html("arrow_upward") diff --git a/dashboard_static/lib/tweets.js b/dashboard_static/lib/tweets.js index 2e99678..da10619 100644 --- a/dashboard_static/lib/tweets.js +++ b/dashboard_static/lib/tweets.js @@ -74,10 +74,10 @@ block.fn.tweets = function(config) { // store list for later // var $list = $("div.tweetcontainer"); var $list = document.querySelector("#latest") + window.sessionStorage.setItem('tweets', JSON.stringify([])); // register default handler for handling tweet data this.actions(function(e, tweet){ - $(window).trigger("filter"); tweets = window.sessionStorage.getItem('tweets'); tweets = JSON.parse(tweets); tweets.push(tweet);