diff --git a/__pycache__/dashboard.cpython-310.pyc b/__pycache__/dashboard.cpython-310.pyc new file mode 100644 index 0000000..fa27820 Binary files /dev/null and b/__pycache__/dashboard.cpython-310.pyc differ diff --git a/dashboard.py b/dashboard.py index 5d7e0d0..7b8637f 100644 --- a/dashboard.py +++ b/dashboard.py @@ -12,7 +12,7 @@ root_content_path = 'dashboard_static' # the action will be called with the context and the event @event('init') def setup(ctx, e): - start_offline_tweets('sports1.txt', event_name="sample") + start_offline_tweets('sports1.txt', event_name="tweet", time_factor=0.1) ctx.count = 0 # fire('sample', {'previous': 0.0}) @@ -21,21 +21,14 @@ def setup(ctx, e): def clip(lower, value, upper): return max(lower, min(value, upper)) -@event('sample') -def generate_sample(ctx, e): - ctx.count += 1 - if ctx.count % 50 == 0: - emit('debug', {'text': 'Log message #'+str(ctx.count)+'!'}) +@event('tweet') +def generate_tweet(ctx, e): tweet = e.data - # print(tweet) # base sample on previous one # sample = clip(-100, e.data['previous'] + random.uniform(+5.0, -5.0), 100) # emit to outside world - emit('sample',{ - 'action': 'add', - 'value': tweet - }) + emit('tweet', tweet) - # chain event - fire('sample', {'previous': tweet}, delay=0.05) + # # chain event + # fire('tweet', {'previous': tweet}, delay=0.05) diff --git a/dashboard_static/index.html b/dashboard_static/index.html index 1269f40..68148e7 100644 --- a/dashboard_static/index.html +++ b/dashboard_static/index.html @@ -6,6 +6,7 @@ Twitter sports dashboard + @@ -15,6 +16,7 @@ +
+ + + + + + + - \ No newline at end of file diff --git a/dashboard_static/js/code.js b/dashboard_static/js/code.js index d71171d..6acacf9 100644 --- a/dashboard_static/js/code.js +++ b/dashboard_static/js/code.js @@ -16,14 +16,140 @@ $(".sport").on("click", function() { } $(this).trigger("selected", [selectedSports.includes(sportName), selectedSports]) // Trigger event + showFeeds() }) function getCSSVariable(name) { return getComputedStyle(root).getPropertyValue(name) } -function tweetCell(tweet, parent) { - var cell = document.createElement("div") +function showFeeds() { + if ($(window).width() < 1280) { + if (selectedSports.length === 0) { + $(".leftcol").show() + $(".centercol").hide() + } else { + $(".leftcol").hide() + $(".centercol").show() + } + } else { + $(".leftcol").show() + $(".centercol").show() + } +} + +$(window).on("resize", function(){ + showFeeds() +}); + +$(window).on("load", function() { + showFeeds() +}) + +function tweetCell(tweet) { + var cell = document.createElement("div"); cell.innerHTML = - "
" -} \ No newline at end of file + `
+ +
+
+ ${tweet.user.name} + @${tweet.user.screen_name} +
+ ${tweet.text} +
+
+ favorite + ${tweet.favorite_count} +
+
+ repeat + ${tweet.retweet_count} +
+
+ chat_bubble + ${tweet.reply_count} +
+
+
+
` + return cell +} + +function filter(tweets, bannedWords=[], searchWords=[], likesTop=null, likesBottom=null, retweetsTop=null, retweetsBottom=null, repliesTop=null, repliesBottom=null) { + if(bannedWords.length > 0){ + tweets = filterBannedWords(bannedWords, tweets) + } + if(searchWords.length > 0){ + tweets = searchForWords(searchWords, tweets) + } + if(likesTop != null || likesBottom != null){ + tweets = filterLikes(likesTop, likesBottom, tweets) + } + if(retweetsTop != null || retweetsBottom != null){ + tweets = filterRetweets(retweetsTop, retweetsBottom, tweets) + } + if(repliesTop != null || repliesBottom != null){ + tweets = filterReplies(repliesTop, repliesBottom, tweets) + } + return tweets +} + +function filterBannedWords(bannedWords, tweets){ + for (let i = 0; i < tweets.length; i++) { + var tweet = tweets[i] + for(let j=0; j < bannedWords.length; j++){ + if (tweet.text.toLowerCase().includes(bannedWords[j].toLowerCase())){ + tweets.splice(i, 1) + break + } + } + } + return tweets +} + +function searchForWords(searchWords, tweets){ + for (let i = 0; i < tweets.length; i++) { + var tweet = tweets[i] + for(let i=0; i < searchWords.length; i++){ + if (!tweet.text.toLowerCase().includes(searchWords[i].toLowerCase())) { + tweets.splice(i, 1) + break + } + } + } + return tweets +} + +function filterLikes(likesTop, likesBottom, tweets){ + for (let i = 0; i < tweets.length; i++) { + var tweet = tweets[i] + if(tweet.favorite_count >= likesTop || tweet.favorite_count <= likesBottom){ + tweets.splice(i, 1) + break + } + } + return tweets +} + +function filterRetweets(retweetsTop, retweetsBottom, tweets){ + for (let i = 0; i < tweets.length; i++) { + var tweet = tweets[i] + if(tweet.retweet_count >= retweetsTop || tweet.retweet_count <= retweetsBottom){ + tweets.splice(i, 1) + break + } + } + return tweets +} + +function filterReplies(repliesTop, repliesBottom, tweets){ + for (let i = 0; i < tweets.length; i++) { + var tweet = tweets[i] + if(tweet.reply_count >= repliesTop || tweet.reply_count <= repliesBottom){ + tweets.splice(i, 1) + break + } + } + return tweets +} 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..6d71a94 100644 --- a/dashboard_static/lib/tweets.js +++ b/dashboard_static/lib/tweets.js @@ -68,53 +68,24 @@ var process_entities = function(message, entities) { block.fn.tweets = function(config) { var options = $.extend({ - memory: 20 + memory: 100 }, config); - // create the necessary HTML in the block container - this.$element.append('
    '); - // store list for later - var $list = this.$element.find('ol'); - + var $list = $("div.tweetcontainer"); // register default handler for handling tweet data this.actions(function(e, tweet){ - var $item = $('
  1. '); + tweets = window.sessionStorage.getItem('tweets'); + tweets = JSON.parse(tweets); + tweets.push(tweet); + var localMemory = 100; + if(tweets.length >= localMemory) { + tweets.shift(); + } + window.sessionStorage.setItem('tweets', JSON.stringify(tweets)); - var $tweet = $('
    '); - var $content = $('
    '); - var $header = $('
    '); - - // Build a tag image and header: - var $account = $(''); - $account.attr("href", "http://twitter.com/" + tweet.user.screen_name); - - var $avatar = $("").addClass("avatar"); - $avatar.attr("src", tweet.user.profile_image_url); - $account.append($avatar); - $account.append($('' + tweet.user.name + '')); - $account.append($(' ')); - $account.append($('@' + tweet.user.screen_name + '')); - $header.append($account); - - // Build timestamp: - var $time = $(''); - $time.append($('' + tweet.created_at + '')); - - $header.append($time); - $content.append($header); - - // Build contents: - var text = process_entities(tweet.text, tweet.entities); - var $text = $('

    ' + text + '

    '); - $content.append($text); - - // Build outer structure of containing divs: - $tweet.append($content); - $item.append($tweet); - - // place new tweet in front of list + var $item = tweetCell(tweet) $list.prepend($item); // remove stale tweets diff --git a/dashboard_static/style/responsive.css b/dashboard_static/style/responsive.css new file mode 100644 index 0000000..379fbba --- /dev/null +++ b/dashboard_static/style/responsive.css @@ -0,0 +1,33 @@ +@media only screen and (max-width: 1280px) { + .maintable { + grid-template-columns: 1fr 1fr; + grid-gap: 32px; + } +} + + +@media only screen and (max-width: 850px) { + .maintable { + grid-template-columns: 1fr; + } + .header-title { + display: none; + } + .sport-name { + font-size: 20px; + } + .column { + grid-row: unset; + } + .colheader { + font-size: 32px; + } + +} + + + + + + /* 360x640 414x896 + 601x962 1280x800 */ \ No newline at end of file diff --git a/dashboard_static/style/style.css b/dashboard_static/style/style.css index 1789f5f..258ca21 100644 --- a/dashboard_static/style/style.css +++ b/dashboard_static/style/style.css @@ -24,6 +24,8 @@ body { background-color: var(--main-bg); color: white; padding: 16px 48px; + display: flex; + flex-direction: column; } .header, .sports, .logo { @@ -45,11 +47,11 @@ body { } .logo img { - height: 40px; + height: 36px; } .logo span { - font-size: 40px; + font-size: 36px; font-weight: 500; margin: 0 8px; } @@ -88,19 +90,43 @@ body { .tweet { display: flex; + background-color: var(--main-dark); + border-radius: 16px; + padding: 16px; } .tweet-profilepicture { border-radius: 100%; + width: 60px; + height: 60px; + /* padding: 8px; */ +} + +.tweet-content { + padding-left: 16px; } .tweet-interactions { display: flex; + margin-top: 8px; } .tweet-interaction { display: flex; align-items: center; + margin-right: 24px; +} + +.tweet-interaction .material-symbols-outlined { + margin-right: 4px; +} + +.tweet-nickname { + font-weight: bold; +} + +.tweet-username { + opacity: 0.8; } .filters-search input { @@ -123,44 +149,74 @@ body { /* Three main columns; CSS Grid */ .maintable { /*background-color: #ffffff; */ /* The colors are there just so that I can see what I'm doing better */ - display: grid; width: 100%; + height: 100%; + display: grid; grid-template-columns: 1fr 1fr 1fr; - grid-template-rows: 1fr 1fr; - - gap: 48px; + grid-template-rows: 1fr; + grid-gap: 48px; /* margin:20px; */ } .main { - margin-top: 48px; + margin-top: 32px; + height: 100%; } .column { border-radius: 16px; } +.leftcol, .centercol { + overflow-y: auto; + grid-row: 1/ -1; +} + .leftcol { background-color: red; - grid-row: 1/ -1; } .centercol { background-color: green; - grid-row: 1/ -1; } -.searchbar { +.rightcol { + display: flex; + flex-direction: column; +} + +.searchcontainer { background-color: blue; - height: 400px; + /* height: 400px; */ } .popchart { background-color: rgba(255, 0, 255, 0.344); - height: 400px; + /* height: 400px; */ } .colheader { + display: block; + font-weight: 500; + font-size: 40px; + padding: 8px 16px; font-size: 38px; padding-left: 30px; } + +.searchbar, .button { + font-weight: bold; + font-size: 32px; + border-radius: 50px; + padding: 10px; + margin: 16px; +} + +.button { + border-radius: 50px; + border: none; +} + +/* .button:hover { + background-color: ; +} */ \ No newline at end of file diff --git a/eca/__pycache__/arff.cpython-310.pyc b/eca/__pycache__/arff.cpython-310.pyc new file mode 100644 index 0000000..dab7427 Binary files /dev/null and b/eca/__pycache__/arff.cpython-310.pyc differ diff --git a/eca/__pycache__/generators.cpython-310.pyc b/eca/__pycache__/generators.cpython-310.pyc new file mode 100644 index 0000000..01498c6 Binary files /dev/null and b/eca/__pycache__/generators.cpython-310.pyc differ