function replaceURLWithHTMLLinks(text) { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/i; return text.replace(exp,"$1"); } function tweetagCallback(json) { html = ""; html += ""; html += ""; html += ""; html += ""+json.user.screen_name+""; html += ""; html += "
" +replaceURLWithHTMLLinks(json.text)+"
"; html += ""+time_since(Date.parse(json.created_at))+""; html += "View on Twitter"; document.write("
"+html+"
"); } function time_since(original) { var foo = new Date; // Generic JS date object var unixtime_ms = foo.getTime(); // Returns milliseconds since the epoch var today = Math.floor(unixtime_ms / 1000); /* Current unix time */ // original = original - 12*3600; original = original.toString().substr(0,10); // console.info("unix time: %i tweet time: %i - difference: %i",today,original,(today-original)); var since = today - original; //console.debug(since); if(window.console) console.info("epoch: %s - %s = %s",today,original,since); var toprint="",days,hours,minutes; if(since>(24*3600)) { days = Math.floor(since/(3600*24)); toprint += days+" day"; if(days>1) toprint += "s"; toprint += " "; since = since%(24*3600); } if(since>3600) { hours = Math.floor(since/3600); toprint += hours+" hour"; if(hours>1) toprint += "s"; toprint += " "; since = since%3600; } if(since>60) { minutes = Math.floor(since/60); toprint += minutes+" minute"; if(minutes>1) toprint += "s"; toprint += " "; since = since%60; } else toprint = "less than a minute"; // toprint += since+" seconds"; toprint += " ago"; return toprint; } tweetagCallback({"contributors":null,"coordinates":null,"geo":null,"retweet_count":null,"favorited":false,"created_at":"Mon May 18 13:26:09 +0000 2009","source":"Twidget","in_reply_to_screen_name":null,"place":null,"user":{"geo_enabled":true,"profile_text_color":"000000","description":"Web entrepreneur/developer. Founder of @storify, @listimonkey, @publitweet, @europatweets","profile_use_background_image":true,"time_zone":"Pacific Time (US & Canada)","url":"http://xdamman.posterous.com","verified":false,"notifications":null,"profile_link_color":"0000ff","follow_request_sent":null,"lang":"en","profile_background_image_url":"http://s.twimg.com/a/1283555538/images/themes/theme1/bg.png","created_at":"Sun Dec 10 21:40:41 +0000 2006","profile_image_url":"http://a2.twimg.com/profile_images/16158822/xavier2_normal.jpg","location":"San Francisco","profile_sidebar_fill_color":"e0ff92","profile_background_tile":false,"followers_count":1462,"screen_name":"xdamman","following":null,"profile_sidebar_border_color":"87bc44","listed_count":141,"friends_count":341,"protected":false,"statuses_count":9262,"name":"Xavier Damman","show_all_inline_media":false,"favourites_count":2496,"profile_background_color":"9ae4e8","id":55993,"contributors_enabled":false,"utc_offset":-28800},"retweeted":false,"truncated":true,"in_reply_to_status_id":null,"id":1835637837,"in_reply_to_user_id":null,"text":"Quickly did a widget to make it easy to quote a tweet within a blog post (without having to do a printscreen) http://tweetag.com/widgets ..."});