Countdown, Coming Soon – Countdown & Clock - Version 1.3.1

Version Description

  • Add new type clock
  • Code improvement
Download this release

Release Info

Developer adamskaat
Plugin Icon 128x128 Countdown, Coming Soon – Countdown & Clock
Version 1.3.1
Comparing to
See all releases

Code changes from version 1.3.0 to 1.3.1

assets/css/admin.css CHANGED
@@ -38,6 +38,11 @@
38
  background-size: 100% 100%;
39
  }
40
 
 
 
 
 
 
41
  .timer-countdown {
42
  background-image: url("../img/DigtalCountdown.jpg");
43
  background-size: 100% 100%;
38
  background-size: 100% 100%;
39
  }
40
 
41
+ .clock1-countdown {
42
+ background-image: url("../img/clock1.png");
43
+ background-size: 100% 100%;
44
+ }
45
+
46
  .timer-countdown {
47
  background-image: url("../img/DigtalCountdown.jpg");
48
  background-size: 100% 100%;
assets/img/clock1.png ADDED
Binary file
assets/js/Admin.js CHANGED
@@ -16,6 +16,64 @@ YcdAdmin.prototype.init = function() {
16
  this.livePreview();
17
  this.redirectToProWebpage();
18
  this.newsletter();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  };
20
 
21
  YcdAdmin.prototype.getTinymceContent = function()
16
  this.livePreview();
17
  this.redirectToProWebpage();
18
  this.newsletter();
19
+
20
+ /*clock*/
21
+ this.clockLivePreview();
22
+ };
23
+
24
+ YcdAdmin.prototype.clockLivePreview = function() {
25
+ this.changeClcokWidth();
26
+ this.changeTimeZone();
27
+ };
28
+
29
+ YcdAdmin.prototype.changeClcokWidth = function() {
30
+ var width = jQuery('#ycd-clock1-width');
31
+
32
+ if (width.length) {
33
+ var that = this;
34
+ width.bind('change', function() {
35
+ var widthVal = parseInt(jQuery(this).val())+'px';
36
+ var cnavas = jQuery('.ycdClock1');
37
+
38
+ cnavas.attr('width', widthVal);
39
+ cnavas.attr('height', widthVal);
40
+
41
+ that.reinitClock();
42
+ });
43
+ }
44
+ };
45
+
46
+ YcdAdmin.prototype.changeTimeZone = function() {
47
+ var timeZone = jQuery('.js-circle-time-zone');
48
+
49
+ if(!timeZone.length) {
50
+ return false;
51
+ }
52
+ var that = this;
53
+
54
+ timeZone.bind('change', function() {
55
+ var val = jQuery(this).val();
56
+ var options = jQuery('.ycdClock1').data('options');
57
+ options['timeZone'] = val;
58
+ jQuery('.ycdClock1').attr('data-options', options);
59
+
60
+ that.reinitClock();
61
+ });
62
+ };
63
+
64
+ YcdAdmin.prototype.reinitClock = function() {
65
+ var cnavas = jQuery('.ycdClock1');
66
+ var dataArgs = cnavas.data('args');
67
+ var dataOptions = cnavas.data('options');
68
+
69
+ var width = jQuery('.ycdClock1').width();
70
+ var height = jQuery('.ycdClock1').height();
71
+
72
+ jQuery('.ycdClock1').remove()
73
+ jQuery('.ycd-countdown-wrapper').prepend('<canvas data-args='+JSON.stringify(dataArgs)+' data-options='+JSON.stringify(dataOptions)+' class="ycdClock1" width="'+width+'px" height="'+height+'px"></canvas>');
74
+
75
+ var obj = new YcdClock();
76
+ obj.init()
77
  };
78
 
79
  YcdAdmin.prototype.getTinymceContent = function()
