generate closed-page countdown on server-side

This commit is contained in:
MaZderMind 2015-12-02 18:17:18 +01:00
parent 8a4fc33751
commit 9d434af7f2
7 changed files with 37 additions and 36 deletions

File diff suppressed because one or more lines are too long

View file

@ -554,23 +554,3 @@ $(function() {
$(this).select();
});
});
// closed-countdown
$(function() {
var
$el = $('.countdown'),
dt = moment($el.data('dt'));
$el.attr('title', 'on '+dt.format('dddd, MMM Do YYYY'))
function update() {
setTimeout(update, 5000);
var now = moment();
if(dt.dayOfYear() == now.dayOfYear() && dt.year() == now.year())
$el.text('today');
else
$el.text( dt.from(now) );
}
update();
});

View file

@ -61,3 +61,34 @@ function handle_lesscss_request($lessfile, $relative_path)
header('Content-Length: '.strlen($css));
print($css);
}
function days_diff($date)
{
$seconds = strtotime( $date ) - time();
$days = intval(ceil($seconds / 60 / 60 / 24));
return $days;
}
function days_diff_readable($date)
{
$days = days_diff($date);
if($days == -1)
return 'yesterday';
if($days == 0)
return 'today';
if($days == 1)
return 'tomorrow';
if($days < -60)
return round(-$days / 30)." months ago";
if($days < 0)
return "$days days ago";
if($days > 60)
return 'in '.round($days / 30)." months";
return "in $days days";
}

View file

@ -1,8 +1,5 @@
<div class="container about">
<? if($next): ?>
<h2>See you soon at <?=h($next['name'])?></h2>
<span class="countdown" data-dt="<?=h($next['start_date'])?>"></span>
<? endif ?>
<? include("$assemblies/countdown.phtml") ?>
<p>
You can watch most of our Recordings at <a href="<?=h($conference->getReleasesUrl())?>"><?=h($conference->getReleasesUrl())?></a>.

View file

@ -0,0 +1,4 @@
<? if($next): ?>
<h2>See you soon at <?=h($next['name'])?></h2>
<span class="countdown"><?=h(days_diff_readable($next['start_date']))?></span>
<? endif ?>

View file

@ -3,10 +3,7 @@
<h1><?=h($conference->getTitle())?> is over!</h1>
<? endif ?>
<? if($next): ?>
<h2>See you soon at <?=h($next['name'])?></h2>
<span class="countdown" data-dt="<?=h($next['start_date'])?>"></span>
<? endif ?>
<? include("$assemblies/countdown.phtml") ?>
<p>
<? if($conference->hasReleases()): ?>

View file

@ -39,7 +39,6 @@
<script type="text/javascript" src="<?=h($assets)?>js/lib/jquery.scrollTo.min.js"></script>
<script type="text/javascript" src="<?=h($assets)?>js/lib/bootstrap.min.js"></script>
<script type="text/javascript" src="<?=h($assets)?>js/lib/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="<?=h($assets)?>js/lib/moment.min.js"></script>
<script type="text/javascript" src="<?=h($assets)?>mejs/mediaelement-and-player.min.js"></script>
<script type="text/javascript" src="<?=h($assets)?>js/lustiges-script.js"></script>