topbar.eta 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <% const timeIcon = `
  2. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
  3. <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  4. <circle cx="12" cy="12" r="10" />
  5. <path d="M12 6v6l4 2" />
  6. </g>
  7. </svg>
  8. ` %>
  9. <% const dateIcon = `
  10. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
  11. <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2">
  12. <path d="M8 2v4m8-4v4" />
  13. <rect width="18" height="18" x="3" y="4" rx="2" />
  14. <path d="M3 10h18M8 14h.01M12 14h.01M16 14h.01M8 18h.01M12 18h.01M16 18h.01" />
  15. </g>
  16. </svg>
  17. ` %>
  18. <% const date = new Date() %>
  19. <header>
  20. <p><%~ timeIcon %> <span id="topbarTime"><%= date.getHours() %>:<%= date.getMinutes() %></span></p>
  21. <p><span id="topbarDate"><%= date.getDate() %>. <%= date.getMonth() + 1 %>. <%= date.getFullYear() %></span> <%~ dateIcon %></p>
  22. <script defer>
  23. setInterval(() => {
  24. const topbarTime = document.querySelector("#topbarTime")
  25. const topbarDate = document.querySelector("#topbarDate")
  26. const date = new Date()
  27. const timeString = `${date.getHours().toString().padStart(2, `0`) }:${date.getMinutes().toString().padStart(2, `0`)}:${date.getSeconds().toString().padStart(2, `0`)}`
  28. const dateString = `${date.getDate() }. ${date.getMonth() + 1 }. ${date.getFullYear()}`
  29. topbarTime.textContent = timeString
  30. if (topbarDate.textContent !== dateString) {
  31. topbarDate.textContent = dateString
  32. }
  33. }, 1000)
  34. </script>
  35. </header>