Twitter Live Feed working
This commit is contained in:
		| @@ -22,9 +22,10 @@ function getCSSVariable(name) { | ||||
|     return getComputedStyle(root).getPropertyValue(name) | ||||
| } | ||||
|  | ||||
| function tweetCell(tweet, parent) { | ||||
| function tweetCell(tweet) { | ||||
|     var cell = document.createElement("div"); | ||||
|     cell.innerHTML = | ||||
| <<<<<<< Updated upstream | ||||
|         '<div class="tweet">'+ | ||||
|             '<img src="' + tweet.user.profile_image_url + '" alt="" class="tweet-profilepicture">' + | ||||
|             '<div class="tweet-content">' + | ||||
| @@ -50,6 +51,33 @@ function tweetCell(tweet, parent) { | ||||
|             '</div>'+ | ||||
|         '</div>'; | ||||
|     parent.append(cell); | ||||
| ======= | ||||
|     `<div class="tweet"> | ||||
|         <img src="${tweet.user.profile_image_url}" alt="" class="tweet-profilepicture"> | ||||
|         <div class="tweet-content">  | ||||
|             <div class="tweet-name"> | ||||
|                 <span class="tweet-nickname">${tweet.user.name}</span> | ||||
|                 <span class="tweet-username">@${tweet.user.screen_name}</span> | ||||
|             </div> | ||||
|             <span class="tweet-text">${tweet.text}</span> | ||||
|             <div class="tweet-interactions"> | ||||
|                 <div class="tweet-interaction tweet-likes"> | ||||
|                     <span class="material-symbols-outlined">favorite</span> | ||||
|                     <span>${tweet.favorite_count}</span> | ||||
|                 </div> | ||||
|                 <div class="tweet-interaction tweet-retweets"> | ||||
|                     <span class="material-symbols-outlined">repeat</span> | ||||
|                     <span>${tweet.retweet_count}</span> | ||||
|                 </div> | ||||
|                 <div class="tweet-interaction tweet-replies"> | ||||
|                     <span class="material-symbols-outlined">chat_bubble</span> | ||||
|                     <span>${tweet.reply_count}</span> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div>` | ||||
|     return cell | ||||
| >>>>>>> Stashed changes | ||||
| } | ||||
|  | ||||
| $(document).on('tweet', console.log(tweet)); | ||||
|   | ||||
| @@ -68,18 +68,21 @@ var process_entities = function(message, entities) { | ||||
|  | ||||
| block.fn.tweets = function(config) { | ||||
|     var options = $.extend({ | ||||
|         memory: 20 | ||||
|         memory: 100 | ||||
|     }, config); | ||||
|  | ||||
| <<<<<<< Updated upstream:template_static/lib/tweets.js | ||||
|     // create the necessary HTML in the block container | ||||
|     //this.$element.append('<ol class="tweet-list stream-items"></ol>'); | ||||
|  | ||||
| ======= | ||||
| >>>>>>> Stashed changes:dashboard_static/lib/tweets.js | ||||
|     // 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){ | ||||
| <<<<<<< Updated upstream:template_static/lib/tweets.js | ||||
|         var $item = $('<li class="stream-item"></li>'); | ||||
|  | ||||
|         var $tweet = $('<div class="tweet"></div>'); | ||||
| @@ -115,6 +118,17 @@ block.fn.tweets = function(config) { | ||||
|         $item.append($tweet); | ||||
|          | ||||
|         // place new tweet in front of list  | ||||
| ======= | ||||
|         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 = tweetCell(tweet) | ||||
| >>>>>>> Stashed changes:dashboard_static/lib/tweets.js | ||||
|         $list.prepend($item); | ||||
|  | ||||
|         // remove stale tweets | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jacktjong
					jacktjong