From 91e0cabf028a16980d1050dbcd95537a31d0414b Mon Sep 17 00:00:00 2001 From: Pedro Rogerio Date: Wed, 6 Aug 2014 10:21:05 -0300 Subject: [PATCH] Minor code improvements --- hashtags/src/tweetlight.js | 17 ++++++++--------- hashtags/src/tweetlight.min.js | 4 ++-- user/src/tweetlight.js | 8 ++++---- user/src/tweetlight.min.js | 6 +++--- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/hashtags/src/tweetlight.js b/hashtags/src/tweetlight.js index ebac883..2012ce6 100644 --- a/hashtags/src/tweetlight.js +++ b/hashtags/src/tweetlight.js @@ -2,8 +2,8 @@ * Tweetlight * Display all tweets with a certain hashtag with pure JavaScript and PHP OAuth Library * Example and documentation at: https://github.com/pinceladasdaweb/tweetlight -* Copyright (c) 2013 -* Version: 3.0.0 (17-DEZ-2013) +* Copyright (c) 2014 +* Version: 3.0.1 (Latest build: Aug 06 2014) * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php * Requires: Twitter API Authentication ---------------*/ @@ -16,8 +16,8 @@ var Browser = (function () { var Tweetlight = { init: function (config) { - this.url = './tweets.php?q=' + encodeURIComponent(config.query) + '&count=' + config.count; - this.container = config.container; + this.url = './tweets.php?q=' + encodeURIComponent(config.query) + '&count=' + config.count; + this.container = config.container; this.onComplete = config.onComplete || function () {}; this.fetch(); }, @@ -51,11 +51,10 @@ var Tweetlight = { var self = this; self.getJSON({url: self.url}, function (data) { - var tweets = JSON.parse(data), - tweet = tweets.statuses; - - var timeline = document.querySelector(self.container), - content = ''; + var tweets = JSON.parse(data), + tweet = tweets.statuses, + timeline = document.querySelector(self.container), + content = ''; self.loop(tweet, function (res) { content += '
  • '+res.user.screen_name+': '+self.twitterLinks(res.text)+''+self.prettyDate(res.created_at)+'
  • '; diff --git a/hashtags/src/tweetlight.min.js b/hashtags/src/tweetlight.min.js index bb85757..2fe74ce 100644 --- a/hashtags/src/tweetlight.min.js +++ b/hashtags/src/tweetlight.min.js @@ -2,8 +2,8 @@ * Tweetlight * Display all tweets with a certain hashtag with pure JavaScript and PHP OAuth Library * Example and documentation at: https://github.com/pinceladasdaweb/tweetlight -* Copyright (c) 2013 -* Version: 3.0.0 (17-DEZ-2013) +* Copyright (c) 2014 +* Version: 3.0.1 (Latest build: Aug 06 2014) * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php * Requires: Twitter API Authentication ---------------*/ diff --git a/user/src/tweetlight.js b/user/src/tweetlight.js index 88a09f6..15d516c 100644 --- a/user/src/tweetlight.js +++ b/user/src/tweetlight.js @@ -2,8 +2,8 @@ * Tweetlight * Display your latest tweets with pure JavaScript and PHP OAuth Library * Example and documentation at: https://github.com/pinceladasdaweb/tweetlight -* Copyright (c) 2013 -* Version: 3.0.0 (17-DEZ-2013) +* Copyright (c) 2014 +* Version: 3.0.1 (Latest build: Aug 06 2014) * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php * Requires: Twitter API Authentication ---------------*/ @@ -16,8 +16,8 @@ var Browser = (function () { var Tweetlight = { init: function (config) { - this.url = './tweets.php?username=' + config.username + '&count=' + config.count; - this.container = config.container; + this.url = './tweets.php?username=' + config.username + '&count=' + config.count; + this.container = config.container; this.onComplete = config.onComplete || function () {}; this.fetch(); }, diff --git a/user/src/tweetlight.min.js b/user/src/tweetlight.min.js index 0cdd6a1..309bf3f 100644 --- a/user/src/tweetlight.min.js +++ b/user/src/tweetlight.min.js @@ -2,9 +2,9 @@ * Tweetlight * Display your latest tweets with pure JavaScript and PHP OAuth Library * Example and documentation at: https://github.com/pinceladasdaweb/tweetlight -* Copyright (c) 2013 -* Version: 3.0.0 (17-DEZ-2013) +* Copyright (c) 2014 +* Version: 3.0.1 (Latest build: Aug 06 2014) * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php * Requires: Twitter API Authentication ---------------*/ -var Browser=function(){var a=navigator.userAgent;return{ie:a.match(/MSIE\s([^;]*)/)}}(),Tweetlight={init:function(a){this.url="./tweets.php?username="+a.username+"&count="+a.count,this.container=a.container,this.onComplete=a.onComplete||function(){},this.fetch()},xhr:function(){return new XMLHttpRequest},getJSON:function(a,b){var c=this,d=c.xhr();a.url=a.url||location.href,a.data=a.data||null,b=b||function(){},d.open("GET",a.url,!0),d.onreadystatechange=function(){200===d.status&&4===d.readyState&&b(d.responseText)},d.send(a.data)},loop:function(a,b){for(var c=0,d=a.length;d>c;)b(a[c],c),c+=1},fetch:function(){var a=this;a.getJSON({url:a.url},function(b){var c=JSON.parse(b),d=document.querySelector(a.container),e="";return c[0].created?(a.loop(c,function(b){e+='
  • '+a.twitterLinks(b.text)+''+a.prettyDate(b.created)+"
  • "}),d.innerHTML=e,a.onComplete(),void 0):(d.innerHTML='
  • Houston, we have a problem...
  • ',void 0)})},prettyDate:function(a){var b=new Date,c=new Date(a);Browser.ie&&(c=Date.parse(a.replace(/( \+)/," UTC$1")));var d=b-c,e=1e3,f=60*e,g=60*f,h=24*g;return isNaN(d)||0>d?"":7*e>d?"just now":f>d?Math.floor(d/e)+" seconds ago":2*f>d?"1 minute ago":g>d?Math.floor(d/f)+" minutes ago":2*g>d?"1 hour ago":h>d?Math.floor(d/g)+" hours ago":d>h&&2*h>d?"yesterday":365*h>d?Math.floor(d/h)+" days ago":"over a year ago"},twitterLinks:function(a){return a=a.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi,'$2').replace(/(^|\W)@(\w+)/g,'$1@$2').replace(/(^|\W)#(\w+)/g,'$1#$2')}}; \ No newline at end of file +var Browser=function(){var a=navigator.userAgent;return{ie:a.match(/MSIE\s([^;]*)/)}}(),Tweetlight={init:function(a){this.url="./tweets.php?username="+a.username+"&count="+a.count,this.container=a.container,this.onComplete=a.onComplete||function(){},this.fetch()},xhr:function(){return new XMLHttpRequest},getJSON:function(a,b){var c=this,d=c.xhr();a.url=a.url||location.href,a.data=a.data||null,b=b||function(){},d.open("GET",a.url,!0),d.onreadystatechange=function(){200===d.status&&4===d.readyState&&b(d.responseText)},d.send(a.data)},loop:function(a,b){for(var c=0,d=a.length;d>c;)b(a[c],c),c+=1},fetch:function(){var a=this;a.getJSON({url:a.url},function(b){var c=JSON.parse(b),d=document.querySelector(a.container),e="";return c[0].created?(a.loop(c,function(b){e+='
  • '+a.twitterLinks(b.text)+''+a.prettyDate(b.created)+"
  • "}),d.innerHTML=e,void a.onComplete()):void(d.innerHTML='
  • Houston, we have a problem...
  • ')})},prettyDate:function(a){var b=new Date,c=new Date(a);Browser.ie&&(c=Date.parse(a.replace(/( \+)/," UTC$1")));var d=b-c,e=1e3,f=60*e,g=60*f,h=24*g;return isNaN(d)||0>d?"":7*e>d?"just now":f>d?Math.floor(d/e)+" seconds ago":2*f>d?"1 minute ago":g>d?Math.floor(d/f)+" minutes ago":2*g>d?"1 hour ago":h>d?Math.floor(d/g)+" hours ago":d>h&&2*h>d?"yesterday":365*h>d?Math.floor(d/h)+" days ago":"over a year ago"},twitterLinks:function(a){return a=a.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi,'$2').replace(/(^|\W)@(\w+)/g,'$1@$2').replace(/(^|\W)#(\w+)/g,'$1#$2')}}; \ No newline at end of file