Add a page to manage chrono
This commit is contained in:
parent
8e7d652688
commit
99a4edb33f
@ -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");
|
||||
|
@ -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;
|
||||
|
||||
|
22
onyx/include/admin/chrono.php
Normal file
22
onyx/include/admin/chrono.php
Normal 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();
|
@ -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);
|
||||
|
@ -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éinitialiser</a>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
@ -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}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user