Created
May 15, 2010 06:27
-
-
Save Arthraim/402062 to your computer and use it in GitHub Desktop.
renjian web widget
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
/* | |
Author: Arthur Wang | |
Version: 0.5 | |
Update: 2010/5/15 | |
Author URI: http://arthraim.cn/ | |
*/ | |
function renjianCallback(statuss) { | |
var sData = [], sHtml = "", j = 1; | |
for (var i=0; i < statuss.length; i++){ | |
if (statuss[i].in_reply_to_user_id != null) continue; | |
if (j > 10) break; | |
sHtml = '<li>'; | |
sHtml += '<div class="text">'; | |
if(statuss[i].text){ | |
sHtml += statuss[i].text.replace(/@(.+?)(?=\s)/g, "@<a href='http://renjian.com/$1' target='_blank'>$1</a>"); | |
sHtml += " "; | |
} | |
if(statuss[i].status_type == "LINK"){ | |
sHtml += "<a href='" + statuss[i].original_url + "' target='_blank'>" + (statuss[i].link_title||statuss[i].link_desc) + "</a>"; | |
if(statuss[i].thumbnail) | |
sHtml += " <a href='" + statuss[i].thumbnail + "' rel='lightbox'><img src='" + statuss[i].thumbnail + "' width='150'/></a>"; | |
} | |
if(statuss[i].status_type == "PICTURE"){ | |
sHtml += " <a href='" + statuss[i].original_url + "' rel='lightbox'><img src='" + statuss[i].original_url + "' width='150'/></a>"; | |
} | |
sHtml += '</div>'; | |
sHtml += '<div class="timeAndWay alt-font">'; | |
sHtml += statuss[i].relative_date + " 通过" + (statuss[i].source=="网站"?"人间网":statuss[i].source); | |
sHtml += '</div>'; | |
sHtml += '</li>'; | |
sData.push(sHtml); | |
j = j + 1; | |
} | |
document.getElementById('microblog_list').innerHTML = sData.join(""); | |
} |
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
<ul id="microblog_list"></ul> | |
<script type="text/javascript" src="renjian_widget.js"></script> | |
<script type="text/javascript" src="http://renjian.com/statuses/user_timeline/YOUR_USERNAME.json?count=50&callback=renjianCallback"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment