T(-) Countdown - Version 2.3.18

Version Description

  • rebuilt method of keeping countdown timer in sync
  • Prevent errors when $(this) isn't an array
  • fixed bug, where timers freeze if you have more than one on a page
  • fully tested with WordPress 4.9.0
Download this release

Release Info

Developer baden03
Plugin Icon 128x128 T(-) Countdown
Version 2.3.18
Comparing to
See all releases

Code changes from version 2.3.17 to 2.3.18

Files changed (3) hide show
  1. countdown-timer.php +3 -3
  2. js/jquery.t-countdown.js +27 -19
  3. readme.txt +13 -4
countdown-timer.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: T(-) Countdown
4
  Text Domain: jquery-t-countdown-widget
5
  Plugin URI: https://plugins.twinpictures.de/plugins/t-minus-countdown/
6
  Description: Display and configure multiple T(-) Countdown timers using a shortcode or sidebar widget.
7
- Version: 2.3.17
8
  Author: twinpictures, baden03
9
  Author URI: https://www.twinpictures.de/
10
  License: GPL2
@@ -12,7 +12,7 @@ License: GPL2
12
 
13
  class WP_TMinusCD {
14
  var $plugin_name = 'T(-) Countdown';
15
- var $version = '2.3.17';
16
  var $domain = 'tminus';
17
  var $plguin_options_page_title = 'T(-) Countdown Options';
18
  var $plugin_options_menue_title = 'T(-) Countdown';
@@ -135,7 +135,7 @@ class WP_TMinusCD {
135
  $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) );
136
 
137
  //lwtCountdown script
138
- wp_register_script('countdown-script', $plugin_url.'/js/jquery.t-countdown.js', array ('jquery'), '1.5.10', 'true');
139
  wp_enqueue_script('countdown-script');
140
 
141
  //force load styles
4
  Text Domain: jquery-t-countdown-widget
5
  Plugin URI: https://plugins.twinpictures.de/plugins/t-minus-countdown/
6
  Description: Display and configure multiple T(-) Countdown timers using a shortcode or sidebar widget.
7
+ Version: 2.3.18
8
  Author: twinpictures, baden03
9
  Author URI: https://www.twinpictures.de/
10
  License: GPL2
12
 
