mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-05 15:17:49 +00:00
Improved Code
This commit is contained in:
parent
e1b9bd46b6
commit
5be0d1c5e9
@ -110,10 +110,6 @@ html {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.light {
|
||||
font-family: "HelveticaNeue-UltraLight", sans-serif;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
<body>
|
||||
|
||||
<div class="top right"><div class="windsun small dimmed"></div><div class="temp"></div><div class="forecast small dimmed"></div></div>
|
||||
<div class="top left"><div class="date small dimmed"></div><div class="hidden" id="timebuffer"></div><div class="time" id="time"></div><div class="calendar xxsmall"></div></div>
|
||||
<div class="top left"><div class="date small dimmed"></div><div class="time" id="time"></div><div class="calendar xxsmall"></div></div>
|
||||
<div class="center-ver center-hor"><!-- <div class="dishwasher light">Vaatwasser is klaar!</div> --></div>
|
||||
<div class="lower-third center-hor"><div class="compliment light"></div></div>
|
||||
<div class="bottom center-hor"><div class="news medium"></div></div>
|
||||
|
@ -10,27 +10,26 @@ var time = {
|
||||
* Updates the time that is shown on the screen
|
||||
*/
|
||||
time.updateTime = function () {
|
||||
|
||||
var _now = moment(),
|
||||
_date = _now.format('[<span class="dayname">]dddd,[</span><span class="longdate">]LL[</span>]');
|
||||
var timeLocation = this.timeLocation;
|
||||
var _now = moment();
|
||||
var _date = _now.format('[<span class="dayname">]dddd,[</span> <span class="longdate">]LL[</span>]');
|
||||
|
||||
|
||||
$(this.dateLocation).updateWithText(_date, 1000);
|
||||
$('.fade').removeClass('fade')
|
||||
$('#timebuffer').html(_now.format('HH:mm').replace(/./g, "<span>$&</span>"));
|
||||
$('#timebuffer').children().each(function( index ) {
|
||||
var diff = $('<div>').html(_now.format(this._timeFormat+':mm').replace(/./g, "<span>$&</span>"));
|
||||
diff.children().each(function( index ) {
|
||||
var _text = $( this ).text();
|
||||
var _i = index+1;
|
||||
var _text2 = $('#time span:nth-child('+_i+')').text();
|
||||
var _text2 = $(timeLocation + ' span:nth-child('+_i+')').text();
|
||||
if (_text != _text2) {
|
||||
$('#time span:nth-child('+_i+')').addClass('fade');
|
||||
$(timeLocation +' span:nth-child('+_i+')').addClass('fade');
|
||||
$(this).addClass('fade');
|
||||
}
|
||||
});
|
||||
$('.fade').fadeTo(400, 0.25, function() {
|
||||
$('#time').html($('#timebuffer').html());
|
||||
$('#time').children().fadeTo(400, 1).removeClass('fade');
|
||||
});
|
||||
$(timeLocation).html(diff.html());
|
||||
$(timeLocation).children().fadeTo(400, 1).removeClass('fade');
|
||||
}).bind(this);
|
||||
|
||||
}
|
||||
|
||||
@ -41,6 +40,7 @@ time.init = function () {
|
||||
} else {
|
||||
time._timeFormat = 'HH';
|
||||
}
|
||||
$(this.timeLocation).html('<span class="fade"></span>');
|
||||
|
||||
this.intervalId = setInterval(function () {
|
||||
this.updateTime();
|
||||
|
Loading…
x
Reference in New Issue
Block a user