assets/js/clock/Clock.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function YcdClock() {
2
+
3
+ }
4
+
5
+ YcdClock.prototype.init = function() {
6
+ jQuery('.ycdClock1').each(function(index, element) {
7
+ var args = jQuery(element).data('args');
8
+ var options = jQuery(element).data('options');
9
+
10
+ if (typeof options == 'undefined' || typeof args == 'undefined') {
11
+ return '';
12
+ }
13
+ var context = element.getContext('2d');
14
+ var width = parseInt(jQuery(this).width());
15
+ var settings = {};
16
+
17
+ settings.timeZone = options['timeZone'];
18
+
19
+ ycdClockConti(width, context, args, settings);
20
+ });
21
+ };
22
+
23
+ jQuery(document).ready(function() {
24
+ var obj = new YcdClock();
25
+ obj.init();
26
+ });
assets/js/clock/canvas_clock.js ADDED
@@ -0,0 +1,1352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Name: canvas_clock.js
3
+ * Author: Michael Kruger
4
+ * Brief:
5
+ *
6
+ * This is a canvas based library with 15 different clocks that can be embedded in webpages.
7
+ * For more info please visit: www.krugaroo.com#canvasClock
8
+ *
9
+ * Copyright 2016 Krugaroo
10
+ * More Info: www.krugaroo.com#canvasClock
11
+ *
12
+ * License: MIT License
13
+ *
14
+ * Copyright (c) 2016 Michael Kruger, Krugaroo
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in
24
+ * all copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
+ * THE SOFTWARE.
33
+ */
34
+
35
+ day_arr=["Sunday", "Monday", "Tuesday","Wednesday","Thursday","Friday","Saturday"];
36
+ month_arr=["January","February","March","April","May","June","July","August","September","October","November","December"];
37
+
38
+ function ycdClockConti(size, cns, clockd, extraOptions)
39
+ {
40
+ cns.clearRect(0,0,size,size);
41
+
42
+ cns.beginPath();
43
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
44
+ cns.rect(0,0,size,size);
45
+ cns.fill();
46
+ cns.closePath();
47
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
48
+
49
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
50
+ {
51
+ indicator(size, cns, clockd);
52
+ }
53
+
54
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
55
+ {
56
+ ycd_time_add((size/2),size/5*3, size, cns, clockd, extraOptions);
57
+ }
58
+
59
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
60
+ {
61
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
62
+ }
63
+
64
+ var now = new Date();
65
+
66
+ if (extraOptions.timeZone) {
67
+ var now = new Date().toLocaleString('en-US', {
68
+ timeZone: extraOptions.timeZone
69
+ });
70
+ }
71
+
72
+ now = new Date(now);
73
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
74
+ now.setTime(now.getTime()+time_off*1000);
75
+ var milisec=now.getMilliseconds();
76
+ var sec=now.getSeconds();
77
+ var min=now.getMinutes();
78
+ var hour=now.getHours()%12;
79
+
80
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
81
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
82
+ cns.lineCap="round";
83
+
84
+ cns.beginPath();
85
+ cns.lineWidth=1;
86
+ cns.moveTo((size/2),(size/2));
87
+ cns.arc((size/2),(size/2),size/3,-1.57+sec*0.1046+milisec/1000*0.1046,-1.569+sec*0.1046+milisec/1000*0.1046,0);
88
+ cns.stroke();
89
+ cns.closePath();
90
+
91
+ cns.beginPath();
92
+ cns.lineWidth=1;
93
+ cns.moveTo((size/2),(size/2));
94
+ cns.arc((size/2),(size/2),size/15,1.57+sec*0.1046+milisec/1000*0.1046,1.569+sec*0.1046+milisec/1000*0.1046,1);
95
+ cns.stroke();
96
+ cns.closePath();
97
+
98
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
99
+ cns.strokeStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
100
+ cns.lineCap="round";
101
+
102
+ cns.beginPath();
103
+ cns.lineWidth=2;
104
+ cns.moveTo((size/2),(size/2));
105
+ cns.arc((size/2),(size/2),size/3,-1.57+min*0.1046+sec/60*0.1046,-1.569+min*0.1046+sec/60*0.1046,0);
106
+ cns.stroke();
107
+ cns.closePath();
108
+
109
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
110
+ cns.strokeStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
111
+ cns.lineCap="round";
112
+
113
+ cns.beginPath();
114
+ cns.lineWidth=3;
115
+ cns.moveTo((size/2),(size/2));
116
+ cns.arc((size/2),(size/2),size/4,-1.57+hour*0.523+min/60*0.523,-1.569+hour*0.523+min/60*0.523,0);
117
+ cns.stroke();
118
+ cns.closePath();
119
+
120
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
121
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
122
+ cns.lineCap="round";
123
+
124
+ cns.beginPath();
125
+ cns.lineWidth=2;
126
+ cns.arc((size/2),(size/2),size/80,0,6.28,0);
127
+ cns.fill();
128
+ cns.closePath();
129
+
130
+ clockd.timer=setTimeout(function(){ycdClockConti(size, cns, clockd, extraOptions)},50);
131
+ }
132
+
133
+ function clock_digital(size, cns, clockd)
134
+ {
135
+ var now=new Date();
136
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
137
+ now.setTime(now.getTime()+time_off*1000);
138
+ var milisec=now.getMilliseconds();
139
+ var sec=now.getSeconds();
140
+ var min=now.getMinutes();
141
+ var hour=now.getHours();
142
+
143
+ cns.clearRect(0,0,size,size);
144
+
145
+ cns.beginPath();
146
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
147
+ cns.rect(0,0,size,size);
148
+ cns.fill();
149
+ cns.closePath();
150
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
151
+
152
+ if(hour<10){hour="0"+hour;}
153
+ if(min<10){min="0"+min;}
154
+ if(sec<10){sec="0"+sec;}
155
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333";
156
+ cns.textBaseline="middle";
157
+ cns.textAlign="center";
158
+ cns.font=size/8+"px Arial";
159
+ cns.fillText(hour+":"+min+":"+sec,(size/2),size/2.5);
160
+
161
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
162
+ {
163
+ date_add((size/2),size/5*3+size/10,size,cns, clockd);
164
+ }
165
+
166
+ clockd.timer=setTimeout(function(){clock_digital(size, cns, clockd)},50);
167
+ }
168
+
169
+ function clock_reverse(size, cns, clockd)
170
+ {
171
+ cns.clearRect(0,0,size,size);
172
+
173
+ cns.beginPath();
174
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
175
+ cns.rect(0,0,size,size);
176
+ cns.fill();
177
+ cns.closePath();
178
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
179
+
180
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
181
+ {
182
+ indicator(size, cns, clockd);
183
+ }
184
+
185
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
186
+ {
187
+ ycd_time_add((size/2),size/5*3, size, cns, clockd);
188
+ }
189
+
190
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
191
+ {
192
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
193
+ }
194
+
195
+ var now=new Date();
196
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
197
+ now.setTime(now.getTime()+time_off*1000);
198
+ var milisec=now.getMilliseconds();
199
+ var sec=now.getSeconds();
200
+ var min=now.getMinutes();
201
+ var hour=now.getHours()%12;
202
+
203
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
204
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
205
+ cns.lineCap="round";
206
+
207
+ cns.beginPath();
208
+ cns.lineWidth=1;
209
+ cns.moveTo((size/2),(size/2));
210
+ cns.arc((size/2),(size/2),size/3,-1.57-sec*0.1046,-1.569-sec*0.1046,0);
211
+ cns.stroke();
212
+ cns.closePath();
213
+
214
+ cns.beginPath();
215
+ cns.lineWidth=1;
216
+ cns.moveTo((size/2),(size/2));
217
+ cns.arc((size/2),(size/2),size/15,1.57-sec*0.1046,1.569-sec*0.1046,1);
218
+ cns.stroke();
219
+ cns.closePath();
220
+
221
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
222
+ cns.strokeStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
223
+ cns.lineCap="round";
224
+
225
+ cns.beginPath();
226
+ cns.lineWidth=2;
227
+ cns.moveTo((size/2),(size/2));
228
+ cns.arc((size/2),(size/2),size/3,-1.57-min*0.1046,-1.569-min*0.1046,0);
229
+ cns.stroke();
230
+ cns.closePath();
231
+
232
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
233
+ cns.strokeStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
234
+ cns.lineCap="round";
235
+
236
+ cns.beginPath();
237
+ cns.lineWidth=3;
238
+ cns.moveTo((size/2),(size/2));
239
+ cns.arc((size/2),(size/2),size/4,-1.57-hour*0.523-min/60*0.523,-1.569-hour*0.523-min/60*0.523,0);
240
+ cns.stroke();
241
+ cns.closePath();
242
+
243
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
244
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
245
+ cns.lineCap="round";
246
+
247
+ cns.beginPath();
248
+ cns.lineWidth=2;
249
+ cns.arc((size/2),(size/2),size/80,0,6.28,0);
250
+ cns.fill();
251
+ cns.closePath();
252
+
253
+ clockd.timer=setTimeout(function(){clock_reverse(size, cns, clockd)},50);
254
+ }
255
+
256
+ function clock_norm(size, cns, clockd)
257
+ {
258
+ var br=[60,120,180];
259
+ var r2=[10,20,30];
260
+ var r3=[40,80,120];
261
+ var r4=[4,5,7];
262
+
263
+ cns.clearRect(0,0,size,size);
264
+
265
+ cns.beginPath();
266
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
267
+ cns.rect(0,0,size,size);
268
+ cns.fill();
269
+ cns.closePath();
270
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
271
+
272
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
273
+ {
274
+ indicator(size, cns, clockd);
275
+ }
276
+
277
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
278
+ {
279
+ ycd_time_add((size/2),size/5*3, size, cns, clockd);
280
+ }
281
+
282
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
283
+ {
284
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
285
+ }
286
+
287
+ var now=new Date();
288
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
289
+ now.setTime(now.getTime()+time_off*1000);
290
+ var milisec=now.getMilliseconds();
291
+ var sec=now.getSeconds();
292
+ var min=now.getMinutes();
293
+ var hour=now.getHours()%12;
294
+
295
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
296
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
297
+ cns.lineCap="round";
298
+
299
+ cns.beginPath();
300
+ cns.lineWidth=1;
301
+ cns.moveTo((size/2),(size/2));
302
+ cns.arc((size/2),(size/2),size/3,-1.57+sec*0.1046,-1.569+sec*0.1046,0);
303
+ cns.stroke();
304
+ cns.closePath();
305
+
306
+ cns.beginPath();
307
+ cns.lineWidth=1;
308
+ cns.moveTo((size/2),(size/2));
309
+ cns.arc((size/2),(size/2),size/15,1.57+sec*0.1046,1.569+sec*0.1046,1);
310
+ cns.stroke();
311
+ cns.closePath();
312
+
313
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
314
+ cns.strokeStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
315
+ cns.lineCap="round";
316
+
317
+ cns.beginPath();
318
+ cns.lineWidth=2;
319
+ cns.moveTo((size/2),(size/2));
320
+ cns.arc((size/2),(size/2),size/3,-1.57+min*0.1046,-1.569+min*0.1046,0);
321
+ cns.stroke();
322
+ cns.closePath();
323
+
324
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
325
+ cns.strokeStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
326
+ cns.lineCap="round";
327
+
328
+ cns.beginPath();
329
+ cns.lineWidth=3;
330
+ cns.moveTo((size/2),(size/2));
331
+ cns.arc((size/2),(size/2),size/4,-1.57+hour*0.523+min/60*0.523,-1.569+hour*0.523+min/60*0.523,0);
332
+ cns.stroke();
333
+ cns.closePath();
334
+
335
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
336
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
337
+ cns.lineCap="round";
338
+
339
+ cns.beginPath();
340
+ cns.lineWidth=2;
341
+ cns.arc((size/2),(size/2),size/60,0,6.28,0);
342
+ cns.fill();
343
+ cns.closePath();
344
+
345
+ clockd.timer=setTimeout(function(){clock_norm(size, cns, clockd)},50);
346
+ }
347
+
348
+ function clock_follow(size, cns, clockd)
349
+ {
350
+ cns.clearRect(0,0,size,size);
351
+
352
+ cns.beginPath();
353
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
354
+ cns.rect(0,0,size,size);
355
+ cns.fill();
356
+ cns.closePath();
357
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
358
+
359
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
360
+ {
361
+ indicator(size, cns, clockd);
362
+ }
363
+
364
+ var now=new Date();
365
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
366
+ now.setTime(now.getTime()+time_off*1000);
367
+ var milisec=now.getMilliseconds();
368
+ var sec=now.getSeconds();
369
+ var min=now.getMinutes();
370
+ var hour=now.getHours()%12;
371
+
372
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
373
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
374
+ cns.lineCap="round";
375
+
376
+ cns.beginPath();
377
+ cns.lineWidth=1;
378
+ cns.arc((size/2),(size/2),size/3,-1.57,-1.569+sec*0.1046+milisec/1000*0.1046,0);
379
+ cns.lineTo((size/2),(size/2));
380
+ cns.stroke();
381
+ cns.closePath();
382
+
383
+ cns.beginPath();
384
+ cns.lineWidth=1;
385
+ cns.moveTo((size/2),(size/2));
386
+ cns.arc((size/2),(size/2),size/17,1.57+sec*0.1046+milisec/1000*0.1046,1.569+sec*0.1046+milisec/1000*0.1046,1);
387
+ cns.stroke();
388
+ cns.closePath();
389
+
390
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
391
+ cns.strokeStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
392
+ cns.beginPath();
393
+ cns.lineWidth=2;
394
+ cns.arc((size/2),(size/2),size/3.5,-1.57,-1.569+min*0.1046+sec/60*0.1046,0);
395
+ cns.lineTo((size/2),(size/2));
396
+ cns.stroke();
397
+ cns.closePath();
398
+
399
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
400
+ cns.strokeStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
401
+ cns.beginPath();
402
+ cns.lineWidth=2;
403
+ cns.arc((size/2),(size/2),size/4.5,-1.57,-1.569+hour*0.523+min/60*0.523,0);
404
+ cns.lineTo((size/2),(size/2));
405
+ cns.stroke();
406
+ cns.closePath();
407
+
408
+ cns.beginPath();
409
+ cns.lineWidth=2;
410
+ cns.arc((size/2),(size/2),size/60,0,6.28,0);
411
+ cns.fill();
412
+ cns.closePath();
413
+
414
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
415
+ {
416
+ ycd_time_add((size/2),size/5*3, size, cns, clockd);
417
+ }
418
+
419
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
420
+ {
421
+ date_add((size/2),size/5*3+size/15, size, cns, clockd);
422
+ }
423
+
424
+ clockd.timer=setTimeout(function(){clock_follow(size, cns, clockd)},50);
425
+ }
426
+
427
+ function clock_circles(size, cns, clockd)
428
+ {
429
+ cns.clearRect(0,0,size,size);
430
+
431
+ cns.beginPath();
432
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
433
+ cns.rect(0,0,size,size);
434
+ cns.fill();
435
+ cns.closePath();
436
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
437
+
438
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
439
+ {
440
+ indicator(size, cns, clockd);
441
+ }
442
+
443
+ var now=new Date();
444
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
445
+ now.setTime(now.getTime()+time_off*1000);
446
+ var milisec=now.getMilliseconds();
447
+ var sec=now.getSeconds();
448
+ var min=now.getMinutes();
449
+ var hour=now.getHours()%12;
450
+
451
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
452
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
453
+ cns.lineCap="round";
454
+ cns.beginPath();
455
+ cns.moveTo((size/2),(size/2));
456
+ cns.arc((size/2),(size/2),size/3,-1.57,-1.569+sec*0.1046+milisec/1000*0.1046,0);
457
+ cns.lineTo((size/2),(size/2));
458
+ cns.fill();
459
+ cns.closePath();
460
+
461
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
462
+ cns.strokeStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
463
+ cns.lineCap="round";
464
+ cns.beginPath();
465
+ cns.moveTo((size/2),(size/2));
466
+ cns.arc((size/2),(size/2),size/3.5,-1.57,-1.569+min*0.1046+sec/60*0.1046,0);
467
+ cns.lineTo((size/2),(size/2));
468
+ cns.fill();
469
+ cns.closePath();
470
+
471
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
472
+ cns.strokeStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
473
+ cns.lineCap="round";
474
+ cns.beginPath();
475
+ cns.moveTo((size/2),(size/2));
476
+ cns.arc((size/2),(size/2),size/4.5,-1.57,-1.569+hour*0.523+min/60*0.523,0);
477
+ cns.lineTo((size/2),(size/2));
478
+ cns.fill();
479
+ cns.closePath();
480
+
481
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
482
+ {
483
+ ycd_time_add((size/2),size/6*3, size, cns, clockd);
484
+ }
485
+
486
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
487
+ {
488
+ date_add((size/2),size/6*3+size/10, size, cns, clockd);
489
+ }
490
+
491
+ clockd.timer=setTimeout(function(){clock_circles(size, cns, clockd)},50);
492
+ }
493
+
494
+ function clock_grow(size, cns, clockd)
495
+ {
496
+ cns.clearRect(0,0,size,size);
497
+
498
+ cns.beginPath();
499
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
500
+ cns.rect(0,0,size,size);
501
+ cns.fill();
502
+ cns.closePath();
503
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
504
+
505
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
506
+ {
507
+ indicator(size, cns, clockd);
508
+ }
509
+
510
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
511
+ {
512
+ ycd_time_add((size/2),size/5*3, size, cns, clockd);
513
+ }
514
+
515
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
516
+ {
517
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
518
+ }
519
+
520
+ var now=new Date();
521
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
522
+ now.setTime(now.getTime()+time_off*1000);
523
+ var milisec=now.getMilliseconds();
524
+ var sec=now.getSeconds();
525
+ var min=now.getMinutes();
526
+ var hour=now.getHours()%12;
527
+
528
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
529
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
530
+ cns.lineCap="round";
531
+ cns.beginPath();
532
+ cns.lineWidth=1;
533
+ cns.moveTo((size/2),(size/2));
534
+ cns.arc((size/2),(size/2),sec*size/200+size/15,-1.57+sec*0.1046+milisec/1000*0.1046,-1.569+sec*0.1046+milisec/1000*0.1046,0);
535
+ cns.stroke();
536
+ cns.closePath();
537
+
538
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
539
+ cns.strokeStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
540
+ cns.lineCap="round";
541
+ cns.lineWidth=1;
542
+ cns.moveTo((size/2),(size/2));
543
+ cns.arc((size/2),(size/2),min*size/200+sec/60*size/200+size/15,-1.57+min*0.1046+sec/60*0.1046,-1.569+min*0.1046+sec/60*0.1046,0);
544
+ cns.stroke();
545
+ cns.closePath();
546
+
547
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
548
+ cns.strokeStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
549
+ cns.lineCap="round";
550
+ cns.lineWidth=2;
551
+ cns.moveTo((size/2),(size/2));
552
+ cns.arc((size/2),(size/2),hour*size/200*3+min/60*size/200*3+size/15,-1.57+hour*0.523+min/60*0.523,-1.569+hour*0.523+min/60*0.523,0);
553
+ cns.stroke();
554
+ cns.closePath();
555
+
556
+ cns.beginPath();
557
+ cns.lineWidth=2;
558
+ cns.arc((size/2),(size/2),size/60,0,6.28,0);
559
+ cns.fill();
560
+ cns.closePath();
561
+
562
+ clockd.timer=setTimeout(function(){clock_grow(size, cns, clockd)},50);
563
+ }
564
+
565
+ function clock_dots(size, cns, clockd)
566
+ {
567
+ cns.clearRect(0,0,size,size);
568
+
569
+ cns.beginPath();
570
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
571
+ cns.rect(0,0,size,size);
572
+ cns.fill();
573
+ cns.closePath();
574
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
575
+
576
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
577
+ {
578
+ indicator(size, cns, clockd);
579
+ }
580
+
581
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
582
+ {
583
+ ycd_time_add((size/2),size/6*3, size, cns, clockd);
584
+ }
585
+
586
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
587
+ {
588
+ date_add((size/2),size/6*3+size/10, size, cns, clockd);
589
+ }
590
+
591
+ var now=new Date();
592
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
593
+ now.setTime(now.getTime()+time_off*1000);
594
+ var milisec=now.getMilliseconds();
595
+ var sec=now.getSeconds();
596
+ var min=now.getMinutes();
597
+ var hour=now.getHours()%12;
598
+
599
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
600
+ cns.strokeStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
601
+ cns.lineCap="round";
602
+ for(var a=0;a<(sec+1);a++)
603
+ {
604
+ var r=parseInt(a)*0.1046;
605
+ var calc=Math.cos(r-1.57)*(size/2.8);
606
+ var y=Math.sin(r-1.57)*(size/2.8);
607
+
608
+ cns.beginPath();
609
+ cns.arc(calc+(size/2),y+(size/2),size/100,0,6.28,0);
610
+ cns.fill();
611
+ cns.closePath();
612
+ }
613
+
614
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
615
+ cns.strokeStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
616
+ cns.lineCap="round";
617
+
618
+ for(var a=0;a<(min+1);a++)
619
+ {
620
+ var r=parseInt(a)*0.1046;
621
+ var calc=Math.cos(r-1.57)*(size/3.4);
622
+ var y=Math.sin(r-1.57)*(size/3.4);
623
+
624
+ cns.beginPath();
625
+ cns.arc(calc+(size/2),y+(size/2),size/100,0,6.28,0);
626
+ cns.fill();
627
+ cns.closePath();
628
+ }
629
+
630
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
631
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
632
+ cns.lineCap="round";
633
+
634
+ for(var a=0;a<(hour+1);a++)
635
+ {
636
+ var r=parseInt(a)*0.523;
637
+ var calc=Math.cos(r-1.57)*(size/4.5);
638
+ var y=Math.sin(r-1.57)*(size/4.5);
639
+
640
+ cns.beginPath();
641
+ cns.arc(calc+(size/2),y+(size/2),size/100,0,6.28,0);
642
+ cns.fill();
643
+ cns.closePath();
644
+ }
645
+
646
+ clockd.timer=setTimeout(function(){clock_dots(size, cns, clockd)},50);
647
+ }
648
+
649
+ function clock_num(size, cns, clockd)
650
+ {
651
+ cns.clearRect(0,0,size,size);
652
+
653
+ cns.beginPath();
654
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
655
+ cns.rect(0,0,size,size);
656
+ cns.fill();
657
+ cns.closePath();
658
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
659
+
660
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
661
+ {
662
+ indicator(size, cns, clockd);
663
+ }
664
+
665
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
666
+ {
667
+ ycd_time_add((size/2),size/5*3, size, cns, clockd);
668
+ }
669
+
670
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
671
+ {
672
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
673
+ }
674
+
675
+ var now=new Date();
676
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
677
+ now.setTime(now.getTime()+time_off*1000);
678
+ var milisec=now.getMilliseconds();
679
+ var sec=now.getSeconds();
680
+ var min=now.getMinutes();
681
+ var hour=now.getHours()%12;
682
+
683
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
684
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
685
+ cns.lineCap="round";
686
+ cns.beginPath();
687
+ cns.lineWidth=1;
688
+ cns.moveTo((size/2),(size/2));
689
+ cns.arc((size/2),(size/2),size/3.2,-1.57+sec*0.1046+milisec/1000*0.1046,-1.569+sec*0.1046+milisec/1000*0.1046,0);
690
+ cns.stroke();
691
+ cns.closePath();
692
+
693
+ cns.textBaseline="middle";
694
+ cns.textAlign="center";
695
+ cns.font=(size/35+5)+"px Arial";
696
+ cns.fillText(sec,Math.cos(-1.57+sec*0.1046+milisec/1000*0.1046)*size/3+(size/2),Math.sin(-1.57+sec*0.1046+milisec/1000*0.1046)*size/3+(size/2))
697
+
698
+ cns.beginPath();
699
+ cns.lineWidth=1;
700
+ cns.moveTo((size/2),(size/2));
701
+ cns.arc((size/2),(size/2),size/15,1.57+sec*0.1046+milisec/1000*0.1046,1.569+sec*0.1046+milisec/1000*0.1046,1);
702
+ cns.stroke();
703
+ cns.closePath();
704
+
705
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
706
+ cns.strokeStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
707
+ cns.beginPath();
708
+ cns.lineWidth=2;
709
+ cns.moveTo((size/2),(size/2));
710
+ cns.arc((size/2),(size/2),size/3.2,-1.57+min*0.1046+sec/60*0.1046,-1.569+min*0.1046+sec/60*0.1046,0);
711
+ cns.stroke();
712
+ cns.closePath();
713
+ cns.fillText(min,Math.cos(-1.57+min*0.1046+sec/60*0.1046)*size/3+(size/2),Math.sin(-1.57+min*0.1046+sec/60*0.1046)*size/3+(size/2))
714
+
715
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
716
+ cns.strokeStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
717
+ cns.beginPath();
718
+ cns.lineWidth=3;
719
+ cns.moveTo((size/2),(size/2));
720
+ cns.arc((size/2),(size/2),size/4,-1.57+hour*0.523+min/60*0.523,-1.569+hour*0.523+min/60*0.523,0);
721
+ cns.stroke();
722
+ cns.closePath();
723
+ if(hour==0){var hour2=12;}else{var hour2=hour;}
724
+ cns.fillText(hour2,Math.cos(-1.57+hour*0.523+min/60*0.523)*size/3.5+(size/2),Math.sin(-1.57+hour*0.523+min/60*0.523)*size/3.5+(size/2))
725
+
726
+ cns.beginPath();
727
+ cns.lineWidth=2;
728
+ cns.arc((size/2),(size/2),size/80,0,6.28,0);
729
+ cns.fill();
730
+ cns.closePath();
731
+
732
+ clockd.timer=setTimeout(function(){clock_num(size, cns, clockd)},50);
733
+ }
734
+
735
+ function clock_random(size, cns, clockd)
736
+ {
737
+ var now=new Date();
738
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
739
+ now.setTime(now.getTime()+time_off*1000);
740
+ var milisec=now.getMilliseconds();
741
+ var sec=now.getSeconds();
742
+ var min=now.getMinutes();
743
+ var hour=now.getHours();
744
+
745
+ if(!clockd.hasOwnProperty("track")){clockd["track"]=20;}
746
+ clockd["track"]=parseInt(clockd["track"])+1;
747
+
748
+ if(parseInt(clockd["track"])>=20)
749
+ {
750
+ cns.clearRect(0,0,size,size);
751
+
752
+ cns.beginPath();
753
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
754
+ cns.rect(0,0,size,size);
755
+ cns.fill();
756
+ cns.closePath();
757
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
758
+
759
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
760
+ {
761
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
762
+ }
763
+
764
+ var hourx=Math.floor(Math.random()*size/1.5)+Math.floor((size/2)/10);
765
+ var houry=Math.floor(Math.random()*size/1.5)+Math.floor((size/2)/10);
766
+
767
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
768
+ cns.strokeStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
769
+ //if(hour==0){hour=12;}else{hour=hour;}
770
+ if(hour<10){hour="0"+hour;}
771
+ if(min<10){min="0"+min;}
772
+ if(sec<10){sec="0"+sec;}
773
+
774
+ cns.textBaseline="middle";
775
+ cns.textAlign="left";
776
+ cns.font=(size/15)+"pt Arial";
777
+ cns.fillText(hour+":"+min+":"+sec,hourx,houry);
778
+
779
+ clockd["track"]=0;
780
+ }
781
+
782
+ clockd.timer=setTimeout(function(){clock_random(size, cns, clockd)},50);
783
+ }
784
+
785
+ function clock_digitalran(size, cns, clockd)
786
+ {
787
+ var now=new Date();
788
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
789
+ now.setTime(now.getTime()+time_off*1000);
790
+ var sec=now.getSeconds();
791
+ var min=now.getMinutes();
792
+ var hour=now.getHours();
793
+ var hexarr=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
794
+ var a=Math.floor(Math.random()*16);
795
+ var b=Math.floor(Math.random()*16);
796
+ var c=Math.floor(Math.random()*16);
797
+ var d=Math.floor(Math.random()*16);
798
+ var e=Math.floor(Math.random()*16);
799
+ var f=Math.floor(Math.random()*16);
800
+
801
+ if(clockd.hasOwnProperty("track"))
802
+ {
803
+ clockd["track"]+=1;
804
+ }
805
+ else
806
+ {
807
+ clockd["track"]=20;
808
+ }
809
+
810
+ if(parseInt(clockd["track"])==20)
811
+ {
812
+ cns.clearRect(0,0,size,size);
813
+
814
+ cns.beginPath();
815
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
816
+ cns.rect(0,0,size,size);
817
+ cns.fill();
818
+ cns.closePath();
819
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
820
+
821
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
822
+ {
823
+ date_add((size/2),size/3*2, size, cns, clockd);
824
+ }
825
+
826
+ if(hour==0){var hour2=12;}else{var hour2=hour;}
827
+ if(hour<10){hour="0"+hour;}
828
+ if(min<10){min="0"+min;}
829
+ if(sec<10){sec="0"+sec;}
830
+ cns.strokeStyle="#333333";
831
+ cns.fillStyle="#"+hexarr[a]+hexarr[b]+hexarr[c]+hexarr[d]+hexarr[e]+hexarr[f];
832
+ cns.textBaseline="middle";
833
+ cns.textAlign="center";
834
+ cns.font=size/7+"px Arial";
835
+ cns.fillText(hour2+":"+min+":"+sec,(size/2),size/2.5);
836
+
837
+ clockd["track"]=0;
838
+ }
839
+
840
+ clockd.timer=setTimeout(function(){clock_digitalran(size, cns, clockd)},50);
841
+ }
842
+
843
+ function clock_bars(size, cns, clockd)
844
+ {
845
+ cns.clearRect(0,0,size,size);
846
+
847
+ cns.beginPath();
848
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
849
+ cns.rect(0,0,size,size);
850
+ cns.fill();
851
+ cns.closePath();
852
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
853
+
854
+ var now=new Date();
855
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
856
+ now.setTime(now.getTime()+time_off*1000);
857
+ var mili=now.getMilliseconds();
858
+ var sec=now.getSeconds();
859
+ var min=now.getMinutes();
860
+ var hour=now.getHours()%12;
861
+
862
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
863
+ {
864
+ cns.strokeStyle=(clockd.hasOwnProperty("indicate_color"))?clockd["indicate_color"]:"#333333";
865
+
866
+ for(var a=0;a<13;a++)
867
+ {
868
+ if(a%3==0){cns.lineWidth=2;}else{cns.lineWidth=1;}
869
+ cns.beginPath();
870
+ cns.moveTo(size/7+size/7.1,size/8+a*size/1.3/12);
871
+ cns.lineTo(size/2.38,size/8+a*size/1.3/12);
872
+ cns.stroke();
873
+ cns.closePath();
874
+
875
+ cns.beginPath();
876
+ cns.moveTo(size/2.35+size/7.1,size/8+a*size/1.3/12);
877
+ cns.lineTo(size/1.45,size/8+a*size/1.3/12);
878
+ cns.stroke();
879
+ cns.closePath();
880
+ }
881
+
882
+ cns.beginPath();
883
+ cns.moveTo(size/7+size/7.1*1.5,size/8);
884
+ cns.lineTo(size/7+size/7.1*1.5,size/8+size/1.3);
885
+ cns.stroke();
886
+ cns.closePath();
887
+
888
+ cns.beginPath();
889
+ cns.moveTo(size/2.38+size/7.1*1.5,size/8);
890
+ cns.lineTo(size/2.38+size/7.1*1.5,size/8+size/1.3);
891
+ cns.stroke();
892
+ cns.closePath();
893
+ }
894
+
895
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
896
+ {
897
+ ycd_time_add((size/2),size/20, size, cns, clockd);
898
+ }
899
+
900
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
901
+ {
902
+ date_add((size/2),size/14*13, size, cns, clockd);
903
+ }
904
+
905
+ cns.strokeStyle=(clockd.hasOwnProperty("indicate_color"))?clockd["indicate_color"]:"#333333";
906
+ cns.lineCap="round";
907
+ cns.fillStyle=(clockd.hasOwnProperty("indicate_color"))?clockd["indicate_color"]:"#333333";
908
+
909
+ cns.beginPath();
910
+ cns.rect(size/7.4,size/8,size/6.8,size/1.3);
911
+ cns.rect(size/2.38,size/8,size/6.8,size/1.3);
912
+ cns.rect(size/1.45,size/8,size/6.8,size/1.3);
913
+ cns.stroke();
914
+ cns.closePath();
915
+
916
+ cns.beginPath();
917
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
918
+ cns.rect(size/7.4,size/8+size/1.3-(size/1.3)*(hour*60+min)/720,size/6.8,(size/1.3)*(hour*60+min)/720);
919
+ cns.fill()
920
+ cns.closePath();
921
+
922
+ cns.beginPath()
923
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
924
+ cns.rect(size/2.38,size/8+size/1.3-(size/1.3)*(min*60+sec)/3600,size/6.8,(size/1.3)*(min*60+sec)/3600);
925
+ cns.fill();
926
+ cns.closePath();
927
+
928
+ cns.beginPath();
929
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
930
+ cns.rect(size/1.45,size/8+size/1.3-(size/1.3)*(sec*1000+mili)/60000,size/6.8,(size/1.3)*(sec*1000+mili)/60000);
931
+ cns.fill();
932
+ cns.closePath();
933
+
934
+ clockd.timer=setTimeout(function(){clock_bars(size, cns, clockd)},50);
935
+ }
936
+
937
+ function clock_planets(size, cns, clockd)
938
+ {
939
+ cns.clearRect(0,0,size,size);
940
+
941
+ cns.beginPath();
942
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
943
+ cns.rect(0,0,size,size);
944
+ cns.fill();
945
+ cns.closePath();
946
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
947
+
948
+ if((clockd.hasOwnProperty("indicate") && clockd.indicate==true) || !clockd.hasOwnProperty("indicate"))
949
+ {
950
+ indicator(size, cns, clockd);
951
+ }
952
+
953
+ if(clockd.hasOwnProperty("time_add") && clockd.time_add)
954
+ {
955
+ ycd_time_add((size/2),size/5*3, size, cns, clockd);
956
+ }
957
+
958
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
959
+ {
960
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
961
+ }
962
+
963
+ var now=new Date();
964
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
965
+ now.setTime(now.getTime()+time_off*1000);
966
+ var milisec=now.getMilliseconds();
967
+ var sec=now.getSeconds();
968
+ var min=now.getMinutes();
969
+ var hour=now.getHours()%12;
970
+
971
+ if(clockd.hasOwnProperty("track")){cns.fillStyle=clockd["track"];}else{cns.fillStyle="#DAA520";}
972
+ cns.beginPath();
973
+ cns.lineWidth=3;
974
+ cns.moveTo((size/2),(size/2));
975
+ cns.arc((size/2),(size/2),size/25,0,6.29,0);
976
+ cns.lineTo((size/2),(size/2));
977
+ cns.fill();
978
+ cns.closePath();
979
+
980
+ var r=parseInt(milisec)*0.00628;
981
+ var calcms=Math.cos(r-1.57)*(size/25);
982
+ var yms=Math.sin(r-1.57)*(size/25);
983
+
984
+ var r=parseInt(sec)*0.1046+parseInt(milisec)/1000*0.1046;
985
+ var calc=Math.cos(r-1.57)*(size/5);
986
+ var y=Math.sin(r-1.57)*(size/5);
987
+
988
+ var r=parseInt(min)*0.1046+parseInt(sec)/60*0.1046;
989
+ var calcm=Math.cos(r-1.57)*(size/3.2);
990
+ var ym=Math.sin(r-1.57)*(size/3.2);
991
+
992
+ var r=parseInt(hour)*0.523+parseInt(min)/60*0.523;
993
+ var calcu=Math.cos(r-1.57)*(size/2.5);
994
+ var yu=Math.sin(r-1.57)*(size/2.5);
995
+
996
+ if(clockd.hasOwnProperty("indicate_color")){cns.strokeStyle=clockd["indicate_color"];}else{cns.strokeStyle="#333";}
997
+
998
+ cns.closePath();
999
+ cns.beginPath();
1000
+ cns.lineWidth=1;
1001
+ cns.arc((size/2),(size/2),(size/5),0,6.28,0);
1002
+ cns.stroke();
1003
+ cns.closePath();
1004
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
1005
+ cns.beginPath();
1006
+ cns.lineWidth=3;
1007
+ cns.arc(calc+(size/2),y+(size/2),size/42,0,6.28,0);
1008
+ cns.fill();
1009
+
1010
+ cns.closePath();
1011
+ cns.beginPath();
1012
+ cns.lineWidth=1;
1013
+ cns.arc((size/2)+calc,(size/2)+y,size/24,0,6.28,0);
1014
+ cns.stroke();
1015
+ cns.closePath();
1016
+ cns.beginPath();
1017
+ cns.lineWidth=3;
1018
+ cns.arc((size/2)+calc+calcms,(size/2)+y+yms,size/110,0,6.28,0);
1019
+ cns.fill();
1020
+
1021
+ cns.beginPath();
1022
+ cns.lineWidth=1;
1023
+ cns.arc((size/2),(size/2),size/3.2,0,6.28,0);
1024
+ cns.stroke();
1025
+ cns.closePath();
1026
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
1027
+ cns.beginPath();
1028
+ cns.lineWidth=3;
1029
+ cns.arc(calcm+(size/2),ym+(size/2),size/24,0,6.28,0);
1030
+ cns.fill();
1031
+ cns.closePath();
1032
+
1033
+ cns.beginPath();
1034
+ cns.lineWidth=1;
1035
+ cns.arc((size/2),(size/2),size/2.5,0,6.28,0);
1036
+ cns.stroke();
1037
+ cns.closePath();
1038
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
1039
+ cns.beginPath();
1040
+ cns.lineWidth=3;
1041
+ cns.arc(calcu+(size/2),yu+(size/2),size/22,0,6.28,0);
1042
+ cns.fill();
1043
+ cns.closePath();
1044
+
1045
+ clockd.timer=setTimeout(function(){clock_planets(size, cns, clockd)},50);
1046
+ }
1047
+
1048
+ function clock_roulette(size, cns, clockd)
1049
+ {
1050
+ var now=new Date();
1051
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
1052
+ now.setTime(now.getTime()+time_off*1000);
1053
+ var milisec=now.getMilliseconds();
1054
+ var sec=now.getSeconds();
1055
+ var min=now.getMinutes();
1056
+ var hour=now.getHours()%12;
1057
+
1058
+ cns.clearRect(0,0,size,size);
1059
+
1060
+ cns.beginPath();
1061
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
1062
+ cns.rect(0,0,size,size);
1063
+ cns.fill();
1064
+ cns.closePath();
1065
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
1066
+
1067
+ var a=hour-2;var b=hour-1;var c=hour+1;var d=hour+2;var e=hour+3;
1068
+ if(a<0){a=24+a;}
1069
+ if(b<0){b=24+b;}
1070
+ if(c>23){c=c-24;}
1071
+ if(d>23){d=d-24;}
1072
+ if(e>23){e=e-24;}
1073
+
1074
+ var f=hour;
1075
+ if(a<10){a="0"+a;}
1076
+ if(b<10){b="0"+b;}
1077
+ if(c<10){c="0"+c;}
1078
+ if(d<10){d="0"+d;}
1079
+ if(e<10){e="0"+e;}
1080
+ if(f<10){f="0"+f;}
1081
+ cns.font=size/10+"pt Arial";
1082
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
1083
+ cns.fillText(a,size/5,size/10-size/5*min/60-size/5*sec/36000);
1084
+ cns.fillText(b,size/5,size/10+size/5-size/5*min/60-size/5*sec/36000);
1085
+ cns.globalAlpha=0.3;
1086
+ cns.fillText(f,size/5,size/10+2*size/5-size/5*min/60-size/5*sec/3600);
1087
+ cns.globalAlpha=1;
1088
+ cns.fillText(c,size/5,size/10+3*size/5-size/5*min/60-size/5*sec/3600);
1089
+ cns.fillText(d,size/5,size/10+4*size/5-size/5*min/60-size/5*sec/3600);
1090
+ cns.fillText(e,size/5,size/10+5*size/5-size/5*min/60-size/5*sec/3600);
1091
+
1092
+ var a=min-2;var b=min-1;var c=min+1;var d=min+2;var e=min+3;
1093
+ if(a<0){a=60+a;}
1094
+ if(b<0){b=60+b;}
1095
+ if(c>59){c=c-60;}
1096
+ if(d>59){d=d-60;}
1097
+ if(e>59){e=e-60;}
1098
+
1099
+ var f=min;
1100
+ if(a<10){a="0"+a;}
1101
+ if(b<10){b="0"+b;}
1102
+ if(c<10){c="0"+c;}
1103
+ if(d<10){d="0"+d;}
1104
+ if(e<10){e="0"+e;}
1105
+ if(f<10){f="0"+f;}
1106
+ cns.fillStyle=(clockd.hasOwnProperty("dial2_color"))?clockd["dial2_color"]:"#333333";
1107
+ cns.fillText(a,size/2,size/10-size/5*sec/60-size/5*milisec/60000);
1108
+ cns.fillText(b,size/2,size/10+size/5-size/5*sec/60-size/5*milisec/60000);
1109
+ cns.globalAlpha=0.3;
1110
+ cns.fillText(f,size/2,size/10+2*size/5-size/5*sec/60-size/5*milisec/60000);
1111
+ cns.globalAlpha=1;
1112
+ cns.fillText(c,size/2,size/10+3*size/5-size/5*sec/60-size/5*milisec/60000);
1113
+ cns.fillText(d,size/2,size/10+4*size/5-size/5*sec/60-size/5*milisec/60000);
1114
+ cns.fillText(e,size/2,size/10+5*size/5-size/5*sec/60-size/5*milisec/60000);
1115
+
1116
+ var a=sec-2;var b=sec-1;var c=sec+1;var d=sec+2;var e=sec+3;
1117
+ if(a<0){a=60+a;}
1118
+ if(b<0){b=60+b;}
1119
+ if(c>59){c=c-60;}
1120
+ if(d>59){d=d-60;}
1121
+ if(e>59){e=e-60;}
1122
+
1123
+ var f=sec;
1124
+ if(a<10){a="0"+a;}
1125
+ if(b<10){b="0"+b;}
1126
+ if(c<10){c="0"+c;}
1127
+ if(d<10){d="0"+d;}
1128
+ if(e<10){e="0"+e;}
1129
+ if(f<10){f="0"+f;}
1130
+ cns.fillStyle=(clockd.hasOwnProperty("dial3_color"))?clockd["dial3_color"]:"#333333";
1131
+ cns.fillText(a,size/5*4,size/10-size/5*milisec/1000);
1132
+ cns.fillText(b,size/5*4,size/10+size/5-size/5*milisec/1000);
1133
+ cns.globalAlpha=0.3;
1134
+ cns.fillText(f,size/5*4,size/10+2*size/5-size/5*milisec/1000);
1135
+ cns.globalAlpha=1;
1136
+ cns.fillText(c,size/5*4,size/10+3*size/5-size/5*milisec/1000);
1137
+ cns.fillText(d,size/5*4,size/10+4*size/5-size/5*milisec/1000);
1138
+ cns.fillText(e,size/5*4,size/10+5*size/5-size/5*milisec/1000);
1139
+
1140
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
1141
+ {
1142
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
1143
+ }
1144
+
1145
+ if(clockd.hasOwnProperty("indicate") && clockd.indicate)
1146
+ {
1147
+ cns.strokeStyle=(clockd.hasOwnProperty("indicate_color"))?clockd["indicate_color"]:"#333333";
1148
+ cns.beginPath();
1149
+ cns.moveTo(0,(size/2));
1150
+ cns.lineTo(size,(size/2));
1151
+ cns.stroke()
1152
+ cns.closePath();
1153
+ }
1154
+
1155
+ clockd.timer=setTimeout(function(){clock_roulette(size, cns, clockd)},50);
1156
+ }
1157
+
1158
+ function clock_binary(size, cns, clockd)
1159
+ {
1160
+ var now=new Date();
1161
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
1162
+ now.setTime(now.getTime()+time_off*1000);
1163
+ var milisec=now.getMilliseconds();
1164
+ var sec=now.getSeconds();
1165
+ var min=now.getMinutes();
1166
+ var hour=now.getHours()%12;
1167
+
1168
+ cns.clearRect(0,0,size,size);
1169
+
1170
+ cns.beginPath();
1171
+ if(clockd.hasOwnProperty("bg_color")){cns.fillStyle=clockd["bg_color"];}else{cns.fillStyle="#ffffff";}
1172
+ cns.rect(0,0,size,size);
1173
+ cns.fill();
1174
+ cns.closePath();
1175
+ if(clockd.hasOwnProperty("bgLoaded") && clockd.bgLoaded==1){if(clockd.hasOwnProperty("bg_opacity")){cns.globalAlpha=clockd["bg_opacity"];cns.drawImage(clockd.bgImage,0,0,size,size);cns.globalAlpha=1;}}
1176
+
1177
+ hourstr="";
1178
+ if(hour<1){hourstr="0";}
1179
+ while(hour>0)
1180
+ {
1181
+ hourstr=hour%2+hourstr;
1182
+ hour=hour-hour%2;
1183
+ hour=hour/2;
1184
+ }
1185
+ if(hourstr.length<6){while(hourstr.length<6){hourstr="0"+hourstr;}}
1186
+
1187
+ minstr="";
1188
+ if(min<1){minstr="0";}
1189
+ while(min>0)
1190
+ {
1191
+ minstr=min%2+minstr;
1192
+ min=min-min%2;
1193
+ min=min/2;
1194
+ }
1195
+ if(minstr.length<6){while(minstr.length<6){minstr="0"+minstr;}}
1196
+
1197
+ secstr="";
1198
+ if(sec<1){secstr="0";}
1199
+ while(sec>0)
1200
+ {
1201
+ secstr=sec%2+secstr;
1202
+ sec=sec-sec%2;
1203
+ sec=sec/2;
1204
+ }
1205
+ if(secstr.length<6){while(secstr.length<6){secstr="0"+secstr;}}
1206
+
1207
+ cns.fillStyle=(clockd.hasOwnProperty("dial1_color"))?clockd["dial1_color"]:"#333333";
1208
+ cns.textBaseline="middle";
1209
+ cns.textAlign="center";
1210
+ cns.font=size/8+"px Courier New";
1211
+ cns.fillText(hourstr,(size/2),size/5);
1212
+ cns.fillText(minstr,(size/2),size/5*2);
1213
+ cns.fillText(secstr,(size/2),size/5*3);
1214
+
1215
+ if(clockd.hasOwnProperty("date_add") && clockd.date_add)
1216
+ {
1217
+ date_add((size/2),size/5*3+size/10, size, cns, clockd);
1218
+ }
1219
+
1220
+ clockd.timer=setTimeout(function(){clock_binary(size, cns, clockd)},50);
1221
+ }
1222
+
1223
+ function clock_stop(clockd)
1224
+ {
1225
+ clearTimeout(clockd.timer);
1226
+ }
1227
+
1228
+ function clock_loadBG(src, clockd)
1229
+ {
1230
+ clockd.bgImage = new Image();
1231
+ clockd.bgImage.onload = function(){ clockd.bgLoaded=1; };
1232
+ clockd.bgImage.src = src;
1233
+
1234
+ if(!clockd.hasOwnProperty("bg_opacity")){clockd.bg_opacity=1;}
1235
+ }
1236
+
1237
+ function indicator(size, cns, clockd)
1238
+ {
1239
+ if(clockd.hasOwnProperty("indicate_color")){cns.strokeStyle=clockd["indicate_color"];}else{cns.strokeStyle="#333";}
1240
+ cns.lineWidth=2;
1241
+
1242
+ for(var a=0;a<12;a++)
1243
+ {
1244
+ var r=parseInt(a)*0.523;
1245
+ var calc=Math.cos(r-1.57);
1246
+ var y=Math.sin(r-1.57);
1247
+
1248
+ if(a%3==0){var ekstra=size/50;}else{var ekstra=0;}
1249
+ cns.beginPath();
1250
+ cns.moveTo(calc*(size/3+ekstra)+(size/2),y*(size/3+ekstra)+(size/2));
1251
+ cns.lineTo(calc*size/3.25+(size/2),y*size/3.25+(size/2));
1252
+ cns.stroke();
1253
+ cns.fill();
1254
+ cns.closePath();
1255
+ }
1256
+ }
1257
+
1258
+ function ycd_time_add(x, y, size, cns, clockd, extraOptions)
1259
+ {
1260
+ if(!clockd.hasOwnProperty("time_add"))
1261
+ {
1262
+ return;
1263
+ }
1264
+
1265
+ var now = new Date();
1266
+ if (extraOptions.timeZone) {
1267
+ now = new Date().toLocaleString('en-US', {
1268
+ timeZone: extraOptions.timeZone
1269
+ });
1270
+ }
1271
+
1272
+ now = new Date(now);
1273
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
1274
+ now.setTime(now.getTime()+time_off*1000);
1275
+ var sec=now.getSeconds();
1276
+ var min=now.getMinutes();
1277
+ var hour=(clockd.hasOwnProperty("time_24h") && clockd["time_24h"])?now.getHours():now.getHours()%12;
1278
+
1279
+ if(hour==0){hour=12;}
1280
+ if(hour<10){hour="0"+hour;}
1281
+ if(min<10){min="0"+min;}
1282
+ if(sec<10){sec="0"+sec;}
1283
+ cns.lineWidth=1;
1284
+ cns.fillStyle=(clockd.hasOwnProperty("time_add_color")?clockd["time_add_color"]:"#333");
1285
+ cns.textBaseline="middle";
1286
+ cns.textAlign="center";
1287
+ cns.font=size/15+"px Arial";
1288
+
1289
+ switch(parseInt(clockd["time_add"]))
1290
+ {
1291
+ case 1:
1292
+ cns.fillText(hour+":"+min+":"+sec,x,y);
1293
+ break;
1294
+ case 2:
1295
+ cns.fillText(hour+":"+min,x,y);
1296
+ break;
1297
+ case 3:
1298
+ hour=now.getHours();
1299
+ if(hour<10){hour="0"+hour;}
1300
+ cns.fillText(hour+":"+min+":"+sec,x,y);
1301
+ break;
1302
+ default:
1303
+ hour=now.getHours();
1304
+ if(hour<10){hour="0"+hour;}
1305
+ cns.fillText(hour+":"+min,x,y);
1306
+ }
1307
+ }
1308
+
1309
+ function date_add(x, y, size, cns, clockd)
1310
+ {
1311
+ if(!clockd.hasOwnProperty("date_add"))
1312
+ {
1313
+ return;
1314
+ }
1315
+
1316
+ var now=new Date();
1317
+ var time_off=(clockd.hasOwnProperty("timeoffset"))?clockd["timeoffset"]:0;
1318
+ now.setTime(now.getTime()+time_off*1000);
1319
+ var day=now.getDate();
1320
+ var year=now.getFullYear();
1321
+ var month=now.getMonth()+1;
1322
+
1323
+ if((month)<10){month="0"+(month);}
1324
+ if(day<10){day="0"+day;}
1325
+
1326
+ cns.lineWidth=1;
1327
+ cns.fillStyle=clockd["date_add_color"];
1328
+ cns.textBaseline="middle";
1329
+ cns.textAlign="center";
1330
+ cns.font=size/20+"px Arial";
1331
+
1332
+ switch(parseInt(clockd["date_add"]))
1333
+ {
1334
+ case 1:
1335
+ cns.fillText(day+"/"+month+"/"+year,x,y);
1336
+ break;
1337
+ case 2:
1338
+ cns.fillText(month+"/"+day+"/"+year,x,y);
1339
+ break;
1340
+ case 3:
1341
+ day=now.getDay();
1342
+ cns.fillText(day_arr[day],x,y);
1343
+ break;
1344
+ case 4:
1345
+ month=now.getMonth();
1346
+ cns.fillText(month_arr[month]+" "+day,x,y);
1347
+ break;
1348
+ default:
1349
+ month=now.getMonth();
1350
+ cns.fillText(day+" "+month_arr[month],x,y);
1351
+ }
1352
+ }
assets/views/main/clock1View.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use ycd\AdminHelper;
3
+ $defaultData = AdminHelper::defaultData();
4
+ $type = $this->getCurrentTypeFromOptions();
5
+ ?>
6
+ <div class="ycd-bootstrap-wrapper">
7
+ <div class="row form-group">
8
+ <div class="col-md-6">
9
+ <label class="ycd-label-of-input"><?php _e('Time zone', YCD_TEXT_DOMAIN); ?></label>
10
+ </div>
11
+ <div class="col-md-5">
12
+ <?php echo AdminHelper::selectBox($defaultData['clock-time-zone'], esc_attr($this->getOptionValue('ycd-clock1-time-zone')), array('name' => 'ycd-clock1-time-zone', 'class' => 'js-ycd-select js-circle-time-zone')); ?>
13
+ </div>
14
+ </div>
15
+ <div class="row form-group">
16
+ <div class="col-md-6">
17
+ <label for="ycd-clock1-width" class="ycd-label-of-input"><?php _e('Dimension', YCD_TEXT_DOMAIN); ?></label>
18
+ </div>
19
+ <div class="col-md-5">
20
+ <input type="number" name="ycd-clock1-width" class="form-control" id="ycd-clock1-width" value="<?php echo esc_attr($this->getOptionValue('ycd-clock1-width')); ?>">
21
+ </div>
22
+ <div class="col-md-1 ycd-label-of-input">
23
+ <?php _e('px', YCD_TEXT_DOMAIN); ?>
24
+ </div>
25
+ </div>
26
+ <div class="row">
27
+ <div class="col-md-6">
28
+ <label class="ycd-label-of-input"><?php _e('Alignment', YCD_TEXT_DOMAIN); ?></label>
29
+ </div>
30
+ <div class="col-md-5">
31
+ <?php echo AdminHelper::selectBox($defaultData['horizontal-alignment'], esc_attr($this->getOptionValue('ycd-clock1-alignment')), array('name' => 'ycd-clock1-alignment', 'class' => 'js-ycd-select ycd-clock1-alignment')); ?>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <?php
36
+ require_once YCD_VIEWS_PATH.'preview.php';
37
+ ?>
38
+ <input type="hidden" name="ycd-type" value="<?php echo esc_attr($type); ?>">
classes/countdown/Clock1Countdown.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ycd;
3
+
4
+ class Clock1Countdown extends Countdown {
5
+
6
+ public function __construct() {
7
+ add_filter('ycdGeneralMetaboxes', array($this, 'metaboxes'));
8
+ add_action('add_meta_boxes', array($this, 'mainOptions'));
9
+ add_filter('ycdCountdownDefaultOptions', array($this, 'defaultOptions'), 1, 1);
10
+ }
11
+
12
+ public function metaboxes($mtaboxes) {
13
+ unset($mtaboxes['generalOptions']);
14
+ unset($mtaboxes['afterCountdownExpire']);
15
+
16
+ return $mtaboxes;
17
+ }
18
+
19
+ public function defaultOptions($options) {
20
+
21
+ return $options;
22
+ }
23
+
24
+ public function includeStyles() {
25
+ wp_enqueue_script("jquery-ui-draggable");
26
+ ScriptsIncluder::registerScript('canvas_clock.js', array('dirUrl' => YCD_COUNTDOWN_JS_URL.'clock/'));
27
+ ScriptsIncluder::enqueueScript('canvas_clock.js');
28
+ ScriptsIncluder::registerScript('Clock.js', array('dirUrl' => YCD_COUNTDOWN_JS_URL.'clock/'));
29
+ ScriptsIncluder::enqueueScript('Clock.js');
30
+ }
31
+
32
+ public function mainOptions(){
33
+ parent::mainOptions();
34
+ add_meta_box('ycdMainOptions', __('Clock options', YCD_TEXT_DOMAIN), array($this, 'mainView'), YCD_COUNTDOWN_POST_TYPE, 'normal', 'high');
35
+ }
36
+
37
+ public function mainView() {
38
+ $typeObj = $this;
39
+ require_once YCD_VIEWS_MAIN_PATH.'clock1View.php';
40
+ }
41
+
42
+ public function renderLivePreview()
43
+ {
44
+ $typeObj = $this;
45
+ require_once YCD_PREVIEW_VIEWS_PATH . 'circlePreview.php';
46
+ }
47
+
48
+ private function getClockArgs() {
49
+ $args = array(
50
+ 'indicate' => true,
51
+ 'indicate_color' => '#222',
52
+ 'dial1_color' => '#666600',
53
+ 'dial2_color' => '#81812e',
54
+ 'dial3_color' => '#9d9d5c',
55
+ 'time_add' => 1,
56
+ 'time_24h' => true,
57
+ 'date_add' => 3,
58
+ 'date_add_color' => '#999',
59
+ );
60
+
61
+ return $args;
62
+ }
63
+
64
+ private function getCanvasOptions() {
65
+ $options = array();
66
+ $width = (int)$this->getOptionValue('ycd-clock1-width');
67
+ $timeZone = $this->getOptionValue('ycd-clock1-time-zone');
68
+
69
+ $options['width'] = $width;
70
+ $options['timeZone'] = $timeZone;
71
+
72
+ return $options;
73
+ }
74
+
75
+ private function getStylesStr() {
76
+ $align = $this->getOptionValue('ycd-clock1-alignment');
77
+ $id = $this->getId();
78
+
79
+ $style = '<style type="text/css">';
80
+ $style .= '.ycd-countdown-'.esc_attr($id).'-wrapper {';
81
+ $style .= 'text-align: '.$align;
82
+ $style .= '}';
83
+ $style .= '</style>';
84
+
85
+ return $style;
86
+ }
87
+
88
+ public function getViewContent() {
89
+ $this->includeStyles();
90
+ $id = $this->getId();
91
+
92
+ $options = $this->getCanvasOptions();
93
+ $width = @$options['width'];
94
+ $args = $this->getClockArgs();
95
+
96
+ $args = json_encode($args);
97
+ $options = json_encode($options);
98
+
99
+ $content = '<div class="ycd-countdown-wrapper ycd-countdown-'.esc_attr($id).'-wrapper">';
100
+ $content .= '<canvas data-args="'.esc_attr($args).'" data-options="'.esc_attr($options).'" class="ycdClock1" width="'.$width.'px" height="'.$width.'px"></canvas>';
101
+ $content .= $this->renderSubscriptionForm();
102
+ $content .= '</div>';
103
+ $content .= $this->getStylesStr();
104
+
105
+ return $content;
106
+ }
107
+ }
classes/countdown/Countdown.php CHANGED
@@ -4,335 +4,335 @@ use \YcdCountdownOptionsConfig;
4
 
