diff --git a/dashboard_static/js/connection.js b/dashboard_static/js/connection.js index a9f1f0f..8d26743 100644 --- a/dashboard_static/js/connection.js +++ b/dashboard_static/js/connection.js @@ -2,4 +2,7 @@ // Sports = all selected sports, ARRAY $(".sport").on("selected", function(e, selected, sports) { console.log(selected, sports); -}) \ No newline at end of file +}) +window.addEventListener('DOMContentLoaded', (event) => { + window.sessionStorage.setItem('tweets', JSON.stringify([])); +}); \ No newline at end of file diff --git a/dashboard_static/lib/tweets.js b/dashboard_static/lib/tweets.js index caae015..6cc4642 100644 --- a/dashboard_static/lib/tweets.js +++ b/dashboard_static/lib/tweets.js @@ -80,6 +80,14 @@ block.fn.tweets = function(config) { // register default handler for handling tweet data this.actions(function(e, tweet){ + tweets = window.sessionStorage.getItem('tweets'); + tweets = JSON.parse(tweets); + tweets.push(tweet); + if(tweets.length >= options.memory) { + tweets.shift(); + } + window.sessionStorage.setItem('tweets', JSON.stringify(tweets)); + var $item = $('
  • '); var $tweet = $('
    ');