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":"Thu Jun 25 08:26:43 +0000 2009","geo":null,"coordinates":null,"in_reply_to_screen_name":null,"truncated":false,"retweeted":false,"source":"Twitter for iPhone","favorited":false,"contributors":null,"place":null,"in_reply_to_user_id":null,"user":{"followers_count":8953,"description":"Journaliste. Je ne mets pas de smiley \u00e0 la fin de mes tweets mais consid\u00e9rez que c'est tout comme.","lang":"en","profile_background_tile":true,"created_at":"Wed Mar 21 10:34:56 +0000 2007","profile_link_color":"06e007","location":"Paris","listed_count":663,"friends_count":996,"statuses_count":9535,"notifications":null,"profile_sidebar_fill_color":"ffffff","show_all_inline_media":false,"following":null,"favourites_count":30,"profile_image_url":"http://a3.twimg.com/profile_images/921442823/n902710544_2870226_958_normal.jpg","contributors_enabled":false,"profile_sidebar_border_color":"ffffff","geo_enabled":false,"screen_name":"vincentglad","protected":false,"verified":false,"profile_use_background_image":false,"time_zone":"Paris","profile_background_color":"ffffff","name":"Vincent Glad","follow_request_sent":null,"id":1731311,"profile_background_image_url":"http://a3.twimg.com/profile_background_images/88413009/macdo.jpg","utc_offset":3600,"profile_text_color":"000000","url":"http://www.slate.fr"},"retweet_count":null,"id":2323771342,"text":"Si on devait \u00e9trangler un chat \u00e0 chaque fois qu'on entend une pub sur Spotify, ce ne serait que justice mais ce serait la fin de l'esp\u00e8ce"});