Skip to content

Commit

Permalink
Merge pull request #73 from Hyleus/freeleech
Browse files Browse the repository at this point in the history
Improve global freeleech implementation
  • Loading branch information
HDVinnie authored Dec 22, 2017
2 parents 2eefbc4 + d5f756a commit 6f2fc36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions config/other.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
*/
'freeleech' => false,

'freeleech_until' => '12/23/2017 3:00 PM EST',

/*
|--------------------------------------------------------------------------
| Double Upload State
Expand Down
19 changes: 14 additions & 5 deletions resources/views/layout/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@

@if (config('other.freeleech') == true || config('other.invite-only') == false || config('other.doubleup') == true)
<script type="text/javascript">
CountDownTimer('12/01/2017 3:00 PM EST', 'promotions');
CountDownTimer('{{config('other.freeleech_until')}}', 'promotions');
function CountDownTimer(dt, id) {
var end = new Date(dt);
Expand All @@ -415,6 +415,15 @@ function CountDownTimer(dt, id) {
var _day = _hour * 24;
var timer;
function formatUnit(text, v) {
console.log(v);
let suffix = "s";
if (v === 1) {
suffix = "";
}
return v + " " + text + suffix;
}
function showRemaining() {
var now = new Date();
var distance = end - now;
Expand All @@ -430,10 +439,10 @@ function showRemaining() {
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);
document.getElementById(id).innerHTML = days + 'day(s)';
document.getElementById(id).innerHTML += hours + 'hour(s)';
document.getElementById(id).innerHTML += minutes + 'minute(s)';
document.getElementById(id).innerHTML += seconds + 'second(s)';
document.getElementById(id).innerHTML = formatUnit("day", days) + ", ";
document.getElementById(id).innerHTML += formatUnit('hour', hours) + ", ";
document.getElementById(id).innerHTML += formatUnit('minute', minutes) + ", ";
document.getElementById(id).innerHTML += formatUnit('second', seconds);
}
timer = setInterval(showRemaining, 1000);
Expand Down

0 comments on commit 6f2fc36

Please sign in to comment.