Created
October 28, 2010 16:51
-
-
Save chrismatthieu/651776 to your computer and use it in GitHub Desktop.
Simple Phono call and answer app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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:[email protected] | |
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