Created
October 20, 2010 08:07
-
-
Save chobie/636001 to your computer and use it in GitHub Desktop.
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
//今見ているページのURLを含んだツイートがあれば表示する | |
//from http://blog.asial.co.jp/659 | |
function myfunc(json) { | |
var box = $('body'); | |
$(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); | |
}); | |
} | |
function template(str, obj, replacement) { | |
return str.replace(/#\{(.+?)\}/g, function() { | |
try { | |
return eval('obj.' + arguments[1]); | |
} catch (e) { | |
return replacement ? replacement : ''; | |
}; | |
}); | |
} | |
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(); | |
} | |
var s=document.createElement('script'); | |
s.charset='UTF-8'; | |
s.src='http://search.twitter.com/search.json?q=' + encodeURI(location.href) +'&rpp=100&callback=myfunc'; | |
document.body.appendChild(s); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment