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":"Fri Aug 28 12:34:34 +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":{"description":"The time that used to separate us has been obliterated. Stop.","contributors_enabled":false,"lang":"en","geo_enabled":true,"profile_background_tile":false,"created_at":"Mon Mar 19 11:38:21 +0000 2007","profile_link_color":"6aaff6","location":"Pittsburgh, PA","notifications":null,"profile_sidebar_fill_color":"363636","following":null,"friends_count":270,"followers_count":2747,"profile_image_url":"http://a0.twimg.com/profile_images/838474260/newest_pawn_normal.png","follow_request_sent":null,"profile_sidebar_border_color":"737373","show_all_inline_media":false,"verified":false,"favourites_count":1618,"screen_name":"texburgher","protected":false,"profile_use_background_image":true,"time_zone":"Eastern Time (US & Canada)","profile_background_color":"1A1B1F","name":"Geoff Barnes","listed_count":386,"id":1493121,"statuses_count":8312,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/5365501/twitterbg2.gif","utc_offset":-18000,"profile_text_color":"737373","url":"http://texburgher.com"},"retweet_count":null,"id":3601586214,"text":"In hindsight, I suppose \"augmented reality in your pocket\" really wasn't the best subject line for my first ever company-wide email."});