Skip to content

Commit

Permalink
Add default current date when logging movie
Browse files Browse the repository at this point in the history
  • Loading branch information
leepeuker committed Jul 5, 2022
1 parent aee582a commit 1335859
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion public/js/logMovie.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ const datepicker = new Datepicker(document.getElementById('watchDate'), {
title: 'Watch date',
})

function getCurrentDate () {
const today = new Date()
const dd = String(today.getDate()).padStart(2, '0')
const mm = String(today.getMonth() + 1).padStart(2, '0') //January is 0!
const yyyy = today.getFullYear()

return dd + '.' + mm + '.' + yyyy
}

const watchModal = document.getElementById('watchDateModal')
watchModal.addEventListener('show.bs.modal', async function (e) {
let movieId = e.relatedTarget.id
let movieTitle = document.getElementById(movieId + '_movieTitle').value
let movieYear = document.getElementById(movieId + '_movieReleaseYear').value

document.getElementById('watchDate').value = ''
document.getElementById('watchDate').value = getCurrentDate()
document.getElementById('tmdbId').value = movieId
document.getElementById('watchDateModalTitle').innerHTML = movieTitle + ' (' + movieYear + ')'
let ratingNumber = await fetchRating(movieId)
Expand Down

0 comments on commit 1335859

Please sign in to comment.