Personal website https://benkurtovic.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

42 lines
1.3 KiB

  1. function load_tweets() {
  2. var element = document.getElementById("twitter");
  3. if (element) {
  4. var callback = "like_a_boss";
  5. var username = "the_earwig";
  6. var count = 4;
  7. var url = "https://twitter.com/statuses/user_timeline/" + username + ".json?count=" + count + "&callback=" + callback;
  8. var script = document.createElement("script");
  9. var head = document.getElementsByTagName("head")[0];
  10. window[callback] = function(tweets) {
  11. head.removeChild(script);
  12. show_tweets(tweets, element);
  13. };
  14. script.src = url;
  15. head.appendChild(script);
  16. }
  17. }
  18. function show_tweets(tweets, element) {
  19. for (t in tweets) {
  20. var tweet = tweets[t];
  21. var t = '<li class="post">' + fmt_text(tweet["text"]) + "<br />";
  22. t += '<a href="http://twitter.com/' + tweet["user"]["screen_name"] + '/status/' + tweet["id_str"] + '">'
  23. t += '<span class="tweet description">' + fmt_date(tweet["created_at"]) + "</span>";
  24. t += "</a></li>";
  25. element.innerHTML += t;
  26. }
  27. }
  28. function fmt_text(t) {
  29. t = t.replace(/(http:\/\/.*?(\s|$))/ig, '<a href="$1">$1</a>$2');
  30. t = t.replace(/\@(.*?)(\s|$)/ig, '<a href="http://twitter.com/$1">@$1</a>$2');
  31. return t;
  32. }
  33. function fmt_date(d) {
  34. return dateFormat(d, "ddd, mmm d, yyyy 'at' h:MM TT");
  35. }