index.js 763 B

123456789101112131415161718192021222324
  1. var timeNode = document.body.appendChild(document.createElement('time-node'));
  2. timeNode.style = `padding: 15px;
  3. background: #000;
  4. color: #e4e5e6;
  5. display: inline-block;
  6. font-weight: bold;
  7. border-radius: 4px;`
  8. var i = 0;
  9. var t = new Date();
  10. function getCurrentTimeString() {
  11. i++;
  12. if(i > 100) {
  13. document.getElementById("deadline-message").className = "visible";
  14. clearInterval(id);
  15. timeNode.remove();
  16. } else {
  17. return new Date().toTimeString().replace(/ .*/, '');
  18. }
  19. }
  20. var id = setInterval(
  21. () => timeNode.innerHTML = getCurrentTimeString(),
  22. 1000
  23. )