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({"contributors":null,"in_reply_to_status_id":null,"in_reply_to_screen_name":null,"in_reply_to_user_id":null,"created_at":"Tue Jul 28 14:30:30 +0000 2009","favorited":false,"source":"TweetDeck","user":{"verified":false,"url":"http://kreature.be","description":"Blogueuse, Bruxelloise, \u00e9tudiante en Droit, tricoteuse, etc.","notifications":null,"profile_text_color":"3c3673","profile_background_image_url":"http://a3.twimg.com/profile_background_images/36569455/background-flexyflow.jpg","created_at":"Thu May 08 12:37:12 +0000 2008","profile_link_color":"fc0570","followers_count":1158,"profile_background_tile":false,"friends_count":508,"profile_background_color":"f7f4f7","profile_image_url":"http://a3.twimg.com/profile_images/413474627/avatartwitwit_normal.jpg","statuses_count":44227,"lang":"en","time_zone":"Brussels","favourites_count":40,"profile_sidebar_fill_color":"a3a3a3","protected":false,"screen_name":"flexyflow","contributors_enabled":false,"following":null,"location":"Bruxelles","name":"Florence M.","geo_enabled":false,"profile_sidebar_border_color":"ab46ab","id":14699626,"utc_offset":3600},"geo":null,"id":2890600858,"truncated":false,"text":"3 \u00e0 4 semaines pour faire r\u00e9parer mon casque pionneer :'( #mediamarkt #caca"});