5
  abstract class Countdown {
6
 
7
- private $id;
8
- private $type;
9
- private $title;
10
- private $savedData;
11
- private $sanitizedData;
12
- private $shortCodeArgs;
13
- private $shortCodeContent;
14
-
15
- abstract protected function getViewContent();
16
-
17
- public function setId($id) {
18
- $this->id = $id;
19
- }
20
-
21
- public function getId() {
22
- return (int)$this->id;
23
- }
24
-
25
- public function setType($type) {
26
- $this->type = $type;
27
- }
28
-
29
- public function getType() {
30
- return $this->type;
31
- }
32
-
33
- public function getTypeTitle() {
34
- $type = $this->getType();
35
- global $YCD_TYPES;
36
- $titles = $YCD_TYPES['titles'];
37
-
38
- $typeTitle = (isset($titles[$type])) ? $titles[$type] : __('Unknown Type', YCD_TEXT_DOMAIN);
39
-
40
- return $typeTitle;
41
- }
42
-
43
- public function setTitle($title) {
44
- $this->title = $title;
45
- }
46
-
47
- public function getTitle() {
48
- return $this->title;
49
- }
50
-
51
- public function setShortCodeContent($shortCodeContent) {
52
- $this->shortCodeContent = $shortCodeContent;
53
- }
54
-
55
- public function getShortCodeContent() {
56
- return $this->shortCodeContent;
57
- }
58
-
59
- public function setShortCodeArgs($shortCodeArgs) {
60
- $this->shortCodeArgs = $shortCodeArgs;
61
- }
62
-
63
- public function getShortCodeArgs() {
64
- return $this->shortCodeArgs;
65
- }
66
-
67
- public function setSavedData($savedData) {
68
- $this->savedData = $savedData;
69
- }
70
-
71
- public function getSavedData() {
72
- return $this->savedData;
73
- }
74
-
75
- public function insertIntoSanitizedData($sanitizedData) {
76
- if (!empty($sanitizedData)) {
77
- $this->sanitizedData[$sanitizedData['name']] = $sanitizedData['value'];
78
- }
79
- }
80
-
81
- public function getSanitizedData() {
82
- return $this->sanitizedData;
83
- }
84
-
85
- public function getMetaBoxes()
86
- {
87
- $metaboxes = $this->defaultMainMetaboxes();
88
-
89
- return apply_filters('ycdGeneralMetaboxes', $metaboxes);
90
- }
91
-
92
- public static function create($data = array()) {
93
- $obj = new static();
94
- $id = $data['ycd-post-id'];
95
- $obj->setId($id);
96
-
97
- // set up apply filter
98
- YcdCountdownOptionsConfig::optionsValues();
99
- foreach ($data as $name => $value) {
100
- $defaultData = $obj->getDefaultDataByName($name);
101
- if (empty($defaultData['type'])) {
102
- $defaultData['type'] = 'string';
103
- }
104
- $sanitizedValue = $obj->sanitizeValueByType($value, $defaultData['type']);
105
- $obj->insertIntoSanitizedData(array('name' => $name,'value' => $sanitizedValue));
106
- }
107
-
108
- $result = $obj->save();
109
- }
110
-
111
- public function save() {
112
- $options = $this->getSanitizedData();
113
- $postId = $this->getId();
114
-
115
- update_post_meta($postId, 'ycd_options', $options);
116
- }
117
-
118
- public function sanitizeValueByType($value, $type) {
119
- switch ($type) {
120
- case 'string':
121
- case 'number':
122
- $sanitizedValue = sanitize_text_field($value);
123
- break;
124
- case 'html':
125
- $sanitizedValue = $value;
126
- break;
127
- case 'array':
128
- $sanitizedValue = $this->recursiveSanitizeTextField($value);
129
- break;
130
- case 'email':
131
- $sanitizedValue = sanitize_email($value);
132
- break;
133
- case "checkbox":
134
- $sanitizedValue = sanitize_text_field($value);
135
- break;
136
- default:
137
- $sanitizedValue = sanitize_text_field($value);
138
- break;
139
- }
140
-
141
- return $sanitizedValue;
142
- }
143
-
144
- public function recursiveSanitizeTextField($array) {
145
- if (!is_array($array)) {
146
- return $array;
147
- }
148
-
149
- foreach ($array as $key => &$value) {
150
- if (is_array($value)) {
151
- $value = $this->recursiveSanitizeTextField($value);
152
- }
153
- else {
154
- /*get simple field type and do sensitization*/
155
- $defaultData = $this->getDefaultDataByName($key);
156
- if (empty($defaultData['type'])) {
157
- $defaultData['type'] = 'string';
158
- }
159
- $value = $this->sanitizeValueByType($value, $defaultData['type']);
160
- }
161
- }
162
-
163
- return $array;
164
- }
165
-
166
- public function getDefaultDataByName($optionName) {
167
- global $YCD_OPTIONS;
168
-
169
- foreach ($YCD_OPTIONS as $option) {
170
- if ($option['name'] == $optionName) {
171
- return $option;
172
- }
173
- }
174
-
175
- return array();
176
- }
177
-
178
- public function getDefaultValue($optionName) {
179
-
180
- if (empty($optionName)) {
181
- return '';
182
- }
183
-
184
- $defaultData = $this->getDefaultDataByName($optionName);
185
-
186
- if (empty($defaultData['defaultValue'])) {
187
- return '';
188
- }
189
-
190
- return $defaultData['defaultValue'];
191
- }
192
-
193
- public function isAllowOption($optionName) {
194
- if(YCD_PKG_VERSION == YCD_FREE_VERSION) {
195
- return true;
196
- }
197
- $defaultData = $this->getDefaultDataByName($optionName);
198
-
199
- if(empty($defaultData['available'])) {
200
- return true;
201
- }
202
-
203
- return YCD_PKG_VERSION >= $defaultData['available'];
204
- }
205
-
206
- public static function parseCountdownDataFromData($data) {
207
- $cdData = array();
208
-
209
- foreach ($data as $key => $value) {
210
- if (strpos($key, 'ycd') === 0) {
211
- $cdData[$key] = $value;
212
- }
213
- }
214
-
215
- return $cdData;
216
- }
217
-
218
- public static function getClassNameCountdownType($type) {
219
- $typeName = ucfirst(strtolower($type));
220
- $className = $typeName.'Countdown';
221
-
222
- return $className;
223
- }
224
-
225
- public static function getTypePathFormCountdownType($type) {
226
- global $YCD_TYPES;
227
- $typePath = '';
228
-
229
- if (!empty($YCD_TYPES['typePath'][$type])) {
230
- $typePath = $YCD_TYPES['typePath'][$type];
231
- }
232
-
233
- return $typePath;
234
- }
235
-
236
- /**
237
- * Get option value from name
238
- * @since 1.0.0
239
- *
240
- * @param string $optionName
241
- * @param bool $forceDefaultValue
242
- * @return string
243
- */
244
- public function getOptionValue($optionName, $forceDefaultValue = false) {
245
- $savedData = CountdownModel::getDataById($this->getId());
246
- $this->setSavedData($savedData);
247
-
248
- return $this->getOptionValueFromSavedData($optionName, $forceDefaultValue);
249
- }
250
-
251
- public function getOptionValueFromSavedData($optionName, $forceDefaultValue = false) {
252
-
253
- $defaultData = $this->getDefaultDataByName($optionName);
254
- $savedData = $this->getSavedData();
255
 
256
- $optionValue = null;
257
-
258
- if (empty($defaultData['type'])) {
259
- $defaultData['type'] = 'string';
260
- }
261
-
262
- if (!empty($savedData)) { //edit mode
263
- if (isset($savedData[$optionName])) { //option exists in the database
264
- $optionValue = $savedData[$optionName];
265
- }
266
- /* if it's a checkbox, it may not exist in the db
267
- * if we don't care about it's existence, return empty string
268
- * otherwise, go for it's default value
269
- */
270
- else if ($defaultData['type'] == 'checkbox' && !$forceDefaultValue) {
271
- $optionValue = '';
272
- }
273
- }
274
-
275
- if (($optionValue === null && !empty($defaultData['defaultValue'])) || ($defaultData['type'] == 'number' && !isset($optionValue))) {
276
- $optionValue = $defaultData['defaultValue'];
277
- }
278
-
279
- if ($defaultData['type'] == 'checkbox') {
280
- $optionValue = $this->boolToChecked($optionValue);
281
- }
282
-
283
- if(isset($defaultData['ver']) && $defaultData['ver'] > YCD_PKG_VERSION) {
284
- if (empty($defaultData['allow'])) {
285
- return $defaultData['defaultValue'];
286
- }
287
- else if (!in_array($optionValue, $defaultData['allow'])) {
288
- return $defaultData['defaultValue'];
289
- }
290
- }
291
-
292
- return $optionValue;
293
- }
294
-
295
- public static function getPostSavedData($postId) {
296
- $savedData = get_post_meta($postId, 'ycd_options');
297
-
298
- if (empty($savedData)) {
299
- return $savedData;
300
- }
301
- $savedData = $savedData[0];
302
-
303
- return $savedData;
304
- }
305
-
306
- /**
307
- * Returns separate countdown types Free or Pro
308
- *
309
- * @since 1.0.0
310
- *
311
- * @return array $countdownType
312
- */
313
- public static function getCountdownTypes() {
314
- global $YCD_TYPES;
315
- $countdownTypesObj = array();
316
- $countdownTypes = $YCD_TYPES['typeName'];
317
-
318
- foreach($countdownTypes as $type => $level) {
319
- if(empty($level)) {
320
- $level = YCD_FREE_VERSION;
321
- }
322
- $typeObj = new CountdownType();
323
- $typeObj->setName($type);
324
- $typeObj->setAccessLevel($level);
325
-
326
- if(YCD_PKG_VERSION >= $level) {
327
- $typeObj->setAvailable(true);
328
- }
329
- $countdownTypesObj[] = $typeObj;
330
- }
331
-
332
- return $countdownTypesObj;
333
- }
334
-
335
- public static function find($id) {
 
 
 
336
  $options = CountdownModel::getDataById($id);
337
 
338
  if(empty($options)) {
@@ -340,53 +340,49 @@ abstract class Countdown {
340
  }
341
  $type = $options['ycd-type'];
342
 
343
- $typePath = self::getTypePathFormCountdownType($type);
344
- $className = self::getClassNameCountdownType($type);
345
 
346
- if (!file_exists($typePath.$className.'.php')) {
347
- return false;
348
- }
349
 
350
- require_once($typePath.$className.'.php');
351
- $className = __NAMESPACE__.'\\'.$className;
352
- $postTitle = get_the_title($id);
353
 
354
- $typeObj = new $className();
355
- $typeObj->setId($id);
356
- $typeObj->setType($type);
357
- $typeObj->setTitle($postTitle);
358
- $typeObj->setSavedData($options);
359
 
360
- return $typeObj;
361
- }
 
 
 
362
 
363
- public function defaultMainMetaboxes() {
364
- $metaboxes = array();
 
 
365
 
366
- $metaboxes['advancedOptions'] = array('title' => 'Advanced options', 'position' => 'normal', 'prioritet' => 'high');
367
- $metaboxes['generalOptions'] = array('title' => 'General options', 'position' => 'normal', 'prioritet' => 'high');
368
- $metaboxes['subscription'] = array('title' => 'Subscription section', 'position' => 'normal', 'prioritet' => 'high');
369
- $metaboxes['afterCountdownExpire'] = array('title' => 'After Expire', 'position' => 'normal', 'prioritet' => 'high');
370
-
371
- return $metaboxes;
372
- }
373
-
374
- public function mainOptions() {
375
- $proLabel = '';
376
-
377
- if (YCD_PKG_VERSION == YCD_FREE_VERSION) {
378
- $proLabel = '<span class="ycd-pro-span"><b>'.__('pro', YCD_TEXT_DOMAIN).'</b></span>';
379
- }
380
  $metaboxes = $this->getMetaBoxes();
381
-
382
- foreach ($metaboxes as $key => $metabox) {
383
- add_meta_box($key, __($metabox['title'], YCD_TEXT_DOMAIN), array($this, $key), YCD_COUNTDOWN_POST_TYPE, $metabox['position'], $metabox['prioritet']);
384
- }
385
-
386
- /*add_meta_box('generalOptions', __('General options ', YCD_TEXT_DOMAIN), array($this, 'generalOptions'), YCD_COUNTDOWN_POST_TYPE, 'normal', 'high');
387
- add_meta_box('Subscription', __('Subscription section '.$proLabel, YCD_TEXT_DOMAIN), array($this, 'subscriptionSection'), YCD_COUNTDOWN_POST_TYPE, 'normal', 'high');
388
- add_meta_box('afterCountdownExpire', __('After Expire '.$proLabel, YCD_TEXT_DOMAIN), array($this, 'afterExpire'), YCD_COUNTDOWN_POST_TYPE, 'normal', 'high');*/
389
- }
390
 
391
  public function afterCountdownExpire() {
392
  require_once YCD_VIEWS_PATH.'afterExpire.php';
@@ -401,7 +397,7 @@ abstract class Countdown {
401
  }
402
 
403
  public function subscription() {
404
- require_once YCD_VIEWS_PATH.'subscriptionSection.php';
405
  }
406
 
407
  public static function isActivePost($postId) {
@@ -411,60 +407,60 @@ abstract class Countdown {
411
  return ($enabled && $postStatus == 'publish');
412
  }
413
 
414
- public function boolToChecked($var) {
415
- return ($var ? 'checked' : '');
416
- }
417
 
418
- public static function getPopupsObj($agrs = array()) {
419
- $postStatus = array('publish');
420
  $popups = array();
421
 
422
- if (!empty($agrs['postStatus'])) {
423
- $postStatus = $agrs['postStatus'];
424
- }
425
 
426
- $posts = get_posts(array(
427
- 'post_type' => YCD_COUNTDOWN_POST_TYPE,
428
- 'post_status' => $postStatus,
429
- 'numberposts' => -1
430
- // 'order' => 'ASC'
431
- ));
432
 
433
- if(empty($posts)) {
434
- return $popups;
435
- }
436
 
437
- foreach ($posts as $post) {
438
- $popupObj = self::find($post->ID);
439
 
440
- if(empty($popupObj)) {
441
- continue;
442
- }
443
- $popups[] = $popupObj;
444
- }
445
 
446
- return $popups;
447
- }
448
 
449
- public static function shapeIdTitleData($popups) {
450
- $idTitle = array();
451
 
452
- if(empty($popups)) {
453
- return $idTitle;
454
- }
455
 
456
- foreach ($popups as $popup) {
457
- $title = $popup->getTitle();
458
 
459
- if(empty($title)) {
460
- $title = __('(no title)', YCD_TEXT_DOMAIN);
461
- }
462
 
463
- $idTitle[$popup->getId()] = $title .' - '. $popup->getTypeTitle();
464
- }
465
 
466
- return $idTitle;
467
- }
468
 
469
  public function getDataAllOptions() {
470
  $options = array();
@@ -478,10 +474,10 @@ abstract class Countdown {
478
  return $options;
479
  }
480
 
481
- public function renderSubscriptionForm() {
482
- if (!$this->getOptionValue('ycd-enable-subscribe-form')) {
483
- return '';
484
- }
485
  $args = array(
486
  'width' => $this->getOptionValue('ycd-subscribe-width') ,
487
  'aboveText' => $this->getOptionValue('ycd-form-above-text'),
@@ -489,15 +485,15 @@ abstract class Countdown {
489
  'submitText' => $this->getOptionValue('ycd-form-submit-text'),
490
  'submitButtonColor' => $this->getOptionValue('ycd-form-submit-color'),
491
  'successMessage' => $this->getOptionValue('ycd-subscribe-success-message'),
492
- 'emailMessage' => $this->getOptionValue('ycd-subscribe-error-message'),
493
  'id' => $this->getId()
494
  );
495
 
496
- $subscription = new Subscription();
497
- $subscription->setOptions($args);
498
 
499
- return $subscription->render();
500
- }
501
 
502
  /**
503
  * Changing default options form changing options by name
@@ -525,4 +521,13 @@ abstract class Countdown {
525
 
526
  return $defaultOptions;
527
  }
 
 
 
 
 
 
 
 
 
528
  }
4
 
5
  abstract class Countdown {
6
 
7
+ private $id;
8
+ private $type;
9
+ private $title;
10
+ private $savedData;
11
+ private $sanitizedData;
12
+ private $shortCodeArgs;
13
+ private $shortCodeContent;
14
+
15
+ abstract protected function getViewContent();
16
+
17
+ public function setId($id) {
18
+ $this->id = $id;
19
+ }
20
+
21
+ public function getId() {
22
+ return (int)$this->id;
23
+ }
24
+
25
+ public function setType($type) {
26
+ $this->type = $type;
27
+ }
28
+
29
+ public function getType() {
30
+ return $this->type;
31
+ }
32
+
33
+ public function getTypeTitle() {
34
+ $type = $this->getType();
35
+ global $YCD_TYPES;
36
+ $titles = $YCD_TYPES['titles'];
37
+
38
+ $typeTitle = (isset($titles[$type])) ? $titles[$type] : __('Unknown Type', YCD_TEXT_DOMAIN);
39
+
40
+ return $typeTitle;
41
+ }
42
+
43
+ public function setTitle($title) {
44
+ $this->title = $title;
45
+ }
46
+
47
+ public function getTitle() {
48
+ return $this->title;
49
+ }
50
+
51
+ public function setShortCodeContent($shortCodeContent) {
52
+ $this->shortCodeContent = $shortCodeContent;
53
+ }
54
+
55
+ public function getShortCodeContent() {
56
+ return $this->shortCodeContent;
57
+ }
58
+
59
+ public function setShortCodeArgs($shortCodeArgs) {
60
+ $this->shortCodeArgs = $shortCodeArgs;
61
+ }
62
+
63
+ public function getShortCodeArgs() {
64
+ return $this->shortCodeArgs;
65
+ }
66
+
67
+ public function setSavedData($savedData) {
68
+ $this->savedData = $savedData;
69
+ }
70
+
71
+ public function getSavedData() {
72
+ return $this->savedData;
73
+ }
74
+
75
+ public function insertIntoSanitizedData($sanitizedData) {
76
+ if (!empty($sanitizedData)) {
77
+ $this->sanitizedData[$sanitizedData['name']] = $sanitizedData['value'];
78
+ }
79
+ }
80
+
81
+ public function getSanitizedData() {
82
+ return $this->sanitizedData;
83
+ }
84
+
85
+ public function getMetaBoxes()
86
+ {
87
+ $metaboxes = $this->defaultMainMetaboxes();
88
+
89
+ return apply_filters('ycdGeneralMetaboxes', $metaboxes);
90
+ }
91
+
92
+ public static function create($data = array()) {
93
+ $obj = new static();
94
+ $id = $data['ycd-post-id'];
95
+ $obj->setId($id);
96
+
97
+ // set up apply filter
98
+ YcdCountdownOptionsConfig::optionsValues();
99
+ foreach ($data as $name => $value) {
100
+ $defaultData = $obj->getDefaultDataByName($name);
101
+ if (empty($defaultData['type'])) {
102
+ $defaultData['type'] = 'string';
103
+ }
104
+ $sanitizedValue = $obj->sanitizeValueByType($value, $defaultData['type']);
105
+ $obj->insertIntoSanitizedData(array('name' => $name,'value' => $sanitizedValue));
106
+ }
107
+
108
+ $result = $obj->save();
109
+ }
110
+
111
+ public function save() {
112
+ $options = $this->getSanitizedData();
113
+ $postId = $this->getId();
114
+
115
+ update_post_meta($postId, 'ycd_options', $options);
116
+ }
117
+
118
+ public function sanitizeValueByType($value, $type) {
119
+ switch ($type) {
120
+ case 'string':
121
+ case 'number':
122
+ $sanitizedValue = sanitize_text_field($value);
123
+ break;
124
+ case 'html':
125
+ $sanitizedValue = $value;
126
+ break;
127
+ case 'array':
128
+ $sanitizedValue = $this->recursiveSanitizeTextField($value);
129
+ break;
130
+ case 'email':
131
+ $sanitizedValue = sanitize_email($value);
132
+ break;
133
+ case "checkbox":
134
+ $sanitizedValue = sanitize_text_field($value);
135
+ break;
136
+ default:
137
+ $sanitizedValue = sanitize_text_field($value);
138
+ break;
139
+ }
140
+
141
+ return $sanitizedValue;
142
+ }
143
+
144
+ public function recursiveSanitizeTextField($array) {
145
+ if (!is_array($array)) {
146
+ return $array;
147
+ }
148
+
149
+ foreach ($array as $key => &$value) {
150
+ if (is_array($value)) {
151
+ $value = $this->recursiveSanitizeTextField($value);
152
+ }
153
+ else {
154
+ /*get simple field type and do sensitization*/
155
+ $defaultData = $this->getDefaultDataByName($key);
156
+ if (empty($defaultData['type'])) {
157
+ $defaultData['type'] = 'string';
158
+ }
159
+ $value = $this->sanitizeValueByType($value, $defaultData['type']);
160
+ }
161
+ }
162
+
163
+ return $array;
164
+ }
165
+
166
+ public function getDefaultDataByName($optionName) {
167
+ global $YCD_OPTIONS;
168
+
169
+ foreach ($YCD_OPTIONS as $option) {
170
+ if ($option['name'] == $optionName) {
171
+ return $option;
172
+ }
173
+ }
174
+
175
+ return array();
176
+ }
177
+
178
+ public function getDefaultValue($optionName) {
179
+
180
+ if (empty($optionName)) {
181
+ return '';
182
+ }
183
+
184
+ $defaultData = $this->getDefaultDataByName($optionName);
185
+
186
+ if (empty($defaultData['defaultValue'])) {
187
+ return '';
188
+ }
189
+
190
+ return $defaultData['defaultValue'];
191
+ }
192
+
193
+ public function isAllowOption($optionName) {
194
+ if(YCD_PKG_VERSION == YCD_FREE_VERSION) {
195
+ return true;
196
+ }
197
+ $defaultData = $this->getDefaultDataByName($optionName);
198
+
199
+ if(empty($defaultData['available'])) {
200
+ return true;
201
+ }
202
+
203
+ return YCD_PKG_VERSION >= $defaultData['available'];
204
+ }
205
+
206
+ public static function parseCountdownDataFromData($data) {
207
+ $cdData = array();
208
+
209
+ foreach ($data as $key => $value) {
210
+ if (strpos($key, 'ycd') === 0) {
211
+ $cdData[$key] = $value;
212
+ }
213
+ }
214
+
215
+ return $cdData;
216
+ }
217
+
218
+ public static function getClassNameCountdownType($type) {
219
+ $typeName = ucfirst(strtolower($type));
220
+ $className = $typeName.'Countdown';
221
+
222
+ return $className;
223
+ }
224
+
225
+ public static function getTypePathFormCountdownType($type) {
226
+ global $YCD_TYPES;
227
+ $typePath = '';
228
+
229
+ if (!empty($YCD_TYPES['typePath'][$type])) {
230
+ $typePath = $YCD_TYPES['typePath'][$type];
231
+ }
232
+
233
+ return $typePath;
234
+ }
235
+
236
+ /**
237
+ * Get option value from name
238
+ * @since 1.0.0
239
+ *
240
+ * @param string $optionName
241
+ * @param bool $forceDefaultValue
242
+ * @return string
243
+ */
244
+ public function getOptionValue($optionName, $forceDefaultValue = false) {
245
+ $savedData = CountdownModel::getDataById($this->getId());
246
+ $this->setSavedData($savedData);
247
+
248
+ return $this->getOptionValueFromSavedData($optionName, $forceDefaultValue);
249
+ }
250
+
251
+ public function getOptionValueFromSavedData($optionName, $forceDefaultValue = false) {
 
 
 
252
 
253
+ $defaultData = $this->getDefaultDataByName($optionName);
254
+ $savedData = $this->getSavedData();
255
+
256
+ $optionValue = null;
257
+
258
+ if (empty($defaultData['type'])) {
259
+ $defaultData['type'] = 'string';
260
+ }
261
+
262
+ if (!empty($savedData)) { //edit mode
263
+ if (isset($savedData[$optionName])) { //option exists in the database
264
+ $optionValue = $savedData[$optionName];
265
+ }
266
+ /* if it's a checkbox, it may not exist in the db
267
+ * if we don't care about it's existence, return empty string
268
+ * otherwise, go for it's default value
269
+ */
270
+ else if ($defaultData['type'] == 'checkbox' && !$forceDefaultValue) {
271
+ $optionValue = '';
272
+ }
273
+ }
274
+
275
+ if (($optionValue === null && !empty($defaultData['defaultValue'])) || ($defaultData['type'] == 'number' && !isset($optionValue))) {
276
+ $optionValue = $defaultData['defaultValue'];
277
+ }
278
+
279
+ if ($defaultData['type'] == 'checkbox') {
280
+ $optionValue = $this->boolToChecked($optionValue);
281
+ }
282
+
283
+ if(isset($defaultData['ver']) && $defaultData['ver'] > YCD_PKG_VERSION) {
284
+ if (empty($defaultData['allow'])) {
285
+ return $defaultData['defaultValue'];
286
+ }
287
+ else if (!in_array($optionValue, $defaultData['allow'])) {
288
+ return $defaultData['defaultValue'];
289
+ }
290
+ }
291
+
292
+ return $optionValue;
293
+ }
294
+
295
+ public static function getPostSavedData($postId) {
296
+ $savedData = get_post_meta($postId, 'ycd_options');
297
+
298
+ if (empty($savedData)) {
299
+ return $savedData;
300
+ }
301
+ $savedData = $savedData[0];
302
+
303
+ return $savedData;
304
+ }
305
+
306
+ /**
307
+ * Returns separate countdown types Free or Pro
308
+ *
309
+ * @since 1.0.0
310
+ *
311
+ * @return array $countdownType
312
+ */
313
+ public static function getCountdownTypes() {
314
+ global $YCD_TYPES;
315
+ $countdownTypesObj = array();
316
+ $countdownTypes = $YCD_TYPES['typeName'];
317
+
318
+ foreach($countdownTypes as $type => $level) {
319
+ if(empty($level)) {
320
+ $level = YCD_FREE_VERSION;
321
+ }
322
+ $typeObj = new CountdownType();
323
+ $typeObj->setName($type);
324
+ $typeObj->setAccessLevel($level);
325
+
326
+ if(YCD_PKG_VERSION >= $level) {
327
+ $typeObj->setAvailable(true);
328
+ }
329
+ $countdownTypesObj[] = $typeObj;
330
+ }
331
+
332
+ return $countdownTypesObj;
333
+ }
334
+
335
+ public static function find($id) {
336
  $options = CountdownModel::getDataById($id);
337
 
338
  if(empty($options)) {
340
  }
341
  $type = $options['ycd-type'];
342
 
343
+ $typePath = self::getTypePathFormCountdownType($type);
344
+ $className = self::getClassNameCountdownType($type);
345
 
346
+ if (!file_exists($typePath.$className.'.php')) {
347
+ return false;
348
+ }
349
 
350
+ require_once($typePath.$className.'.php');
351
+ $className = __NAMESPACE__.'\\'.$className;
352
+ $postTitle = get_the_title($id);
353
 
354
+ $typeObj = new $className();
355
+ $typeObj->setId($id);
356
+ $typeObj->setType($type);
357
+ $typeObj->setTitle($postTitle);
358
+ $typeObj->setSavedData($options);
359
 
360
+ return $typeObj;
361
+ }
362
+
363
+ public function defaultMainMetaboxes() {
364
+ $metaboxes = array();
365
 
366
+ $metaboxes['advancedOptions'] = array('title' => 'Advanced options', 'position' => 'normal', 'prioritet' => 'high');
367
+ $metaboxes['generalOptions'] = array('title' => 'General options', 'position' => 'normal', 'prioritet' => 'high');
368
+ $metaboxes['subscription'] = array('title' => 'Subscription section', 'position' => 'normal', 'prioritet' => 'high');
369
+ $metaboxes['afterCountdownExpire'] = array('title' => 'After Expire', 'position' => 'normal', 'prioritet' => 'high');
370
 
371
+ return $metaboxes;
372
+ }
373
+
374
+ public function mainOptions() {
375
+ $proLabel = '';
376
+
377
+ if (YCD_PKG_VERSION == YCD_FREE_VERSION) {
378
+ $proLabel = '<span class="ycd-pro-span"><b>'.__('pro', YCD_TEXT_DOMAIN).'</b></span>';
379
+ }
 
 
 
 
 
380
  $metaboxes = $this->getMetaBoxes();
381
+
382
+ foreach ($metaboxes as $key => $metabox) {
383
+ add_meta_box($key, __($metabox['title'], YCD_TEXT_DOMAIN), array($this, $key), YCD_COUNTDOWN_POST_TYPE, $metabox['position'], $metabox['prioritet']);
384
+ }
385
+ }
 
 
 
 
386
 
387
  public function afterCountdownExpire() {
388
  require_once YCD_VIEWS_PATH.'afterExpire.php';
397
  }
398
 
399
  public function subscription() {
400
+ require_once YCD_VIEWS_PATH.'subscriptionSection.php';
401
  }
402
 
403
  public static function isActivePost($postId) {
407
  return ($enabled && $postStatus == 'publish');
408
  }
409
 
410
+ public function boolToChecked($var) {
411
+ return ($var ? 'checked' : '');
412
+ }
413
 
414
+ public static function getPopupsObj($agrs = array()) {
415
+ $postStatus = array('publish');
416
  $popups = array();
417
 
418
+ if (!empty($agrs['postStatus'])) {
419
+ $postStatus = $agrs['postStatus'];
420
+ }
421
 
422
+ $posts = get_posts(array(
423
+ 'post_type' => YCD_COUNTDOWN_POST_TYPE,
424
+ 'post_status' => $postStatus,
425
+ 'numberposts' => -1
426
+ // 'order' => 'ASC'
427
+ ));
428
 
429
+ if(empty($posts)) {
430
+ return $popups;
431
+ }
432
 
433
+ foreach ($posts as $post) {
434
+ $popupObj = self::find($post->ID);
435
 
436
+ if(empty($popupObj)) {
437
+ continue;
438
+ }
439
+ $popups[] = $popupObj;
440
+ }
441
 
442
+ return $popups;
443
+ }
444
 
445
+ public static function shapeIdTitleData($popups) {
446
+ $idTitle = array();
447
 
448
+ if(empty($popups)) {
449
+ return $idTitle;
450
+ }
451
 
452
+ foreach ($popups as $popup) {
453
+ $title = $popup->getTitle();
454
 
455
+ if(empty($title)) {
456
+ $title = __('(no title)', YCD_TEXT_DOMAIN);
457
+ }
458
 
459
+ $idTitle[$popup->getId()] = $title .' - '. $popup->getTypeTitle();
460
+ }
461
 
462
+ return $idTitle;
463
+ }
464
 
465
  public function getDataAllOptions() {
466
  $options = array();
474
  return $options;
475
  }
476
 
477
+ public function renderSubscriptionForm() {
478
+ if (!$this->getOptionValue('ycd-enable-subscribe-form')) {
479
+ return '';
480
+ }
481
  $args = array(
482
  'width' => $this->getOptionValue('ycd-subscribe-width') ,
483
  'aboveText' => $this->getOptionValue('ycd-form-above-text'),
485
  'submitText' => $this->getOptionValue('ycd-form-submit-text'),
486
  'submitButtonColor' => $this->getOptionValue('ycd-form-submit-color'),
487
  'successMessage' => $this->getOptionValue('ycd-subscribe-success-message'),
488
+ 'emailMessage' => $this->getOptionValue('ycd-subscribe-error-message'),
489
  'id' => $this->getId()
490
  );
491
 
492
+ $subscription = new Subscription();
493
+ $subscription->setOptions($args);
494
 
495
+ return $subscription->render();
496
+ }
497
 
498
  /**
499
  * Changing default options form changing options by name
521
 
522
  return $defaultOptions;
523
  }
524
+
525
+ public function getCurrentTypeFromOptions() {
526
+ $type = $this->getOptionValue('ycd-type');
527
+ if(empty($type)) {
528
+ $type = $_GET['ycd_type'];
529
+ }
530
+
531
+ return $type;
532
+ }
533
  }
config/config.php CHANGED
@@ -26,6 +26,7 @@ class YcdCountdownConfig {
26
  self::addDefine('YCD_CONFIG_PATH', YCD_COUNTDOWN_PATH.'config/');
27
  self::addDefine('YCD_ASSETS_PATH', YCD_COUNTDOWN_PATH.'/assets/');
28
  self::addDefine('YCD_VIEWS_PATH', YCD_ASSETS_PATH.'views/');
 
29
  self::addDefine('YCD_PREVIEW_VIEWS_PATH', YCD_VIEWS_PATH.'preview/');
30
  self::addDefine('YCD_CSS_PATH', YCD_ASSETS_PATH.'css/');
31
  self::addDefine('YCD_JS_PATH', YCD_ASSETS_PATH.'js/');
@@ -44,7 +45,7 @@ class YcdCountdownConfig {
44
  self::addDefine('YCD_FILTER_REPEAT_INTERVAL', 50);
45
  self::addDefine('YCD_CRON_REPEAT_INTERVAL', 1);
46
  self::addDefine('YCD_TABLE_LIMIT', 15);
47
- self::addDefine('YCD_VERSION', 1.3);
48
  self::addDefine('YCD_VERSION_PRO', 1.18);
49
  self::addDefine('YCD_FREE_VERSION', 1);
50
  self::addDefine('YCD_SILVER_VERSION', 2);
26
  self::addDefine('YCD_CONFIG_PATH', YCD_COUNTDOWN_PATH.'config/');
27
  self::addDefine('YCD_ASSETS_PATH', YCD_COUNTDOWN_PATH.'/assets/');
28
  self::addDefine('YCD_VIEWS_PATH', YCD_ASSETS_PATH.'views/');
29
+ self::addDefine('YCD_VIEWS_MAIN_PATH', YCD_VIEWS_PATH.'main/');
30
  self::addDefine('YCD_PREVIEW_VIEWS_PATH', YCD_VIEWS_PATH.'preview/');
31
  self::addDefine('YCD_CSS_PATH', YCD_ASSETS_PATH.'css/');
32
  self::addDefine('YCD_JS_PATH', YCD_ASSETS_PATH.'js/');
45
  self::addDefine('YCD_FILTER_REPEAT_INTERVAL', 50);
46
  self::addDefine('YCD_CRON_REPEAT_INTERVAL', 1);
47
  self::addDefine('YCD_TABLE_LIMIT', 15);
48
+ self::addDefine('YCD_VERSION', 1.31);
49
  self::addDefine('YCD_VERSION_PRO', 1.18);
50
  self::addDefine('YCD_FREE_VERSION', 1);
51
  self::addDefine('YCD_SILVER_VERSION', 2);
config/optionsConfig.php CHANGED
@@ -8,6 +8,7 @@ class YcdCountdownOptionsConfig {
8
  $YCD_TYPES['typeName'] = apply_filters('ycdTypes', array(
9
  'circle' => YCD_FREE_VERSION,
10
  'timer' => YCD_FREE_VERSION,
 
11
  'circlePopup' => YCD_SILVER_VERSION,
12
  'flipClock' => YCD_SILVER_VERSION,
13
  'flipClockPopup' => YCD_SILVER_VERSION
@@ -16,6 +17,7 @@ class YcdCountdownOptionsConfig {
16
  $YCD_TYPES['typePath'] = apply_filters('ycdTypePaths', array(
17
  'circle' => YCD_COUNTDOWNS_PATH,
18
  'timer' => YCD_COUNTDOWNS_PATH,
 
19
  'circlePopup' => YCD_COUNTDOWNS_PATH,
20
  'flipClock' => YCD_COUNTDOWNS_PATH,
21
  'flipClockPopup' => YCD_COUNTDOWNS_PATH
@@ -24,6 +26,7 @@ class YcdCountdownOptionsConfig {
24
  $YCD_TYPES['titles'] = apply_filters('ycdTitles', array(
25
  'circle' => __('Circle', YCD_TEXT_DOMAIN),
26
  'timer' => __('Digital', YCD_TEXT_DOMAIN),
 
27
  'circlePopup' => __('Circle Popup', YCD_TEXT_DOMAIN),
28
  'flipClock' => __('Flip Clock', YCD_TEXT_DOMAIN),
29
  'flipClockPopup' => __('Flip Clock Popup', YCD_TEXT_DOMAIN)
@@ -91,23 +94,14 @@ class YcdCountdownOptionsConfig {
91
  $options[] = array('name' => 'ycd-timer-content-padding', 'type' => 'number', 'defaultValue' => 0);
92
  $options[] = array('name' => 'ycd-timer-bg-image', 'type' => 'checkbox', 'defaultValue' => 0);
93
  $options[] = array('name' => 'ycd-timer-content-alignment', 'type' => 'text', 'defaultValue' => 'center');
 
 
 
 
94
 
95
- // flip clock
96
- $options[] = array('name' => 'ycd-flip-countdown-alignment', 'type' => 'text', 'defaultValue' => 'left');
97
- $options[] = array('name' => 'ycd-flip-countdown-year', 'type' => 'checkbox', 'defaultValue' => '');
98
- $options[] = array('name' => 'ycd-flip-countdown-year-text', 'type' => 'text', 'defaultValue' => __('Years', YCD_TEXT_DOMAIN));
99
- $options[] = array('name' => 'ycd-flip-countdown-week', 'type' => 'checkbox', 'defaultValue' => '');
100
- $options[] = array('name' => 'ycd-flip-countdown-week-text', 'type' => 'text', 'defaultValue' => __('Weeks', YCD_TEXT_DOMAIN));
101
- $options[] = array('name' => 'ycd-flip-countdown-days', 'type' => 'checkbox', 'defaultValue' => 'on');
102
- $options[] = array('name' => 'ycd-flip-countdown-days-text', 'type' => 'text', 'defaultValue' => __('DAYS', YCD_TEXT_DOMAIN));
103
- $options[] = array('name' => 'ycd-flip-countdown-hours', 'type' => 'checkbox', 'defaultValue' => 'on');
104
- $options[] = array('name' => 'ycd-flip-countdown-hours-text', 'type' => 'text', 'defaultValue' => __('HOURS', YCD_TEXT_DOMAIN));
105
- $options[] = array('name' => 'ycd-flip-countdown-minutes', 'type' => 'checkbox', 'defaultValue' => 'on');
106
- $options[] = array('name' => 'ycd-flip-countdown-minutes-text', 'type' => 'text', 'defaultValue' => __('MINUTES', YCD_TEXT_DOMAIN));
107
- $options[] = array('name' => 'ycd-flip-countdown-seconds', 'type' => 'checkbox', 'defaultValue' => 'on');
108
- $options[] = array('name' => 'ycd-flip-countdown-seconds-text', 'type' => 'text', 'defaultValue' => __('SECONDS', YCD_TEXT_DOMAIN));
109
- $options[] = array('name' => 'ycd-flip-countdown-expire-behavior', 'type' => 'text', 'defaultValue' => 'hideCountdown');
110
- $options[] = array('name' => 'ycd-flip-expire-text', 'type' => 'html', 'defaultValue' => '');
111
 
112
  $options[] = array('name' => 'ycd-countdown-hide-mobile', 'type' => 'checkbox', 'defaultValue' => '');
113
  $options[] = array('name' => 'ycd-countdown-show-mobile', 'type' => 'checkbox', 'defaultValue' => '');
8
  $YCD_TYPES['typeName'] = apply_filters('ycdTypes', array(
9
  'circle' => YCD_FREE_VERSION,
10
  'timer' => YCD_FREE_VERSION,
11
+ 'clock1' => YCD_FREE_VERSION,
12
  'circlePopup' => YCD_SILVER_VERSION,
13
  'flipClock' => YCD_SILVER_VERSION,
14
  'flipClockPopup' => YCD_SILVER_VERSION
17
  $YCD_TYPES['typePath'] = apply_filters('ycdTypePaths', array(
18
  'circle' => YCD_COUNTDOWNS_PATH,
19
  'timer' => YCD_COUNTDOWNS_PATH,
20
+ 'clock1' => YCD_COUNTDOWNS_PATH,
21
  'circlePopup' => YCD_COUNTDOWNS_PATH,
22
  'flipClock' => YCD_COUNTDOWNS_PATH,
23
  'flipClockPopup' => YCD_COUNTDOWNS_PATH
26
  $YCD_TYPES['titles'] = apply_filters('ycdTitles', array(
27
  'circle' => __('Circle', YCD_TEXT_DOMAIN),
28
  'timer' => __('Digital', YCD_TEXT_DOMAIN),
29
+ 'clock1' => __('Clock 1', YCD_TEXT_DOMAIN),
30
  'circlePopup' => __('Circle Popup', YCD_TEXT_DOMAIN),
31
  'flipClock' => __('Flip Clock', YCD_TEXT_DOMAIN),
32
  'flipClockPopup' => __('Flip Clock Popup', YCD_TEXT_DOMAIN)
94
  $options[] = array('name' => 'ycd-timer-content-padding', 'type' => 'number', 'defaultValue' => 0);
95
  $options[] = array('name' => 'ycd-timer-bg-image', 'type' => 'checkbox', 'defaultValue' => 0);
96
  $options[] = array('name' => 'ycd-timer-content-alignment', 'type' => 'text', 'defaultValue' => 'center');
97
+
98
+ // clock
99
+ $options[] = array('name' => 'ycd-clock1-time-zone', 'type' => 'text', 'defaultValue' => '');
100
+ $options[] = array('name' => 'ycd-clock1-width', 'type' => 'text', 'defaultValue' => 200);
101
 
102
+ if(YCD_PKG_VERSION > YCD_FREE_VERSION) {
103
+ require_once dirname(__FILE__) . '/proOptionsConfig.php';
104
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  $options[] = array('name' => 'ycd-countdown-hide-mobile', 'type' => 'checkbox', 'defaultValue' => '');
107
  $options[] = array('name' => 'ycd-countdown-show-mobile', 'type' => 'checkbox', 'defaultValue' => '');
config/proOptionsConfig.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class proOptionsConfig {
4
+ public function __construct() {
5
+ add_filter('ycdCountdownDefaultOptions', array($this, 'defaultOptions'), 1, 1);
6
+ }
7
+
8
+ public function defaultOptions($defaults) {
9
+ // flip clock
10
+ $defaults[] = array('name' => 'ycd-flip-countdown-alignment', 'type' => 'text', 'defaultValue' => 'left');
11
+ $defaults[] = array('name' => 'ycd-flip-countdown-year', 'type' => 'checkbox', 'defaultValue' => '');
12
+ $defaults[] = array('name' => 'ycd-flip-countdown-year-text', 'type' => 'text', 'defaultValue' => __('Years', YCD_TEXT_DOMAIN));
13
+ $defaults[] = array('name' => 'ycd-flip-countdown-week', 'type' => 'checkbox', 'defaultValue' => '');
14
+ $defaults[] = array('name' => 'ycd-flip-countdown-week-text', 'type' => 'text', 'defaultValue' => __('Weeks', YCD_TEXT_DOMAIN));
15
+ $defaults[] = array('name' => 'ycd-flip-countdown-days', 'type' => 'checkbox', 'defaultValue' => 'on');
16
+ $defaults[] = array('name' => 'ycd-flip-countdown-days-text', 'type' => 'text', 'defaultValue' => __('DAYS', YCD_TEXT_DOMAIN));
17
+ $defaults[] = array('name' => 'ycd-flip-countdown-hours', 'type' => 'checkbox', 'defaultValue' => 'on');
18
+ $defaults[] = array('name' => 'ycd-flip-countdown-hours-text', 'type' => 'text', 'defaultValue' => __('HOURS', YCD_TEXT_DOMAIN));
19
+ $defaults[] = array('name' => 'ycd-flip-countdown-minutes', 'type' => 'checkbox', 'defaultValue' => 'on');
20
+ $defaults[] = array('name' => 'ycd-flip-countdown-minutes-text', 'type' => 'text', 'defaultValue' => __('MINUTES', YCD_TEXT_DOMAIN));
21
+ $defaults[] = array('name' => 'ycd-flip-countdown-seconds', 'type' => 'checkbox', 'defaultValue' => 'on');
22
+ $defaults[] = array('name' => 'ycd-flip-countdown-seconds-text', 'type' => 'text', 'defaultValue' => __('SECONDS', YCD_TEXT_DOMAIN));
23
+ $defaults[] = array('name' => 'ycd-flip-countdown-expire-behavior', 'type' => 'text', 'defaultValue' => 'hideCountdown');
24
+ $defaults[] = array('name' => 'ycd-flip-expire-text', 'type' => 'html', 'defaultValue' => '');
25
+ $defaults[] = array('name' => 'ycd-flipclock-column-size', 'type' => 'html', 'defaultValue' => '1');
26
+
27
+ return $defaults;
28
+ }
29
+ }
30
+
31
+ new proOptionsConfig();
countdown-builder.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Countdown builder
4
  * Description: The best countdown plugin
5
- * Version: 1.3.0
6
  * Author: Adam Skaat
7
  * Author URI: https://edmonsoft.com/countdown
8
  * License: GPLv2
2
  /**
3
  * Plugin Name: Countdown builder
4
  * Description: The best countdown plugin
5
+ * Version: 1.3.1
6
  * Author: Adam Skaat
7
  * Author URI: https://edmonsoft.com/countdown
8
  * License: GPLv2
helpers/AdminHelper.php CHANGED
@@ -3,292 +3,295 @@ namespace ycd;
3
 
4
  class AdminHelper {
5
 
6
- public static function buildCreateCountdownUrl($type) {
7
- $isAvailable = $type->isAvailable();
8
- $name = $type->getName();
9
 
10
- $url = YCD_COUNTDOWN_ADMIN_URL.'post-new.php?post_type='.YCD_COUNTDOWN_POST_TYPE.'&ycd_type='.$name;
11
 
12
- if (!$isAvailable) {
13
- $url = YCD_COUNTDOWN_PRO_URL;
14
- }
15
 
16
- return $url;
17
- }
18
 
19
- public static function buildCreateCountdownAttrs($type) {
20
- $attrStr = '';
21
- $isAvailable = $type->isAvailable();
22
 
23
- if (!$isAvailable) {
24
- $args = array(
25
  'target' => '_blank'
26
- );
27
- $attrStr = self::createAttrs($args);
28
- }
29
 
30
- return $attrStr;
31
- }
32
 
33
- public static function getCountdownThumbClass($type) {
34
- $isAvailable = $type->isAvailable();
35
- $name = $type->getName();
36
 
37
- $typeClassName = $name.'-countdown';
38
 
39
- if (!$isAvailable) {
40
- $typeClassName .= '-pro ycd-pro-version';
41
- }
42
 
43
- return $typeClassName;
44
- }
45
 
46
- public static function getCountdownThumbText($type) {
47
- $isAvailable = $type->isAvailable();
48
- $name = $type->getName();
49
 
50
- $content = '';
51
 
52
- if (!$isAvailable) {
53
- $content = '<p class="ycd-type-title-pro">'.__('PRO Features', YCD_TEXT_DOMAIN).'</p>';
54
- }
55
 
56
- return $content;
57
- }
58
 
59
- public static function defaultData() {
60
 
61
- $data = array();
62
 
63
- $data['ycd-circle-animation'] = array(
64
- 'smooth' => __('Smooth', YCD_TEXT_DOMAIN),
65
- 'ticks' => __('Ticks', YCD_TEXT_DOMAIN)
66
- );
67
 
68
- $data['ycd-dimension-measure'] = array(
69
- 'px' => __('Px', YCD_TEXT_DOMAIN),
70
- '%' => __('%', YCD_TEXT_DOMAIN)
71
- );
72
 
73
- $data['ycd-countdown-direction'] = array(
74
- 'Clockwise' => __('Clockwise', YCD_TEXT_DOMAIN),
75
- 'Counter-clockwise' => __('Counter clockwise', YCD_TEXT_DOMAIN),
76
- 'Both' => __('Both', YCD_TEXT_DOMAIN)
77
- );
78
 
79
- $data['bg-image-size'] = array(
80
- 'auto' => __('Auto', YCD_TEXT_DOMAIN),
81
- 'cover' => __('Cover', YCD_TEXT_DOMAIN),
82
- 'contain' => __('Contain', YCD_TEXT_DOMAIN)
83
- );
84
 
85
- $data['bg-image-repeat'] = array(
86
- 'repeat' => __('Repeat', YCD_TEXT_DOMAIN),
87
- 'repeat-x' => __('Repeat x', YCD_TEXT_DOMAIN),
88
- 'repeat-y' => __('Repeat y', YCD_TEXT_DOMAIN),
89
- 'no-repeat' => __('Not Repeat', YCD_TEXT_DOMAIN)
90
- );
91
 
92
- for($i = 7; $i <= 15; $i++) {
93
- $data['font-size'][$i] = __($i.'px', YCD_TEXT_DOMAIN);
94
- }
95
 
96
- for($i = 7; $i <= 40; $i++) {
97
- $data['font-size-number'][$i] = __($i.'px', YCD_TEXT_DOMAIN);
98
- }
99
-
100
- $data['font-weight'] = array(
101
- 'normal' => __('Normal', YCD_TEXT_DOMAIN),
102
- 'bold' => __('Bold', YCD_TEXT_DOMAIN),
103
- 'bolder' => __('Bolder', YCD_TEXT_DOMAIN),
104
- 'lighter' => __('Lighter', YCD_TEXT_DOMAIN),
105
- '100' => __('100', YCD_TEXT_DOMAIN),
106
- '200' => __('200', YCD_TEXT_DOMAIN),
107
- '300' => __('300', YCD_TEXT_DOMAIN),
108
- '400' => __('400', YCD_TEXT_DOMAIN),
109
- '500' => __('500', YCD_TEXT_DOMAIN),
110
- '600' => __('600', YCD_TEXT_DOMAIN),
111
- '700' => __('700', YCD_TEXT_DOMAIN),
112
- '800' => __('800', YCD_TEXT_DOMAIN),
113
- '900' => __('900', YCD_TEXT_DOMAIN),
114
- 'initial' => __('Initial', YCD_TEXT_DOMAIN),
115
- 'inherit' => __('Inherit', YCD_TEXT_DOMAIN)
116
- );
117
-
118
- $data['font-style'] = array(
119
- 'normal' => __('Normal', YCD_TEXT_DOMAIN),
120
- 'italic' => __('Italic', YCD_TEXT_DOMAIN),
121
- 'initial' => __('Initial', YCD_TEXT_DOMAIN)
122
- );
123
-
124
- $data['font-family'] = array(
125
- 'inherit' => 'Inherit',
126
- 'Century Gothic' => 'Century Gothic',
127
- 'Diplomata SC' => 'Diplomata SC',
128
- 'flavors' => 'Flavors',
129
- 'Open Sans' => 'Open Sans',
130
- 'Droid Sans' =>'Droid Sans',
131
- 'Droid Serif' => 'Droid Serif',
132
- 'chewy' => 'Chewy',
133
- 'oswald' => 'Oswald',
134
- 'Dancing Script' => 'Dancing Script',
135
- 'Merriweather' => 'Merriweather',
136
- 'Roboto Condensed' => 'Roboto Condensed',
137
- 'Oswald' => 'Oswald',
138
- 'PT Sans' => 'PT Sans',
139
- 'Helvetica' => 'Helvetica',
140
- 'Montserrat' => 'Montserrat'
141
- );
142
-
143
- $data['countdownExpireTime'] = array(
144
- 'template' => array(
145
- 'fieldWrapperAttr' => array(
146
- 'class' => 'col-md-6 ycd-choice-option-wrapper'
147
- ),
148
- 'labelAttr' => array(
149
- 'class' => 'col-md-6 ycd-choice-option-wrapper'
150
- ),
151
- 'groupWrapperAttr' => array(
152
- 'class' => 'row form-group ycd-choice-wrapper'
153
- )
154
- ),
155
- 'buttonPosition' => 'right',
156
- 'nextNewLine' => true,
157
- 'fields' => array(
158
- array(
159
- 'attr' => array(
160
- 'type' => 'radio',
161
- 'name' => 'ycd-countdown-expire-behavior',
162
- 'class' => 'ycd-countdown-hide-behavior',
163
- 'data-attr-href' => 'ycd-countdown-default-behavior',
164
- 'value' => 'default'
165
- ),
166
- 'label' => array(
167
- 'name' => __('Default', YCD_TEXT_DOMAIN)
168
- )
169
- ),
170
- array(
171
- 'attr' => array(
172
- 'type' => 'radio',
173
- 'name' => 'ycd-countdown-expire-behavior',
174
- 'class' => 'ycd-countdown-hide-behavior',
175
- 'data-attr-href' => 'ycd-countdown-hide-behavior',
176
- 'value' => 'hideCountdown'
177
- ),
178
- 'label' => array(
179
- 'name' => __('Hide Countdown', YCD_TEXT_DOMAIN)
180
- )
181
- ),
182
- array(
183
- 'attr' => array(
184
- 'type' => 'radio',
185
- 'name' => 'ycd-countdown-expire-behavior',
186
- 'class' => 'ycd-countdown-show-text',
187
- 'data-attr-href' => 'ycd-countdown-show-text',
188
- 'value' => 'showText'
189
- ),
190
- 'label' => array(
191
- 'name' => __('Show Text', YCD_TEXT_DOMAIN)
192
- )
193
- ),
194
- array(
195
- 'attr' => array(
196
- 'type' => 'radio',
197
- 'name' => 'ycd-countdown-expire-behavior',
198
- 'class' => 'ycd-countdown-redirect-url',
199
- 'data-attr-href' => 'ycd-countdown-redirect-url',
200
- 'value' => 'redirectToURL'
201
- ),
202
- 'label' => array(
203
- 'name' => __('Redirect To URL', YCD_TEXT_DOMAIN)
204
- )
205
- )
206
- )
207
- );
208
-
209
- $data['countdownFlipExpireTime'] = array(
210
- 'template' => array(
211
- 'fieldWrapperAttr' => array(
212
- 'class' => 'col-md-7 ycd-choice-option-wrapper'
213
- ),
214
- 'labelAttr' => array(
215
- 'class' => 'col-md-5 ycd-choice-option-wrapper'
216
- ),
217
- 'groupWrapperAttr' => array(
218
- 'class' => 'row form-group ycd-choice-wrapper'
219
- )
220
- ),
221
- 'buttonPosition' => 'right',
222
- 'nextNewLine' => true,
223
- 'fields' => array(
224
- array(
225
- 'attr' => array(
226
- 'type' => 'radio',
227
- 'name' => 'ycd-flip-countdown-expire-behavior',
228
- 'class' => 'ycd-flip-countdown-hide-behavior',
229
- 'data-attr-href' => 'ycd-flip-countdown-default-behavior',
230
- 'value' => 'default'
231
- ),
232
- 'label' => array(
233
- 'name' => __('Default', YCD_TEXT_DOMAIN)
234
- )
235
- ),
236
- array(
237
- 'attr' => array(
238
- 'type' => 'radio',
239
- 'name' => 'ycd-flip-countdown-expire-behavior',
240
- 'class' => 'ycd-flip-countdown-hide-behavior',
241
- 'data-attr-href' => 'ycd-flip-countdown-hide-behavior',
242
- 'value' => 'hideCountdown'
243
- ),
244
- 'label' => array(
245
- 'name' => __('Hide Countdown', YCD_TEXT_DOMAIN)
246
- )
247
- ),
248
- array(
249
- 'attr' => array(
250
- 'type' => 'radio',
251
- 'name' => 'ycd-flip-countdown-expire-behavior',
252
- 'class' => 'ycd-flip-countdown-show-text',
253
- 'data-attr-href' => 'ycd-flip-countdown-show-text',
254
- 'value' => 'showText'
255
- ),
256
- 'label' => array(
257
- 'name' => __('Show Text', YCD_TEXT_DOMAIN)
258
- )
259
- ),
260
- array(
261
- 'attr' => array(
262
- 'type' => 'radio',
263
- 'name' => 'ycd-flip-countdown-expire-behavior',
264
- 'class' => 'ycd-flip-countdown-redirect-url',
265
- 'data-attr-href' => 'ycd-flip-countdown-redirect-url',
266
- 'value' => 'redirectToURL'
267
- ),
268
- 'label' => array(
269
- 'name' => __('Redirect To URL', YCD_TEXT_DOMAIN)
270
- )
271
- )
272
- )
273
- );
274
-
275
- $data['time-zone'] = self::getTimeZones();
276
-
277
- $data['horizontal-alignment'] = array(
278
- 'left' => __('Left', YCD_TEXT_DOMAIN),
279
- 'center' => __('Center', YCD_TEXT_DOMAIN),
280
- 'right' => __('Right', YCD_TEXT_DOMAIN)
281
- );
282
-
283
- $data['userRoles'] = self::getAllUserRoles();
284
- $data['countries-names'] = apply_filters('ycdCountries', array());
285
- $data['countries-is'] = array(
286
- 'is' => __('Is', YCD_TEXT_DOMAIN),
287
- 'isNot' => __('Is not', YCD_TEXT_DOMAIN),
288
- );
289
-
290
- return apply_filters('ycdDefaults', $data);
291
- }
 
 
 
292
 
293
  public static function getAllUserRoles() {
294
  $rulesArray = array();
@@ -308,44 +311,44 @@ class AdminHelper {
308
  return $rulesArray;
309
  }
310
 
311
- public static function selectBox($data, $selectedValue, $attrs) {
312
 
313
- $attrString = '';
314
- $selected = '';
315
 
316
- if(!empty($attrs) && isset($attrs)) {
317
 
318
- foreach ($attrs as $attrName => $attrValue) {
319
- $attrString .= ''.$attrName.'="'.$attrValue.'" ';
320
- }
321
- }
322
 
323
- $selectBox = '<select '.$attrString.'>';
324
 
325
- foreach ($data as $value => $label) {
326
 
327
- /*When is multiselect*/
328
- if(is_array($selectedValue)) {
329
- $isSelected = in_array($value, $selectedValue);
330
- if($isSelected) {
331
- $selected = 'selected';
332
- }
333
- }
334
- else if($selectedValue == $value) {
335
- $selected = 'selected';
336
- }
337
- else if(is_array($value) && in_array($selectedValue, $value)) {
338
- $selected = 'selected';
339
- }
340
 
341
- $selectBox .= '<option value="'.$value.'" '.$selected.'>'.$label.'</option>';
342
- $selected = '';
343
- }
344
 
345
- $selectBox .= '</select>';
346
 
347
- return $selectBox;
348
- }
349
 
350
  /**
351
  * ToDo add description for this function
3
 
4
  class AdminHelper {
5
 
6
+ public static function buildCreateCountdownUrl($type) {
7
+ $isAvailable = $type->isAvailable();
8
+ $name = $type->getName();
9
 
10
+ $url = YCD_COUNTDOWN_ADMIN_URL.'post-new.php?post_type='.YCD_COUNTDOWN_POST_TYPE.'&ycd_type='.$name;
11
 
12
+ if (!$isAvailable) {
13
+ $url = YCD_COUNTDOWN_PRO_URL;
14
+ }
15
 
16
+ return $url;
17
+ }
18
 
19
+ public static function buildCreateCountdownAttrs($type) {
20
+ $attrStr = '';
21
+ $isAvailable = $type->isAvailable();
22
 
23
+ if (!$isAvailable) {
24
+ $args = array(
25
  'target' => '_blank'
26
+ );
27
+ $attrStr = self::createAttrs($args);
28
+ }
29
 
30
+ return $attrStr;
31
+ }
32
 
33
+ public static function getCountdownThumbClass($type) {
34
+ $isAvailable = $type->isAvailable();
35
+ $name = $type->getName();
36
 
37
+ $typeClassName = $name.'-countdown';
38
 
39
+ if (!$isAvailable) {
40
+ $typeClassName .= '-pro ycd-pro-version';
41
+ }
42
 
43
+ return $typeClassName;
44
+ }
45
 
46
+ public static function getCountdownThumbText($type) {
47
+ $isAvailable = $type->isAvailable();
48
+ $name = $type->getName();
49
 
50
+ $content = '';
51
 
52
+ if (!$isAvailable) {
53
+ $content = '<p class="ycd-type-title-pro">'.__('PRO Features', YCD_TEXT_DOMAIN).'</p>';
54
+ }
55
 
56
+ return $content;
57
+ }
58
 
59
+ public static function defaultData() {
60
 
61
+ $data = array();
62
 
63
+ $data['ycd-circle-animation'] = array(
64
+ 'smooth' => __('Smooth', YCD_TEXT_DOMAIN),
65
+ 'ticks' => __('Ticks', YCD_TEXT_DOMAIN)
66
+ );
67
 
68
+ $data['ycd-dimension-measure'] = array(
69
+ 'px' => __('Px', YCD_TEXT_DOMAIN),
70
+ '%' => __('%', YCD_TEXT_DOMAIN)
71
+ );
72
 
73
+ $data['ycd-countdown-direction'] = array(
74
+ 'Clockwise' => __('Clockwise', YCD_TEXT_DOMAIN),
75
+ 'Counter-clockwise' => __('Counter clockwise', YCD_TEXT_DOMAIN),
76
+ 'Both' => __('Both', YCD_TEXT_DOMAIN)
77
+ );
78
 
79
+ $data['bg-image-size'] = array(
80
+ 'auto' => __('Auto', YCD_TEXT_DOMAIN),
81
+ 'cover' => __('Cover', YCD_TEXT_DOMAIN),
82
+ 'contain' => __('Contain', YCD_TEXT_DOMAIN)
83
+ );
84
 
85
+ $data['bg-image-repeat'] = array(
86
+ 'repeat' => __('Repeat', YCD_TEXT_DOMAIN),
87
+ 'repeat-x' => __('Repeat x', YCD_TEXT_DOMAIN),
88
+ 'repeat-y' => __('Repeat y', YCD_TEXT_DOMAIN),
89
+ 'no-repeat' => __('Not Repeat', YCD_TEXT_DOMAIN)
90
+ );
91
 
92
+ for($i = 7; $i <= 15; $i++) {
93
+ $data['font-size'][$i] = __($i.'px', YCD_TEXT_DOMAIN);
94
+ }
95
 
96
+ for($i = 7; $i <= 40; $i++) {
97
+ $data['font-size-number'][$i] = __($i.'px', YCD_TEXT_DOMAIN);
98
+ }
99
+
100
+ $data['font-weight'] = array(
101
+ 'normal' => __('Normal', YCD_TEXT_DOMAIN),
102
+ 'bold' => __('Bold', YCD_TEXT_DOMAIN),
103
+ 'bolder' => __('Bolder', YCD_TEXT_DOMAIN),
104
+ 'lighter' => __('Lighter', YCD_TEXT_DOMAIN),
105
+ '100' => __('100', YCD_TEXT_DOMAIN),
106
+ '200' => __('200', YCD_TEXT_DOMAIN),
107
+ '300' => __('300', YCD_TEXT_DOMAIN),
108
+ '400' => __('400', YCD_TEXT_DOMAIN),
109
+ '500' => __('500', YCD_TEXT_DOMAIN),
110
+ '600' => __('600', YCD_TEXT_DOMAIN),
111
+ '700' => __('700', YCD_TEXT_DOMAIN),
112
+ '800' => __('800', YCD_TEXT_DOMAIN),
113
+ '900' => __('900', YCD_TEXT_DOMAIN),
114
+ 'initial' => __('Initial', YCD_TEXT_DOMAIN),
115
+ 'inherit' => __('Inherit', YCD_TEXT_DOMAIN)
116
+ );
117
+
118
+ $data['font-style'] = array(
119
+ 'normal' => __('Normal', YCD_TEXT_DOMAIN),
120
+ 'italic' => __('Italic', YCD_TEXT_DOMAIN),
121
+ 'initial' => __('Initial', YCD_TEXT_DOMAIN)
122
+ );
123
+
124
+ $data['font-family'] = array(
125
+ 'inherit' => 'Inherit',
126
+ 'Century Gothic' => 'Century Gothic',
127
+ 'Diplomata SC' => 'Diplomata SC',
128
+ 'flavors' => 'Flavors',
129
+ 'Open Sans' => 'Open Sans',
130
+ 'Droid Sans' =>'Droid Sans',
131
+ 'Droid Serif' => 'Droid Serif',
132
+ 'chewy' => 'Chewy',
133
+ 'oswald' => 'Oswald',
134
+ 'Dancing Script' => 'Dancing Script',
135
+ 'Merriweather' => 'Merriweather',
136
+ 'Roboto Condensed' => 'Roboto Condensed',
137
+ 'Oswald' => 'Oswald',
138
+ 'PT Sans' => 'PT Sans',
139
+ 'Helvetica' => 'Helvetica',
140
+ 'Montserrat' => 'Montserrat'
141
+ );
142
+
143
+ $data['countdownExpireTime'] = array(
144
+ 'template' => array(
145
+ 'fieldWrapperAttr' => array(
146
+ 'class' => 'col-md-6 ycd-choice-option-wrapper'
147
+ ),
148
+ 'labelAttr' => array(
149
+ 'class' => 'col-md-6 ycd-choice-option-wrapper'
150
+ ),
151
+ 'groupWrapperAttr' => array(
152
+ 'class' => 'row form-group ycd-choice-wrapper'
153
+ )
154
+ ),
155
+ 'buttonPosition' => 'right',
156
+ 'nextNewLine' => true,
157
+ 'fields' => array(
158
+ array(
159
+ 'attr' => array(
160
+ 'type' => 'radio',
161
+ 'name' => 'ycd-countdown-expire-behavior',
162
+ 'class' => 'ycd-countdown-hide-behavior',
163
+ 'data-attr-href' => 'ycd-countdown-default-behavior',
164
+ 'value' => 'default'
165
+ ),
166
+ 'label' => array(
167
+ 'name' => __('Default', YCD_TEXT_DOMAIN)
168
+ )
169
+ ),
170
+ array(
171
+ 'attr' => array(
172
+ 'type' => 'radio',
173
+ 'name' => 'ycd-countdown-expire-behavior',
174
+ 'class' => 'ycd-countdown-hide-behavior',
175
+ 'data-attr-href' => 'ycd-countdown-hide-behavior',
176
+ 'value' => 'hideCountdown'
177
+ ),
178
+ 'label' => array(
179
+ 'name' => __('Hide Countdown', YCD_TEXT_DOMAIN)
180
+ )
181
+ ),
182
+ array(
183
+ 'attr' => array(
184
+ 'type' => 'radio',
185
+ 'name' => 'ycd-countdown-expire-behavior',
186
+ 'class' => 'ycd-countdown-show-text',
187
+ 'data-attr-href' => 'ycd-countdown-show-text',
188
+ 'value' => 'showText'
189
+ ),
190
+ 'label' => array(
191
+ 'name' => __('Show Text', YCD_TEXT_DOMAIN)
192
+ )
193
+ ),
194
+ array(
195
+ 'attr' => array(
196
+ 'type' => 'radio',
197
+ 'name' => 'ycd-countdown-expire-behavior',
198
+ 'class' => 'ycd-countdown-redirect-url',
199
+ 'data-attr-href' => 'ycd-countdown-redirect-url',
200
+ 'value' => 'redirectToURL'
201
+ ),
202
+ 'label' => array(
203
+ 'name' => __('Redirect To URL', YCD_TEXT_DOMAIN)
204
+ )
205
+ )
206
+ )
207
+ );
208
+
209
+ $data['countdownFlipExpireTime'] = array(
210
+ 'template' => array(
211
+ 'fieldWrapperAttr' => array(
212
+ 'class' => 'col-md-7 ycd-choice-option-wrapper'
213
+ ),
214
+ 'labelAttr' => array(
215
+ 'class' => 'col-md-5 ycd-choice-option-wrapper'
216
+ ),
217
+ 'groupWrapperAttr' => array(
218
+ 'class' => 'row form-group ycd-choice-wrapper'
219
+ )
220
+ ),
221
+ 'buttonPosition' => 'right',
222
+ 'nextNewLine' => true,
223
+ 'fields' => array(
224
+ array(
225
+ 'attr' => array(
226
+ 'type' => 'radio',
227
+ 'name' => 'ycd-flip-countdown-expire-behavior',
228
+ 'class' => 'ycd-flip-countdown-hide-behavior',
229
+ 'data-attr-href' => 'ycd-flip-countdown-default-behavior',
230
+ 'value' => 'default'
231
+ ),
232
+ 'label' => array(
233
+ 'name' => __('Default', YCD_TEXT_DOMAIN)
234
+ )
235
+ ),
236
+ array(
237
+ 'attr' => array(
238
+ 'type' => 'radio',
239
+ 'name' => 'ycd-flip-countdown-expire-behavior',
240
+ 'class' => 'ycd-flip-countdown-hide-behavior',
241
+ 'data-attr-href' => 'ycd-flip-countdown-hide-behavior',
242
+ 'value' => 'hideCountdown'
243
+ ),
244
+ 'label' => array(
245
+ 'name' => __('Hide Countdown', YCD_TEXT_DOMAIN)
246
+ )
247
+ ),
248
+ array(
249
+ 'attr' => array(
250
+ 'type' => 'radio',
251
+ 'name' => 'ycd-flip-countdown-expire-behavior',
252
+ 'class' => 'ycd-flip-countdown-show-text',
253
+ 'data-attr-href' => 'ycd-flip-countdown-show-text',
254
+ 'value' => 'showText'
255
+ ),
256
+ 'label' => array(
257
+ 'name' => __('Show Text', YCD_TEXT_DOMAIN)
258
+ )
259
+ ),
260
+ array(
261
+ 'attr' => array(
262
+ 'type' => 'radio',
263
+ 'name' => 'ycd-flip-countdown-expire-behavior',
264
+ 'class' => 'ycd-flip-countdown-redirect-url',
265
+ 'data-attr-href' => 'ycd-flip-countdown-redirect-url',
266
+ 'value' => 'redirectToURL'
267
+ ),
268
+ 'label' => array(
269
+ 'name' => __('Redirect To URL', YCD_TEXT_DOMAIN)
270
+ )
271
+ )
272
+ )
273
+ );
274
+
275
+ $data['time-zone'] = self::getTimeZones();
276
+
277
+ $timeZone = array('' => __('Current time zone', YCD_TEXT_DOMAIN))+self::getTimeZones();
278
+ $data['clock-time-zone'] = $timeZone;
279
+
280
+ $data['horizontal-alignment'] = array(
281
+ 'left' => __('Left', YCD_TEXT_DOMAIN),
282
+ 'center' => __('Center', YCD_TEXT_DOMAIN),
283
+ 'right' => __('Right', YCD_TEXT_DOMAIN)
284
+ );
285
+
286
+ $data['userRoles'] = self::getAllUserRoles();
287
+ $data['countries-names'] = apply_filters('ycdCountries', array());
288
+ $data['countries-is'] = array(
289
+ 'is' => __('Is', YCD_TEXT_DOMAIN),
290
+ 'isNot' => __('Is not', YCD_TEXT_DOMAIN),
291
+ );
292
+
293
+ return apply_filters('ycdDefaults', $data);
294
+ }
295
 
296
  public static function getAllUserRoles() {
297
  $rulesArray = array();
311
  return $rulesArray;
312
  }
313
 
314
+ public static function selectBox($data, $selectedValue, $attrs) {
315
 
316
+ $attrString = '';
317
+ $selected = '';
318
 
319
+ if(!empty($attrs) && isset($attrs)) {
320
 
321
+ foreach ($attrs as $attrName => $attrValue) {
322
+ $attrString .= ''.$attrName.'="'.$attrValue.'" ';
323
+ }
324
+ }
325
 
326
+ $selectBox = '<select '.$attrString.'>';
327
 
328
+ foreach ($data as $value => $label) {
329
 
330
+ /*When is multiselect*/
331
+ if(is_array($selectedValue)) {
332
+ $isSelected = in_array($value, $selectedValue);
333
+ if($isSelected) {
334
+ $selected = 'selected';
335
+ }
336
+ }
337
+ else if($selectedValue == $value) {
338
+ $selected = 'selected';
339
+ }
340
+ else if(is_array($value) && in_array($selectedValue, $value)) {
341
+ $selected = 'selected';
342
+ }
343
 
344
+ $selectBox .= '<option value="'.$value.'" '.$selected.'>'.$label.'</option>';
345
+ $selected = '';
346
+ }
347
 
348
+ $selectBox .= '</select>';
349
 
350
+ return $selectBox;
351
+ }
352
 
353
  /**
354
  * ToDo add description for this function
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: adamskaat
3
  Tags: countdown, timer, countdown timer
4
  Requires at least: 3.8
5
- Tested up to: 5.0
6
- Stable tag: 1.3.0
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -33,6 +33,10 @@ Coming soon
33
 
34
  == Changelog ==
35
 
 
 
 
 
36
  = 1.3.0 =
37
  * Fixed possibility multiple timer on the same page
38
 
2
  Contributors: adamskaat
3
  Tags: countdown, timer, countdown timer
4
  Requires at least: 3.8
5
+ Tested up to: 5.0.2
6
+ Stable tag: 1.3.1
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
33
 
34
  == Changelog ==
35
 
36
+ = 1.3.1 =
37
+ * Add new type clock
38
+ * Code improvement
39
+
40
  = 1.3.0 =
41
  * Fixed possibility multiple timer on the same page
42