Skip to content

Instantly share code, notes, and snippets.

@pietro-rutzen
Created June 19, 2020 02:01
Show Gist options
  • Save pietro-rutzen/4c68949b05467d164b7b46db993efa90 to your computer and use it in GitHub Desktop.
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
<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