Add a page to manage chrono

This commit is contained in:
nemunaire 2014-01-14 19:45:56 +01:00
parent 8e7d652688
commit 99a4edb33f
8 changed files with 63 additions and 26 deletions

View File

@ -72,6 +72,15 @@ if ($n && $p[0] == SALT_ADMIN)
$page = require("admin/certificate.php");
break;
case "chrono":
case "chrono/":
case "chrono/init":
case "chrono/init/":
case "chrono/start":
case "chrono/start/":
$page = require("admin/chrono.php");
break;
case "exercices/import":
case "exercices/import/":
$page = require("admin/import_exercices.php");

View File

@ -1,6 +1,10 @@
function update_end()
{
var left = (end_challenge - new Date())/1000;
var left;
if (typeof end_challenge === 'undefined')
left = 14400;
else
left = (end_challenge - new Date())/1000;
if (left < 0) left = 0;

View File

@ -0,0 +1,22 @@
<?php
if(!defined('ONYX')) exit;
$p = $out[0];
if (count($p) > 2)
{
switch($p[2])
{
case "start":
file_put_contents($VAR["misc_dir"]."/challenge_started", time());
break;
case "init":
unlink($VAR["misc_dir"]."/challenge_started");
break;
}
}
header("Location: /".SALT_ADMIN."/");
exit();

View File

@ -14,7 +14,13 @@ require_once("common/Theme.class.php");
$template = new Template();
$template->assign("ERRmessage", false);
$template->assign("END", $VAR['end_challenge']);
if (is_file($VAR["misc_dir"]."/challenge_started"))
{
$VAR["start_challenge"] = intval(file_get_contents($VAR["misc_dir"]."/challenge_started"));
$VAR["end_challenge"] = $VAR["start_challenge"] + 14400;
$template->assign("END", $VAR['end_challenge']);
}
if (!empty($LANG))
$template->assign("LANG", $LANG);

View File

@ -25,4 +25,14 @@
{/if}
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Chrono</h3>
</div>
<div class="panel-body">
<a href="/{$SALT_ADMIN}/chrono/start" class="btn btn-success">Start</a>
<a href="/{$SALT_ADMIN}/chrono/init" class="btn btn-danger">R&eacute;initialiser</a>
</div>
</div>
{/block}

View File

@ -11,7 +11,9 @@
{block name=end}
<script src="/js/countdown.js"></script>
<script type="text/javascript">
{if isset($END)}
var end_challenge = new Date({$END * 1000});
{/if}
update_end();
</script>
{/block}

View File

@ -42,17 +42,9 @@
{block name=end}
<script src="/js/countdown.js"></script>
<script type="text/javascript">
var end_challenge = new Date({$END * 1000});
{literal}
$(document).ready(function() {
update_end();
$('#carousel-team').carousel({
interval: 10000 });
setInterval( function() {
update_end();
}, 1000);
});
{/literal}
{if isset($END)}
var end_challenge = new Date({$END * 1000});
{/if}
update_end();
</script>
{/block}

View File

@ -8,18 +8,10 @@
{block name=end}
<script src="/js/countdown.js"></script>
<script type="text/javascript">
var end_challenge = new Date({$END * 1000});
{literal}
$(document).ready(function() {
update_end();
$('#carousel-team').carousel({
interval: 2000 });
setInterval( function() {
update_end();
}, 1000);
});
{/literal}
{if isset($END)}
var end_challenge = new Date({$END * 1000});
{/if}
update_end();
</script>
{/block}