Created
July 1, 2013 03:45
-
-
Save tbaba/5898228 to your computer and use it in GitHub Desktop.
こーひーおいしいです
This file contains 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
$ -> | |
$('form').on 'submit' -> | |
keyword = "#{$(":text").val()} lang:ja" | |
$.ajax | |
method: 'GET' | |
url: 'http://search.twitter.com/search.json?callback=?' | |
data: | |
q: keyword | |
show_user: true | |
rpp: 100 | |
beforeSend: (data) -> | |
$('#search').empty() | |
success: (data) -> | |
for i in [0..10] | |
profileImageUrl = data.results[i].profile_image_url # Twitterアイコン | |
text = data.results[i].text # 投稿内容(テキスト) | |
user = data.results[i].from_user # ユーザー名(screen name) | |
created = data.results[i].created_at # 投稿日時 | |
source = data.results[i].source # 利用クライアント(使用せず) | |
postId = data.results[i].id_str # 個別投稿のID(※訂正後:"id_str"ならOK) | |
userProfile = "http://twitter.com/#{user}" # ユーザーのURL | |
permaLink = "http://twitter.com/#{user}/status/#{postId}" # パーマリンクURL | |
$("#search").append """ | |
<div class="post post#{i}"> | |
<p class='icon'><a href='#{userProfile}' target='_blank'><img src='#{profileImageUrl}' / alt='#{user}' /></a></p> | |
<div class='wrapper'> | |
<p class='user'><a href='#{userProfile}' target='_blank'>#{user}</a></p> | |
<p class='text'>#{text}</p> | |
<p class='created'><a href='#{permaLink}' target='_blank'>#{created}</p> | |
</div> | |
</div> | |
""" | |
$(".post#{i}").fadeIn('slow').animate('marginTop': '10px') | |
error: (data) -> | |
alert '処理に失敗しました' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
azs 🐦