mirror of
https://github.com/voc/streaming-website
synced 2024-11-10 06:34:17 +00:00
generate closed-page countdown on server-side
This commit is contained in:
parent
8a4fc33751
commit
9d434af7f2
7 changed files with 37 additions and 36 deletions
7
assets/js/lib/moment.min.js
vendored
7
assets/js/lib/moment.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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>.
|
||||
|
|
4
template/assemblies/countdown.phtml
Normal file
4
template/assemblies/countdown.phtml
Normal 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 ?>
|
|
@ -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()): ?>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue