Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

tmp disable settings

Christian Feif2f363b3052c
diff --git a/client/index.html b/client/index.html
index ad38175..6cf743d 100644
--- a/client/index.html
+++ b/client/index.html
@@ -11,7 +11,7 @@
<header>
<h1 class="">My-YT</h1>
<search-videos></search-videos>
- <button id="open-settings">🔧 Settings</button>
+ <a href="/settings">🔧 Settings</a>
</header>
<main>
@@ -28,33 +28,35 @@
</details>
</main>
-
- <dialog id="settings">
- <button id="close">X</button>
- <div>
- <h5>Settings </h5>
- </div>
- <br>
- <add-channel-form></add-channel-form>
- <br>
- <form>
- <label for="show-thumbnails">
- Show video thumbnails
- </label>
- <input type="checkbox" id="show-thumbnails"/>
- </form>
- <br>
- <div>
- <input type="text" id="add-ignored-term"/>
- <ul id="ignored-terms"></ul>
- </div>
- </dialog>
-
<dialog id="summary">
<button id="close">X</button>
<div></div>
</dialog>
+
+ <template id="settings-template">
+ <div id="settings">
+ <button id="close">X</button>
+ <div>
+ <h5>Settings </h5>
+ </div>
+ <br>
+ <add-channel-form></add-channel-form>
+ <br>
+ <form>
+ <label for="show-thumbnails">
+ Show video thumbnails
+ </label>
+ <input type="checkbox" id="show-thumbnails"/>
+ </form>
+ <br>
+ <div>
+ <input type="text" id="add-ignored-term"/>
+ <ul id="ignored-terms"></ul>
+ </div>
+ </div>
+ </template>
+
<script type="module" src="/components/channels-list.js"></script>
<script type="module" src="/components/search-videos.js"></script>
<script type="module" src="/components/add-channel-form.js"></script>
diff --git a/client/main.css b/client/main.css
index c3ec2a3..6a17f54 100644
--- a/client/main.css
+++ b/client/main.css
@@ -154,17 +154,6 @@ form {
-
-#open-settings {
- display: block;
- border-radius: 4px;
- font-size: 1rem;
- padding: 0.5rem;
- background-color: transparent;
- color: inherit;
- border: none;
- outline: none;
-}
#settings {
position: relative;
}
diff --git a/client/main.js b/client/main.js
index 188d7ce..24b6a4e 100644
--- a/client/main.js
+++ b/client/main.js
@@ -77,12 +77,6 @@ eventSource.onmessage = (message) => {
}
-// settings modal
-const $settings = document.querySelector("dialog#settings")
-const $openSettings = document.querySelector("#open-settings")
-const $closeSettings = $settings.querySelector("button")
-$openSettings.addEventListener("click", () => $settings.showModal())
-$closeSettings.addEventListener("click", () => $settings.close())
// summary modal
const $summary = document.querySelector('dialog#summary')
@@ -91,31 +85,32 @@ $closeSummary.addEventListener("click", () => $summary.close())
$summary.addEventListener('close', () => {})
// settings ui
-const $showThumbnails = document.getElementById('show-thumbnails')
-$showThumbnails.addEventListener('click', (event) => {
- event.preventDefault()
- store.toggle(store.showThumbnailsKey)
- applyShowThumbnails(store.get(store.showThumbnailsKey))
-})
-const $addIgnoredTerm = document.getElementById('add-ignored-term')
-$addIgnoredTerm.addEventListener('keyup', (event) => {
- event.preventDefault()
- if (event.key !== 'Enter') return
- const ignoredTerm = $addIgnoredTerm.value.trim().toLowerCase()
- if (ignoredTerm) {
- store.push(store.ignoreTermsKey, ignoredTerm)
- $addIgnoredTerm.value = ''
- }
- applyIgnoredTerms(store.get(store.ignoreTermsKey))
-})
-
-function applyIgnoredTerms (ignoredTerms) {
- const $ignoredTerms = document.getElementById('ignored-terms')
- $ignoredTerms.innerHTML = ignoredTerms.map(term => /*html*/`<li class="ignored-term">${term}</li>`).join('')
- if (ignoredTerms.length === 0) {
- $ignoredTerms.innerHTML = /*html*/`<li>No ignored terms</li>`
- }
-}
+// const $showThumbnails = document.getElementById('show-thumbnails')
+// $showThumbnails.addEventListener('click', (event) => {
+// event.preventDefault()
+// store.toggle(store.showThumbnailsKey)
+// applyShowThumbnails(store.get(store.showThumbnailsKey))
+// })
+// const $addIgnoredTerm = document.getElementById('add-ignored-term')
+// $addIgnoredTerm.addEventListener('keyup', (event) => {
+// event.preventDefault()
+// if (event.key !== 'Enter') return
+// const ignoredTerm = $addIgnoredTerm.value.trim().toLowerCase()
+// if (ignoredTerm) {
+// store.push(store.ignoreTermsKey, ignoredTerm)
+// $addIgnoredTerm.value = ''
+// }
+// applyIgnoredTerms(store.get(store.ignoreTermsKey))
+// })
+
+// function applyIgnoredTerms (ignoredTerms) {
+// const $ignoredTerms = document.getElementById('ignored-terms')
+// if (!$ignoredTerms) return
+// $ignoredTerms.innerHTML = ignoredTerms.map(term => /*html*/`<li class="ignored-term">${term}</li>`).join('')
+// if (ignoredTerms.length === 0) {
+// $ignoredTerms.innerHTML = /*html*/`<li>No ignored terms</li>`
+// }
+// }
const $showDownloadedVideos = document.getElementById('show-downloaded-videos')
handleClick($showDownloadedVideos, (event) => {
@@ -133,12 +128,9 @@ handleClick($showIgnoredVideos, (event) => {
document.body.classList.toggle('show-ignored-videos')
})
-// apply settings
-applyShowThumbnails(store.get(store.showThumbnailsKey))
-applyIgnoredTerms(store.get(store.ignoreTermsKey))
+// applyShowThumbnails(store.get(store.showThumbnailsKey))
+// applyIgnoredTerms(store.get(store.ignoreTermsKey))
-// observe dialog open/close and prevent body background scroll
-observeDialogOpenPreventScroll($settings)
observeDialogOpenPreventScroll($summary)
function handleClick ($el, handler) {
@@ -157,14 +149,15 @@ function observeDialogOpenPreventScroll (dialog) {
}).observe(dialog, { attributes: true, childList: true, subtree: true })
}
-function applyShowThumbnails(showThumbnails) {
- if (showThumbnails) {
- document.body.classList.remove('hide-thumbnails')
- } else {
- document.body.classList.add('hide-thumbnails')
- }
- document.querySelector('#show-thumbnails').checked = showThumbnails
-}
+// function applyShowThumbnails(showThumbnails) {
+// if (showThumbnails) {
+// document.body.classList.remove('hide-thumbnails')
+// } else {
+// document.body.classList.add('hide-thumbnails')
+// }
+// const $showThumbnailsCheckbox = document.querySelector('#show-thumbnails')
+// if ($showThumbnailsCheckbox) $showThumbnailsCheckbox.checked = showThumbnails
+// }
function createVideoElement (video) {
const $video = document.createElement('video-element')