(data, content)
| 103 | }); |
| 104 | |
| 105 | function createVideoTemplate(data, content) { |
| 106 | content.innerHTML = |
| 107 | '<p id="content-close"><i class="fas fa-times-circle"></i></p>'; |
| 108 | const videos = data.results; |
| 109 | if (videos.length > 0) { |
| 110 | console.log('Videos:', videos); |
| 111 | const length = videos.length > 4 ? 4 : videos.length; |
| 112 | const iframeContainer = document.createElement('div'); |
| 113 | for (let i = 0; i < length; i++) { |
| 114 | const video = videos[i]; |
| 115 | const iframe = createIframe(video); |
| 116 | iframeContainer.appendChild(iframe); |
| 117 | content.appendChild(iframeContainer); |
| 118 | } |
| 119 | } else { |
| 120 | console.log('No trailer'); |
| 121 | const noTrailer = document.createElement('h2'); |
| 122 | noTrailer.setAttribute('class', 'notrail'); |
| 123 | noTrailer.innerText = 'Sorry trailer not available 😢'; |
| 124 | content.appendChild(noTrailer); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | document.addEventListener('click', (e) => { |
| 129 | if (e.target.tagName === 'IMG') { |
no test coverage detected