diff options
author | JinweiClarkChao <[email protected]> | 2014-09-23 22:34:14 +0800 |
---|---|---|
committer | Jinwei Zhao <[email protected]> | 2017-01-13 15:07:44 +0800 |
commit | b214f38d2c24a890ce36512a0c8bab965e27a508 (patch) | |
tree | 1522b651444407cbf120798e79be4657f1b472ab /Back/Blocks/time/script.js | |
parent | e13882d1656b143533cec307a19425e0a56ec999 (diff) | |
download | jinwei.me-b214f38d2c24a890ce36512a0c8bab965e27a508.tar.gz |
README
Diffstat (limited to 'Back/Blocks/time/script.js')
-rw-r--r-- | Back/Blocks/time/script.js | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/Back/Blocks/time/script.js b/Back/Blocks/time/script.js deleted file mode 100644 index fb8ba69..0000000 --- a/Back/Blocks/time/script.js +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | |||
2 | var 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 | ||