-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreloj.html
192 lines (156 loc) · 6.58 KB
/
reloj.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="reloj.css">
</head>
<body>
<div id="content">
<div id="hours1" class="rueda">
<div class="card c0">0</div>
<div class="card c1">1</div>
<div class="card c2">2</div>
<div class="card c3"></div>
<div class="card c4"></div>
<div class="card c5"></div>
<div class="card c6"></div>
<div class="card c7"></div>
<div class="card c8"></div>
<div class="card c9"></div>
</div>
<div id="hours2" class="rueda">
<div class="card c0">0</div>
<div class="card c1">1</div>
<div class="card c2">2</div>
<div class="card c3">3</div>
<div class="card c4">4</div>
<div class="card c5">5</div>
<div class="card c6">6</div>
<div class="card c7">7</div>
<div class="card c8">8</div>
<div class="card c9">9</div>
</div>
<div id="minutes1" class="rueda">
<div class="card c0">0</div>
<div class="card c1">1</div>
<div class="card c2">2</div>
<div class="card c3">3</div>
<div class="card c4">4</div>
<div class="card c5">5</div>
<div class="card c6"></div>
<div class="card c7"></div>
<div class="card c8"></div>
<div class="card c9"></div>
</div>
<div id="minutes2" class="rueda">
<div class="card c0">0</div>
<div class="card c1">1</div>
<div class="card c2">2</div>
<div class="card c3">3</div>
<div class="card c4">4</div>
<div class="card c5">5</div>
<div class="card c6">6</div>
<div class="card c7">7</div>
<div class="card c8">8</div>
<div class="card c9">9</div>
</div>
<div id="seconds1" class="rueda">
<div class="card c0">0</div>
<div class="card c1">1</div>
<div class="card c2">2</div>
<div class="card c3">3</div>
<div class="card c4">4</div>
<div class="card c5">5</div>
<div class="card c6"></div>
<div class="card c7"></div>
<div class="card c8"></div>
<div class="card c9"></div>
</div>
<div id="seconds2" class="rueda">
<div class="card c0">0</div>
<div class="card c1">1</div>
<div class="card c2">2</div>
<div class="card c3">3</div>
<div class="card c4">4</div>
<div class="card c5">5</div>
<div class="card c6">6</div>
<div class="card c7">7</div>
<div class="card c8">8</div>
<div class="card c9">9</div>
</div>
</div>
<script>
/*function llenarRueda(rueda, inicio, limite)
{
var ruedaReloj = document.getElementById(rueda);
cadena = "";
for (i = inicio; i<10; i++){
cadena = cadena + "<div class='card c" + i + "'>"
if (i <= limite) cadena = cadena + i
cadena = cadena + "</div>";
}
for (i = 0; i<inicio; i++){
cadena = cadena + "<div class='card c" + i + "'>"
if (i <= limite) cadena = cadena + i
cadena = cadena + "</div>";
}
//alert(cadena)
ruedaReloj.innerHTML = cadena;
}
//llenarRueda("minuto1",0,5);
var time = new Date();
var horas1 = time.getHours();
while (horas1 %10 != 0) horas1--;
horas1 = horas1 / 10;
llenarRueda("hours1", horas1, 2);
var horas2 = time.getHours();
horas2 = horas2 - (horas1*10);
llenarRueda("hours2", horas2, 9);
var minutes1 = time.getMinutes();
while (minutes1 %10 != 0) minutes1--;
minutes1 = minutes1 / 10;
llenarRueda("minutes1", minutes1, 5);
var minutes2 = time.getMinutes();
minutes2 = minutes2 - (minutes1*10);
llenarRueda("minutes2", minutes2, 9);
var seconds1 = time.getSeconds();
while (seconds1 %10 != 0) seconds1--;
seconds1 = seconds1 / 10;
llenarRueda("seconds1", seconds1, 5);
var seconds2 = time.getSeconds();
seconds2 = seconds2 - (seconds1*10);
llenarRueda("seconds2", seconds2, 9);
*/
function setRotation(el, ang){
var webkitTransform = document.getElementById(el).style.webkitTransform;
var current_angle = parseInt(webkitTransform.match(/\d+/));
webkitTransform ? current_angle = parseInt(webkitTransform.match(/\d+/)) : current_angle = 0;
var rotations = Math.floor(current_angle/360);
if ((current_angle-360*rotations) != ang) {
var new_angle;
ang == 0 ? new_angle = 360 * (rotations+1) : new_angle = 360 * rotations + ang;
document.getElementById(el).style.webkitTransform = "rotateX(-" + new_angle + "deg)";
}
}
function tickToc(){
var today = new Date();
var seconds1 = Math.floor(today.getSeconds()/10);
var seconds2 = today.getSeconds() % 10;
var minutes1 = Math.floor(today.getMinutes()/10);
var minutes2 = today.getMinutes() % 10;
var hours1 = Math.floor(today.getHours()/10);
var hours2 = today.getHours() % 10;
setRotation("hours1", (hours1 * 36));
setRotation("hours2", (hours2 * 36));
setRotation("minutes1", (minutes1 * 36));
setRotation("minutes2", (minutes2 * 36));
setRotation("seconds1", (seconds1 * 36));
setRotation("seconds2", (seconds2 * 36));
setTimeout("tickToc()", 1000);
}
tickToc();
</script>
</body>
</html>