-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebphone-embedded.html
54 lines (46 loc) · 1.8 KB
/
webphone-embedded.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!-- Exemplo Webphone com interface propria ou oculto -->
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
<style>
iframe {
display: none;
}
</style>
</head>
<body>
<a href="#" id="ligar">489999999</a>
<script>
$(function() {
// Exemplo com jQuery
$('body').on('click', "#ligar", function(e) {
e.preventDefault();
$('#totalvoice').show();
chamaNumero($(this).text());
});
});
//todas as mensagens oriundas do webphone são recebidas aqui.
window.onmessage = function(e) {
//quando receber uma ligacao
if (e.data.message == 'chegandoChamada') {
$('#totalvoice').show();
alert('Chegando Chamada de ' + e.data.numeroChegando + ' para: ' + e.data.numeroDestino + ' chamada_recebida_id: ' + e.data.chamadaRecebidaId);
}
if (e.data.message == 'status') {
if(e.data.status == 'encerrada') {
$('#totalvoice').hide();
}
alert('Status: ' + e.data.status);
}
};
function chamaNumero(numero) {
var iframe = document.getElementById("totalvoice");
iframe.contentWindow.postMessage({
message: 'chamaNumero',
'numero': numero
}, '*');
}
</script>
<iframe id="totalvoice" width="500px" height="250px" allow="microphone" src="URL_WEBPHONE_EMBEDDED" frameborder="0"></iframe>
</body>
</html>