aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinweiClarkChao <[email protected]>2014-08-22 17:23:02 +0800
committerJinwei Zhao <[email protected]>2017-01-13 15:07:42 +0800
commit80255411ee7040e0cebbf6b05d2ce323f6f2596e (patch)
tree295b0ef6c85e7cb091b63719ab041596879690fa /Back/Blocks/time/script.js
parent13be3d058713e1467ffc573a90cc694b80526135 (diff)
downloadjinwei.me-80255411ee7040e0cebbf6b05d2ce323f6f2596e.tar.gz
backup
Diffstat (limited to 'Back/Blocks/time/script.js')
-rw-r--r--Back/Blocks/time/script.js98
1 files changed, 98 insertions, 0 deletions
diff --git a/Back/Blocks/time/script.js b/Back/Blocks/time/script.js
new file mode 100644
index 0000000..fb8ba69
--- /dev/null
+++ b/Back/Blocks/time/script.js
@@ -0,0 +1,98 @@
1
2var update = function() {
3
4 // initialise screen
5 // selects all elements with class on and removes it
6 $('.on').removeClass("on");
7 $("#its").addClass('on');
8
9 // initialise date variables
10 current = new Date();
11 var hour = current.getHours();
12 if (hour > 12) {hour -= 12};
13 var minutes = current.getMinutes();
14
15 // set modifier
16 if (minutes < 3){
17 $("#oclock").addClass('on');
18 }else if (minutes < 33){
19 $("#past").addClass('on');
20 $("#minutes").addClass('on');
21 }else if (minutes <= 57){
22 $("#to").addClass('on');
23 $("#minutes").addClass('on');
24 hour === 12 ? hour = 1: hour += 1;
25 minutes = 60 - minutes;
26 }else{
27 $("#oclock").addClass('on');
28 hour === 12 ? hour = 1: hour += 1;
29 minutes = 60 - minutes;
30 }
31
32 //set minutes
33 if (minutes >= 3){
34 if(minutes < 7){
35 $("#fiveMod").addClass('on');
36 }else if (minutes < 13){
37 $("#tenMod").addClass('on');
38 }else if (minutes < 17){
39 $("#quarter").addClass('on');
40 $("#minutes").removeClass('on');
41 }else if (minutes < 23){
42 $("#twenty").addClass('on');
43 }else if (minutes < 27){
44 $("#twenty").addClass('on');
45 $("#fiveMod").addClass('on');
46 }else if (minutes < 33){
47 $("#half").addClass('on');
48 $("#minutes").removeClass('on');
49 }
50 }
51
52 //set hours
53 switch (hour){
54 case 1 :
55 $("#one").addClass('on');
56 break;
57 case 2 :
58 $("#two").addClass('on');
59 break;
60 case 3 :
61 $("#three").addClass('on');
62 break;
63 case 4 :
64 $("#four").addClass('on');
65 break;
66 case 5 :
67 $("#five").addClass('on');
68 break;
69 case 6 :
70 $("#six").addClass('on');
71 break;
72 case 7 :
73 $("#seven").addClass('on');
74 break;
75 case 8 :
76 $("#eight").addClass('on');
77 break;
78 case 9 :
79 $("#nine").addClass('on');
80 break;
81 case 10 :
82 $("#ten").addClass('on');
83 break;
84 case 11 :
85 $("#eleven").addClass('on');
86 break;
87 case 12 :
88 $("#twelve").addClass('on');
89 break;
90 }
91
92}
93
94// run update on load and repeat every 30 seconds afterwards
95$(document).ready(function(){
96 update();
97 setInterval(update,30000);
98}); \ No newline at end of file
Powered by cgit v1.2.3 (git 2.41.0)