setup for future days

main
Benjamin Kraft 2 weeks ago
parent c29d6d937b
commit 68bdad57a7
  1. 15
      public/index.php
  2. 11
      public/main.js
  3. 4
      public/run.php
  4. 5
      public/styles.css

@ -5,9 +5,22 @@
</head>
<body>
<?php
<div id="response">Response</div>
<?php
for ($i = 1; $i <= 25; $i++){
echo
"<div class='day' id='day-$i'>
<h3>Day $i</h3>
<button data-url='/run.php?day=$i&part=1'>Part 1</button>
<button data-url='/run.php?day=$i&part=2'>Part 2</button>
</div>";
}
?>
<script type="application/javascript" src="main.js"></script>
</body>
</html>

@ -0,0 +1,11 @@
for (let i = 1; i <= 25; i++){
let buttons = document.querySelectorAll(`#day-${i} > button`);
buttons.forEach(button => {
button.addEventListener('click', async () => {
const response = await (await fetch(button.dataset['url'])).json();
document.getElementById('response').innerText = response.result;
});
});
}

@ -30,9 +30,9 @@ if ($dayNumber){
'data' => null
];
echo json_encode($response);
die();
}
}
}
}
echo json_encode([]);

@ -4,7 +4,10 @@ body {
background-color: rgb(30, 30, 30);
}
* {
body > * {
color: white;
}
* {
font-family: "Red Hat Mono", serif;
}
Loading…
Cancel
Save