13
  class WP_TMinusCD {
14
  var $plugin_name = 'T(-) Countdown';
15
+ var $version = '2.3.18';
16
  var $domain = 'tminus';
17
  var $plguin_options_page_title = 'T(-) Countdown Options';
18
  var $plugin_options_menue_title = 'T(-) Countdown';
135
  $plugin_url = plugins_url() .'/'. dirname( plugin_basename(__FILE__) );
136
 
137
  //lwtCountdown script
138
+ wp_register_script('countdown-script', $plugin_url.'/js/jquery.t-countdown.js', array ('jquery'), '1.5.12', 'true');
139
  wp_enqueue_script('countdown-script');
140
 
141
  //force load styles
js/jquery.t-countdown.js CHANGED
@@ -1,5 +1,5 @@
1
  /*
2
- * T- Countdown v1.5.10
3
  * http://plugins.twinpictures.de/plugins/t-minus-countdown/
4
  *
5
  * Copyright 2017, Twinpictures
@@ -26,17 +26,20 @@
26
 
27
  (function($){
28
  $.fn.tminusCountDown = function (options) {
 
 
 
29
  config = {};
30
  $.extend(config, options);
31
  tminusTargetTime = this.setTminustminusTargetTime(config);
 
 
32
  var nowobj = $.parseJSON( tminusnow );
33
  nowTime = new Date(nowobj.now);
34
 
35
  style = config.style;
36
  $.data($(this)[0], 'style', config.style);
37
 
38
- before = new Date();
39
- $.data($(this)[0], 'before', before);
40
  $.data($(this)[0], 'status', 'play');
41
  $.data($(this)[0], 'id', config.id);
42
 
@@ -71,7 +74,9 @@
71
  }
72
  $('#' + $(this).attr('id') + ' .' + style + '-digit').html('<div class="tc_top"></div><div class="tc_bottom"></div>');
73
 
 
74
  diffSecs = Math.floor((tminusTargetTime.valueOf()-nowTime.valueOf())/1000);
 
75
  $(this).doTminusCountDown($(this).attr('id'), diffSecs, 500);
76
 
77
  return this;
@@ -124,6 +129,7 @@
124
  weeks = Math.floor(Math.abs(diffSecs/60/60/24/7));
125
  }
126
  style = $.data($(this)[0], 'style');
 
127
  $this.dashTminusChangeTo(id, style + '-seconds_dash', secs, duration ? duration : 500);
128
  $this.dashTminusChangeTo(id, style + '-minutes_dash', mins, duration ? duration : 1000);
129
  $this.dashTminusChangeTo(id, style + '-hours_dash', hours, duration ? duration : 1000);
@@ -132,8 +138,10 @@
132
  $this.dashTminusChangeTo(id, style + '-weeks_dash', weeks, duration ? duration : 1000);
133
  $this.dashTminusChangeTo(id, style + '-weeks_trip_dash', weeks, duration ? duration : 1000);
134
 
 
135
  $.data($this[0], 'diffSecs', diffSecs);
136
 
 
137
  //events
138
  if( $.data($this[0], 'event_id') ){
139
  $this.checkEvent(id, diffSecs);
@@ -141,23 +149,19 @@
141
 
142
  if (diffSecs > 0 || $.data($this[0], 'launchtarget') == 'countup'){
143
  if($.data($this[0], 'status') == 'play'){
144
- var delta = 0;
145
- delay = 1000;
146
- now = new Date();
147
- before = $.data($this[0], 'before');
148
- elapsedTime = (now.getTime() - before.getTime());
149
- if(elapsedTime >= delay + 1000){
150
- delta += Math.floor(1*(elapsedTime/delay));
151
- }
152
- else{
153
- delta = 1;
154
- }
155
- before = new Date();
156
- $.data($this[0], 'before', before);
157
- style = $.data($this[0], 'style');
158
  t = setTimeout( function() {
159
- $this.doTminusCountDown(id, diffSecs-delta);
160
- } , 1000);
161
  }
162
  }
163
  //cb = $.data($this[0], 'callback')
@@ -171,8 +175,11 @@
171
  };
172
 
173
  $.fn.dashTminusChangeTo = function(id, dash, n, duration) {
 
174
  $this = $('#' + id);
175
  style = $.data($this[0], 'style');
 
 
176
  for (var i=($this.find('.' + dash + ' .' + style + '-digit').length-1); i>=0; i--){
177
  var d = n%10;
178
  n = (n - d) / 10;
@@ -181,6 +188,7 @@
181
  };
182
 
183
  $.fn.digitTminusChangeTo = function (digit, n, duration) {
 
184
  if (!duration){
185
  duration = 500;
186
  }
1
  /*
2
+ * T- Countdown v1.5.12
3
  * http://plugins.twinpictures.de/plugins/t-minus-countdown/
4
  *
5
  * Copyright 2017, Twinpictures
26
 
27
  (function($){
28
  $.fn.tminusCountDown = function (options) {
29
+ if ($(this)[0] == undefined)
30
+ return;
31
+
32
  config = {};
33
  $.extend(config, options);
34
  tminusTargetTime = this.setTminustminusTargetTime(config);
35
+ $.data($(this)[0], 'tminusTargetTime', tminusTargetTime);
36
+
37
  var nowobj = $.parseJSON( tminusnow );
38
  nowTime = new Date(nowobj.now);
39
 
40
  style = config.style;
41
  $.data($(this)[0], 'style', config.style);
42
 
 
 
43
  $.data($(this)[0], 'status', 'play');
44
  $.data($(this)[0], 'id', config.id);
45
 
74
  }
75
  $('#' + $(this).attr('id') + ' .' + style + '-digit').html('<div class="tc_top"></div><div class="tc_bottom"></div>');
76
 
77
+ //caculate the initial difference in seconds between now and launch
78
  diffSecs = Math.floor((tminusTargetTime.valueOf()-nowTime.valueOf())/1000);
79
+ //console.log(diffSecs);
80
  $(this).doTminusCountDown($(this).attr('id'), diffSecs, 500);
81
 
82
  return this;
129
  weeks = Math.floor(Math.abs(diffSecs/60/60/24/7));
130
  }
131
  style = $.data($(this)[0], 'style');
132
+
133
  $this.dashTminusChangeTo(id, style + '-seconds_dash', secs, duration ? duration : 500);
134
  $this.dashTminusChangeTo(id, style + '-minutes_dash', mins, duration ? duration : 1000);
135
  $this.dashTminusChangeTo(id, style + '-hours_dash', hours, duration ? duration : 1000);
138
  $this.dashTminusChangeTo(id, style + '-weeks_dash', weeks, duration ? duration : 1000);
139
  $this.dashTminusChangeTo(id, style + '-weeks_trip_dash', weeks, duration ? duration : 1000);
140
 
141
+ //why exactly are we doing this?
142
  $.data($this[0], 'diffSecs', diffSecs);
143
 
144
+ //console.log('update diffSecs to: ', diffSecs);
145
  //events
146
  if( $.data($this[0], 'event_id') ){
147
  $this.checkEvent(id, diffSecs);
149
 
150
  if (diffSecs > 0 || $.data($this[0], 'launchtarget') == 'countup'){
151
  if($.data($this[0], 'status') == 'play'){
152
+
153
+ //why set the style here?
154
+ //style = $.data($this[0], 'style');
155
+
156
+ //recaculate diffSecs
157
+ nowTime = new Date();
158
+ //console.log('hey dude: ', tminusTargetTime.valueOf(), $.data($this[0], 'tminusTargetTime').valueOf() );
159
+
160
+ diffSecs = Math.floor(($.data($this[0], 'tminusTargetTime').valueOf()-nowTime.valueOf())/1000);
161
+
 
 
 
 
162
  t = setTimeout( function() {
163
+ $this.doTminusCountDown(id, diffSecs);
164
+ } , 1000);
165
  }
166
  }
167
  //cb = $.data($this[0], 'callback')
175
  };
176
 
177
  $.fn.dashTminusChangeTo = function(id, dash, n, duration) {
178
+
179
  $this = $('#' + id);
180
  style = $.data($this[0], 'style');
181
+
182
+ //console.log('.' + dash + ' .' + style + '-digit');
183
  for (var i=($this.find('.' + dash + ' .' + style + '-digit').length-1); i>=0; i--){
184
  var d = n%10;
185
  n = (n - d) / 10;
188
  };
189
 
190
  $.fn.digitTminusChangeTo = function (digit, n, duration) {
191
+
192
  if (!duration){
193
  duration = 500;
194
  }
readme.txt CHANGED
@@ -3,9 +3,9 @@
3
  Contributors: twinpictures, baden03
4
  Donate link: https://plugins.twinpictures.de/plugins/t-minus-countdown/
5
  Tags: countdown, timer, clock, ticker, widget, event, counter, count down, twinpictures, t minus, t-minus, t(-), t(-) countdown, t-countdown, t (-) countdown, plugin-oven, pluginoven, G2, spaceBros, littlewebtings, jQuery, javascript
6
- Requires at least: 4.0
7
- Tested up to: 4.8
8
- Stable tag: 2.3.17
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -65,6 +65,12 @@ Ah yes! <a href='https://twitter.com/#!/twinpictures'>@Twinpictures</a> is on th
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
68
  = 2.3.17 =
69
  * scripts do not load on customize.php page
70
  * removed now.php from js
@@ -303,4 +309,7 @@ Ah yes! <a href='https://twitter.com/#!/twinpictures'>@Twinpictures</a> is on th
303
  * The plugin came to be.
304
 
305
  == Upgrade Notice ==
306
- scripts do not load on customize.php page & removed now.php from js. fully tested with WordPress 4.8
 
 
 
3
  Contributors: twinpictures, baden03
4
  Donate link: https://plugins.twinpictures.de/plugins/t-minus-countdown/
5
  Tags: countdown, timer, clock, ticker, widget, event, counter, count down, twinpictures, t minus, t-minus, t(-), t(-) countdown, t-countdown, t (-) countdown, plugin-oven, pluginoven, G2, spaceBros, littlewebtings, jQuery, javascript
6
+ Requires at least: 4.5
7
+ Tested up to: 4.9.1
8
+ Stable tag: 2.3.18
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
65
 
66
  == Changelog ==
67
 
68
+ = 2.3.18 =
69
+ * rebuilt method of keeping countdown timer in sync
70
+ * Prevent errors when $(this) isn't an array
71
+ * fixed bug, where timers freeze if you have more than one on a page
72
+ * fully tested with WordPress 4.9.0
73
+
74
  = 2.3.17 =
75
  * scripts do not load on customize.php page
76
  * removed now.php from js
309
  * The plugin came to be.
310
 
311
  == Upgrade Notice ==
312
+ * rebuilt method of keeping countdown timer in sync
313
+ * Prevent errors when $(this) isn't an array
314
+ * fixed bug, where timers freeze if you have more than one on a page
315
+ * fully tested with WordPress 4.9.0