├── README.md ├── tweecool.js └── tweecool.min.js /README.md: -------------------------------------------------------------------------------- 1 | # TweeCool Jquery Plugin 2 | 3 | [TweeCool](http://www.tweecool.com/) is free, fast,simple and reliable 4 | 5 | ## Step 1 6 | 7 | Copy and paste the following script between <head> and </head> 8 | 9 | ``` 10 | 11 | 12 | 21 | ``` 22 | 23 | ## Step 2 24 | 25 | Copy and paste the following script between <body> and </body> 26 | 27 | ``` 28 |
29 | ``` 30 | 31 | ## Settings 32 | 33 | username : Your username 34 | limit : Number of tweets to show (Default value: 5) 35 | profile_image : Show profile image (Default value: true) 36 | show_time : Show tweet time (Default value: true) 37 | show_media : Show media (Default value: false) 38 | show_media_size : Set media size (Default value: thumb) 39 | show_actions : Show action box such as 'reply', 'retweet' and 'favorite' (Default value: false) 40 | action_reply_icon : Reply icon, add your HTML tags or ASCII code (Default value: '↵') 41 | action_retweet_icon : Retweet icon, add your HTML tags or ASCII code (Default value: ∝) 42 | action_favorite_icon : Favorite icon, add your HTML tags or ASCII code (Default value: '❤') 43 | profile_img_url : If set to 'tweet' the profile image will have tweet URL, otherwise it will be the user's profile URL (Default value: profile) 44 | show_retweeted_text : if set to 'true', this will show the original retweeted text and avoid any truncated text (Default value: false) 45 | -------------------------------------------------------------------------------- /tweecool.js: -------------------------------------------------------------------------------- 1 | /*Name : TweeCool 2 | *version: 1.9 3 | *Description: Get the latest tweets from twitter. 4 | *Website: www.tweecool.com 5 | *Licence: No licence, feel free to do whatever you want. 6 | *Author: TweeCool 7 | */ 8 | (function($) { 9 | $.fn.extend({ 10 | 11 | tweecool : function(options) { 12 | 13 | var defaults = { 14 | username : 'tweecool', 15 | limit : 5, 16 | profile_image : true, 17 | show_time : true, 18 | show_media : false, 19 | show_media_size: 'thumb', //values: small, large, thumb, medium 20 | show_actions: false, 21 | action_reply_icon: '↵', 22 | action_retweet_icon: '∝', 23 | action_favorite_icon: '❤', 24 | profile_img_url: 'profile', //Values: profile, tweet 25 | show_retweeted_text: false //This will show the original tweet in order to avoid any truncated text, and also the "RT @tweecool:" is removed which helps with 140 character limit 26 | 27 | } 28 | 29 | var options = $.extend(defaults, options); 30 | 31 | function xTimeAgo(time) { 32 | var nd = new Date(); 33 | //var gmtDate = Date.UTC(nd.getFullYear(), nd.getMonth(), nd.getDate(), nd.getHours(), nd.getMinutes(), nd.getMilliseconds()); 34 | var gmtDate = Date.parse(nd); 35 | var tweetedTime = time * 1000; //convert seconds to milliseconds 36 | var timeDiff = (gmtDate - tweetedTime) / 1000; //convert milliseconds to seconds 37 | 38 | var second = 1, minute = 60, hour = 60 * 60, day = 60 * 60 * 24, week = 60 * 60 * 24 * 7, month = 60 * 60 * 24 * 30, year = 60 * 60 * 24 * 365; 39 | 40 | if (timeDiff > second && timeDiff < minute) { 41 | return Math.round(timeDiff / second) + " second"+(Math.round(timeDiff / second) > 1?'s':'')+" ago"; 42 | } else if (timeDiff >= minute && timeDiff < hour) { 43 | return Math.round(timeDiff / minute) + " minute"+(Math.round(timeDiff / minute) > 1?'s':'')+" ago"; 44 | } else if (timeDiff >= hour && timeDiff < day) { 45 | return Math.round(timeDiff / hour) + " hour"+(Math.round(timeDiff / hour) > 1?'s':'' )+" ago"; 46 | } else if (timeDiff >= day && timeDiff < week) { 47 | return Math.round(timeDiff / day) + " day"+(Math.round(timeDiff / day) > 1 ?'s':'')+" ago"; 48 | } else if (timeDiff >= week && timeDiff < month) { 49 | return Math.round(timeDiff / week) + " week"+(Math.round(timeDiff / week) > 1?'s':'')+" ago"; 50 | } else if (timeDiff >= month && timeDiff < year) { 51 | return Math.round(timeDiff / month) + " month"+(Math.round(timeDiff / month) > 1 ?'s':'')+" ago"; 52 | } else { 53 | return 'over a year ago'; 54 | } 55 | } 56 | 57 | return this.each(function() { 58 | var o = options; 59 | var wrapper = $(this); 60 | var wInner = $('