Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1047afbf40
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (50 sloc) 1.509 kb
{% extends "base.html" %}
{% block content %}
<form action="" >
<p>Type some Twitter user names below to see who's too cool for you.<br>
Also include some user names you know follow you:</p>
<div style="float:left">
<textarea name="usernames" cols="20" rows="20">katyperry
justinbieber
peterbe
</textarea><input type="submit" value="Test">
</div>
</form>
<div id="results">
</div>
<div style="clear:left">&nbsp;</div>
{% end %}
{% block extra_js %}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
$(function() {
$('form').submit(function() {
var usernames = $('textarea').val().split('\n');
$.getJSON('/json', {'usernames': usernames.join(',')}, function (response) {
if (!$('#results ul').size()) {
$('<h3>', {text: 'Too cool for me:'}).appendTo($('#results'));
$('<ul>').attr('id', 'followsyounot').appendTo($('#results'));
$('<h3>', {text: 'Follows me:'}).appendTo($('#results'));
$('<ul>').attr('id', 'followsyou').appendTo($('#results'));
} else {
$('#results li').remove();
}
var c;
if (response.ERROR) {
alert('ERROR: ' + response.ERROR);
return;
}
$.each(response, function(x, y) {
if (y)
c = $('ul#followsyou');
else
c = $('ul#followsyounot');
$('<a>', {href: '/following/' + x, text: x})
.appendTo($('<li>').appendTo(c));
});
});
return false;
});
});
</script>
{% end %}
Jump to Line
Something went wrong with that request. Please try again.