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 16:56:15 +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":"(not really lost) in translation.\r\nNew media, media marketing & communication + photography. Former head of 360\u00b0 Digital Influence @ Ogilvy Paris","lang":"fr","profile_background_tile":false,"created_at":"Thu Mar 15 13:02:27 +0000 2007","profile_link_color":"990000","location":"Paris","listed_count":139,"followers_count":2226,"statuses_count":10022,"notifications":null,"profile_sidebar_fill_color":"F3F3F3","show_all_inline_media":false,"following":null,"friends_count":890,"profile_image_url":"http://a3.twimg.com/profile_images/912858635/9020e286-1a99-4d0d-9861-f4bddf40347f_normal.png","contributors_enabled":false,"profile_sidebar_border_color":"DFDFDF","favourites_count":12,"screen_name":"lilzeon","protected":false,"geo_enabled":true,"profile_use_background_image":true,"time_zone":"Paris","profile_background_color":"EBEBEB","name":"Laurent Francois","follow_request_sent":null,"id":1220921,"verified":false,"profile_background_image_url":"http://s.twimg.com/a/1281572621/images/themes/theme7/bg.gif","utc_offset":3600,"profile_text_color":"333333","url":"http://www.tout-ca.com"},"retweet_count":null,"id":2312889945,"text":"\"Certain advertisers insist on targeting ads only to people using Microsoft's IE. The reason? IE users click more on ads\".Stephen Bake"});