apps

https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js
http://firebugx.js
http://jquery-ui-1.7.2.custom.min.js
http://strftime.js

var allTweets = [];
var allTweeters = {};

function reset() {
allTweets = [];
allTweeters = {};
$(“#tweets”).slideUp(1000, function() { $(this).html(“”).show(); set_hash() });
}

function displayTweets(tweets) {

$(“.tweet”).removeClass(“new”);

for (var i=0; i<tweets.length; i++) {
var tweet = tweets[i];
var domNode = $("

“);
domNode.hide();

var dateText = new Date(tweet.created_at).strftime(“%Y-%m-%d %H:%M:%S”);
var dateLink = $(““).attr(“href”, “http://twitter.com/&#8221; + tweet.user.screen_name + “/status/” + tweet.id).text(dateText);
domNode.append( $(““).append(dateLink));

// put created_at date on dom node. Crude.
domNode.attr(“created_at”, dateText );

var screenLink = $(““).text( tweet.user.screen_name ).attr(“href”, “http://twitter.com/&#8221; + tweet.user.screen_name );
domNode.append( $(““).append(screenLink) );

var t = escapeHTML( tweet.text );
t = t.replace(/@(S+)/g, “@$1“)
t = t.replace(/(https?:S+)/g, “$1“)
domNode.append( $(““).html( t ) );

var last = null;
var found = false;
$(“.tweet”).each(function(idx) {
//console.log(“found node at index ” + idx );
if (!found &&
(!last && domNode.attr(“created_at”) > $(this).attr(“created_at”))
|| ( last && last.attr(“created_at”) > domNode.attr(“created_at”) && $(this).attr(“created_at”) 0) {
var names = window.location.hash.substr(1).split(/,/);
for (var i=0; i 0) {
// for everything except the first load, try to get lots more tweets,
// but limit the load to tweets after the first seen tweet, in an
// effort to keep the page dense.
url += “&since_id=” + allTweets[ allTweets.length – 1 ].id;
url += “&count=50”
} else {
url += “&count=50”
}
url += “&callback=?”;
$.getJSON(url, function(tweets) {
console.log(“got ” + tweets.length + ” tweet(s)”);

tweets.sort(function(a,b) {
var da = new Date( a.created_at );
var db = new Date( b.created_at );
return db – da;
});

displayTweets(tweets);

allTweets = allTweets.concat(tweets);
allTweeters[ username ] = tweets;
set_hash();

// sort list by created_at, so we know when the first and
// last tweets were.
allTweets.sort(function(a,b) {
var da = new Date( a.created_at );
var db = new Date( b.created_at );
return db – da;
});

$(“#spinny”).hide();
});

}

function escapeHTML(h) {
return h.replace(/&/g, “&”).replace(//g, “>”);
}

function set_hash() {
var names = [];
for (var name in allTweeters) {
names[ names.length ] = name;
}
console.log( names );
console.log(“setting hash to ” + names.join(“,”));
window.location.hash = names.join(“,”);
}

Start with: clear