Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (66 sloc) 1.58 KB
<!DOCTYPE html>
<html>
<head>
<title>Tweets</title>
<script type="text/javascript" src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<script type="text/javascript">
var socket;
var wsUrl = 'ws://' + location.hostname + '/ws/tweets';
function connect(){
socket = new WebSocket(wsUrl);
socket.onmessage = function(e) {
//console.log( e );
var tweet = e.data;
var ts = e.timeStamp;
var left = Math.floor( Math.random() * window.innerWidth );
var top = Math.floor( Math.random() * window.innerHeight );
var div = "<div class=\"balloon-bottom\" style=\"position:absolute; top:" + top + "px; left:" + left + "px;\">" + tweet + "</div>";
$('body').append( div );
}
}
</script>
<style>
/* balloon bottom */
.balloon-bottom {
position: relative;
display: inline-block;
padding: 0 15px;
width: auto;
min-width: 115px;
height: 40px;
line-height: 34px;
color: #19283C;
text-align: center;
background: #F6F6F6;
border: 3px solid #19283C;
z-index: 0;
}
.balloon-bottom:before {
content: "";
position: absolute;
bottom: -8px; left: 50%;
margin-left: -9px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 9px 9px 0 9px;
border-color: #F6F6F6 transparent transparent transparent;
z-index: 0;
}
.balloon-bottom:after {
content: "";
position: absolute;
bottom: -12px; left: 50%;
margin-left: -10px;
width: 0px;
height: 0px;
border-style: solid;
border-width: 10px 10px 0 10px;
border-color: #19283C transparent transparent transparent;
z-index: -1;
}
</style>
</head>
<body onload="connect()">
</body>
</html>