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_status_id":null,"created_at":"Wed Jun 24 08:58:00 +0000 2009","geo":null,"coordinates":null,"in_reply_to_screen_name":null,"truncated":false,"retweeted":false,"source":"web","favorited":false,"contributors":null,"place":null,"in_reply_to_user_id":null,"user":{"geo_enabled":false,"description":"Technology, Blogging, Photography, Publishing, Consumerism, Social Media, 3D Graphics, Humor and golf. I am the Credit Terrorist.","lang":"en","profile_background_tile":false,"created_at":"Thu Feb 14 10:55:36 +0000 2008","profile_link_color":"3C3C3C","location":"Statesboro Georgia GA","verified":false,"follow_request_sent":null,"notifications":null,"profile_sidebar_fill_color":"ae7e50","following":null,"profile_image_url":"http://a1.twimg.com/profile_images/632518457/Allen-200-01152010_normal.jpg","profile_sidebar_border_color":"000000","followers_count":902,"screen_name":"AllenHarkleroad","listed_count":15,"friends_count":577,"protected":false,"statuses_count":16512,"profile_use_background_image":true,"time_zone":"Eastern Time (US & Canada)","profile_background_color":"ffffff","name":"AllenHarkleroad","show_all_inline_media":false,"favourites_count":141,"id":13466982,"contributors_enabled":false,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/80058567/Twitter-1600x2000-gray.jpg","utc_offset":-18000,"profile_text_color":"000000","url":"http://smarterotti.com"},"retweet_count":null,"id":2308119281,"text":"\"Don't be irreplaceable. If you can't be replaced, you can't be promoted.\" #Wisdom #Quotes"});