diff --git a/dashboard_static/js/code.js b/dashboard_static/js/code.js new file mode 100644 index 0000000..6f5074e --- /dev/null +++ b/dashboard_static/js/code.js @@ -0,0 +1,107 @@ +let root = document.documentElement // Used for css variables + +let selectedSports = [] + +$(".sport").on("click", function() { + $(this).toggleClass("selected") + + let sportName = $(this).children()[1].innerHTML // 2nd element, which is the sport name + + + let index = selectedSports.indexOf(sportName) + if (index > -1 ) { // If element is found in array + selectedSports.splice(index, 1) // Remove sport at index + } else { + selectedSports.push(sportName) // Add sport to array + } + + $(this).trigger("selected", [selectedSports.includes(sportName), selectedSports]) // Trigger event +}) + +function getCSSVariable(name) { + return getComputedStyle(root).getPropertyValue(name) +} + +function tweetCell(tweet, parent) { + var cell = document.createElement("div"); + cell.innerHTML = + '
'+ + '' + + '
' + + '
'+ + ''+tweet.user.name+' '+ + '@'+tweet.user.screen_name+''+ + '
'+ + ''+tweet.text+''+ + '
'+ + '
'+ + 'favorite'+ + ''+tweet.favorite_count+''+ + '
'+ + '
'+ + 'repeat'+ + ''+tweet.retweet_count+''+ + '
'+ + '
'+ + 'chat_bubble'+ + ''+tweet.reply_count+''+ + '
'+ + '
'+ + '
'+ + '
'; + parent.append(cell); +} + + +var atweet = { + "created_at": "Sat Nov 16 12:51:41 +0000 2019", + "text": "@BobGreenburg @ONeill_Coffee Congrats to the excellent football program at Wilmington. One classy organization!", + "source": "Twitter for iPhone<\/a>", + "user": { + "name": "Express Youngstown", + "screen_name": "ExpressProsYO", + "url": "http:\/\/apply.expresspros.com\/", + "profile_image_url": "http:\/\/pbs.twimg.com\/profile_images\/775167844921188353\/fWquHsOK_normal.jpg", + }, + "quote_count": 0, + "reply_count": 0, + "retweet_count": 0, + "favorite_count": 0, + "entities": { + "hashtags": [ + + ], + "urls": [ + + ], + "user_mentions": [ + { + "screen_name": "BobGreenburg", + "name": "Bob Greenburg", + "id": 483881032, + "id_str": "483881032", + "indices": [ + 0, + 13 + ] + }, + { + "screen_name": "ONeill_Coffee", + "name": "O'NeillCoffeeCompany", + "id": 2804543925, + "id_str": "2804543925", + "indices": [ + 14, + 28 + ] + } + ], + "symbols": [ + + ] + }, +} + +for (let i = 0; i < 2; i++) { + tweetCell(atweet, $(".leftcol")); +} \ No newline at end of file