Skip to content

Commit

Permalink
Merge pull request #39 from leepeuker/update-movie-logging-default-date
Browse files Browse the repository at this point in the history
Add default current date when logging movie
  • Loading branch information
leepeuker authored Jul 5, 2022
2 parents aee582a + 1335859 commit 26c59a8
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 26c59a8

Please sign in to comment.