I use a snippet of code in Java Script to change the image and url of a floating WhatsApp contact button, alternating according to commercial and non-commercial periods. This code works well, but it is necessary to increase the number of operators that receive requests by creating a random distribution during the commercial period. I tried some ways to no avail, does anyone know how to fix this?
This is the current code:
<script type="text/javascript">
var now = new Date();
var today = now.getDay();
var startTime = new Date();
startTime.setHours(08);
startTime.setMinutes(00);
startTime.setSeconds(00);
var endTime = new Date();
endTime.setHours(18);
endTime.setMinutes(30);
endTime.setSeconds(00);
var comercial = '<div style="position: fixed; z-index: 1000; width: 123px; height: 140px; bottom: 15px; right: 5px;"><a href="https://wa.me/554830345599?text=Ol%C3%A1,%20quero%20saber%20mais%20sobre:%20$$title$$%20($$url$$)%0A%20*ENVIE%20PARA%20INICIAR*" target="_blank" rel="noopener noreferrer"><img class="size-medium wp-image-2986" src="https://secret.innovacestas.com.br/wp-content/uploads/2020/12/logo-whatsapp-1.png" alt="Atendimento Direto via WhatsApp" width="112" height="90" /></a>';
var plantao = '<div style="position: fixed; z-index: 1000; width: 123px; height: 140px; bottom: 15px; right: 5px;"><a href="https://wa.me/5548996605599?text=Ol%C3%A1,%20quero%20saber%20mais%20sobre:%20$$title$$%20($$url$$)%0A%20*ENVIE%20PARA%20INICIAR*" target="_blank" rel="noopener noreferrer"><img class="size-medium wp-image-2986" src="https://secret.innovacestas.com.br/wp-content/uploads/2020/04/logo-whatsapp-png.png" alt="Atendimento Direto via WhatsApp" width="112" height="90" /></a>';
if ((today > 0) && (today < 6) && (now > startTime) && (now < endTime))
{document.write(comercial);}
else
{document.write(plantao);}
</script>
Aucun commentaire:
Enregistrer un commentaire