Clean up dashboard clock code

video-slicer-reencoder
Moe 2022-09-10 09:22:05 -07:00
parent 645c7e180a
commit 73fcb117db
2 changed files with 26 additions and 10 deletions

View File

@ -2,3 +2,6 @@
#clock ul { width:100%; margin:0 auto; padding:0px; list-style:none; }
#clock ul li { display:inline; font-size:1.6em; text-align:center;font-family:monospace;}
#clock .point { position:relative; -moz-animation:mymove 1s ease infinite; -webkit-animation:mymove 1s ease infinite; }
#time-date {
font-size: 90%;
}

View File

@ -12,8 +12,9 @@ $(document).ready(function() {
timeDate.innerHTML = dayNames[newDate.getDay()] + " " + newDate.getDate() + ' ' + monthNames[newDate.getMonth()] + ' ' + newDate.getFullYear();
}
if($user.details.clock_date_format){
var clockDateFormat = `${$user.details.clock_date_format}`
updateDate = function(){
const newTimeString = $user.details.clock_date_format
const newTimeString = clockDateFormat
.replaceAll('$DAYNAME',dayNames[newDate.getDay()])
.replaceAll('$DAY',newDate.getDate())
.replaceAll('$MONTHNAME',monthNames[newDate.getMonth()])
@ -35,17 +36,29 @@ $(document).ready(function() {
if(timeHour.classList.contains('twentyfour') && hours > 12)hours = hours - 12;
timeHour.innerHTML = hours
}
var setAll = function(){
function setAll(){
var theDate = new Date()
var currentMinute = theDate.getMinutes()
var currentHour = theDate.getHours()
var currentDay = theDate.getHours()
second(theDate)
if(currentMinute !== theDate.getMinutes())minute(theDate)
if(currentHour !== theDate.getHours())hour(theDate)
if(currentDay !== theDate.getDay())updateDate()
if(lastMinute !== currentMinute){
minute(theDate)
lastMinute = currentMinute
}
if(lastHour !== currentHour){
hour(theDate)
lastHour = currentHour
}
if(lastDay !== currentDay){
updateDate()
lastDay = currentDay
}
}
setAll()
var currentHour = newDate.getHours()
var currentMinute = newDate.getMinutes()
var currentDay = newDate.getDay()
var lastHour = newDate.getHours()
var lastMinute = newDate.getMinutes()
var lastDay = newDate.getDay()
setInterval(function(){
setAll()
},1000);
@ -55,9 +68,9 @@ $(document).ready(function() {
updateDate()
document.getElementById("clock").onclick = function(){
timeHour.classList.toggle('twentyfour')
currentHour = null
lastHour = null
setAll()
currentHour = newDate.getHours()
lastHour = newDate.getHours()
updateDate()
}
});