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({"in_reply_to_screen_name":null,"created_at":"Sun Jun 28 09:08:06 +0000 2009","retweet_count":null,"truncated":false,"geo":null,"coordinates":null,"source":"Twitter for iPhone","place":null,"contributors":null,"retweeted":false,"in_reply_to_status_id":null,"user":{"follow_request_sent":null,"profile_sidebar_border_color":"19a7d6","description":"British Actor, Writer, Lord of Dance, Prince of Swimwear & Blogger","lang":"en","created_at":"Tue Jul 15 11:45:30 +0000 2008","location":"London","followers_count":1721793,"profile_use_background_image":true,"time_zone":"London","profile_background_color":"a5e6fa","listed_count":31822,"following":null,"notifications":null,"friends_count":53388,"statuses_count":3066,"profile_background_image_url":"http://a1.twimg.com/profile_background_images/107684890/twitter_1.5mill_g-tech.jpg","profile_text_color":"333333","profile_image_url":"http://a1.twimg.com/profile_images/1035438413/6b94699a-0e00-43f4-adf3-0b54663f4531_normal.png","show_all_inline_media":false,"favourites_count":7,"contributors_enabled":false,"profile_background_tile":false,"profile_link_color":"1c83a6","protected":false,"screen_name":"stephenfry","geo_enabled":false,"name":"Stephen Fry","profile_sidebar_fill_color":"48ccf4","id":15439395,"verified":true,"utc_offset":0,"url":"http://www.stephenfry.com"},"favorited":false,"id":2369926238,"in_reply_to_user_id":null,"text":"Oh my sod-mothering heavens. I have just played the Tristan Chord on Wagner's Steinway. A piano Liszt played also. And Rubinstein. *faints*"});