Created
September 13, 2012 15:18
-
-
Save sergiopvilar/3715025 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<!-- Código do widget que o Zopim fornece --> | |
<script type="text/javascript"> | |
window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s= | |
d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set. | |
_.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8'); | |
$.src='//cdn.zopim.com/?SxVBIjAfwRPgCoA4EUksLiAoxtRRxOjT';z.t=+new Date;$. | |
type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script'); | |
</script> | |
</head> | |
<body> | |
<p id="status"></p> | |
<form id="atendimento" method="POST"> | |
<label>Nome: </label><input type="text" name="nome" /><br /> | |
<label>Telefone: </label><input type="text" name="telefone" /><br /> | |
<label>Email: </label><input type="text" name="email" /><br /> | |
<label>Cidade: </label> | |
<select name="cidade"> | |
<option>João Pessoa</option> | |
<option>Natal</option> | |
</select><br /><br /> | |
<input type="submit" value="Entrar no chat" /> | |
</form> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> | |
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.0.min.js"><\/script>')</script> | |
<script type="text/javascript"> | |
$(document).ready(function(){ | |
// Esconde o chat e o botão no carregamento | |
$zopim.livechat.window.hide(); | |
$zopim.livechat.button.hide(); | |
// Função que altera o status do atendente | |
function updateStatus(s){ | |
if(s=="online"){ | |
$('#status').html('Atendimento online'); | |
}else if(s=="away"){ | |
$('#status').html('Atendimento ausente'); | |
} | |
} | |
$zopim(function() { $zopim.livechat.setOnStatus(updateStatus) }); | |
// Função que roda no submit do formulário | |
$('#atendimento').submit(function(){ | |
// Concatena demais informações | |
demais = 'Telefone: '+$('input[name=telefone]').val()+'\nCidade: '+$('select[name=cidade]').val(); | |
// Envia as informações do usuário para o atendente | |
$zopim(function() { | |
$zopim.livechat.set({ | |
language: 'pt', | |
name: $('input[name=nome]').val(), | |
email: $('input[name=email]').val(), | |
notes: demais | |
}); | |
}); | |
// Abre o chat | |
$zopim.livechat.window.show() | |
return false; | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment