function load_tweets() { var element = document.getElementById("twitter"); if (element) { var callback = "like_a_boss"; var username = "the_earwig"; var count = 4; var url = "https://twitter.com/statuses/user_timeline/" + username + ".json?count=" + count + "&callback=" + callback; var script = document.createElement("script"); var head = document.getElementsByTagName("head")[0]; window[callback] = function(tweets) { head.removeChild(script); show_tweets(tweets, element); }; script.src = url; head.appendChild(script); } } function show_tweets(tweets, element) { for (t in tweets) { var tweet = tweets[t]; var t = '
  • ' + fmt_text(tweet["text"]) + "
    "; t += '' t += '' + fmt_date(tweet["created_at"]) + ""; t += "
  • "; element.innerHTML += t; } } function fmt_text(t) { t = t.replace(/(http:\/\/.*?(\s|$))/ig, '$1$2'); t = t.replace(/\@(.*?)(\s|$)/ig, '@$1$2'); return t; } function fmt_date(d) { return dateFormat(d, "ddd, mmm d, yyyy 'at' h:MM TT"); }