diff --git a/static/rot/rot.js b/static/rot/rot.js index 97e68d1d..98b47016 100644 --- a/static/rot/rot.js +++ b/static/rot/rot.js @@ -58,7 +58,7 @@ const txtElm = document.querySelector('.volume-percentage'); if (txtElm) txtElm.innerHTML = percentage; - + const slider = document.querySelector('.volume-slider'); if (slider) { const thumb = slider.querySelector('.volume-thumb'); @@ -122,15 +122,15 @@ let p = pinnedPost.nextElementSibling; if (!p) return false; - + let statusBody = p.querySelector(".StatusBody"); if (!statusBody) return false; - + let txtElm = statusBody.querySelector(".text"); if (!txtElm) return false; - + if (txtElm.innerHTML.replace(/(<([^>]+)>)/ig, '').search(/profile them/ig) == -1) return false; @@ -257,65 +257,65 @@ addEventListener('locationchange', updateRot); addEventListener('popstate', updateRot); - + function createAudioControls() { let NavPanel = document.querySelector('.NavPanel'); let sideDrawer = document.querySelector('.side-drawer'); if (!NavPanel && !sideDrawer) return; - + if (document.querySelector('.audioControl')) return; - + //Initialize audio controls and event listeners console.log("Adding music controls"); const panel = document.createElement("div"); panel.className = "panel panel-default"; - + const panelHeading = document.createElement("div"); panelHeading.className = "panel-heading"; panel.appendChild(panelHeading); - + const title = document.createElement("div"); title.className = "title"; title.innerText = "Music Controls"; panelHeading.appendChild(title); - + const panelBody = document.createElement("div"); panelBody.className = "panel-body"; panel.appendChild(panelBody); - + const audioControl = document.createElement("div"); audioControl.className = "audioControl"; panelBody.appendChild(audioControl); - + const mutebutton = document.createElement("label"); mutebutton.className = "mutebutton"; audioControl.appendChild(mutebutton); - + const musicmute = document.createElement("input"); musicmute.className = "music-mute"; musicmute.setAttribute("type", "checkbox"); musicmute.checked = true; mutebutton.appendChild(musicmute); - + const mutecheck = document.createElement("span"); mutecheck.className = "mutecheck"; mutecheck.title = "Mute music"; mutebutton.appendChild(mutecheck); - + const volumeSlider = document.createElement("div"); volumeSlider.className = "volume-slider"; audioControl.appendChild(volumeSlider); - + const volumeTrack = document.createElement("div"); volumeTrack.className = "volume-track"; volumeSlider.appendChild(volumeTrack); - + const volumeFill = document.createElement("div"); volumeFill.className = "volume-fill"; volumeTrack.appendChild(volumeFill); - + const volumeThumb = document.createElement("div"); volumeThumb.className = "volume-thumb"; volumeSlider.appendChild(volumeThumb); @@ -329,16 +329,16 @@ volumeStepUp.className = "volume-button-up button-default"; volumeStepUp.innerText = ""; audioControl.appendChild(volumeStepUp); - + const volumePercentage = document.createElement("div"); volumePercentage.className = "volume-percentage"; audioControl.appendChild(volumePercentage); - + if (NavPanel) NavPanel.insertAdjacentElement('afterend', panel); else if (sideDrawer) sideDrawer.insertAdjacentElement('beforeend', audioControl); - + { let isDragging = false; @@ -372,7 +372,7 @@ volumeSlider.addEventListener('mousedown', onMouseDown); } - + audio.muted = musicmute.checked = localStorage.audiomuted === "true"; musicmute.addEventListener('click', () => { localStorage.audiomuted = audio.muted = musicmute.checked; @@ -391,10 +391,10 @@ updateVolumeLabel(); } - + createAudioControls(); window.addEventListener('resize', createAudioControls); - + new MutationObserver((mutationRecords, observer) => { createAudioControls(); }).observe(document.body, {