A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
feat: show big player settings
Christian Fei09e9a47a9e2d
diff --git a/client/index.html b/client/index.htmlindex e8c0abb..c7a595d 100644--- a/client/index.html+++ b/client/index.html@@ -53,6 +53,13 @@</label><input type="checkbox" id="show-thumbnails"/></form>+ <br>+ <form>+ <label for="show-big-player">+ Show big video player+ </label>+ <input type="checkbox" id="show-big-player"/>+ </form><!--<br><div>diff --git a/client/lib/store.js b/client/lib/store.jsindex c314d60..15c9245 100644--- a/client/lib/store.js+++ b/client/lib/store.js@@ -1,20 +1,22 @@export default class Store {showThumbnailsKey = 'showThumbnails'+ showBigPlayerKey = 'showBigPlayer'lastVideosKey = 'lastVideos'ignoreTermsKey = 'ignoreTerms'constructor() {if (!localStorage.getItem(this.showThumbnailsKey)) localStorage.setItem(this.showThumbnailsKey, 'true')+ if (!localStorage.getItem(this.showBigPlayerKey)) localStorage.setItem(this.showBigPlayerKey, 'true')if (!localStorage.getItem(this.lastVideosKey)) localStorage.setItem(this.lastVideosKey, '{}')if (!localStorage.getItem(this.ignoreTermsKey)) localStorage.setItem(this.ignoreTermsKey, '[]')}toggle (key) {- if (![this.showThumbnailsKey].includes(key)) return console.error('invalid key', key)+ if (![this.showThumbnailsKey, this.showBigPlayerKey].includes(key)) return console.error('invalid key', key)localStorage.setItem(key, localStorage.getItem(key) === 'true' ? 'false' : 'true')}get(key) {- if (![this.showThumbnailsKey, this.lastVideosKey, this.ignoreTermsKey].includes(key)) return console.error('invalid key', key)+ if (![this.showThumbnailsKey, this.showBigPlayerKey, this.lastVideosKey, this.ignoreTermsKey].includes(key)) return console.error('invalid key', key)return JSON.parse(localStorage.getItem(key))}set(key, value) {diff --git a/client/main.css b/client/main.cssindex 78265ab..699f366 100644--- a/client/main.css+++ b/client/main.css@@ -178,18 +178,18 @@ video-element, video-element video {transition: width 0.2s ease-in;}@media all and (min-width: 60em) {- video-element.big {+ .show-big-player video-element.big {width: 50%;}- video-element.big video {+ .show-big-player video-element.big video {width: 100%;}}@media all and (max-width: 60em) {- video-element.big {+ .show-big-player video-element.big {width: 100%;}- video-element.big video {+ .show-big-player video-element.big video {width: 100%;}}diff --git a/client/main.js b/client/main.jsindex 32c7243..25e9ecb 100644--- a/client/main.js+++ b/client/main.js@@ -68,7 +68,7 @@ const routes = {document.querySelector('channels-list').dataset['list'] = channelsListapplyShowThumbnails(store.get(store.showThumbnailsKey))-+ applyShowBigPlayer(store.get(store.showBigPlayerKey))} },'/settings': { template: document.getElementById('settings-template'), async initialize () {console.log('initalize /settings')@@ -81,6 +81,14 @@ const routes = {store.toggle(store.showThumbnailsKey)applyShowThumbnails(store.get(store.showThumbnailsKey))})++ const $showBigPlayer = document.getElementById('show-big-player')+ store.get(store.showBigPlayerKey) ? $showBigPlayer.setAttribute('checked', 'true') : $showBigPlayer.removeAttribute('checked')++ $showBigPlayer.addEventListener('click', (event) => {+ store.toggle(store.showBigPlayerKey)+ applyShowBigPlayer(store.get(store.showBigPlayerKey))+ })} },'/404': { template: document.getElementById('not-found-template') }}@@ -231,4 +239,13 @@ function applyShowThumbnails(showThumbnails) {}const $showThumbnailsCheckbox = document.getElementById('show-thumbnails')if ($showThumbnailsCheckbox) $showThumbnailsCheckbox.checked = showThumbnails+}+function applyShowBigPlayer(showBigPlayer) {+ if (showBigPlayer) {+ document.body.classList.add('show-big-player')+ } else {+ document.body.classList.remove('show-big-player')+ }+ const $showBigPlayerCheckbox = document.getElementById('show-big-player')+ if ($showBigPlayerCheckbox) $showBigPlayerCheckbox.checked = showBigPlayer}\ No newline at end of file