Loading static/index.html +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ <main> <h1>Was möchtest du tun?</h1> <a href="./test.html?id=practice" class="btn big">Linux üben</a> <a href="./test.html?id=pooltest" class="btn primary big">Den Pooltest ablegen</a> <a href="./test.html?id=pooltest" class="btn primary big" id="pooltest-start-btn">Den Pooltest ablegen</a> </main> <a href="https://gitlab.cl.uni-heidelberg.de/technik/teaching/yalikejazz" class="ribbon" target="_blank">Quelltext</a> <script type="module" src="./js/index.mjs"></script> Loading static/js/index.mjs +29 −5 Original line number Diff line number Diff line const now = Date.now() /** * @param {Date} now Now * @returns The first of the current month, as date object */ function getFirstOfMonth(now) { return new Date(now.getFullYear(), now.getMonth(), 1) } document.querySelectorAll("[data-hidden-until]").forEach(element => { const hiddenUntil = Date.parse(element.dataset.hiddenUntil) function addDays(date, daysToAdd) { return new Date(date.getFullYear(), date.getMonth(), date.getDate() + daysToAdd) } element.style.display = now < hiddenUntil ? "none" : "inherit" }) const now = new Date() // Yes, the date uses zero-based indexing for months... const APRIL = 3 const OCTOBER = 9 const SATURDAY = 6 // Saturday is the 6th day of the week, with Sunday being the 0th if(now.getMonth() === APRIL || now.getMonth() === OCTOBER) { // We have a new semester now, so we want to hide the pool test until the Saturday before the lectures start. // Lectures start more or less in the middle of the month, so the following logic works out what date this saturday is. const first = getFirstOfMonth(now) const firstWeekday = first.getDay() const unlockDate = firstWeekday === SATURDAY ? addDays(first, 14) : addDays(first, 13 - firstWeekday) if(now.getDate() < unlockDate.getDate()) { document.querySelector("#pooltest-start-btn").style.display = "none" } } Loading
static/index.html +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ <main> <h1>Was möchtest du tun?</h1> <a href="./test.html?id=practice" class="btn big">Linux üben</a> <a href="./test.html?id=pooltest" class="btn primary big">Den Pooltest ablegen</a> <a href="./test.html?id=pooltest" class="btn primary big" id="pooltest-start-btn">Den Pooltest ablegen</a> </main> <a href="https://gitlab.cl.uni-heidelberg.de/technik/teaching/yalikejazz" class="ribbon" target="_blank">Quelltext</a> <script type="module" src="./js/index.mjs"></script> Loading
static/js/index.mjs +29 −5 Original line number Diff line number Diff line const now = Date.now() /** * @param {Date} now Now * @returns The first of the current month, as date object */ function getFirstOfMonth(now) { return new Date(now.getFullYear(), now.getMonth(), 1) } document.querySelectorAll("[data-hidden-until]").forEach(element => { const hiddenUntil = Date.parse(element.dataset.hiddenUntil) function addDays(date, daysToAdd) { return new Date(date.getFullYear(), date.getMonth(), date.getDate() + daysToAdd) } element.style.display = now < hiddenUntil ? "none" : "inherit" }) const now = new Date() // Yes, the date uses zero-based indexing for months... const APRIL = 3 const OCTOBER = 9 const SATURDAY = 6 // Saturday is the 6th day of the week, with Sunday being the 0th if(now.getMonth() === APRIL || now.getMonth() === OCTOBER) { // We have a new semester now, so we want to hide the pool test until the Saturday before the lectures start. // Lectures start more or less in the middle of the month, so the following logic works out what date this saturday is. const first = getFirstOfMonth(now) const firstWeekday = first.getDay() const unlockDate = firstWeekday === SATURDAY ? addDays(first, 14) : addDays(first, 13 - firstWeekday) if(now.getDate() < unlockDate.getDate()) { document.querySelector("#pooltest-start-btn").style.display = "none" } }