Unblocking The Main Thread Solving ANRs and Frozen Frames
Playing With The Web
1. Playing with the web
or “The geek shall inherit the earth”
Christian Heilmann | http://wait-till-i.com | http://twitter.com/codepo8
Geek Meet Stockholm, December 2008
29. preg_match_all(quot;/tabledata1quot;>([^<]+)</
td>/quot;,$feed,$cells);
if(is_numeric($cells[1][1])){
$out = ‘{quot;fromquot;:quot;’.$from.’quot;,quot;toquot;:quot;’.
$to.’quot;,quot;factorquot;:quot;’.$cells[1][1].’quot;}’;
} else {
$out = ‘{quot;errorquot;:quot;Could not convert
currencies, are you sure about the
names?quot;}’;
}
} else {
$out = ‘{quot;errorquot;:quot;Invalid Currency format,
must be three lettersquot;}’;
}
if(isset($callback)){
if(preg_match(quot;/[a-z|A-Z|_|-|$|0-9|.]/quot;,
$callback)){
$out = $callback.’(’.$out.’)';
54. /*
Useful tweets badge by Christian Heilmann
*/
var tweets = function(){
var x = document.getElementById('mytweet');
if(x){
var twitterUserId = x.className.replace('user-','');
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'http://pipes.yahoo.com/pipes/pipe.run?' +
'_id=f7229d01b79e508d543fb84e8a0abb0d&_render=json' +
'&id=' + twitterUserId + '&_callback=tweets.tweet';
document.getElementsByTagName('head')[0].appendChild(s);
};
function tweet(data){
if(data && data.value && data.value.items){
if(typeof data.value.items.length !== 'undefined'){
var ul = document.createElement('ul');
var all = data.value.items.length;
var end = all > 5 ? 5 : all;
for(var i=0;i < end;i++){
55. var now = data.value.items[i];
var li = document.createElement('li');
var a = document.createElement('a');
a.href = now.link;
a.appendChild(
document.createTextNode(now.title)
);
li.appendChild(a);
ul.appendChild(li);
}
x.appendChild(ul);
}
}
};
return{
tweet:tweet
}
}();