Clean up dashboard clock code
parent
645c7e180a
commit
73fcb117db
|
@ -2,3 +2,6 @@
|
||||||
#clock ul { width:100%; margin:0 auto; padding:0px; list-style:none; }
|
#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 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; }
|
#clock .point { position:relative; -moz-animation:mymove 1s ease infinite; -webkit-animation:mymove 1s ease infinite; }
|
||||||
|
#time-date {
|
||||||
|
font-size: 90%;
|
||||||
|
}
|
||||||
|
|
|
@ -12,8 +12,9 @@ $(document).ready(function() {
|
||||||
timeDate.innerHTML = dayNames[newDate.getDay()] + " " + newDate.getDate() + ' ' + monthNames[newDate.getMonth()] + ' ' + newDate.getFullYear();
|
timeDate.innerHTML = dayNames[newDate.getDay()] + " " + newDate.getDate() + ' ' + monthNames[newDate.getMonth()] + ' ' + newDate.getFullYear();
|
||||||
}
|
}
|
||||||
if($user.details.clock_date_format){
|
if($user.details.clock_date_format){
|
||||||
|
var clockDateFormat = `${$user.details.clock_date_format}`
|
||||||
updateDate = function(){
|
updateDate = function(){
|
||||||
const newTimeString = $user.details.clock_date_format
|
const newTimeString = clockDateFormat
|
||||||
.replaceAll('$DAYNAME',dayNames[newDate.getDay()])
|
.replaceAll('$DAYNAME',dayNames[newDate.getDay()])
|
||||||
.replaceAll('$DAY',newDate.getDate())
|
.replaceAll('$DAY',newDate.getDate())
|
||||||
.replaceAll('$MONTHNAME',monthNames[newDate.getMonth()])
|
.replaceAll('$MONTHNAME',monthNames[newDate.getMonth()])
|
||||||
|
@ -35,17 +36,29 @@ $(document).ready(function() {
|
||||||
if(timeHour.classList.contains('twentyfour') && hours > 12)hours = hours - 12;
|
if(timeHour.classList.contains('twentyfour') && hours > 12)hours = hours - 12;
|
||||||
timeHour.innerHTML = hours
|
timeHour.innerHTML = hours
|
||||||
}
|
}
|
||||||
var setAll = function(){
|
function setAll(){
|
||||||
var theDate = new Date()
|
var theDate = new Date()
|
||||||
|
var currentMinute = theDate.getMinutes()
|
||||||
|
var currentHour = theDate.getHours()
|
||||||
|
var currentDay = theDate.getHours()
|
||||||
second(theDate)
|
second(theDate)
|
||||||
if(currentMinute !== theDate.getMinutes())minute(theDate)
|
if(lastMinute !== currentMinute){
|
||||||
if(currentHour !== theDate.getHours())hour(theDate)
|
minute(theDate)
|
||||||
if(currentDay !== theDate.getDay())updateDate()
|
lastMinute = currentMinute
|
||||||
|
}
|
||||||
|
if(lastHour !== currentHour){
|
||||||
|
hour(theDate)
|
||||||
|
lastHour = currentHour
|
||||||
|
}
|
||||||
|
if(lastDay !== currentDay){
|
||||||
|
updateDate()
|
||||||
|
lastDay = currentDay
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setAll()
|
setAll()
|
||||||
var currentHour = newDate.getHours()
|
var lastHour = newDate.getHours()
|
||||||
var currentMinute = newDate.getMinutes()
|
var lastMinute = newDate.getMinutes()
|
||||||
var currentDay = newDate.getDay()
|
var lastDay = newDate.getDay()
|
||||||
setInterval(function(){
|
setInterval(function(){
|
||||||
setAll()
|
setAll()
|
||||||
},1000);
|
},1000);
|
||||||
|
@ -55,9 +68,9 @@ $(document).ready(function() {
|
||||||
updateDate()
|
updateDate()
|
||||||
document.getElementById("clock").onclick = function(){
|
document.getElementById("clock").onclick = function(){
|
||||||
timeHour.classList.toggle('twentyfour')
|
timeHour.classList.toggle('twentyfour')
|
||||||
currentHour = null
|
lastHour = null
|
||||||
setAll()
|
setAll()
|
||||||
currentHour = newDate.getHours()
|
lastHour = newDate.getHours()
|
||||||
updateDate()
|
updateDate()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue