Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support for geocoding

  • Loading branch information...
commit cbf181e899825ffc0df5cba75e6067797b658349 1 parent 5958462
@elektronaut authored
View
8 README.rdoc
@@ -36,9 +36,17 @@ Stopping, starting and refreshing manually::
$("#twitterSearch").each(function(){ this.twitter.start(); });
$("#twitterSearch").each(function(){ this.twitter.refresh(); });
+Restricting results by geocode is possible:
+
+ $("#twitterSearch").liveTwitter('bacon', {geocode: '59.919151,10.749950,50km'});
+
== Changelog
+=== 1.3.3
+
+* Now supports geocoding
+
=== 1.3.2
* Profile image and username is toggleable, can also be shown on user_timeline.
View
10 jquery.livetwitter.js
@@ -1,11 +1,11 @@
/*
- * jQuery LiveTwitter 1.3.2
+ * jQuery LiveTwitter 1.3.3
* - Live updating Twitter plugin for jQuery
*
* Copyright (c) 2009 Inge Jørgensen (elektronaut.no)
* Licensed under the MIT license (MIT-LICENSE.txt)
*
- * $Date: 2009/09/16 $
+ * $Date: 2009/11/20$
*/
/*
@@ -89,7 +89,11 @@
var encodedQuery = encodeURIComponent(this.query);
var url = '';
if(twitter.mode == 'search'){
- url = "http://search.twitter.com/search.json?q="+encodedQuery+"&callback=?";
+ if(this.settings.geocode){
+ url = "http://search.twitter.com/search.json?q="+encodedQuery+"&geocode="+encodeURIComponent(this.settings.geocode)+"&callback=?";
+ } else {
+ url = "http://search.twitter.com/search.json?q="+encodedQuery+"&callback=?";
+ }
} else if(twitter.mode == 'user_timeline') {
url = "http://twitter.com/statuses/user_timeline/"+encodedQuery+".json?count="+twitter.limit+"&callback=?";
}
View
2  jquery.livetwitter.min.js
@@ -1 +1 @@
-(function(a){if(!a.fn.reverse){a.fn.reverse=function(){return this.pushStack(this.get().reverse(),arguments)}}a.fn.liveTwitter=function(c,b){a(this).each(function(){var d={};if(this.twitter){d=jQuery.extend(this.twitter.settings,b);this.twitter.settings=d;if(c){this.twitter.query=c}this.twitter.limit=d.limit;this.twitter.mode=d.mode;if(this.twitter.interval){this.twitter.refresh()}}else{d=jQuery.extend({mode:"search",rate:15000,limit:10,refresh:true},b);if(typeof d.showAuthor=="undefined"){if(d.mode=="search"){d.showAuthor=true}else{d.showAuthor=false}}window.twitter_callback=function(){return true};this.twitter={settings:d,query:c,limit:d.limit,mode:d.mode,interval:false,container:this,lastTimeStamp:0,relativeTime:function(g){var f=Date.parse(g);var i=(Date.parse(Date())-f)/1000;var h="";if(i<60){h=i+" seconds ago"}else{if(i<120){h="a minute ago"}else{if(i<(45*60)){h=(parseInt(i/60,10)).toString()+" minutes ago"}else{if(i<(90*60)){h="an hour ago"}else{if(i<(24*60*60)){h=""+(parseInt(i/3600,10)).toString()+" hours ago"}else{if(i<(48*60*60)){h="a day ago"}else{h=(parseInt(i/86400,10)).toString()+" days ago"}}}}}}return h},refreshTime:function(){var f=this;a(f.container).find("span.time").each(function(){a(this).html(f.relativeTime(this.timeStamp))})},refresh:function(f){var i=this;if(this.settings.refresh||f){var h=encodeURIComponent(this.query);var g="";if(i.mode=="search"){g="http://search.twitter.com/search.json?q="+h+"&callback=?"}else{if(i.mode=="user_timeline"){g="http://twitter.com/statuses/user_timeline/"+h+".json?count="+i.limit+"&callback=?"}}a.getJSON(g,function(k){var j=null;if(i.mode=="search"){j=k.results}else{j=k}a(j).reverse().each(function(){var p="";var n="";if(i.mode=="search"){p=this.from_user;n=this.profile_image_url}else{p=this.user.screen_name;n=this.user.profile_image_url}var l=this.user;var o=this.text.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/,function(r){return r.link(r)});o=o.replace(/@[A-Za-z0-9_]+/,function(r){return r.link("http://twitter.com/"+r.replace(/^@/,""))});if(Date.parse(this.created_at)>i.lastTimeStamp){var q='<div class="tweet tweet-'+this.id+'">';if(i.settings.showAuthor){q+='<img width="24" height="24" src="'+n+'" /><p class="text"><span class="username"><a href="http://twitter.com/'+p+'">'+p+"</a>:</span> "}else{q+='<p class="text"> '}q+=o+' <span class="time">'+i.relativeTime(this.created_at)+"</span></p></div>";a(i.container).prepend(q);var m=this.created_at;a(i.container).find("span.time:first").each(function(){this.timeStamp=m});if(!f){a(i.container).find(".tweet-"+this.id).hide().fadeIn()}i.lastTimeStamp=Date.parse(this.created_at)}});a(i.container).find("div.tweet:gt("+(i.limit-1)+")").remove()})}},start:function(){var f=this;if(!this.interval){this.interval=setInterval(function(){f.refresh()},f.settings.rate);this.refresh(true)}},stop:function(){if(this.interval){clearInterval(this.interval);this.interval=false}}};var e=this.twitter;this.timeInterval=setInterval(function(){e.refreshTime()},5000);this.twitter.start()}});return this}})(jQuery);
+(function(a){if(!a.fn.reverse){a.fn.reverse=function(){return this.pushStack(this.get().reverse(),arguments)}}a.fn.liveTwitter=function(c,b){a(this).each(function(){var d={};if(this.twitter){d=jQuery.extend(this.twitter.settings,b);this.twitter.settings=d;if(c){this.twitter.query=c}this.twitter.limit=d.limit;this.twitter.mode=d.mode;if(this.twitter.interval){this.twitter.refresh()}}else{d=jQuery.extend({mode:"search",rate:15000,limit:10,refresh:true},b);if(typeof d.showAuthor=="undefined"){if(d.mode=="search"){d.showAuthor=true}else{d.showAuthor=false}}window.twitter_callback=function(){return true};this.twitter={settings:d,query:c,limit:d.limit,mode:d.mode,interval:false,container:this,lastTimeStamp:0,relativeTime:function(g){var f=Date.parse(g);var i=(Date.parse(Date())-f)/1000;var h="";if(i<60){h=i+" seconds ago"}else{if(i<120){h="a minute ago"}else{if(i<(45*60)){h=(parseInt(i/60,10)).toString()+" minutes ago"}else{if(i<(90*60)){h="an hour ago"}else{if(i<(24*60*60)){h=""+(parseInt(i/3600,10)).toString()+" hours ago"}else{if(i<(48*60*60)){h="a day ago"}else{h=(parseInt(i/86400,10)).toString()+" days ago"}}}}}}return h},refreshTime:function(){var f=this;a(f.container).find("span.time").each(function(){a(this).html(f.relativeTime(this.timeStamp))})},refresh:function(f){var i=this;if(this.settings.refresh||f){var h=encodeURIComponent(this.query);var g="";if(i.mode=="search"){if(this.settings.geocode){g="http://search.twitter.com/search.json?q="+h+"&geocode="+encodeURIComponent(this.settings.geocode)+"&callback=?"}else{g="http://search.twitter.com/search.json?q="+h+"&callback=?"}}else{if(i.mode=="user_timeline"){g="http://twitter.com/statuses/user_timeline/"+h+".json?count="+i.limit+"&callback=?"}}a.getJSON(g,function(k){var j=null;if(i.mode=="search"){j=k.results}else{j=k}a(j).reverse().each(function(){var p="";var n="";if(i.mode=="search"){p=this.from_user;n=this.profile_image_url}else{p=this.user.screen_name;n=this.user.profile_image_url}var l=this.user;var o=this.text.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/,function(r){return r.link(r)});o=o.replace(/@[A-Za-z0-9_]+/,function(r){return r.link("http://twitter.com/"+r.replace(/^@/,""))});if(Date.parse(this.created_at)>i.lastTimeStamp){var q='<div class="tweet tweet-'+this.id+'">';if(i.settings.showAuthor){q+='<img width="24" height="24" src="'+n+'" /><p class="text"><span class="username"><a href="http://twitter.com/'+p+'">'+p+"</a>:</span> "}else{q+='<p class="text"> '}q+=o+' <span class="time">'+i.relativeTime(this.created_at)+"</span></p></div>";a(i.container).prepend(q);var m=this.created_at;a(i.container).find("span.time:first").each(function(){this.timeStamp=m});if(!f){a(i.container).find(".tweet-"+this.id).hide().fadeIn()}i.lastTimeStamp=Date.parse(this.created_at)}});a(i.container).find("div.tweet:gt("+(i.limit-1)+")").remove()})}},start:function(){var f=this;if(!this.interval){this.interval=setInterval(function(){f.refresh()},f.settings.rate);this.refresh(true)}},stop:function(){if(this.interval){clearInterval(this.interval);this.interval=false}}};var e=this.twitter;this.timeInterval=setInterval(function(){e.refreshTime()},5000);this.twitter.start()}});return this}})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.