ajax aoc panel (main site)
This commit is contained in:
@@ -26,7 +26,7 @@ $year = $post['extras']['aoc:year'];
|
||||
|
||||
<?php
|
||||
global $PARAM_AOCCALENDAR;
|
||||
$PARAM_AOCCALENDAR = ['year' => $year, 'nav'=>true];
|
||||
$PARAM_AOCCALENDAR = ['year' => $year, 'nav'=>true, 'linkheader'=>false, 'ajax'=>false];
|
||||
require (__DIR__ . '/../fragments/panel_aoc_calendar.php')
|
||||
?>
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
<?php
|
||||
require_once(__DIR__ . '/../internals/adventofcode.php');
|
||||
|
||||
global $PARAM_AOCPANEL;
|
||||
$year = $PARAM_AOCPANEL['year'];
|
||||
$years = AdventOfCode::listYears();
|
||||
$year = end($years);
|
||||
?>
|
||||
|
||||
<div class="index_pnl_base">
|
||||
|
||||
<div class="index_pnl_header">
|
||||
<a href="<?php echo AdventOfCode::getURLForYear($year); ?>">Advent of Code <?php echo $year; ?></a>
|
||||
<a href="<?php echo AdventOfCode::getURLForYear($year); ?>">Advent of Code</a>
|
||||
</div>
|
||||
<div class="index_pnl_content">
|
||||
|
||||
<?php
|
||||
global $PARAM_AOCCALENDAR;
|
||||
$PARAM_AOCCALENDAR = ['year' => $year, 'nav'=>false];
|
||||
$PARAM_AOCCALENDAR = ['year' => $year, 'nav'=>true, 'linkheader'=>true, 'ajax'=>true];
|
||||
require (__DIR__ . '/../fragments/panel_aoc_calendar.php')
|
||||
?>
|
||||
|
||||
|
||||
@@ -2,26 +2,51 @@
|
||||
|
||||
global $PARAM_AOCCALENDAR;
|
||||
|
||||
$year = $PARAM_AOCCALENDAR['year'];
|
||||
$shownav = $PARAM_AOCCALENDAR['nav'];
|
||||
$year = $PARAM_AOCCALENDAR['year'];
|
||||
$shownav = $PARAM_AOCCALENDAR['nav'];
|
||||
$linkheader = $PARAM_AOCCALENDAR['linkheader'];
|
||||
$ajax = $PARAM_AOCCALENDAR['ajax'];
|
||||
$frame = isset($PARAM_AOCCALENDAR['frame']) ? $PARAM_AOCCALENDAR['frame'] : true;
|
||||
$frameid = isset($PARAM_AOCCALENDAR['frameid']) ? $PARAM_AOCCALENDAR['frameid'] : ('aoc_frame_' . getRandomToken(16));
|
||||
|
||||
$assocdays = AdventOfCode::listSingleYearAssociative($year);
|
||||
$prev_year = $shownav ? AdventOfCode::getPrevYear($year) : null;
|
||||
$next_year = $shownav ? AdventOfCode::getNextYear($year) : null;
|
||||
|
||||
if ($ajax) includeAdditionalScript("/data/javascript/aoc_panel_interactive.js", 'defer', true);
|
||||
|
||||
?>
|
||||
|
||||
<div class="aoc_calendar_parent">
|
||||
<?php if ($frame) echo '<div class="aoc_calendar_parent" id="' . $frameid . '">'; ?>
|
||||
<div class="aoc_calendar">
|
||||
<div class="aoc_calendar_header">
|
||||
<?php
|
||||
if ($prev_year !== null) echo '<a href="' . AdventOfCode::getURLForYear($prev_year) . '" class="aoc_calendar_header_link aoc_prev" ><</a>';
|
||||
else echo '<a href="#" class="aoc_calendar_header_link aoc_prev aoc_link_hidden" ><</a>';
|
||||
if ($prev_year !== null)
|
||||
{
|
||||
if ($ajax)
|
||||
echo '<a href="javascript:void();" onclick="javascript:changeAOCPanel(' . $prev_year . ', ' . ($shownav?'true':'false') . ', ' . ($linkheader?'true':'false') . ', ' . ($ajax?'true':'false') . ', \'' . $frameid . '\')" class="aoc_calendar_header_link aoc_prev" ><</a>';
|
||||
else
|
||||
echo '<a href="' . AdventOfCode::getURLForYear($prev_year) . '" class="aoc_calendar_header_link aoc_prev" ><</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a href="#" class="aoc_calendar_header_link aoc_prev aoc_link_hidden" ><</a>';
|
||||
}
|
||||
|
||||
echo '<span class="aoc_calendar_header_title">'.$year.'</span>';
|
||||
if ($linkheader) echo '<span class="aoc_calendar_header_title"><a href="' . AdventOfCode::getURLForYear($year) . '">'.$year.'</a></span>';
|
||||
else echo '<span class="aoc_calendar_header_title">'.$year.'</span>';
|
||||
|
||||
if ($next_year !== null) echo '<a href="' . AdventOfCode::getURLForYear($next_year) . '" class="aoc_calendar_header_link aoc_next" >></a>';
|
||||
else echo '<a href="" class="aoc_calendar_header_link aoc_next aoc_link_hidden" >></a>';
|
||||
if ($next_year !== null)
|
||||
{
|
||||
if ($ajax)
|
||||
echo '<a href="javascript:void();" onclick="javascript:changeAOCPanel(' . $next_year . ', ' . ($shownav?'true':'false') . ', ' . ($linkheader?'true':'false') . ', ' . ($ajax?'true':'false') . ', \'' . $frameid . '\')" class="aoc_calendar_header_link aoc_next" >></a>';
|
||||
else
|
||||
echo '<a href="' . AdventOfCode::getURLForYear($next_year) . '" class="aoc_calendar_header_link aoc_next" >></a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<a href="" class="aoc_calendar_header_link aoc_next aoc_link_hidden" >></a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -39,4 +64,4 @@ $next_year = $shownav ? AdventOfCode::getNextYear($year) : null;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($frame) echo '</div>'; ?>
|
||||
|
||||
Reference in New Issue
Block a user