Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   let agoraValue = 0;
  2.  
  3.   const doDom = () => {
  4.     const relogio = document.querySelector("#relogio");
  5.     const b = relogio.getAttribute("data-server-time").split(",");
  6.     const agora = new Date(b[0], (b[1]-1), b[2], b[3], b[4], b[5]);
  7.     agoraValue = agora.valueOf();
  8.     setInterval(iniciaCronometro,1000);
  9.   };
  10.      
  11.   const iniciaCronometro = () => {
  12.     const myDate = new Date(agoraValue);
  13.     const h = myDate.getHours();
  14.     const i = ("0" + String(myDate.getMinutes())).slice(-2);
  15.     const timeAgora = parseFloat(document.getElementById("TIMEATUAL").value);
  16.     relogio.innerHTML = h+':'+i;
  17.     document.getElementById("TIMEATUAL").value = (timeAgora + 1);
  18.     agoraValue = agoraValue + 1000;
  19.   };
  20.    
  21.   // Await DOM to be loaded
  22.   if (document.readyState === 'loading') {
  23.     document.addEventListener('DOMContentLoaded', () => {
  24.       doDom();
  25.     });
  26.   } else {
  27.     doDom();
  28.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement