From 3980ebefa110eb19224c90f5de30d44afad5da0f Mon Sep 17 00:00:00 2001 From: FrozenCow Date: Sun, 13 Feb 2011 22:56:23 +0100 Subject: [PATCH] Revert "Removed Clock" This reverts commit 9ca8f8dc64e9a28da81a538a3578c2b2a8b34c88. --- web/clock_day.png | Bin 0 -> 481 bytes web/clock_night.png | Bin 0 -> 490 bytes web/map.js | 41 +++++++++++++++++++++++++++++++++++++++++ web/style.css | 8 ++++++++ 4 files changed, 49 insertions(+) create mode 100644 web/clock_day.png create mode 100644 web/clock_night.png diff --git a/web/clock_day.png b/web/clock_day.png new file mode 100644 index 0000000000000000000000000000000000000000..1ea044b33174fe6098034006080c929c89c4646b GIT binary patch literal 481 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85sCBfH0%q>A!YBLG}_)Usv{9Jc43M3~y~OegFzdmbgZgIOpf) zrskC}I2WZRmZYXAlxLP?D7bt2281{Ai36>&@pN$vu{hm3*)Z#{fkf;4rs)Y@A6c!+ zUoA2;iL{w9DVl{zRc`hqpQSAh9%0VS>jgH5U)J>IST^~1o1Ww=?it%sI7MHnTn*Bh zZ0^Zl>%YIwlZ9>PJ5~Mj*I(-gZS9+Jz@R4VPu>5OMkg*MGV(o}CnV5j)G^(;gKzr5 z>(jFt4&43Q{$<)@wW__+k)DUIFf+bRK9(eMbp0H2pWU-fW>j}9lGWH+nalcg)9K{c zu)BGc|2U65y45wM;pvXf+hMQ&@9F1fX!w3)>OC{xsR7&#Ib6wx+cH;~_&DrZ9;3X} z?0t#egWt+?7Awq1-2BsVnruhTqWAp*ESon!_;%5<_SBSHHCtz$64)#CaC<+WTE69` zHx7RPn3kILFOvOM&F>kc!FYFF^Lq}in4dF`Fh}aF6REd2!|2ec&HP0{QC8#^Gk0q5 Viq1Fx)&m2Z!PC{xWt~$(697m1!M*?h literal 0 HcmV?d00001 diff --git a/web/clock_night.png b/web/clock_night.png new file mode 100644 index 0000000000000000000000000000000000000000..79b1af8c8cfaf6ce342eed1260050849635bea7c GIT binary patch literal 490 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85sCBfH0%q>A!YBLG}_)Usv{9Jc42>99#GNa{&rTmbgZgIOpf) zrskC}I2WZRmZYXAlxLP?D7bt2281{Ai36>2^>lFzu{hm3d4KjH2brVsO9H$!CdK|? zx4I`MYgEFq^zJWlkM`F}99E*5OS|}-j6MFbDo%Se!?mmA)T=awf6NEPG(8TN?#h1m zX|dgj0{zPQdt&x2U+6F`H1*}y_wTptdA?=Qg4f?v_g}5jVC^iB@QVPVyeJ literal 0 HcmV?d00001 diff --git a/web/map.js b/web/map.js index 4506d4aa..ab51debd 100644 --- a/web/map.js +++ b/web/map.js @@ -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 = $('
'); + 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, diff --git a/web/style.css b/web/style.css index a4bfe819..388c4c86 100644 --- a/web/style.css +++ b/web/style.css @@ -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);