Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var cachedCalls = []
  2.  
  3. function updateCalls(calls) {
  4.     if (calls.length === 1) {
  5.         setCall(calls[0])
  6.         updateInterval = setInterval(function() { nextNews() }, 10000);
  7.     } else {
  8.         clearInterval(updateInterval)
  9.         setCall(calls.pop())       
  10.         setTimeout(updateCalls(calls),3000)
  11.     }
  12. }
  13.  
  14. function setCall(call) {
  15.     cachedCalls.append(call)
  16.     for (var call, index in cachedCalls) {
  17.         if (index > 3) {
  18.             cachedCalls.length = 4;
  19.             break;
  20.         }      
  21.  
  22.         if (index === 0) {
  23.             /**
  24.              * Update values
  25.              */
  26.             $('#nome' + index).html(call.nomePaciente)
  27.             $('#sala' + index).html(call.idSala)
  28.             $('#medico').html(call.nomeMedico)
  29.             $('#especialidade').html(call.especialidade)
  30.  
  31.             /**
  32.              * Play animations
  33.              */
  34.             $('#nome' + index).removeClass('hurry')
  35.             $('#sala' + index).removeClass('hurry')
  36.             $('#nome' + index).addClass('hurry')
  37.             $('#sala' + index).addClass('hurry')           
  38.  
  39.             playAudioCall(call.nomePaciente, call.idSala)
  40.         } else {
  41.             $('#nome' + index).html(call.nomePaciente)
  42.             $('#sala' + index).html(call.idSala)
  43.         }
  44.     }
  45. }
  46.  
  47. function playAudioCall (nome, sala) {
  48.     utter.text = nome + "Sala" + sala;
  49.     utter.voice = english_voice;
  50.     window.speechSynthesis.speak(utter);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement