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 May 14 14:55:36 +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":"I can make you smoke some kryptonite / That'll turn your brain into dynamite","lang":"en","profile_background_tile":false,"created_at":"Sat Dec 01 21:11:02 +0000 2007","profile_link_color":"3d3d3d","location":"Paris, France","verified":false,"follow_request_sent":null,"notifications":null,"profile_sidebar_fill_color":"ededed","following":null,"profile_image_url":"http://a3.twimg.com/profile_images/1092321335/sara_normal.jpg","profile_sidebar_border_color":"171717","followers_count":599,"screen_name":"le_hasard","listed_count":70,"friends_count":427,"protected":false,"statuses_count":5166,"profile_use_background_image":false,"time_zone":"Paris","profile_background_color":"6e6e6e","name":"Sara","show_all_inline_media":false,"favourites_count":342,"id":10773502,"contributors_enabled":false,"profile_background_image_url":"http://s.twimg.com/a/1281738360/images/themes/theme1/bg.png","utc_offset":3600,"profile_text_color":"1f1e1e","url":"http://stochastique.org"},"retweet_count":null,"id":1795526312,"text":"Et je d\u00e9cerne mon prix du jour pour la meilleure orthographe alternative \u00e0 : \"\u00e9tant pationnait\"."});