Revert "Removed Clock"

This reverts commit 9ca8f8dc64e9a28da81a538a3578c2b2a8b34c88.
This commit is contained in:
FrozenCow 2011-02-13 22:56:23 +01:00
parent 058ab0eea7
commit 3980ebefa1
4 changed files with 49 additions and 0 deletions

BIN
web/clock_day.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

BIN
web/clock_night.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

View file

@ -28,6 +28,47 @@ DynMapType.prototype = {
}
};
function MinecraftClock(element) { this.element = element; }
MinecraftClock.prototype = {
element: null,
timeout: null,
time: null,
create: function(element) {
if (!element) element = $('<div/>');
this.element = element;
return element;
},
setTime: function(time) {
if (this.timeout != null) {
window.clearTimeout(this.timeout);
this.timeout = null;
}
this.time = time;
this.element
.addClass((time.day <= 4) ? 'day' : 'night')
.removeClass((time.day <= 4) ? 'day' : 'night')
.text(this.formatTime(time));
if (this.timeout == null) {
var me = this;
this.timeout = window.setTimeout(function() {
me.timeout = null;
me.setTime(getMinecraftTime(me.time.servertime+(1000/60)));
}, 700);
}
},
formatTime: function(time) {
var formatDigits = function(n, digits) {
var s = n.toString();
while (s.length < digits) {
s = '0' + s;
}
return s;
}
return formatDigits(time.hours, 2) + ':' + formatDigits(time.minutes, 2);
}
};
function MinecraftTimeOfDay(element) { this.element = element; }
MinecraftTimeOfDay.prototype = {
element: null,

View file

@ -69,6 +69,14 @@ a, a:visited, label {
border: 0px;
}
.clock {
padding-left: 16px;
color: #dede90;
background-repeat: no-repeat;
}
.clock.night { background-image: url(clock_night.png); }
.clock.day { background-image: url(clock_day.png); }
.compass {
background-repeat: no-repeat;
background-image: url(compass.png);