timepiece 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c284c38dfc4fe85d07c377331bf1ea408ad94e4
4
- data.tar.gz: dd2a1147e6282d3d33a37b935ffbad905e05103d
3
+ metadata.gz: 3a37bf25526114eabdd9bb6b6e1c908f638ed38c
4
+ data.tar.gz: 602b85542bd34b8cf8df335174ec67318f64e346
5
5
  SHA512:
6
- metadata.gz: 1d56c89c9d07baa6ae0d766474b4b3d1219340ea9cc521087262b6ce9a990000757bc5958f40e67a0c9416853753a983cf59a547f3483acced6f1dd1c6865dce
7
- data.tar.gz: 154f1bf10371014913e8f77af520307a5687361c2181cfce72d05687576f73e196369619b5f7795abe3b7eefb3204bfba3d5c5c33c3d89cd94316c8be6449f3f
6
+ metadata.gz: 2b25392445fbdb28953eb96c7736126ddb212aaec2e929b91abb1175b5be3cc3b936e172f0d6e58d7ebd41a2c4a52973c6d59ffb3d3b4b2aacdb73fcf8626645
7
+ data.tar.gz: 2c3f2bb8bccadb4b054a0adab7e773ea4dade88092a4b6b6cc347664e234d9947350924628a92b10fb2378f968a664e9cc8ca3faaf7e510228df0c51a4b3a78e
@@ -1,389 +1,391 @@
1
- get_analog_hours = []
2
- get_analog_minutes = []
3
- get_analog_seconds = []
1
+ (function($){
2
+ get_analog_hours = []
3
+ get_analog_minutes = []
4
+ get_analog_seconds = []
4
5
 
5
- function get_analog(){
6
- var zones = []
7
- $(".timepiece-analog").each(function(){ zones.push($(this).attr('data-timezone')) })
8
- var timezones = { 'timezones' : zones }
9
- $.ajax({ type: "POST", url: "/timepiece/clock.json", data: timezones, dataType: "json", cache: false }).success(function(time){
10
- for(var i = 0; i < time.length; i++){
11
- get_analog_hours.push(parseInt(time[i].hours,10))
12
- get_analog_minutes.push(parseInt(time[i].minutes,10))
13
- get_analog_seconds.push(parseInt(time[i].seconds,10))
14
- }
15
- analog_hours = get_analog_hours
16
- analog_minutes = get_analog_minutes
17
- analog_seconds = get_analog_seconds
18
- });
19
- }
6
+ function get_analog(){
7
+ var zones = []
8
+ $(".timepiece-analog").each(function(){ zones.push($(this).attr('data-timezone')) })
9
+ var timezones = { 'timezones' : zones }
10
+ $.ajax({ type: "POST", url: "/timepiece/clock.json", data: timezones, dataType: "json", cache: false }).success(function(time){
11
+ for(var i = 0; i < time.length; i++){
12
+ get_analog_hours.push(parseInt(time[i].hours,10))
13
+ get_analog_minutes.push(parseInt(time[i].minutes,10))
14
+ get_analog_seconds.push(parseInt(time[i].seconds,10))
15
+ }
16
+ analog_hours = get_analog_hours
17
+ analog_minutes = get_analog_minutes
18
+ analog_seconds = get_analog_seconds
19
+ });
20
+ }
20
21
 
21
- function show_analog(){
22
- analog = setInterval(function(){
23
- analog_running = true;
24
- for(i = 0; i < analog_hours.length; i++){
25
- if (analog_seconds[i] < 59){
26
- analog_seconds[i] += 1
27
- } else {
28
- analog_seconds[i] = 0
29
- if (analog_minutes[i] < 59){
30
- analog_minutes[i] += 1
22
+ function show_analog(){
23
+ analog = setInterval(function(){
24
+ analog_running = true;
25
+ for(i = 0; i < analog_hours.length; i++){
26
+ if (analog_seconds[i] < 59){
27
+ analog_seconds[i] += 1
31
28
  } else {
32
- analog_minutes[i] = 0
33
- if (analog_hours[i] < 23){
34
- analog_hours[i] += 1
29
+ analog_seconds[i] = 0
30
+ if (analog_minutes[i] < 59){
31
+ analog_minutes[i] += 1
35
32
  } else {
36
- analog_hours[i] = 0
33
+ analog_minutes[i] = 0
34
+ if (analog_hours[i] < 23){
35
+ analog_hours[i] += 1
36
+ } else {
37
+ analog_hours[i] = 0
38
+ }
37
39
  }
38
40
  }
39
41
  }
40
- }
41
- $(".timepiece-analog").each(function(i, e){
42
- if(analog_hours[i] >= 6 && analog_hours[i] < 18){
43
- $(e).addClass('timepiece-analog-day')
44
- $(e).removeClass('timepiece-analog-night')
45
- }else{
46
- $(e).addClass('timepiece-analog-night')
47
- $(e).removeClass('timepiece-analog-day')
48
- }
49
- $(e).html(function(){
50
- if(analog_hours[i] > 12){
51
- $(e).data('analog_hours', analog_hours[i] - 12)
52
- }else if(analog_hours[i] == 0){
53
- $(e).data('analog_hours', 12)
54
- }else if(analog_hours[i] == 12){
55
- $(e).data('analog_hours', 12)
56
- }else if(analog_hours[i] < 12){
57
- $(e).data('analog_hours', analog_hours[i])
42
+ $(".timepiece-analog").each(function(i, e){
43
+ if(analog_hours[i] >= 6 && analog_hours[i] < 18){
44
+ $(e).addClass('timepiece-analog-day')
45
+ $(e).removeClass('timepiece-analog-night')
46
+ }else{
47
+ $(e).addClass('timepiece-analog-night')
48
+ $(e).removeClass('timepiece-analog-day')
58
49
  }
59
- $(e).data('hours_angle', ($(e).data('analog_hours') * 30) + (analog_minutes[i] / 2));
60
- $(e).data('minutes_angle', analog_minutes[i] * 6);
61
- $(e).data('seconds_angle', analog_seconds[i] * 6);
62
- $('.timepiece-hours-container', $(e)).css({'-ms-transform':'rotateZ(' + $(e).data('hours_angle') + 'deg)','-webkit-transform':'rotateZ(' + $(e).data('hours_angle') + 'deg)','transform':'rotateZ(' + $(e).data('hours_angle') + 'deg)'}); // angle set on each
63
- $('.timepiece-minutes-container', $(e)).css({'-ms-transform':'rotateZ(' + $(e).data('minutes_angle') + 'deg)','-webkit-transform':'rotateZ(' + $(e).data('minutes_angle') + 'deg)','transform':'rotateZ(' + $(e).data('minutes_angle') + 'deg)'});
64
- $('.timepiece-seconds-container', $(e)).css({'-ms-transform':'rotateZ(' + $(e).data('seconds_angle') + 'deg)','-webkit-transform':'rotateZ(' + $(e).data('seconds_angle') + 'deg)','transform':'rotateZ(' + $(e).data('seconds_angle') + 'deg)'});
50
+ $(e).html(function(){
51
+ if(analog_hours[i] > 12){
52
+ $(e).data('analog_hours', analog_hours[i] - 12)
53
+ }else if(analog_hours[i] == 0){
54
+ $(e).data('analog_hours', 12)
55
+ }else if(analog_hours[i] == 12){
56
+ $(e).data('analog_hours', 12)
57
+ }else if(analog_hours[i] < 12){
58
+ $(e).data('analog_hours', analog_hours[i])
59
+ }
60
+ $(e).data('hours_angle', ($(e).data('analog_hours') * 30) + (analog_minutes[i] / 2));
61
+ $(e).data('minutes_angle', analog_minutes[i] * 6);
62
+ $(e).data('seconds_angle', analog_seconds[i] * 6);
63
+ $('.timepiece-hours-container', $(e)).css({'-ms-transform':'rotateZ(' + $(e).data('hours_angle') + 'deg)','-webkit-transform':'rotateZ(' + $(e).data('hours_angle') + 'deg)','transform':'rotateZ(' + $(e).data('hours_angle') + 'deg)'}); // angle set on each
64
+ $('.timepiece-minutes-container', $(e)).css({'-ms-transform':'rotateZ(' + $(e).data('minutes_angle') + 'deg)','-webkit-transform':'rotateZ(' + $(e).data('minutes_angle') + 'deg)','transform':'rotateZ(' + $(e).data('minutes_angle') + 'deg)'});
65
+ $('.timepiece-seconds-container', $(e)).css({'-ms-transform':'rotateZ(' + $(e).data('seconds_angle') + 'deg)','-webkit-transform':'rotateZ(' + $(e).data('seconds_angle') + 'deg)','transform':'rotateZ(' + $(e).data('seconds_angle') + 'deg)'});
66
+ })
65
67
  })
66
- })
67
- }, 1000)
68
- }
68
+ }, 1000)
69
+ }
69
70
 
70
- get_hours = []
71
- get_minutes = []
72
- get_seconds = []
71
+ get_hours = []
72
+ get_minutes = []
73
+ get_seconds = []
73
74
 
74
- function get_time(){
75
- var zones = []
76
- $(".timepiece").each(function(){ zones.push($(this).attr('data-timezone')) })
77
- var timezones = { 'timezones' : zones }
78
- $.ajax({ type: "POST", url: "/timepiece/clock.json", data: timezones, dataType: "json", cache: false }).success(function(time){
79
- for(var i = 0; i < time.length; i++){
80
- get_hours.push(parseInt(time[i].hours,10))
81
- get_minutes.push(parseInt(time[i].minutes,10))
82
- get_seconds.push(parseInt(time[i].seconds,10))
83
- }
84
- hours = get_hours
85
- minutes = get_minutes
86
- seconds = get_seconds
87
- });
88
- }
75
+ function get_time(){
76
+ var zones = []
77
+ $(".timepiece").each(function(){ zones.push($(this).attr('data-timezone')) })
78
+ var timezones = { 'timezones' : zones }
79
+ $.ajax({ type: "POST", url: "/timepiece/clock.json", data: timezones, dataType: "json", cache: false }).success(function(time){
80
+ for(var i = 0; i < time.length; i++){
81
+ get_hours.push(parseInt(time[i].hours,10))
82
+ get_minutes.push(parseInt(time[i].minutes,10))
83
+ get_seconds.push(parseInt(time[i].seconds,10))
84
+ }
85
+ hours = get_hours
86
+ minutes = get_minutes
87
+ seconds = get_seconds
88
+ });
89
+ }
89
90
 
90
- function show_time(){
91
- clock = setInterval(function(){
92
- clock_running = true;
93
- for(i = 0; i < hours.length; i++){
94
- if (seconds[i] < 59){
95
- seconds[i] += 1
96
- } else {
97
- seconds[i] = 0
98
- if (minutes[i] < 59){
99
- minutes[i] += 1
100
- } else {
101
- minutes[i] = 0
102
- if (hours[i] < 23){
103
- hours[i] += 1
104
- } else {
105
- hours[i] = 0
106
- }
107
- }
108
- }
109
- }
110
- $(".timepiece").each(function(i, e){
111
- $(e).html(function(){
112
- if($(e).attr("data-tptype") == '12'){
113
- if(hours[i] > 12){
114
- $(e).data('hours', hours[i] - 12)
115
- abbr = 'pm'
116
- }else if(hours[i] == 0){
117
- $(e).data('hours', 12)
118
- abbr = 'am'
119
- }else if(hours[i] == 12){
120
- $(e).data('hours', 12)
121
- abbr = 'pm'
122
- }else if(hours[i] < 12){
123
- $(e).data('hours', hours[i])
124
- abbr = 'am'
125
- }
126
- if($(e).attr("data-abbr_separator") == '.'){
127
- abbr = abbr.replace(/([apm])/g, '$1.')
128
- }
129
- if($(e).attr("data-lead") == '0' || $(e).attr("data-lead") == 'zero' ){
130
- $('.timepiece-hours', $(e)).html(( $(e).data('hours') < 10 ? "0" : "" ) + $(e).data('hours'));
131
- }else if($(e).attr("data-lead") == '_' || $(e).attr("data-lead") == 'space' ){
132
- $('.timepiece-hours', $(e)).html(( $(e).data('hours') < 10 ? "&#8199;" : "" ) + $(e).data('hours'));
133
- }else{
134
- $('.timepiece-hours', $(e)).html($(e).data('hours'));
135
- }
136
- $('.timepiece-minutes', $(e)).html(( minutes[i] < 10 ? "0" : "" ) + minutes[i]);
137
- $('.timepiece-seconds', $(e)).html(( seconds[i] < 10 ? "0" : "" ) + seconds[i]);
138
- $('.timepiece-abbr', $(e)).html(abbr);
139
- if(abbr == 'am'){
140
- $('.timepiece-abbr', $(e)).removeClass('timepiece-abbr-pm');
141
- $('.timepiece-abbr', $(e)).addClass('timepiece-abbr-am');
142
- } else {
143
- $('.timepiece-abbr', $(e)).removeClass('timepiece-abbr-am');
144
- $('.timepiece-abbr', $(e)).addClass('timepiece-abbr-pm');
145
- }
146
- }else{
147
- $('.timepiece-hours', $(e)).html(( hours[i] < 10 ? "0" : "" ) + hours[i]);
148
- $('.timepiece-minutes', $(e)).html(( minutes[i] < 10 ? "0" : "" ) + minutes[i]);
149
- $('.timepiece-seconds', $(e)).html(( seconds[i] < 10 ? "0" : "" ) + seconds[i]);
150
- }
151
- })
152
- })
153
- }, 1000)
154
- }
91
+ function show_time(){
92
+ clock = setInterval(function(){
93
+ clock_running = true;
94
+ for(i = 0; i < hours.length; i++){
95
+ if (seconds[i] < 59){
96
+ seconds[i] += 1
97
+ } else {
98
+ seconds[i] = 0
99
+ if (minutes[i] < 59){
100
+ minutes[i] += 1
101
+ } else {
102
+ minutes[i] = 0
103
+ if (hours[i] < 23){
104
+ hours[i] += 1
105
+ } else {
106
+ hours[i] = 0
107
+ }
108
+ }
109
+ }
110
+ }
111
+ $(".timepiece").each(function(i, e){
112
+ $(e).html(function(){
113
+ if($(e).attr("data-tptype") == '12'){
114
+ if(hours[i] > 12){
115
+ $(e).data('hours', hours[i] - 12)
116
+ abbr = 'pm'
117
+ }else if(hours[i] == 0){
118
+ $(e).data('hours', 12)
119
+ abbr = 'am'
120
+ }else if(hours[i] == 12){
121
+ $(e).data('hours', 12)
122
+ abbr = 'pm'
123
+ }else if(hours[i] < 12){
124
+ $(e).data('hours', hours[i])
125
+ abbr = 'am'
126
+ }
127
+ if($(e).attr("data-abbr_separator") == '.'){
128
+ abbr = abbr.replace(/([apm])/g, '$1.')
129
+ }
130
+ if($(e).attr("data-lead") == '0' || $(e).attr("data-lead") == 'zero' ){
131
+ $('.timepiece-hours', $(e)).html(( $(e).data('hours') < 10 ? "0" : "" ) + $(e).data('hours'));
132
+ }else if($(e).attr("data-lead") == '_' || $(e).attr("data-lead") == 'space' ){
133
+ $('.timepiece-hours', $(e)).html(( $(e).data('hours') < 10 ? "&#8199;" : "" ) + $(e).data('hours'));
134
+ }else{
135
+ $('.timepiece-hours', $(e)).html($(e).data('hours'));
136
+ }
137
+ $('.timepiece-minutes', $(e)).html(( minutes[i] < 10 ? "0" : "" ) + minutes[i]);
138
+ $('.timepiece-seconds', $(e)).html(( seconds[i] < 10 ? "0" : "" ) + seconds[i]);
139
+ $('.timepiece-abbr', $(e)).html(abbr);
140
+ if(abbr == 'am'){
141
+ $('.timepiece-abbr', $(e)).removeClass('timepiece-abbr-pm');
142
+ $('.timepiece-abbr', $(e)).addClass('timepiece-abbr-am');
143
+ } else {
144
+ $('.timepiece-abbr', $(e)).removeClass('timepiece-abbr-am');
145
+ $('.timepiece-abbr', $(e)).addClass('timepiece-abbr-pm');
146
+ }
147
+ }else{
148
+ $('.timepiece-hours', $(e)).html(( hours[i] < 10 ? "0" : "" ) + hours[i]);
149
+ $('.timepiece-minutes', $(e)).html(( minutes[i] < 10 ? "0" : "" ) + minutes[i]);
150
+ $('.timepiece-seconds', $(e)).html(( seconds[i] < 10 ? "0" : "" ) + seconds[i]);
151
+ }
152
+ })
153
+ })
154
+ }, 1000)
155
+ }
155
156
 
156
- get_timer_days = []
157
- get_timer_hours = []
158
- get_timer_minutes = []
159
- get_timer_seconds = []
157
+ get_timer_days = []
158
+ get_timer_hours = []
159
+ get_timer_minutes = []
160
+ get_timer_seconds = []
160
161
 
161
- function set_timer(){
162
- $(".timepiece-timer").each(function(){
163
- get_timer_days.push(parseInt($(this).attr('data-days'),10))
164
- get_timer_hours.push(parseInt($(this).attr('data-hours'),10))
165
- get_timer_minutes.push(parseInt($(this).attr('data-minutes'),10))
166
- get_timer_seconds.push(parseInt($(this).attr('data-seconds'),10))
167
- timer_days = get_timer_days
168
- timer_hours = get_timer_hours
169
- timer_minutes = get_timer_minutes
170
- timer_seconds = get_timer_seconds
171
- });
172
- }
162
+ function set_timer(){
163
+ $(".timepiece-timer").each(function(){
164
+ get_timer_days.push(parseInt($(this).attr('data-days'),10))
165
+ get_timer_hours.push(parseInt($(this).attr('data-hours'),10))
166
+ get_timer_minutes.push(parseInt($(this).attr('data-minutes'),10))
167
+ get_timer_seconds.push(parseInt($(this).attr('data-seconds'),10))
168
+ timer_days = get_timer_days
169
+ timer_hours = get_timer_hours
170
+ timer_minutes = get_timer_minutes
171
+ timer_seconds = get_timer_seconds
172
+ });
173
+ }
173
174
 
174
- function show_timer(){
175
- timer = setInterval(function(){
176
- timer_running = true;
177
- for(i = 0; i < timer_hours.length; i++){
178
- if (timer_seconds[i] < 59){
179
- timer_seconds[i] += 1
180
- } else {
181
- timer_seconds[i] = 0
182
- if (timer_minutes[i] < 59){
183
- timer_minutes[i] += 1
175
+ function show_timer(){
176
+ timer = setInterval(function(){
177
+ timer_running = true;
178
+ for(i = 0; i < timer_hours.length; i++){
179
+ if (timer_seconds[i] < 59){
180
+ timer_seconds[i] += 1
184
181
  } else {
185
- timer_minutes[i] = 0
186
- if (timer_hours[i] < 23){
187
- timer_hours[i] += 1
182
+ timer_seconds[i] = 0
183
+ if (timer_minutes[i] < 59){
184
+ timer_minutes[i] += 1
188
185
  } else {
189
- timer_hours[i] = 0
190
- timer_days[i] += 1
186
+ timer_minutes[i] = 0
187
+ if (timer_hours[i] < 23){
188
+ timer_hours[i] += 1
189
+ } else {
190
+ timer_hours[i] = 0
191
+ timer_days[i] += 1
192
+ }
191
193
  }
192
194
  }
193
195
  }
194
- }
195
- $(".timepiece-timer").each(function(i, e){
196
- $(e).html(function(){
197
- $('.timepiece-days', $(e)).html(timer_days[i]);
198
- if (timer_days[i] == 1){
199
- $('.tp-descriptor-days', $(e)).html('&nbsp;day ');
200
- } else {
201
- $('.tp-descriptor-days', $(e)).html('&nbsp;days ');
202
- }
203
- $('.timepiece-hours', $(e)).html(timer_hours[i]);
204
- if (timer_hours[i] == 1){
205
- $('.tp-descriptor-hours', $(e)).html('&nbsp;hour ');
206
- } else {
207
- $('.tp-descriptor-hours', $(e)).html('&nbsp;hours ');
208
- }
209
- $('.timepiece-minutes', $(e)).html(timer_minutes[i]);
210
- if (timer_minutes[i] == 1){
211
- $('.tp-descriptor-minutes', $(e)).html('&nbsp;minute ');
212
- } else {
213
- $('.tp-descriptor-minutes', $(e)).html('&nbsp;minutes ');
214
- }
215
- $('.timepiece-seconds', $(e)).html(timer_seconds[i]);
216
- if (timer_seconds[i] == 1){
217
- $('.tp-descriptor-seconds', $(e)).html('&nbsp;second ');
218
- } else {
219
- $('.tp-descriptor-seconds', $(e)).html('&nbsp;seconds ');
220
- }
196
+ $(".timepiece-timer").each(function(i, e){
197
+ $(e).html(function(){
198
+ $('.timepiece-days', $(e)).html(timer_days[i]);
199
+ if (timer_days[i] == 1){
200
+ $('.tp-descriptor-days', $(e)).html('&nbsp;day ');
201
+ } else {
202
+ $('.tp-descriptor-days', $(e)).html('&nbsp;days ');
203
+ }
204
+ $('.timepiece-hours', $(e)).html(timer_hours[i]);
205
+ if (timer_hours[i] == 1){
206
+ $('.tp-descriptor-hours', $(e)).html('&nbsp;hour ');
207
+ } else {
208
+ $('.tp-descriptor-hours', $(e)).html('&nbsp;hours ');
209
+ }
210
+ $('.timepiece-minutes', $(e)).html(timer_minutes[i]);
211
+ if (timer_minutes[i] == 1){
212
+ $('.tp-descriptor-minutes', $(e)).html('&nbsp;minute ');
213
+ } else {
214
+ $('.tp-descriptor-minutes', $(e)).html('&nbsp;minutes ');
215
+ }
216
+ $('.timepiece-seconds', $(e)).html(timer_seconds[i]);
217
+ if (timer_seconds[i] == 1){
218
+ $('.tp-descriptor-seconds', $(e)).html('&nbsp;second ');
219
+ } else {
220
+ $('.tp-descriptor-seconds', $(e)).html('&nbsp;seconds ');
221
+ }
222
+ })
221
223
  })
222
- })
223
- }, 1000)
224
- }
224
+ }, 1000)
225
+ }
225
226
 
226
- get_countdown_days = []
227
- get_countdown_hours = []
228
- get_countdown_minutes = []
229
- get_countdown_seconds = []
227
+ get_countdown_days = []
228
+ get_countdown_hours = []
229
+ get_countdown_minutes = []
230
+ get_countdown_seconds = []
230
231
 
231
- function set_countdown(){
232
- $(".timepiece-countdown").each(function(){
233
- get_countdown_days.push(parseInt($(this).attr('data-days'),10))
234
- get_countdown_hours.push(parseInt($(this).attr('data-hours'),10))
235
- get_countdown_minutes.push(parseInt($(this).attr('data-minutes'),10))
236
- get_countdown_seconds.push(parseInt($(this).attr('data-seconds'),10))
237
- countdown_days = get_countdown_days
238
- countdown_hours = get_countdown_hours
239
- countdown_minutes = get_countdown_minutes
240
- countdown_seconds = get_countdown_seconds
241
- });
242
- }
232
+ function set_countdown(){
233
+ $(".timepiece-countdown").each(function(){
234
+ get_countdown_days.push(parseInt($(this).attr('data-days'),10))
235
+ get_countdown_hours.push(parseInt($(this).attr('data-hours'),10))
236
+ get_countdown_minutes.push(parseInt($(this).attr('data-minutes'),10))
237
+ get_countdown_seconds.push(parseInt($(this).attr('data-seconds'),10))
238
+ countdown_days = get_countdown_days
239
+ countdown_hours = get_countdown_hours
240
+ countdown_minutes = get_countdown_minutes
241
+ countdown_seconds = get_countdown_seconds
242
+ });
243
+ }
243
244
 
244
- function show_countdown(){
245
- countdown = setInterval(function(){
246
- countdown_running = true;
247
- for(i = 0; i < countdown_hours.length; i++){
248
- if (countdown_seconds[i] > 0){
249
- countdown_seconds[i] -= 1
250
- } else {
251
- countdown_seconds[i] = 59
252
- if (countdown_minutes[i] > 0){
253
- countdown_minutes[i] -= 1
245
+ function show_countdown(){
246
+ countdown = setInterval(function(){
247
+ countdown_running = true;
248
+ for(i = 0; i < countdown_hours.length; i++){
249
+ if (countdown_seconds[i] > 0){
250
+ countdown_seconds[i] -= 1
254
251
  } else {
255
- countdown_minutes[i] = 59
256
- if (countdown_hours[i] > 0){
257
- countdown_hours[i] -= 1
252
+ countdown_seconds[i] = 59
253
+ if (countdown_minutes[i] > 0){
254
+ countdown_minutes[i] -= 1
258
255
  } else {
259
- countdown_hours[i] = 23
260
- if (countdown_days[i] > 0){
261
- countdown_days[i] -= 1
256
+ countdown_minutes[i] = 59
257
+ if (countdown_hours[i] > 0){
258
+ countdown_hours[i] -= 1
262
259
  } else {
263
- countdown_days[i] = 0
264
- countdown_hours[i] = 0
265
- countdown_minutes[i] = 0
266
- countdown_seconds[i] = 0
260
+ countdown_hours[i] = 23
261
+ if (countdown_days[i] > 0){
262
+ countdown_days[i] -= 1
263
+ } else {
264
+ countdown_days[i] = 0
265
+ countdown_hours[i] = 0
266
+ countdown_minutes[i] = 0
267
+ countdown_seconds[i] = 0
268
+ }
267
269
  }
268
270
  }
269
271
  }
270
272
  }
271
- }
272
- $(".timepiece-countdown").each(function(i, e){
273
- $(e).html(function(){
274
- $('.timepiece-days', $(e)).html(countdown_days[i]);
275
- if (countdown_days[i] == 1){
276
- $('.tp-descriptor-days', $(e)).html('&nbsp;day ');
277
- } else {
278
- $('.tp-descriptor-days', $(e)).html('&nbsp;days ');
279
- }
280
- $('.timepiece-hours', $(e)).html(countdown_hours[i]);
281
- if (countdown_hours[i] == 1){
282
- $('.tp-descriptor-hours', $(e)).html('&nbsp;hour ');
283
- } else {
284
- $('.tp-descriptor-hours', $(e)).html('&nbsp;hours ');
285
- }
286
- $('.timepiece-minutes', $(e)).html(countdown_minutes[i]);
287
- if (countdown_minutes[i] == 1){
288
- $('.tp-descriptor-minutes', $(e)).html('&nbsp;minute ');
289
- } else {
290
- $('.tp-descriptor-minutes', $(e)).html('&nbsp;minutes ');
291
- }
292
- $('.timepiece-seconds', $(e)).html(countdown_seconds[i]);
293
- if (countdown_seconds[i] == 1){
294
- $('.tp-descriptor-seconds', $(e)).html('&nbsp;second ');
295
- } else {
296
- $('.tp-descriptor-seconds', $(e)).html('&nbsp;seconds ');
297
- }
273
+ $(".timepiece-countdown").each(function(i, e){
274
+ $(e).html(function(){
275
+ $('.timepiece-days', $(e)).html(countdown_days[i]);
276
+ if (countdown_days[i] == 1){
277
+ $('.tp-descriptor-days', $(e)).html('&nbsp;day ');
278
+ } else {
279
+ $('.tp-descriptor-days', $(e)).html('&nbsp;days ');
280
+ }
281
+ $('.timepiece-hours', $(e)).html(countdown_hours[i]);
282
+ if (countdown_hours[i] == 1){
283
+ $('.tp-descriptor-hours', $(e)).html('&nbsp;hour ');
284
+ } else {
285
+ $('.tp-descriptor-hours', $(e)).html('&nbsp;hours ');
286
+ }
287
+ $('.timepiece-minutes', $(e)).html(countdown_minutes[i]);
288
+ if (countdown_minutes[i] == 1){
289
+ $('.tp-descriptor-minutes', $(e)).html('&nbsp;minute ');
290
+ } else {
291
+ $('.tp-descriptor-minutes', $(e)).html('&nbsp;minutes ');
292
+ }
293
+ $('.timepiece-seconds', $(e)).html(countdown_seconds[i]);
294
+ if (countdown_seconds[i] == 1){
295
+ $('.tp-descriptor-seconds', $(e)).html('&nbsp;second ');
296
+ } else {
297
+ $('.tp-descriptor-seconds', $(e)).html('&nbsp;seconds ');
298
+ }
299
+ })
298
300
  })
299
- })
300
- }, 1000)
301
- }
302
-
303
- function reset_analog(){
304
- get_analog_hours = []
305
- get_analog_minutes = []
306
- get_analog_seconds = []
307
- get_analog()
308
- }
309
-
310
- function reset_time(){
311
- get_hours = []
312
- get_minutes = []
313
- get_seconds = []
314
- get_time()
315
- }
316
-
317
- function reset_timer(){
318
- get_timer_days = []
319
- get_timer_hours = []
320
- get_timer_minutes = []
321
- get_timer_seconds = []
322
- set_timer()
323
- }
324
-
325
- function reset_countdown(){
326
- get_countdown_days = []
327
- get_countdown_hours = []
328
- get_countdown_minutes = []
329
- get_countdown_seconds = []
330
- set_countdown()
331
- }
332
-
333
- /* Let's discuss when those functions will be performed. */
301
+ }, 1000)
302
+ }
334
303
 
335
- $(document).ready(function(){
336
- // Might want to reformat to move if-statement : should also be performed before 'reset_time' so as not to make a blank AJAX request.
337
- if ($(".timepiece-analog").length > 0){
304
+ function reset_analog(){
305
+ get_analog_hours = []
306
+ get_analog_minutes = []
307
+ get_analog_seconds = []
338
308
  get_analog()
339
- show_analog()
340
309
  }
341
- if ($(".timepiece").length > 0){
342
- get_time()
343
- show_time()
310
+
311
+ function reset_time(){
312
+ get_hours = []
313
+ get_minutes = []
314
+ get_seconds = []
315
+ get_time()
344
316
  }
345
- if ($(".timepiece-timer").length > 0){
317
+
318
+ function reset_timer(){
319
+ get_timer_days = []
320
+ get_timer_hours = []
321
+ get_timer_minutes = []
322
+ get_timer_seconds = []
346
323
  set_timer()
347
- show_timer()
348
324
  }
349
- if ($(".timepiece-countdown").length > 0){
325
+
326
+ function reset_countdown(){
327
+ get_countdown_days = []
328
+ get_countdown_hours = []
329
+ get_countdown_minutes = []
330
+ get_countdown_seconds = []
350
331
  set_countdown()
351
- show_countdown()
352
332
  }
353
- })
354
- $(document).on('page:load', function(){
355
- if ($(".timepiece-analog").length > 0){
356
- if (analog_running){
357
- clearInterval(analog);
333
+
334
+ /* Let's discuss when those functions will be performed. */
335
+
336
+ $(document).ready(function(){
337
+ // Might want to reformat to move if-statement : should also be performed before 'reset_time' so as not to make a blank AJAX request.
338
+ if ($(".timepiece-analog").length > 0){
339
+ get_analog()
340
+ show_analog()
358
341
  }
359
- reset_analog();
360
- }
361
- if ($(".timepiece").length > 0){
362
- if (clock_running){
363
- clearInterval(clock);
342
+ if ($(".timepiece").length > 0){
343
+ get_time()
344
+ show_time()
364
345
  }
365
- reset_time();
366
- }
367
- if ($(".timepiece-timer").length > 0){
368
- if (timer_running){
369
- clearInterval(timer);
346
+ if ($(".timepiece-timer").length > 0){
347
+ set_timer()
348
+ show_timer()
370
349
  }
371
- reset_timer();
372
- // FIXME: Some code may be superfluous. We've fixed the interval glitch but we should investigate when $(document).ready is running. How much do we really need our reset functions?
373
- }
374
- if ($(".timepiece-countdown").length > 0){
375
- if (countdown_running){
376
- clearInterval(countdown);
350
+ if ($(".timepiece-countdown").length > 0){
351
+ set_countdown()
352
+ show_countdown()
377
353
  }
378
- reset_countdown();
379
- }
380
- })
354
+ })
355
+ $(document).on('page:load', function(){
356
+ if ($(".timepiece-analog").length > 0){
357
+ if (analog_running){
358
+ clearInterval(analog);
359
+ }
360
+ reset_analog();
361
+ }
362
+ if ($(".timepiece").length > 0){
363
+ if (clock_running){
364
+ clearInterval(clock);
365
+ }
366
+ reset_time();
367
+ }
368
+ if ($(".timepiece-timer").length > 0){
369
+ if (timer_running){
370
+ clearInterval(timer);
371
+ }
372
+ reset_timer();
373
+ // FIXME: Some code may be superfluous. We've fixed the interval glitch but we should investigate when $(document).ready is running. How much do we really need our reset functions?
374
+ }
375
+ if ($(".timepiece-countdown").length > 0){
376
+ if (countdown_running){
377
+ clearInterval(countdown);
378
+ }
379
+ reset_countdown();
380
+ }
381
+ })
381
382
 
382
- $(window).focus(function(){
383
- if ($(".timepiece-analog").length > 0){
384
- reset_analog()
385
- }
386
- if ($(".timepiece").length > 0){
387
- reset_time()
388
- }
389
- })
383
+ $(window).focus(function(){
384
+ if ($(".timepiece-analog").length > 0){
385
+ reset_analog()
386
+ }
387
+ if ($(".timepiece").length > 0){
388
+ reset_time()
389
+ }
390
+ })
391
+ }(jQuery));
@@ -1,3 +1,3 @@
1
1
  module Timepiece
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timepiece
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thom Bruce