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');
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,29 +372,21 @@
volumeSlider.addEventListener('mousedown', onMouseDown);
}
audio.muted = musicmute.checked = localStorage.audiomuted === "true";
musicmute.addEventListener('click', () => {
localStorage.audiomuted = audio.muted = musicmute.checked;
playMusic();
})
volumeStepDwn.addEventListener('click', () => {
var e = audio.volume - 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);
})
volumeStepDwn.addEventListener('click', () => volumeAdd(-0.05))
volumeStepUp.addEventListener('click', () => volumeAdd(0.05))
updateVolumeLabel();
}
createAudioControls();
window.addEventListener('resize', createAudioControls);
new MutationObserver((mutationRecords, observer) => {
createAudioControls();
}).observe(document.body, {