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":"Sat May 23 12:36:19 +0000 2009","geo":null,"coordinates":null,"in_reply_to_screen_name":null,"truncated":false,"retweeted":false,"source":"TwitterBar","favorited":false,"contributors":null,"place":null,"in_reply_to_user_id":null,"user":{"verified":false,"description":"Webzine culturel francophone.Critiques musicales, litt\u00e9raires, cin\u00e9ma, BD, News et interviews. Via @oncle_ben @Emgenius @withoutmyhat @jeffard ...","lang":"fr","profile_background_tile":false,"created_at":"Tue May 27 09:23:02 +0000 2008","profile_link_color":"575bf4","location":"France","listed_count":74,"notifications":null,"profile_sidebar_fill_color":"99CC33","statuses_count":4969,"following":null,"profile_image_url":"http://a3.twimg.com/profile_images/54716731/benzine_normal.jpg","show_all_inline_media":false,"profile_sidebar_border_color":"829D5E","followers_count":886,"contributors_enabled":false,"screen_name":"Benzinemag","favourites_count":4,"friends_count":291,"protected":false,"profile_use_background_image":true,"time_zone":"Paris","profile_background_color":"fdfcfc","name":"Benzinemag","geo_enabled":false,"id":14918797,"follow_request_sent":null,"profile_background_image_url":"http://a1.twimg.com/profile_background_images/14991316/image.jpg","utc_offset":3600,"profile_text_color":"442015","url":"http://www.benzinemag.net"},"retweet_count":null,"id":1892851800,"text":"#benzschuller Ceci est un exemple de question pos\u00e9e \u00e0 S\u00e9bastien Schuller via Twitter"});