Created
January 8, 2009 20:16
-
-
Save pope/44862 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // tb.js | |
| // TweetBackRedux 0.2 JS code | |
| // Copyright (c) 2009 Jeremy Hilton < @jeremyhilton > | |
| // This file is part of TweetBackRedux. | |
| // | |
| // TweetBackRedux is free software: you can redistribute it and/or modify | |
| // it under the terms of the GNU General Public License as published by | |
| // the Free Software Foundation, either version 3 of the License, or | |
| // (at your option) any later version. | |
| // | |
| // TweetBackRedux is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| // GNU General Public License for more details. | |
| // | |
| // You should have received a copy of the GNU General Public License | |
| // along with TweetBackRedux. If not, see <http://www.gnu.org/licenses/>. | |
| $(document).ready(function() { | |
| $.getJSON("/tb_shorten_lib.php?url="+document.location.href, function(data) { | |
| var urls = []; | |
| $.each(data.urls, function(key, value) { | |
| urls.push(value); | |
| }); | |
| $.getJSON('http://search.twitter.com/search.json?rpp=100&q=&ors=' + urls.join("+") + '&callback=?', | |
| function(twitter_data) { | |
| var tweet_backs = [], | |
| tweet_back_list = [], | |
| t_count = 0; | |
| $.each(twitter_data.results, function(key, item) { | |
| for (var x in urls) { | |
| if (urls.hasOwnProperty(x)) { | |
| // see if the URL returned matches one of the URLS we searched for. The Twitter search API is not case sensitive, URL shorteners are. This causes invalid tweetbacks to be returned. | |
| if (item.text.match(urls[x].replace(/\//g, "\\/"))) { | |
| tweet_back_list.push("<li style='display: block; background-image: url("+item.profile_image_url+"); background-repeat:no-repeat; padding-left:50px; height: 50px; padding-bottom: 10px;'><b>"+item.from_user+":</b> "+item.text+" "+item.created_at+"</li>"); | |
| t_count++; | |
| break; | |
| } | |
| } | |
| } | |
| }); | |
| tweet_backs.push("<b>"+t_count+" Total TweetBacks:</b>"); | |
| tweet_backs.push("<ul>"); | |
| tweet_backs.push(tweet_back_list.join("")); | |
| tweet_backs.push("</ul>"); | |
| $("#tweetbacks").html(tweet_backs.join("")); | |
| } | |
| ); | |
| }); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment