<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Visualize your Twitter Timiline with jQuery and SIMILE</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://simile.mit.edu/timeline/api/timeline-api.js" type="text/javascript"></script>
<style type="text/css" media="screen">
body { background-color: #000; font: 14px Helvetica, Arial; color: #fff; }
#my-timeline, #source { margin-top: 15px; }
#criteria, #my-timeline, #source { margin-bottom: 15px; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.1/processing-api.min.js"></script>
.timeline-band-layer-inner { font-size: 10px; }
.timeline-event-bubble-title, .timeline-event-bubble-body { color: black; }
.timeline-event-bubble-time { padding-top: 5px; color: #ccccc; font-size: 9px; }
</style>
<script type="text/javascript">
$(function() {
$("#my-timeline").hide();
$('#getTwitterTimeline').click(function() {
getTwitterTimeline($('#userName').val());
});
});
var timeLine;
function getTwitterTimeline(userName) {
var eventSource = new Timeline.DefaultEventSource();
var url = 'http://twitter.com/status/user_timeline/' + userName + '.json?count=200&callback=?';
$.getJSON(url, function(data) {
$("#my-timeline").fadeIn('slow');
var mostRecentTweetDate = new Date(1);
$.each(data, function(i, item) {
var dateEvent = Date.parse(item.created_at);
mostRecentTweetDate = (dateEvent > mostRecentTweetDate) ? dateEvent : mostRecentTweetDate;
var html = replaceUrlWithHtmlLinks(item.text);
var evt = new Timeline.DefaultEventSource.Event(
new Date(dateEvent), //start
null, //end
null, //latestStart
null, //earliestEnd
true, //instant
item.text.substr(0, 47) + '...', //text
html //description
);
eventSource.add(evt);
});
var bandInfos = [
Timeline.createBandInfo({
trackGap: 0.2,
width: "80%",
intervalUnit: Timeline.DateTime.HOUR,
intervalPixels: 500,
eventSource: eventSource,
timeZone: new Date().getTimezoneOffset() / 60,
date: new Date(mostRecentTweetDate).toGMTString()
}),
Timeline.createBandInfo({
showEventText: false,
trackHeight: 0.5,
trackGap: 0.2,
width: "20%",
intervalUnit: Timeline.DateTime.DAY,
intervalPixels: 300,
eventSource: eventSource,
timeZone: new Date().getTimezoneOffset() / 60,
date: new Date(mostRecentTweetDate).toGMTString()
})
];
bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true;
timeLine = Timeline.create($("#my-timeline")[0], bandInfos);
});
}
var resizeTimerID = null;
$('body').resize(function() {
if (resizeTimerID == null) {
resizeTimerID = window.setTimeout(function() {
resizeTimerID = null;
timeLine.layout();
}, 500);
}
});
function replaceUrlWithHtmlLinks(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1'>$1</a>");
}
</script>
</head>
<body>
<h3>Visualize your Twitter Timeline with jQuery and SIMILE</h3>
<div id="criteria">
<span>Twitter Username: </span>
<input id="userName" type="text" value="elijahmanor" />
<button id="getTwitterTimeline">Twitter Timeline</button>
</div>
<div id="my-timeline" style="height: 200px;"></div>
<a id="source" href="http://jsbin.com/alubi/edit" target="_blank">View, Run, & Edit Source Code</a>
</body>
</html>
if (document.getElementById('hello')) {
document.getElementById('hello').innerHTML = 'Hello World - this was inserted using JavaScript';
}
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |