37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
import { getMovieById } from './rest_api';
|
||
|
||
export async function loadMovieData() {
|
||
const id = new URLSearchParams(location.search).get('id');
|
||
|
||
const movie = await getMovieById(id);
|
||
|
||
document.querySelector('iframe').setAttribute('src', movie.video);
|
||
document.querySelector('#movieTitle').innerHTML = movie.title;
|
||
document.querySelector('#movieDescription').innerHTML = movie.description;
|
||
|
||
const movieInfoTemplate = `
|
||
<h3>О фильме</h3>
|
||
<ul class="list-group list-group-flush my-3">
|
||
<li class="list-group-item">
|
||
<span class="fw-bold">Год производства:</span> ${movie.releaseDate}
|
||
</li>
|
||
<li class="list-group-item">
|
||
<span class="fw-bold">Страна:</span> ${movie.country}
|
||
</li>
|
||
<li class="list-group-item">
|
||
<span class="fw-bold">Слоган:</span> <span class="text-secondary">«${movie.tagline}»</span>
|
||
</li>
|
||
<li class="list-group-item">
|
||
<span class="fw-bold">Режиссер:</span> ${movie.director}
|
||
</li>
|
||
<li class="list-group-item">
|
||
<span class="fw-bold">Возраст:</span> ${movie.ageRating}
|
||
</li>
|
||
</ul>
|
||
`;
|
||
|
||
document.querySelector('#movieInfoContainer').innerHTML = movieInfoTemplate;
|
||
}
|
||
|
||
export default loadMovieData;
|