Created
December 1, 2010 19:22
-
-
Save saghul/724051 to your computer and use it in GitHub Desktop.
Phono hello world 1
This file contains 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..." /> | |
<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