Skip to content

Instantly share code, notes, and snippets.

@tsloughter
Created April 8, 2011 00:24
Show Gist options
  • Save tsloughter/909066 to your computer and use it in GitHub Desktop.
Save tsloughter/909066 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title></title>
</head>
<body>
<h1></h1>
<style>
#box, #input {
padding: 10px;
margin: 5px;
width: 500px;
text-shadow: #ccc -1px -1px 2px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-o-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: inset 0 0 30px #eee;
-moz-box-shadow: inset 0 0 30px #eee;
-o-box-shadow: inset 0 0 30px #eee;
box-shadow: inset 0 0 30px #eee;
}
#box {
height: 100px;
overflow: scroll;
overflow-x: hidden;
border: 1px solid #888;
background: #f8f8f8 url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAZCAYAAADwkER/AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAADdJREFUCNdVzDEOwCAUw9DX/Nv2/kMLRXQD4cFylsAd9KAtvcFz1p5bLfjWwQhGIYUrmMEsiIMfNxwSOsvoNw4AAAAASUVORK5CYII=') repeat-x;
}
#input {
font-size: 20px;
line-height: 20px;
}
.code {
width: 558px;
font-size: 10px;
line-height: 12px;
overflow: hidden;
}
</style>
<div><input id=input placeholder=you-chat-here /></div>
<div id=box></div>
<div id=pubnub pub-key=demo sub-key=demo></div>
<script src=http://cdn.pubnub.com/pubnub-3.1.min.js></script>
<script>(function(){
var box = PUBNUB.$('box'), input = PUBNUB.$('input'), channel = 'chat';
PUBNUB.subscribe({
channel : channel,
callback : function(text) { box.innerHTML = (''+text).replace( /[<>]/g, '' ) + '<br/>' + box.innerHTML; }
});
PUBNUB.bind( 'keyup', input, function(e) {
(e.keyCode || e.charCode) === 13 && PUBNUB.publish({
channel : channel, message : "tristan : "+input.value, x : (input.value = '')
});
} );
})();</script>
<hr>
<address></address>
<!-- hhmts start --> Last modified: Thu Apr 7 19:08:24 CDT 2011 <!-- hhmts end -->
</body> </html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment