A much shorter script

If anyone is interested, I refactored the code to avoid the many duplications I found. I tested:
- both orientations
- clicking on a date or on button
- clicking very fast to try to go past the limits

I didn't test:
- keyboard navigation
- autoplay (it didn't work for me in the original file)

I don't have much experience with JS or jQuery, so any comment is appreciated.