Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ctaloi/3012441 to your computer and use it in GitHub Desktop.
Save ctaloi/3012441 to your computer and use it in GitHub Desktop.
Simple Phono call and answer app
<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..." />
<div id="pickup" style="display:none"><input id="pickup" type="button" value="pickup" /></div>
<div id="hangup" style="display:none"><input id="hangup" type="button" value="hangup" /></div>
<span id="status"></span>
<script>
$(document).ready(function(){
var phono = $.phono({
apiKey: "6e442b984dfa26cd102423b7bc5aaebd",
onReady: function() {
$("#call").attr("disabled", false).val("Call");
alert("My Address address is sip:" + this.sessionId);
},
phone: {
onIncomingCall: function(event) {
var call = event.call;
// alert("Incoming call");
$("#pickup").show();
$("#status").html("Incoming call");
$("#pickup").click(function() {
$("#status").html("answered");
call.answer();
$("#pickup").hide();
$("#hangup").show();
});
$("#hangup").click(function() {
$("#status").html("hungup");
call.hangup();
$("#hangup").hide();
});
}
}
});
$("#call").click(function() {
$("#call").attr("disabled", true).val("Busy");
var call = phono.phone.dial("985-655-2500", { // sip:chrismatthieu@proxy01.sipphone.com
onRing: function() {
$("#status").html("Ringing");
},
onAnswer: function() {
$("#status").html("Answered");
$("#hangup").show();
$("#hangup").click(function() {
$("#status").html("hungup");
call.hangup();
$("#hangup").hide();
});
},
onHangup: function() {
$("#call").attr("disabled", false).val("Call");
$("#status").html("Hungup");
}
});
});
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment