-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable Content Security Policy and fix violations (#645)
- Loading branch information
Robert Clark
authored
Feb 19, 2021
1 parent
8a4b036
commit b61f723
Showing
8 changed files
with
49 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
|
||
$(document).ready -> | ||
clock = $('#time_remaining') | ||
updateClock(clock) | ||
setInterval(updateClock, 1000, clock) | ||
|
||
countdown = (endTime) -> | ||
diff = endTime - new Date() | ||
|
||
diff = 0 if diff < 0 | ||
days = Math.floor(diff/1000/60/60/24) | ||
diff -= days * 1000*60*60*24 | ||
hours = Math.floor(diff/1000/60/60) | ||
diff -= hours * 1000*60*60 | ||
minutes = Math.floor(diff/1000/60) | ||
diff -= minutes * 1000*60 | ||
seconds = Math.floor(diff/1000) | ||
return {"days": days, "hours": hours, "minutes":minutes, "seconds":seconds} | ||
|
||
updateClock = (clock_elem) -> | ||
t = countdown(new Date(parseFloat(clock_elem.data('endtime')))) | ||
clock_elem.text( | ||
'Time Remaining: ' + | ||
t.days + 'd ' + | ||
t.hours + 'h ' + | ||
t.minutes + 'm ' + | ||
t.seconds + 's' | ||
) | ||
if t.total <= 0 | ||
clearInterval timeinterval | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,3 @@ | ||
.pull-right#clock | ||
%h4 | ||
#time_remaining | ||
|
||
:coffeescript | ||
countdown = (endTime) -> | ||
diff = endTime - new Date() | ||
diff = 0 if diff < 0 | ||
days = Math.floor(diff/1000/60/60/24) | ||
diff -= days * 1000*60*60*24 | ||
hours = Math.floor(diff/1000/60/60) | ||
diff -= hours * 1000*60*60 | ||
minutes = Math.floor(diff/1000/60) | ||
diff -= minutes * 1000*60 | ||
seconds = Math.floor(diff/1000) | ||
return {"days": days, "hours": hours, "minutes":minutes, "seconds":seconds} | ||
|
||
updateClock = (clock_elem) -> | ||
t = countdown(new Date(#{endTime.to_f * 1000})) | ||
clock_elem.innerHTML = 'Time Remaining: ' + t.days + 'd ' + t.hours + 'h ' + t.minutes + 'm ' + t.seconds + 's' | ||
if t.total <= 0 | ||
clearInterval timeinterval | ||
return | ||
|
||
clock = document.getElementById('time_remaining') | ||
updateClock(clock) | ||
setInterval(updateClock, 1000, clock) | ||
#time_remaining{'data-endtime' => endTime.to_f * 1000} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Chartkick.options[:nonce] = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters