Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 144 lines (133 sloc) 4.195 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
<?
if(isset($_GET['term'])) {
$term = addslashes($_GET['term']);
} else {
$term = "instagr";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Theinternetpresents.com - a twitter slideshow by @jasonmcleod</title>
<style>
* {
font-family:Arial, Helvetica, sans-serif;
}
body,html {
margin:0px;
padding:0px;
background:black;
}
#caption {
background:rgba(255,255,255,.2);
color:#fff;
font-size:20px;
position:absolute;
bottom:0px;
left:0px;
padding:20px;
text-shadow: 2px 2px 2px #000;
}
</style>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>

var rpp = 5;
var mostRecent = 0;
var term = "<?=$term?>";
var tweets = [];
var cycleRunning = false;

$(function() {
$(window).resize(function() {
fit(document.getElementById("fullscreen"));
});
});
function firehose() {
$.getJSON("http://search.twitter.com/search.json?q=" + term + "&rpp=" + rpp + "&since_id=" + mostRecent + "&callback=?",function(msg) {
for(var r=0;r<msg.results.length;r++) {
mostRecent = msg.results[r].id;
var url = findLink(msg.results[r].text);
var img = url?"resolveImage.php?url=" + url:false;
tweets.push({
user:msg.results[r].from_user,
image:img,
text:msg.results[r].text
});
if(img) {
tweets[tweets.length-1].loaded = new Image();
if(!cycleRunning) {
tweets[tweets.length-1].loaded.onload = function() {
//fit(this);
cycle();
}
}
tweets[tweets.length-1].loaded.src = img;
}
}
});
}
function cycle() {
cycleRunning = true;
if(tweets.length>0) {
var thisTweet = tweets.shift();
if(thisTweet.image) {
var preload = new Image();
preload.onload = function() {
$("#fullscreen").fadeOut(500,function() {
$("#fullscreen").attr("src",thisTweet.image);
fit(this);
$("#caption").html("<strong>@" + thisTweet.user + "</strong>: " + thisTweet.text);
$("#fullscreen").fadeIn();
});
}
preload.src = thisTweet.image;
} else {
$("#fullscreen").fadeOut();
$("#caption").html("<strong>@" + thisTweet.user + "</strong>: " + thisTweet.text);
}
}
}
setInterval(firehose,10000); firehose();
setInterval(cycle,5000);
function findLink(msg) {
if(msg.indexOf("http://")>-1) {
url = msg.split("http://");
url = "http://" + url[1].split(" ")[0];
return url;
} else {
return false;
}
}
function fit(which) {
var winWidth=$(window).width();
var winHeight=$(window).height();
var imageWidth=which.width;
var imageHeight=which.height;
var picHeight = imageHeight / imageWidth;
var picWidth = imageWidth / imageHeight;
if ((winHeight / winWidth) > picHeight) {
$("#fullscreen").css("width",winWidth).css("height",picHeight*winWidth);
} else {
$("#fullscreen").css("height",winHeight).css("width",picWidth*winHeight);
};
$("#fullscreen").css({marginLeft: ((winWidth - $("#fullscreen").width())/2) });
$("#fullscreen").css({marginTop:((winHeight - $("#fullscreen").height())/2) });
}

</script>
<img src="clear.gif" id="fullscreen" />
<p id="caption">Downloading some internet...<br />
Add any term at the end of the URL to change the content.</p>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19109053-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</body>
</html>
Something went wrong with that request. Please try again.