Compare commits

...

2 commits

Author SHA1 Message Date
uwaa
8c44100220 rot.js volume step simplify 2025-01-27 13:15:13 +00:00
uwaa
e323fa404b whitespace cleanup 2025-01-27 13:14:30 +00:00

View file

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