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":"Tue Jul 07 09:28:41 +0000 2009","geo":null,"coordinates":null,"in_reply_to_screen_name":null,"truncated":false,"retweeted":false,"source":"Twitstat Mobile","favorited":false,"contributors":null,"place":null,"in_reply_to_user_id":null,"user":{"description":"@Wepika co-founder & @CafeNumerique promoter. Coder, thinker, speaker, optimistic & DIYholic (I build up my house). What would you like to drink ?","lang":"en","profile_background_tile":true,"created_at":"Thu May 08 08:17:03 +0000 2008","profile_link_color":"3b5998","followers_count":1582,"location":"Belgium","listed_count":149,"notifications":null,"friends_count":981,"profile_sidebar_fill_color":"6d84b4","statuses_count":5870,"following":null,"profile_image_url":"http://a2.twimg.com/profile_images/1020035370/profil_seynaeve_normal.jpg","show_all_inline_media":false,"favourites_count":6,"profile_sidebar_border_color":"94a4c6","contributors_enabled":false,"screen_name":"seynaeve","geo_enabled":true,"protected":false,"profile_use_background_image":true,"time_zone":"Brussels","profile_background_color":"e6e7ea","name":"Edouard Seynaeve \u2714","verified":false,"id":14697773,"follow_request_sent":null,"profile_background_image_url":"http://a1.twimg.com/profile_background_images/11495896/seynaeve_google_tw.jpg","utc_offset":3600,"profile_text_color":"333333","url":"http://www.seynaeve.me"},"retweet_count":null,"id":2511768167,"text":"La communication Ryanair, c\u2019est du twitter IRL: Une courte id\u00e9e a la con et tous les m\u00e9dias RT"});