Skip to content

Instantly share code, notes, and snippets.

@loopingrage
Created October 17, 2010 17:27
Show Gist options
  • Save loopingrage/631045 to your computer and use it in GitHub Desktop.
Save loopingrage/631045 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script src="http://s.phono.com/releases/0.1/jquery.phono.js"></script>
</head>
<body>
<div>
<textarea id="chatHistory" style="height:300px; width:500px"></textarea>
</div>
<div>
<input id="chatText" type="text" style="width:450px" />
<input id="sendChat" type="button" disabled="true" value="Send" />
</div>
<script>
$(document).ready(function() {
var myPhono = $.phono({
onReady: function(){
$("#sendChat").attr("disabled", false);
},
messaging: {
onMessage: function(event) {
var message = event.message;
console.log(message.from + ": " + message.body);
$('#chatHistory').append("\n" + message.from + ": " + message.body);
}
}
}); // end .phono
$('#sendChat').click(function() {
var msg = $('#chatText').val();
$('#chatHistory').append("\nYou: " + msg);
$('#chatText').val('');
myPhono.messaging.send("phono-echo@tropo.im", msg);
console.log("Sent: " + msg);
});
}); // end ready
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment