Created
June 19, 2020 02:01
-
-
Save pietro-rutzen/4c68949b05467d164b7b46db993efa90 to your computer and use it in GitHub Desktop.
Javascript útil para lidar com páginas de programação de eventos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
const arrayDays = [] | |
for (let i = {{ firstDay }}; i <= {{ lastDay }}; i++) { | |
arrayDays.push(i); | |
} | |
let arrayIndex = 0; | |
$('.up-arrow').click(function(){ | |
if (arrayIndex === 0) { | |
arrayIndex = arrayDays.length-1 | |
} else { | |
arrayIndex = arrayIndex -1 | |
} | |
handleDays(arrayIndex) | |
}) | |
$('.down-arrow').click(function(){ | |
if (arrayIndex === arrayDays.length-1) { | |
arrayIndex = 0 | |
} else { | |
arrayIndex = arrayIndex + 1 | |
} | |
handleDays(arrayIndex) | |
}) | |
handleDays = (index) => { | |
console.log(index) | |
for (let i = {{ firstDay }}; i <= {{ lastDay }}; i++) { | |
$('div[data-day]').css('display', 'none') | |
$('.schedule-page_controls_header_day').text(arrayDays[index].toString()) | |
$('div[data-day='+arrayDays[index]+']').css('display', 'flex') | |
} | |
} | |
handleDays(arrayIndex) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment