A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
feat: bigger video when playing (experiment)
Christian Fei174e32e61bcc
diff --git a/client/components/video-element.js b/client/components/video-element.jsindex e79b250..c72fcb6 100644--- a/client/components/video-element.js+++ b/client/components/video-element.js@@ -84,7 +84,6 @@ class VideoElement extends HTMLElement {handleClickAddListener(this.querySelector('.action.ignore'), this.toggleIgnoreVideoHandler.bind(this))handleClickAddListener(this.querySelector('.channel-name'), this.filterByChannelHandler.bind(this))handleClickAddListener(this.querySelector('.play-video-placeholder'), this.watchVideoHandler.bind(this))- this.querySelector('video') && this.registerVideoEvents(this.querySelector('video'))}unregisterEvents () {handleClickRemoveListener(this.querySelector('.action.download'), this.downloadVideoHandler.bind(this))@@ -108,8 +107,9 @@ class VideoElement extends HTMLElement {Download the video instead <a href="/videos/${this.video.id}" target="_blank">here</a></p></video>`- this.pauseOtherVideos()+this.querySelector('video').play()+ this.registerVideoEvents(this.querySelector('video'))}downloadVideoHandler (event) {event.preventDefault()@@ -179,13 +179,22 @@ class VideoElement extends HTMLElement {$searchInput.dispatchEvent(new Event('search'))}registerVideoEvents (video) {- video.addEventListener('play', this.pauseOtherVideos.bind(this, video))+ video.addEventListener('play', () => {+ console.log('video event play')+ this.classList.add('big')+ this.pauseOtherVideos(video)+ })}unregisterVideoEvents (video) {video.removeEventListener('play', this.pauseOtherVideos.bind(this, video))}pauseOtherVideos (video) {- document.querySelectorAll('video').forEach(v => v !== video && !v.paused && v.pause())+ document.querySelectorAll('video').forEach(v => {+ if (v !== video) {+ v.pause()+ v.parentElement.classList.remove('big')+ }+ })}}customElements.define('video-element', VideoElement)diff --git a/client/main.css b/client/main.cssindex c0a3554..bb04660 100644--- a/client/main.css+++ b/client/main.css@@ -116,11 +116,6 @@ form {-----.video {position: relative;width: 400px;@@ -178,6 +173,29 @@ form {cursor: pointer;}+++@media all and (min-width: 50em) {+ video-element.big {+ width: 50%;+ }+ video-element.big video {+ width: 100%;+ }+}+@media all and (max-width: 50em) {+ video-element.big {+ width: 100%;+ }+ video-element.big video {+ width: 100%;+ }+}+++++.play-video-placeholder {height: 225px;background-color: #ceaf80;