Skip to content

Instantly share code, notes, and snippets.

@dbarria
Last active November 22, 2017 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbarria/a8c4c86ea5b88afc498d3dd4a9e070ad to your computer and use it in GitHub Desktop.
Save dbarria/a8c4c86ea5b88afc498d3dd4a9e070ad to your computer and use it in GitHub Desktop.
Levantar la ventana del widget después de 10 segundos de inactividad
<html>
<head>
<!-- Carga del widget de Let's Talk -->
<script type="application/javascript" src="https://we.letsta.lk/widget.js"></script>
<!-- Carga de la versión de jQuery es usada en https://www.bci.cl/webPublico/planes.html#/contratoplanes/landing -->
<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- Carga de una librería de jQUery que permite detectar cuándo un usuario está inactivo, cumpliendo todas las siguientes condiciones durante un tiempo dado:
- No ha movido el mouse
- No ha utilizado el scroll del mouse
- No ha utilizado el teclado
Más detalles de la librería en https://github.com/thorst/jquery-idletimer -->
<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-idletimer/1.0.0/idle-timer.min.js"></script>
<style>
body, html {
height: 100%;
margin: 0;
overflow-y: visible;
}
.bg {
/* The image used */
background-image: url("http://misc.letsta.lk.s3.amazonaws.com/images/bcicuentacorriente.png");
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: top;
background-repeat: no-repeat;
background-size: cover;
}
</style>
</head>
<body>
<div class="bg"></div>
<script type="application/javascript">
// Inicialización del widget de Let's Talk
window.$LT(function(messenger) {
messenger.setByName("viaje-planes")
})
$(function() {
// Inicialización del plugin de inactividad para detectar tiempo de inactividad a los 10 segundos
$.idleTimer(10000);
// Evento que dispara el plugin de inactividad cuando se cumple la condición de inactividad
$( document ).on( "idle.idleTimer", function(event, elem, obj){
// Se destruye el timer para asegurar que solo se gatille una vez
$( document ).idleTimer("destroy");
// Llamada a la API del Widget para levantar la ventana de chat
window.$LT.setDisplayState('small');
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment