bridgetown_theme_single_page_opt_in 0.1.54 → 0.1.55

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45923b0ef5238b63e6a6769358ec326432fce19b8078f407662a38802e7dd8bd
4
- data.tar.gz: 631de7284998ebbe97f9e87eafc3b7c299cbb8012fd185bd90455bed256cbd87
3
+ metadata.gz: f1de560abda47476b85491a70710d4d85b06fabfc5cc95e766dc8f551b910c57
4
+ data.tar.gz: 6b7a5e94a79719475f5806c7051005f701a3dd422d8530e80d0b8d39a7f1d8c0
5
5
  SHA512:
6
- metadata.gz: de1d91c68161a69ab9e57e28eeacbd34408e7cccc35f5b74ac4fa4a543753089f21458dbf4051d2010ada263ffa5f65d42765abc94b678eb4892e833b9701c54
7
- data.tar.gz: 1bbab2b865c5d39a71fd911bf70a0922153024bb8a97451a42bbeaef61f5a6691d544c8248c025729318649ed0d2f90196b929bd39dbd6a8c0863a6be80542e4
6
+ metadata.gz: d867135171a29f75ebc02b3d0d78aa98d0d2983b6a2b6a850a9a1625ad4722b218b0c76c4c170a2d35933b90214aabae76428901637f8c42b9028f3c3fcd996a
7
+ data.tar.gz: 18ab097f3b83577d6259754fd0339e86b5ce9b9790f298a0132ff79e44cd9a598a2a496f16f19bd48760b75fb8d4e64636fa877e37a662303b57c75a1dc75be0
@@ -4,6 +4,130 @@ add_gem("dotenv")
4
4
  gsub_file("config/initializers.rb", /^((?!#.)end)/, " init :bridgetown_theme_single_page_opt_in\nend")
5
5
  gsub_file("src/index.md", "layout: default", "layout: bridgetown_theme_single_page_opt_in/landing")
6
6
 
7
+ class CountDown {
8
+ constructor(expirationTime, onRender, onComplete) {
9
+ this.setExpirationTime(expirationTime);
10
+
11
+ this.onRender = onRender;
12
+ this.onComplete = onComplete;
13
+ }
14
+
15
+ setExpirationTime(expirationTime) {
16
+ // get the current time
17
+ const currentTime = new Date().getTime();
18
+ // calculate the remaining time
19
+ this.timeRemaining = expirationTime - currentTime;
20
+
21
+ this.timeRemaining <= 0 ?
22
+ this.complete() :
23
+ this.start();
24
+ }
25
+
26
+
27
+ complete() {
28
+ if (typeof this.onComplete === 'function') {
29
+ onComplete();
30
+ }
31
+ }
32
+ getTime() {
33
+ return {
34
+ days: Math.floor(this.timeRemaining / 1000 / 60 / 60 / 24),
35
+ hours: Math.floor(this.timeRemaining / 1000 / 60 / 60) % 24,
36
+ minutes: Math.floor(this.timeRemaining / 1000 / 60) % 60,
37
+ seconds: Math.floor(this.timeRemaining / 1000) % 60
38
+ };
39
+ }
40
+
41
+ update() {
42
+ if (typeof this.onRender === 'function') {
43
+ this.onRender(this.getTime());
44
+ }
45
+ }
46
+
47
+ start() {
48
+ // update the countdown
49
+ this.update();
50
+
51
+ // setup a timer
52
+ const intervalId = setInterval(() => {
53
+ // update the timer
54
+ this.timeRemaining -= 1000;
55
+
56
+ if (this.timeRemaining < 0) {
57
+ // call the callback
58
+ complete();
59
+
60
+ // clear the interval if expired
61
+ clearInterval(intervalId);
62
+ } else {
63
+ this.update();
64
+ }
65
+
66
+ }, 1000);
67
+ }
68
+ }
69
+
70
+ // Get the expiration
71
+ const getExpirationTime = () => {
72
+ const expiration = document.querySelector('.timer-expiration').innerHTML;
73
+ return Date.parse(expiration);
74
+ };
75
+
76
+ // select elements
77
+ const app = document.querySelector('.countdown-row');
78
+ const message = document.querySelector('.message');
79
+ const heading = document.querySelector('h1');
80
+
81
+
82
+ const format = (t) => {
83
+ return t < 10 ? '0' + t : t;
84
+ };
85
+
86
+ create_file "frontend/javascript/lander.js" do
87
+ "const render = (time) => {
88
+ app.innerHTML = `
89
+ <span class="countdown-section">
90
+ <span class="countdown-amount" style="color: rgb(0, 0, 0);">${format(time.days)}</span>
91
+ <span class="countdown-period" style="color: var(--pale-blue);">Days</span>
92
+ </span>
93
+ <span class="countdown-section">
94
+ <span class="countdown-amount" style="color: rgb(0, 0, 0);">${format(time.hours)}</span>
95
+ <span class="countdown-period" style="color: var(--pale-blue);">Hours</span>
96
+ </span>
97
+ <span class="countdown-section">
98
+ <span class="countdown-amount" style="color: rgb(0, 0, 0);">${format(time.minutes)}</span>
99
+ <span class="countdown-period" style="color: var(--pale-blue);">Minutes</span>
100
+ </span>
101
+ <span class="countdown-section">
102
+ <span class="countdown-amount" style="color: rgb(0, 0, 0);">${format(time.seconds)}</span>
103
+ <span class="countdown-period" style="color: var(--pale-blue);">Seconds</span>
104
+ </span>
105
+ `;
106
+ };
107
+
108
+
109
+ const showMessage = () => {
110
+ message.innerHTML = `Happy New Year!`;
111
+ app.innerHTML = '';
112
+ heading.style.display = 'none';
113
+ };
114
+
115
+ const hideMessage = () => {
116
+ message.innerHTML = '';
117
+ heading.style.display = 'block';
118
+ };
119
+
120
+ const complete = () => {
121
+ showMessage();
122
+ };
123
+
124
+ const countdownTimer = new CountDown(
125
+ getExpirationTime(),
126
+ render,
127
+ complete
128
+ );"
129
+ end
130
+
7
131
  remove_file("src/_data/site_metadata.yml")
8
132
  create_file "src/_data/site_metadata.yml" do
9
133
  <<~YAML
@@ -125,11 +249,11 @@ end
125
249
  create_file "src/_data/event_details.yml" do
126
250
  <<~YAML
127
251
  opener: "LIVE, Seminar Begins: "
128
- date: {{ (Time.now + 2 * 60).strftime('%Y/%m/%d %H:%M:%S %Z') }}
252
+ date: (Time.now + 2 * 60).strftime('%Y/%m/%d %H:%M:%S %Z')
129
253
  timezone: EDT
130
- seminar_date: {{ (Time.now + 2 * 60).strftime('%Y/%m/%d %H:%M:%S %Z') }}
131
- show_link_time: {{ (Time.now + 3 * 60).strftime('%Y/%m/%d %H:%M:%S %Z') }}
132
- close_cart_time: {{ (Time.now + 4 * 60).strftime('%Y/%m/%d %H:%M:%S %Z') }}
254
+ seminar_date: (Time.now + 2 * 60).strftime('%Y/%m/%d %H:%M:%S %Z')
255
+ show_link_time: (Time.now + 3 * 60).strftime('%Y/%m/%d %H:%M:%S %Z')
256
+ close_cart_time: (Time.now + 4 * 60).strftime('%Y/%m/%d %H:%M:%S %Z')
133
257
  YAML
134
258
  end
135
259
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SinglePageOptInTheme
4
- VERSION = "0.1.54"
4
+ VERSION = "0.1.55"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown_theme_single_page_opt_in
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.54
4
+ version: 0.1.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - graial