Skip to content

Instantly share code, notes, and snippets.

@saghul
Created December 1, 2010 19:22
Show Gist options
  • Save saghul/724051 to your computer and use it in GitHub Desktop.
Save saghul/724051 to your computer and use it in GitHub Desktop.
Phono hello world 1
<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>
<input id="call" type="button" disabled="true" value="Loading..." />
<span id="status"></span>
<script>
$(document).ready(function(){
var phono = $.phono({
apiKey: "XXXXXXXXXXXXXXXXXXXXXXXXX",
onReady: function() {
$("#call").attr("disabled", false).val("Call");
$("#status").html("Phono is ready!");
},
onUnready: function() {
$("#status").html("Phono has disconnected");
}
});
var call = null;
$("#call").click(function() {
if (call === null) {
$("#call").attr("disabled", true).val("Calling...");
call = phono.phone.dial("sip:[email protected]", {
onRing: function() {
$("#call").attr("disabled", false).val("Hangup");
$("#status").html("Ringing");
},
onAnswer: function() {
$("#status").html("Answered");
},
onHangup: function() {
$("#call").attr("disabled", false).val("Call");
$("#status").html("Hangup");
call = null;
},
onError: function() {
$("#call").attr("disabled", false).val("Call");
$("#status").html("Error");
call = null;
}
}); // end phono dial
} else {
call.hangup();
call = null;
$("#call").attr("disabled", false).val("Call");
$("#status").html("Hangup");
}
}); // end click handler
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment