Created
September 20, 2012 15:23
-
-
Save toshimaru/3756569 to your computer and use it in GitHub Desktop.
get tweets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see. http://blog.asial.co.jp/659 | |
<script type="text/javascript"> | |
/** | |
* コールバック | |
*/ | |
function myfunc(json) { | |
var box = $('#twitterBox'); | |
$(json.results).each(function(i, v) { | |
v.jp_created_at = dateJp(v.created_at); | |
var html = template('<div class="twit">\ | |
<blockquote class="commentOne">\ | |
<p class="commentText">#{text}</p><p class="twitDate">#{jp_created_at}<\/p>\ | |
<span class="arrow" \/>\ | |
<\/blockquote>\ | |
<img class="profileImg" src="#{profile_image_url}" \/>\ | |
<span class="twitterUser"><a href="http://twitter.com/#{from_user}" target="twitter">#{from_user}</a><\/span>\ | |
<\/div>', v); | |
box.append(html); | |
}); | |
} | |
/** | |
* HTMLテンプレート | |
*/ | |
function template(str, obj, replacement) { | |
return str.replace(/#\{(.+?)\}/g, function() { | |
try { | |
return eval('obj.' + arguments[1]); | |
} catch (e) { | |
return replacement ? replacement : ''; | |
}; | |
}); | |
} | |
/** | |
* 日付変換 | |
* thanks @see http://l-w-i.net/m/20081202_01.txt | |
*/ | |
function dateJp(dateStr){ | |
var d = dateStr.split(" "); | |
var post_date = d[0] + " " + d[2] + " " + d[1] + " " + d[3] + " " + d[4]; | |
var date = new Date(post_date); | |
date.setHours(date.getHours() + 9); | |
return date.toString(); | |
} | |
</script> | |
<script type="text/javascript" src="http://search.twitter.com/search.json?q=github&rpp=10&callback=myfunc"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment