~hristoast/mousikofidi

447b5485bff1f0ed0cc1e738182243aaffcd7171 — Hristos N. Triantafillou 7 months ago 4b779b8 0.19
Click the now playing title to jump to it (#81)

Cleaned up unneeded title setting code in playAudio() and playVideo(),
these two functions could probably be DRY'd up now.

I've also removed a bunch of javascript tests that no longer apply due
to the aforementioned cleanup.
M mousikofidi/static/js/player.js => mousikofidi/static/js/player.js +12 -3
@@ 92,8 92,6 @@ function playAudio(targetArrow, dontPlay) {
        audio.play();

    nowPlayingNumDiv.setAttribute("data-nowplaying-num", thisTrackNum);
    playingTitleSpan.textContent = title;
    pageTitle.textContent = playingTextTitle;

    if (mobileHidden === false) {
        followTrack = audioFollowCheckbox.checked === true;


@@ 135,7 133,6 @@ function playVideo(targetArrow, dontPlay) {
        video.play();
    }
    videoNowPlayingNumDiv.setAttribute("data-nowplaying-num", thisTrackNum);
    videoPlayingTitleSpan.textContent = title;
    video.scrollIntoView({block: 'start', behavior: 'smooth'});

    if ((shuffle === "on") || (shuffleMobile === "on")) {


@@ 533,6 530,10 @@ function paused(_, event, trackType) {

        // The inner span gets wiped out when the outer p's text is set.  Recreate and set it.
        nowPlayingTextP.appendChild(document.createElement("span"));
        nowPlayingTextP.childNodes[1].onclick = function() {
            var scrollTarget = document.getElementById(playArrows[nowPlayingTrackNum].id + "-target");
            scrollTarget.scrollIntoView({block: 'start', behavior: 'smooth'});
        };
        nowPlayingTextP.childNodes[1].style.fontWeight = "bold";
        nowPlayingTextP.childNodes[1].textContent = playingText;



@@ 544,6 545,10 @@ function paused(_, event, trackType) {

        // The inner span gets wiped out when the outer p's text is set.  Recreate and set it.
        nowPlayingTextP.appendChild(document.createElement("span"));
        nowPlayingTextP.childNodes[1].onclick = function() {
            var scrollTarget = document.getElementById(playArrows[nowPlayingTrackNum].id + "-target");
            scrollTarget.scrollIntoView({block: 'start', behavior: 'smooth'});
        };
        nowPlayingTextP.childNodes[1].style.fontWeight = "bold";
        nowPlayingTextP.childNodes[1].textContent = playingText;
    }


@@ 757,6 762,10 @@ function setUp() {
    if (audio) {
        // Load up the first track
        audio.src = playArrows[currentTrack].getAttribute("data-browse").replace("browse", "serve");
        playingTitleSpan.onclick = function() {
            var scrollTarget = document.getElementById(playArrows[currentTrack].id + "-target");
            scrollTarget.scrollIntoView({block: 'start', behavior: 'smooth'});
        };
        playingTitleSpan.textContent = playingText;
        title.textContent = playingTextTitle;


M mousikofidi/static/js/player.min.js => mousikofidi/static/js/player.min.js +1 -1
@@ 1,1 1,1 @@
var audio=document.getElementById("audio");var audioNowPlayingTextP=document.getElementById("now-playing");var videoNowPlayingTextP=document.getElementById("video-now-playing");var nowPlayingNumDiv=document.getElementById("now-playing-num");var audioPlaybackEndedDiv=document.getElementById("audio-playback-ended");var videoPlaybackEndedDiv=document.getElementById("video-playback-ended");var videoNowPlayingNumDiv=document.getElementById("video-now-playing-num");var pageTitle=document.getElementById("title");var playArrows=document.getElementsByClassName("play-arrow");var playingTitleSpan=document.getElementById("playing-title");var videoPlayingTitleSpan=document.getElementById("video-playing-title");var playlist=document.getElementById("playlist");if(playlist){var tracks=playlist.getElementsByClassName("title")}var video=document.getElementById("video");var videoArrows=document.getElementsByClassName("video-arrow");var videoPlaylist=document.getElementById("video-playlist");if(videoPlaylist){var videoTracks=videoPlaylist.getElementsByClassName("video-title")}else{if(playlist){var videoTracks=playlist.getElementsByClassName("video-title")}}var prevBtn=document.getElementById("prev");var nextBtn=document.getElementById("next");var repeatBtn=document.getElementById("repeat");var shuffleBtn=document.getElementById("shuffle");var prevBtnMobile=document.getElementById("mobile-prev");var nextBtnMobile=document.getElementById("mobile-next");var repeatBtnMobile=document.getElementById("mobile-repeat");var shuffleBtnMobile=document.getElementById("mobile-shuffle");var randomOrderHolder=document.getElementById("randorder");var videoPrevBtn=document.getElementById("vid-prev");var videoNextBtn=document.getElementById("vid-next");var videoRepeatBtn=document.getElementById("vid-repeat");var videoShuffleBtn=document.getElementById("vid-shuffle");var videoPrevBtnMobile=document.getElementById("mobile-vid-prev");var videoNextBtnMobile=document.getElementById("mobile-vid-next");var videoRepeatBtnMobile=document.getElementById("mobile-vid-repeat");var videoShuffleBtnMobile=document.getElementById("mobile-vid-shuffle");var videoRandomOrderHolder=document.getElementById("vid-randorder");var params=new URLSearchParams(window.location.search);var single=document.getElementById("single");var singleLinkButton=document.getElementById("time-link");var audioLinkButton=document.getElementById("audio-time-link");var videoLinkButton=document.getElementById("video-time-link");var iconsEnabled=document.getElementById("icons-enabled");var theaterViewButton=document.getElementById("video-theater-view");var audioFollowCheckbox=document.getElementById("follow-track");var audioFollowCheckboxMobile=document.getElementById("mobile-follow-track");function playAudio(b,d){if(b){var h=b.getAttribute("data-browse")}else{return false}var n=h.replace("browse","serve");var f=pageTitle.getAttribute("data-sitename");var m=b.getAttribute("data-num");var i=b.getAttribute("data-title");var j="Now Playing: "+i+" | "+f;var e=shuffleBtn.getAttribute("data-stat");var l=shuffleBtnMobile.getAttribute("data-stat");var a=window.getComputedStyle(document.getElementsByClassName("mobile-hide")[0])["display"]==="none";var k;if(audio.src.endsWith(n)!==true){audio.src=n}if(typeof d==="undefined"){audio.play()}nowPlayingNumDiv.setAttribute("data-nowplaying-num",m);playingTitleSpan.textContent=i;pageTitle.textContent=j;if(a===false){k=audioFollowCheckbox.checked===true}else{k=audioFollowCheckboxMobile.checked===true}if(k){var g=document.getElementById(b.id+"-target");g.scrollIntoView({block:"start",behavior:"smooth"})}if((e==="on")||(l==="on")){setRandomOrder("audio")}}function playAudioClickListener(){audioPlaybackEndedDiv.setAttribute("data-playback-ended","false");playAudio(this)}function playVideo(g,a){if(g){var f=g.getAttribute("data-browse")}else{return false}var h=f.replace("browse","serve");var e=videoShuffleBtn.getAttribute("data-stat");var d=videoShuffleBtnMobile.getAttribute("data-stat");var b=g.getAttribute("data-num");if(typeof a==="undefined"){video.src=h;video.play()}videoNowPlayingNumDiv.setAttribute("data-nowplaying-num",b);videoPlayingTitleSpan.textContent=title;video.scrollIntoView({block:"start",behavior:"smooth"});if((e==="on")||(d==="on")){setRandomOrder("video")}}function playVideoClickListener(){videoPlaybackEndedDiv.setAttribute("data-playback-ended","false");playVideo(this)}function randInt(a){return Math.floor(Math.random()*a)}function setRandomOrder(e){if(e==="audio"){var b=playArrows;var f=randomOrderHolder.getAttribute("data-randorder");var g=randomOrderHolder}else{if(e==="video"){var b=videoArrows;var f=videoRandomOrderHolder.getAttribute("data-randorder");var g=videoRandomOrderHolder}}var h=randomizeTrackOrder(b.length,e);var d=randomStringFromArray(h);if(f==="none"){g.setAttribute("data-randorder",d)}else{if(f===d){while(f===d){var a=randomizeTrackOrder(b.length,e);d=randomStringFromArray(a)}}else{g.setAttribute("data-randorder",d)}}}function endedTrackListener(y,m){if(m==="audio"){var n=playArrows;var i=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var e=randomOrderHolder;var v=audioPlaybackEndedDiv;var g=playAudio;var s=repeatBtn.getAttribute("data-stat");var w=repeatBtnMobile.getAttribute("data-stat");var a=((s=="one")||(w=="one"));var k=((s=="all")||(w=="all"));var u=shuffleBtn.getAttribute("data-stat");var x=shuffleBtnMobile.getAttribute("data-stat");var h=((u=="on")||(x=="on"))}else{if(m==="video"){var n=videoArrows;var i=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");var e=videoRandomOrderHolder;var v=videoPlaybackEndedDiv;var g=playVideo;var s=videoRepeatBtn.getAttribute("data-stat");var w=videoRepeatBtnMobile.getAttribute("data-stat");var j=((s=="on")||(w=="on"));var u=videoShuffleBtn.getAttribute("data-stat");var x=videoShuffleBtnMobile.getAttribute("data-stat");var h=((u=="on")||(x=="on"))}}var z=(v.getAttribute("data-playback-ended")==="true");var b=n.length-1;if(a){g(n[i])}else{if(h){if(z){return}else{var r=e.getAttribute("data-randorder");var o=r.split(",");var q=o.shift();if((o!="")&&(q!=="undefined")){g(n[q]);var p=randomStringFromArray(o);e.setAttribute("data-randorder",p)}else{if((k)&&(q==="undefined")){var d=randInt(b);g(n[d]);setRandomOrder(m)}else{var l=g(n[q]);if(k){setRandomOrder(m);var f=e.getAttribute("data-randorder");var t=f.split(",");g(n[t[0]])}else{v.setAttribute("data-playback-ended","true")}}}}}else{if(h===false){if(i<b){i++;g(n[i])}else{if(k){g(n[0])}else{if((a===false)&&k===false){}}}}}}}function endedAudioListener(){endedTrackListener(this,"audio")}function endedVideoListener(){endedTrackListener(this,"video")}function skipTrack(j,r){var f=j.getAttribute("data-cmd");if(r==="audio"){var o=playArrows;var e=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var i=randomOrderHolder;var n=playAudio;var k=shuffleBtn.getAttribute("data-stat");var p=shuffleBtnMobile.getAttribute("data-stat");var q=tracks}else{if(r==="video"){var o=videoArrows;var e=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");var i=videoRandomOrderHolder;var n=playVideo;var k=videoShuffleBtn.getAttribute("data-stat");var p=videoShuffleBtnMobile.getAttribute("data-stat");var q=videoTracks}}var h=q.length-1;if((k==="on")||(p==="on")){var l=i.getAttribute("data-randorder");var g=l.split(",");if(g.length>0){var b=g.shift();var m=o[b];if(typeof(m)==="undefined"){var d=randInt(q.length);n(o[d]);setRandomOrder(r)}else{n(m);var a=randomStringFromArray(g);i.setAttribute("data-randorder",a)}}else{if(repeat==="all"){var d=randInt(q.length);n(o[d]);setRandomOrder(r)}}}else{if(k==="off"){if(f==="fwd"){if(e<h){e++;n(o[e])}else{n(o[0])}}else{if(f==="prev"){if(e>0){e--;n(o[e])}else{n(o[h])}}}}}}function skipAudioListener(){skipTrack(this,"audio")}function skipVideoListener(){skipTrack(this,"video")}function toggleRepeat(b){var a=b.getAttribute("data-stat");if(a==="off"){b.setAttribute("data-stat","one");b.textContent="Repeat One ";if(iconsEnabled){b.appendChild(document.createElement("i"));b.childNodes[1].classList.add("fas","fa-redo");b.style.paddingTop="9px";b.style.paddingRight="15px";b.style.paddingBottom="9px";b.style.paddingLeft="15px"}}else{if(a==="one"){b.setAttribute("data-stat","all");b.textContent="Repeat All";if(iconsEnabled){b.appendChild(document.createElement("span"));b.childNodes[1].classList.add("fa-stack");b.childNodes[1].appendChild(document.createElement("i"));b.childNodes[1].appendChild(document.createElement("i"));b.childNodes[1].childNodes[0].classList.add("fas","fa-redo","fa-stack-1x");b.childNodes[1].childNodes[1].classList.add("fas","fa-infinity","fa-stack-1x");b.childNodes[1].childNodes[1].style.fontSize="0.4em";b.style.marginBottom="0";b.style.paddingTop="5px";b.style.paddingRight="5px";b.style.paddingBottom="5px";b.style.paddingLeft="15px"}}else{if(a==="all"){b.setAttribute("data-stat","off");b.textContent="No Repeat";if(iconsEnabled){b.appendChild(document.createElement("span"));b.childNodes[1].classList.add("fa-stack");b.childNodes[1].appendChild(document.createElement("i"));b.childNodes[1].appendChild(document.createElement("i"));b.childNodes[1].childNodes[0].classList.add("fas","fa-redo","fa-stack-1x");b.childNodes[1].childNodes[1].classList.add("fas","fa-slash","fa-stack-1x");b.style.marginBottom="0";b.style.paddingTop="5px";b.style.paddingRight="5px";b.style.paddingBottom="5px";b.style.paddingLeft="15px"}}}}}function toggleRepeatListener(){toggleRepeat(this)}function randomizeTrackOrder(d,f){if(f==="audio"){var b=nowPlayingNumDiv.getAttribute("data-nowplaying-num")}else{if(f==="video"){var b=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num")}}var a=0;var g=[];while(g.length<d-1){var e=randInt(d);while(e==b){e=randInt(d)}if(g.indexOf(e)===-1){g.push(e)}}return g}function randomStringFromArray(b){if(b==="none"){return}var a="";for(c=0;c<b.length;c++){a+=b[c];if(c<b.length-1){a+=","}}return a}function toggleShuffle(d,b){var a=d.getAttribute("data-stat");if(a==="off"){setRandomOrder(b);d.setAttribute("data-stat","on");d.textContent="Shuffle On ";if(iconsEnabled){d.appendChild(document.createElement("i"));d.childNodes[1].classList.add("fas","fa-random");d.style.paddingTop="9px";d.style.paddingRight="15px";d.style.paddingBottom="9px";d.style.paddingLeft="15px"}}else{if(a==="on"){d.setAttribute("data-stat","off");d.textContent="Shuffle Off";if(iconsEnabled){d.appendChild(document.createElement("span"));d.childNodes[1].classList.add("fa-stack");d.childNodes[1].appendChild(document.createElement("i"));d.childNodes[1].appendChild(document.createElement("i"));d.childNodes[1].childNodes[0].classList.add("fas","fa-random","fa-stack-1x");d.childNodes[1].childNodes[1].classList.add("fas","fa-slash","fa-stack-1x");d.style.marginBottom="0";d.style.paddingTop="5px";d.style.paddingRight="5px";d.style.paddingBottom="5px";d.style.paddingLeft="15px"}}}}function toggleShuffleAudioListener(){toggleShuffle(this,"audio")}function toggleShuffleVideoListener(){toggleShuffle(this,"video")}function paused(d,g,f){if(f==="audio"){var b=audioNowPlayingTextP;var a=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var e=playArrows[a].getAttribute("data-title");var h=pageTitle.getAttribute("data-sitename")}else{if(f==="video"){var b=videoNowPlayingTextP;var a=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");var e=videoArrows[a].getAttribute("data-title")}}if(g==="playing"){if(f==="audio"){pageTitle.textContent="Now Playing: "+e+" | "+h}b.textContent="Now Playing: ";b.appendChild(document.createElement("span"));b.childNodes[1].style.fontWeight="bold";b.childNodes[1].textContent=e}else{if(g==="paused"){if(f==="audio"){pageTitle.textContent="Paused: "+e+" | "+h}b.textContent="Paused: ";b.appendChild(document.createElement("span"));b.childNodes[1].style.fontWeight="bold";b.childNodes[1].textContent=e}}}function playingAudioHandler(){paused(this,"playing","audio")}function pausedAudioHandler(){paused(this,"paused","audio")}function playingVideoHandler(){paused(this,"playing","video")}function pausedVideoHandler(){paused(this,"paused","video")}function giveLink(f){var d;var e;var h;var g;if(f==="audio"){g=audio}else{if(f==="video"){g=video}else{if(f==="single"){g=single}}}var b=window.location.protocol+"//"+window.location.host+window.location.pathname+"?t="+Math.floor(g.currentTime);if(f==="audio"){d=playArrows;e=nowPlayingNumDiv.getAttribute("data-nowplaying-num");h="&a="}else{if(f==="video"){d=videoArrows;e=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");h="&v="}}if(d){var a=d[e].getAttribute("id");b+=h+a}if(f==="video"){b+="#videoplayer"}var i=document.createElement("textarea");i.value=b;document.body.appendChild(i);i.select();document.execCommand("copy");document.body.removeChild(i);return b}function singleLinkListener(){giveLink("single")}function audioLinkListener(){giveLink("audio")}function videoLinkListener(){giveLink("video")}function seekTrack(){var a=params.get("a");var b=params.get("v");var d=params.get("t");if((a===null)&&(b===null)){single.currentTime=d;single.autoplay=true}else{if(a){playAudio(playArrows.namedItem(a));audio.currentTime=d;audio.autoplay=true}if(b){playVideo(videoArrows.namedItem(b));video.currentTime=d;video.autoplay=true}}}function toggletheaterView(d){var a=document.getElementsByTagName("body")[0];var e=((document.getElementById("current-theme").getAttribute("data-theme")==="/css/water/light.standalone")||(document.getElementById("current-theme").getAttribute("data-theme")==="/css/water/dark.standalone"));var b=d.getAttribute("data-stat")==="on";if(b){d.setAttribute("data-stat","off");d.textContent="Theater View: Off";if(e){a.style.maxWidth="800px"}if(iconsEnabled){d.appendChild(document.createElement("span"));d.childNodes[1].classList.add("fa-stack");d.childNodes[1].appendChild(document.createElement("i"));d.childNodes[1].appendChild(document.createElement("i"));d.childNodes[1].childNodes[0].classList.add("fas","fa-theater-masks","fa-stack-1x");d.childNodes[1].childNodes[1].classList.add("fas","fa-slash","fa-stack-1x");d.style.marginBottom="0";d.style.paddingTop="5px";d.style.paddingRight="5px";d.style.paddingBottom="5px";d.style.paddingLeft="15px"}}else{d.setAttribute("data-stat","on");d.textContent="Theater View: On ";if(e){a.style.maxWidth="100%"}if(iconsEnabled){d.appendChild(document.createElement("i"));d.childNodes[1].classList.add("fas","fa-theater-masks");d.style.paddingTop="9px";d.style.paddingRight="15px";d.style.paddingBottom="9px";d.style.paddingLeft="15px"}}window.location.href="#videoplayer"}function theaterViewListener(){toggletheaterView(this)}function setUp(){var i=0;if(nowPlayingNumDiv){var d=nowPlayingNumDiv.getAttribute("data-nowplaying-num")}var h=pageTitle.getAttribute("data-sitename");if(playArrows.length>0){var e=playArrows[0].getAttribute("data-title");var a="Paused: "+e+" | "+h}if(tracks){for(c=0;c<playArrows.length;c++){var f=playArrows.item(c);f.addEventListener("click",playAudioClickListener);f.setAttribute("data-num",c)}}if(audio){audio.src=playArrows[i].getAttribute("data-browse").replace("browse","serve");playingTitleSpan.textContent=e;title.textContent=a;audio.addEventListener("ended",endedAudioListener);audio.addEventListener("playing",playingAudioHandler);audio.addEventListener("pause",pausedAudioHandler);prevBtn.addEventListener("click",skipAudioListener);nextBtn.addEventListener("click",skipAudioListener);repeatBtn.addEventListener("click",toggleRepeatListener);shuffleBtn.addEventListener("click",toggleShuffleAudioListener);prevBtnMobile.addEventListener("click",skipAudioListener);nextBtnMobile.addEventListener("click",skipAudioListener);repeatBtnMobile.addEventListener("click",toggleRepeatListener);shuffleBtnMobile.addEventListener("click",toggleShuffleAudioListener)}if(videoTracks){for(c=0;c<videoArrows.length;c++){var b=videoArrows.item(c);b.addEventListener("click",playVideoClickListener);b.setAttribute("data-num",c)}}if(videoArrows.length>0){var g=videoArrows[0].getAttribute("data-title")}if(video){video.src=videoArrows[i].getAttribute("data-browse").replace("browse","serve");videoPlayingTitleSpan.textContent=g;video.addEventListener("ended",endedVideoListener);video.addEventListener("playing",playingVideoHandler);video.addEventListener("pause",pausedVideoHandler);videoPrevBtn.addEventListener("click",skipVideoListener);videoNextBtn.addEventListener("click",skipVideoListener);videoRepeatBtn.addEventListener("click",toggleRepeatListener);videoShuffleBtn.addEventListener("click",toggleShuffleVideoListener);videoPrevBtnMobile.addEventListener("click",skipVideoListener);videoNextBtnMobile.addEventListener("click",skipVideoListener);videoRepeatBtnMobile.addEventListener("click",toggleRepeatListener);videoShuffleBtnMobile.addEventListener("click",toggleShuffleVideoListener)}if(singleLinkButton){singleLinkButton.addEventListener("click",singleLinkListener)}if(audioLinkButton){audioLinkButton.addEventListener("click",audioLinkListener)}if(videoLinkButton){videoLinkButton.addEventListener("click",videoLinkListener)}if(params.has("t")){seekTrack()}if(theaterViewButton){theaterViewButton.addEventListener("click",theaterViewListener)}}window.onload=setUp();
\ No newline at end of file
var audio=document.getElementById("audio");var audioNowPlayingTextP=document.getElementById("now-playing");var videoNowPlayingTextP=document.getElementById("video-now-playing");var nowPlayingNumDiv=document.getElementById("now-playing-num");var audioPlaybackEndedDiv=document.getElementById("audio-playback-ended");var videoPlaybackEndedDiv=document.getElementById("video-playback-ended");var videoNowPlayingNumDiv=document.getElementById("video-now-playing-num");var pageTitle=document.getElementById("title");var playArrows=document.getElementsByClassName("play-arrow");var playingTitleSpan=document.getElementById("playing-title");var videoPlayingTitleSpan=document.getElementById("video-playing-title");var playlist=document.getElementById("playlist");if(playlist){var tracks=playlist.getElementsByClassName("title")}var video=document.getElementById("video");var videoArrows=document.getElementsByClassName("video-arrow");var videoPlaylist=document.getElementById("video-playlist");if(videoPlaylist){var videoTracks=videoPlaylist.getElementsByClassName("video-title")}else{if(playlist){var videoTracks=playlist.getElementsByClassName("video-title")}}var prevBtn=document.getElementById("prev");var nextBtn=document.getElementById("next");var repeatBtn=document.getElementById("repeat");var shuffleBtn=document.getElementById("shuffle");var prevBtnMobile=document.getElementById("mobile-prev");var nextBtnMobile=document.getElementById("mobile-next");var repeatBtnMobile=document.getElementById("mobile-repeat");var shuffleBtnMobile=document.getElementById("mobile-shuffle");var randomOrderHolder=document.getElementById("randorder");var videoPrevBtn=document.getElementById("vid-prev");var videoNextBtn=document.getElementById("vid-next");var videoRepeatBtn=document.getElementById("vid-repeat");var videoShuffleBtn=document.getElementById("vid-shuffle");var videoPrevBtnMobile=document.getElementById("mobile-vid-prev");var videoNextBtnMobile=document.getElementById("mobile-vid-next");var videoRepeatBtnMobile=document.getElementById("mobile-vid-repeat");var videoShuffleBtnMobile=document.getElementById("mobile-vid-shuffle");var videoRandomOrderHolder=document.getElementById("vid-randorder");var params=new URLSearchParams(window.location.search);var single=document.getElementById("single");var singleLinkButton=document.getElementById("time-link");var audioLinkButton=document.getElementById("audio-time-link");var videoLinkButton=document.getElementById("video-time-link");var iconsEnabled=document.getElementById("icons-enabled");var theaterViewButton=document.getElementById("video-theater-view");var audioFollowCheckbox=document.getElementById("follow-track");var audioFollowCheckboxMobile=document.getElementById("mobile-follow-track");function playAudio(b,d){if(b){var h=b.getAttribute("data-browse")}else{return false}var n=h.replace("browse","serve");var f=pageTitle.getAttribute("data-sitename");var m=b.getAttribute("data-num");var i=b.getAttribute("data-title");var j="Now Playing: "+i+" | "+f;var e=shuffleBtn.getAttribute("data-stat");var l=shuffleBtnMobile.getAttribute("data-stat");var a=window.getComputedStyle(document.getElementsByClassName("mobile-hide")[0])["display"]==="none";var k;if(audio.src.endsWith(n)!==true){audio.src=n}if(typeof d==="undefined"){audio.play()}nowPlayingNumDiv.setAttribute("data-nowplaying-num",m);if(a===false){k=audioFollowCheckbox.checked===true}else{k=audioFollowCheckboxMobile.checked===true}if(k){var g=document.getElementById(b.id+"-target");g.scrollIntoView({block:"start",behavior:"smooth"})}if((e==="on")||(l==="on")){setRandomOrder("audio")}}function playAudioClickListener(){audioPlaybackEndedDiv.setAttribute("data-playback-ended","false");playAudio(this)}function playVideo(g,a){if(g){var f=g.getAttribute("data-browse")}else{return false}var h=f.replace("browse","serve");var e=videoShuffleBtn.getAttribute("data-stat");var d=videoShuffleBtnMobile.getAttribute("data-stat");var b=g.getAttribute("data-num");if(typeof a==="undefined"){video.src=h;video.play()}videoNowPlayingNumDiv.setAttribute("data-nowplaying-num",b);video.scrollIntoView({block:"start",behavior:"smooth"});if((e==="on")||(d==="on")){setRandomOrder("video")}}function playVideoClickListener(){videoPlaybackEndedDiv.setAttribute("data-playback-ended","false");playVideo(this)}function randInt(a){return Math.floor(Math.random()*a)}function setRandomOrder(e){if(e==="audio"){var b=playArrows;var f=randomOrderHolder.getAttribute("data-randorder");var g=randomOrderHolder}else{if(e==="video"){var b=videoArrows;var f=videoRandomOrderHolder.getAttribute("data-randorder");var g=videoRandomOrderHolder}}var h=randomizeTrackOrder(b.length,e);var d=randomStringFromArray(h);if(f==="none"){g.setAttribute("data-randorder",d)}else{if(f===d){while(f===d){var a=randomizeTrackOrder(b.length,e);d=randomStringFromArray(a)}}else{g.setAttribute("data-randorder",d)}}}function endedTrackListener(y,m){if(m==="audio"){var n=playArrows;var i=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var e=randomOrderHolder;var v=audioPlaybackEndedDiv;var g=playAudio;var s=repeatBtn.getAttribute("data-stat");var w=repeatBtnMobile.getAttribute("data-stat");var a=((s=="one")||(w=="one"));var k=((s=="all")||(w=="all"));var u=shuffleBtn.getAttribute("data-stat");var x=shuffleBtnMobile.getAttribute("data-stat");var h=((u=="on")||(x=="on"))}else{if(m==="video"){var n=videoArrows;var i=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");var e=videoRandomOrderHolder;var v=videoPlaybackEndedDiv;var g=playVideo;var s=videoRepeatBtn.getAttribute("data-stat");var w=videoRepeatBtnMobile.getAttribute("data-stat");var j=((s=="on")||(w=="on"));var u=videoShuffleBtn.getAttribute("data-stat");var x=videoShuffleBtnMobile.getAttribute("data-stat");var h=((u=="on")||(x=="on"))}}var z=(v.getAttribute("data-playback-ended")==="true");var b=n.length-1;if(a){g(n[i])}else{if(h){if(z){return}else{var r=e.getAttribute("data-randorder");var o=r.split(",");var q=o.shift();if((o!="")&&(q!=="undefined")){g(n[q]);var p=randomStringFromArray(o);e.setAttribute("data-randorder",p)}else{if((k)&&(q==="undefined")){var d=randInt(b);g(n[d]);setRandomOrder(m)}else{var l=g(n[q]);if(k){setRandomOrder(m);var f=e.getAttribute("data-randorder");var t=f.split(",");g(n[t[0]])}else{v.setAttribute("data-playback-ended","true")}}}}}else{if(h===false){if(i<b){i++;g(n[i])}else{if(k){g(n[0])}else{if((a===false)&&k===false){}}}}}}}function endedAudioListener(){endedTrackListener(this,"audio")}function endedVideoListener(){endedTrackListener(this,"video")}function skipTrack(j,r){var f=j.getAttribute("data-cmd");if(r==="audio"){var o=playArrows;var e=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var i=randomOrderHolder;var n=playAudio;var k=shuffleBtn.getAttribute("data-stat");var p=shuffleBtnMobile.getAttribute("data-stat");var q=tracks}else{if(r==="video"){var o=videoArrows;var e=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");var i=videoRandomOrderHolder;var n=playVideo;var k=videoShuffleBtn.getAttribute("data-stat");var p=videoShuffleBtnMobile.getAttribute("data-stat");var q=videoTracks}}var h=q.length-1;if((k==="on")||(p==="on")){var l=i.getAttribute("data-randorder");var g=l.split(",");if(g.length>0){var b=g.shift();var m=o[b];if(typeof(m)==="undefined"){var d=randInt(q.length);n(o[d]);setRandomOrder(r)}else{n(m);var a=randomStringFromArray(g);i.setAttribute("data-randorder",a)}}else{if(repeat==="all"){var d=randInt(q.length);n(o[d]);setRandomOrder(r)}}}else{if(k==="off"){if(f==="fwd"){if(e<h){e++;n(o[e])}else{n(o[0])}}else{if(f==="prev"){if(e>0){e--;n(o[e])}else{n(o[h])}}}}}}function skipAudioListener(){skipTrack(this,"audio")}function skipVideoListener(){skipTrack(this,"video")}function toggleRepeat(b){var a=b.getAttribute("data-stat");if(a==="off"){b.setAttribute("data-stat","one");b.textContent="Repeat One ";if(iconsEnabled){b.appendChild(document.createElement("i"));b.childNodes[1].classList.add("fas","fa-redo");b.style.paddingTop="9px";b.style.paddingRight="15px";b.style.paddingBottom="9px";b.style.paddingLeft="15px"}}else{if(a==="one"){b.setAttribute("data-stat","all");b.textContent="Repeat All";if(iconsEnabled){b.appendChild(document.createElement("span"));b.childNodes[1].classList.add("fa-stack");b.childNodes[1].appendChild(document.createElement("i"));b.childNodes[1].appendChild(document.createElement("i"));b.childNodes[1].childNodes[0].classList.add("fas","fa-redo","fa-stack-1x");b.childNodes[1].childNodes[1].classList.add("fas","fa-infinity","fa-stack-1x");b.childNodes[1].childNodes[1].style.fontSize="0.4em";b.style.marginBottom="0";b.style.paddingTop="5px";b.style.paddingRight="5px";b.style.paddingBottom="5px";b.style.paddingLeft="15px"}}else{if(a==="all"){b.setAttribute("data-stat","off");b.textContent="No Repeat";if(iconsEnabled){b.appendChild(document.createElement("span"));b.childNodes[1].classList.add("fa-stack");b.childNodes[1].appendChild(document.createElement("i"));b.childNodes[1].appendChild(document.createElement("i"));b.childNodes[1].childNodes[0].classList.add("fas","fa-redo","fa-stack-1x");b.childNodes[1].childNodes[1].classList.add("fas","fa-slash","fa-stack-1x");b.style.marginBottom="0";b.style.paddingTop="5px";b.style.paddingRight="5px";b.style.paddingBottom="5px";b.style.paddingLeft="15px"}}}}}function toggleRepeatListener(){toggleRepeat(this)}function randomizeTrackOrder(d,f){if(f==="audio"){var b=nowPlayingNumDiv.getAttribute("data-nowplaying-num")}else{if(f==="video"){var b=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num")}}var a=0;var g=[];while(g.length<d-1){var e=randInt(d);while(e==b){e=randInt(d)}if(g.indexOf(e)===-1){g.push(e)}}return g}function randomStringFromArray(b){if(b==="none"){return}var a="";for(c=0;c<b.length;c++){a+=b[c];if(c<b.length-1){a+=","}}return a}function toggleShuffle(d,b){var a=d.getAttribute("data-stat");if(a==="off"){setRandomOrder(b);d.setAttribute("data-stat","on");d.textContent="Shuffle On ";if(iconsEnabled){d.appendChild(document.createElement("i"));d.childNodes[1].classList.add("fas","fa-random");d.style.paddingTop="9px";d.style.paddingRight="15px";d.style.paddingBottom="9px";d.style.paddingLeft="15px"}}else{if(a==="on"){d.setAttribute("data-stat","off");d.textContent="Shuffle Off";if(iconsEnabled){d.appendChild(document.createElement("span"));d.childNodes[1].classList.add("fa-stack");d.childNodes[1].appendChild(document.createElement("i"));d.childNodes[1].appendChild(document.createElement("i"));d.childNodes[1].childNodes[0].classList.add("fas","fa-random","fa-stack-1x");d.childNodes[1].childNodes[1].classList.add("fas","fa-slash","fa-stack-1x");d.style.marginBottom="0";d.style.paddingTop="5px";d.style.paddingRight="5px";d.style.paddingBottom="5px";d.style.paddingLeft="15px"}}}}function toggleShuffleAudioListener(){toggleShuffle(this,"audio")}function toggleShuffleVideoListener(){toggleShuffle(this,"video")}function paused(d,g,f){if(f==="audio"){var b=audioNowPlayingTextP;var a=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var e=playArrows[a].getAttribute("data-title");var h=pageTitle.getAttribute("data-sitename")}else{if(f==="video"){var b=videoNowPlayingTextP;var a=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");var e=videoArrows[a].getAttribute("data-title")}}if(g==="playing"){if(f==="audio"){pageTitle.textContent="Now Playing: "+e+" | "+h}b.textContent="Now Playing: ";b.appendChild(document.createElement("span"));b.childNodes[1].onclick=function(){var i=document.getElementById(playArrows[a].id+"-target");i.scrollIntoView({block:"start",behavior:"smooth"})};b.childNodes[1].style.fontWeight="bold";b.childNodes[1].textContent=e}else{if(g==="paused"){if(f==="audio"){pageTitle.textContent="Paused: "+e+" | "+h}b.textContent="Paused: ";b.appendChild(document.createElement("span"));b.childNodes[1].onclick=function(){var i=document.getElementById(playArrows[a].id+"-target");i.scrollIntoView({block:"start",behavior:"smooth"})};b.childNodes[1].style.fontWeight="bold";b.childNodes[1].textContent=e}}}function playingAudioHandler(){paused(this,"playing","audio")}function pausedAudioHandler(){paused(this,"paused","audio")}function playingVideoHandler(){paused(this,"playing","video")}function pausedVideoHandler(){paused(this,"paused","video")}function giveLink(f){var d;var e;var h;var g;if(f==="audio"){g=audio}else{if(f==="video"){g=video}else{if(f==="single"){g=single}}}var b=window.location.protocol+"//"+window.location.host+window.location.pathname+"?t="+Math.floor(g.currentTime);if(f==="audio"){d=playArrows;e=nowPlayingNumDiv.getAttribute("data-nowplaying-num");h="&a="}else{if(f==="video"){d=videoArrows;e=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");h="&v="}}if(d){var a=d[e].getAttribute("id");b+=h+a}if(f==="video"){b+="#videoplayer"}var i=document.createElement("textarea");i.value=b;document.body.appendChild(i);i.select();document.execCommand("copy");document.body.removeChild(i);return b}function singleLinkListener(){giveLink("single")}function audioLinkListener(){giveLink("audio")}function videoLinkListener(){giveLink("video")}function seekTrack(){var a=params.get("a");var b=params.get("v");var d=params.get("t");if((a===null)&&(b===null)){single.currentTime=d;single.autoplay=true}else{if(a){playAudio(playArrows.namedItem(a));audio.currentTime=d;audio.autoplay=true}if(b){playVideo(videoArrows.namedItem(b));video.currentTime=d;video.autoplay=true}}}function toggletheaterView(d){var a=document.getElementsByTagName("body")[0];var e=((document.getElementById("current-theme").getAttribute("data-theme")==="/css/water/light.standalone")||(document.getElementById("current-theme").getAttribute("data-theme")==="/css/water/dark.standalone"));var b=d.getAttribute("data-stat")==="on";if(b){d.setAttribute("data-stat","off");d.textContent="Theater View: Off";if(e){a.style.maxWidth="800px"}if(iconsEnabled){d.appendChild(document.createElement("span"));d.childNodes[1].classList.add("fa-stack");d.childNodes[1].appendChild(document.createElement("i"));d.childNodes[1].appendChild(document.createElement("i"));d.childNodes[1].childNodes[0].classList.add("fas","fa-theater-masks","fa-stack-1x");d.childNodes[1].childNodes[1].classList.add("fas","fa-slash","fa-stack-1x");d.style.marginBottom="0";d.style.paddingTop="5px";d.style.paddingRight="5px";d.style.paddingBottom="5px";d.style.paddingLeft="15px"}}else{d.setAttribute("data-stat","on");d.textContent="Theater View: On ";if(e){a.style.maxWidth="100%"}if(iconsEnabled){d.appendChild(document.createElement("i"));d.childNodes[1].classList.add("fas","fa-theater-masks");d.style.paddingTop="9px";d.style.paddingRight="15px";d.style.paddingBottom="9px";d.style.paddingLeft="15px"}}window.location.href="#videoplayer"}function theaterViewListener(){toggletheaterView(this)}function setUp(){var i=0;if(nowPlayingNumDiv){var d=nowPlayingNumDiv.getAttribute("data-nowplaying-num")}var h=pageTitle.getAttribute("data-sitename");if(playArrows.length>0){var e=playArrows[0].getAttribute("data-title");var a="Paused: "+e+" | "+h}if(tracks){for(c=0;c<playArrows.length;c++){var f=playArrows.item(c);f.addEventListener("click",playAudioClickListener);f.setAttribute("data-num",c)}}if(audio){audio.src=playArrows[i].getAttribute("data-browse").replace("browse","serve");playingTitleSpan.onclick=function(){var j=document.getElementById(playArrows[i].id+"-target");j.scrollIntoView({block:"start",behavior:"smooth"})};playingTitleSpan.textContent=e;title.textContent=a;audio.addEventListener("ended",endedAudioListener);audio.addEventListener("playing",playingAudioHandler);audio.addEventListener("pause",pausedAudioHandler);prevBtn.addEventListener("click",skipAudioListener);nextBtn.addEventListener("click",skipAudioListener);repeatBtn.addEventListener("click",toggleRepeatListener);shuffleBtn.addEventListener("click",toggleShuffleAudioListener);prevBtnMobile.addEventListener("click",skipAudioListener);nextBtnMobile.addEventListener("click",skipAudioListener);repeatBtnMobile.addEventListener("click",toggleRepeatListener);shuffleBtnMobile.addEventListener("click",toggleShuffleAudioListener)}if(videoTracks){for(c=0;c<videoArrows.length;c++){var b=videoArrows.item(c);b.addEventListener("click",playVideoClickListener);b.setAttribute("data-num",c)}}if(videoArrows.length>0){var g=videoArrows[0].getAttribute("data-title")}if(video){video.src=videoArrows[i].getAttribute("data-browse").replace("browse","serve");videoPlayingTitleSpan.textContent=g;video.addEventListener("ended",endedVideoListener);video.addEventListener("playing",playingVideoHandler);video.addEventListener("pause",pausedVideoHandler);videoPrevBtn.addEventListener("click",skipVideoListener);videoNextBtn.addEventListener("click",skipVideoListener);videoRepeatBtn.addEventListener("click",toggleRepeatListener);videoShuffleBtn.addEventListener("click",toggleShuffleVideoListener);videoPrevBtnMobile.addEventListener("click",skipVideoListener);videoNextBtnMobile.addEventListener("click",skipVideoListener);videoRepeatBtnMobile.addEventListener("click",toggleRepeatListener);videoShuffleBtnMobile.addEventListener("click",toggleShuffleVideoListener)}if(singleLinkButton){singleLinkButton.addEventListener("click",singleLinkListener)}if(audioLinkButton){audioLinkButton.addEventListener("click",audioLinkListener)}if(videoLinkButton){videoLinkButton.addEventListener("click",videoLinkListener)}if(params.has("t")){seekTrack()}if(theaterViewButton){theaterViewButton.addEventListener("click",theaterViewListener)}}window.onload=setUp();
\ No newline at end of file

M mousikofidi/static/js/tests.js => mousikofidi/static/js/tests.js +2 -58
@@ 896,33 896,19 @@ function testPlayAudio() {
    playAudio(realFlac, "Don't play!");

    var nowPlaying1 = nowPlayingNumDiv.getAttribute("data-nowplaying-num");
    var title1 = pageTitle.textContent;
    var titleSpan1 = playingTitleSpan.textContent;

    playAudio(realMp3, "Don't play!");

    var nowPlaying2 = nowPlayingNumDiv.getAttribute("data-nowplaying-num");
    var title2 = pageTitle.textContent;
    var titleSpan2 = playingTitleSpan.textContent;

    playAudio(realOgg, "Don't play!");

    var nowPlaying3 = nowPlayingNumDiv.getAttribute("data-nowplaying-num");
    var title3 = pageTitle.textContent;
    var titleSpan3 = playingTitleSpan.textContent;

    console.log("nowPlaying1: " + nowPlaying1);
    console.log("nowPlaying2: " + nowPlaying2);
    console.log("nowPlaying3: " + nowPlaying3);

    console.log("title1: " + title1);
    console.log("title2: " + title2);
    console.log("title3: " + title3);

    console.log("titleSpan1: " + titleSpan1);
    console.log("titleSpan2: " + titleSpan2);
    console.log("titleSpan3: " + titleSpan3);

    if (nowPlaying1 != 6) {
        console.log("TEST FAILED");
        console.log("nowPlaying1 did equal '6'!!");


@@ 944,48 930,6 @@ function testPlayAudio() {
        return false;
    }

    if (title1.split("|")[0] != "Now Playing: MousikóFídi Test FLAC ") {
        console.log("TEST FAILED");
        console.log("title1.split("|")[0] did equal 'MousikóFídi Test FLAC '!!");
        console.log("End: testPlayAudio()");
        return false;
    }

    if (title2.split("|")[0] != "Now Playing: MousikóFídi Test MP3 ") {
        console.log("TEST FAILED");
        console.log("title1.split("|")[0] did equal 'MousikóFídi Test MP3 '!!");
        console.log("End: testPlayAudio()");
        return false;
    }

    if (title3.split("|")[0] != "Now Playing: MousikóFídi Test OGG ") {
        console.log("TEST FAILED");
        console.log("title1.split("|")[0] did equal 'MousikóFídi Test OGG '!!");
        console.log("End: testPlayAudio()");
        return false;
    }

    if (titleSpan1 != "MousikóFídi Test FLAC") {
        console.log("TEST FAILED");
        console.log("titleSpan1 did equal 'MousikóFídi Test FLAC'!!");
        console.log("End: testPlayAudio()");
        return false;
    }

    if (titleSpan2 != "MousikóFídi Test MP3") {
        console.log("TEST FAILED");
        console.log("titleSpan2 did equal 'MousikóFídi Test MP3'!!");
        console.log("End: testPlayAudio()");
        return false;
    }

    if (titleSpan3 != "MousikóFídi Test OGG") {
        console.log("TEST FAILED");
        console.log("titleSpan3 did equal 'MousikóFídi Test OGG'!!");
        console.log("End: testPlayAudio()");
        return false;
    }

    console.log("End: testPlayAudio()");
    return true;
}


@@ 993,8 937,8 @@ function testPlayAudio() {
function testPlayVideo() {
    console.log("Begin: testPlayVideo()");

    var realMp4 = audioArrows[16];
    var realWebm = audioArrows[18];
    var realMp4 = audioArrows[4];
    var realWebm = audioArrows[6];

    playVideo(realMp4, "Don't play!");


M mousikofidi/templates/audio_player.html => mousikofidi/templates/audio_player.html +1 -1
@@ 1,5 1,5 @@
<div class="center" id="player">
  <p id="now-playing" title="The status of the current track.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>
  <p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>
  <div data-nowplaying-num="0" id="now-playing-num"></div>
  <div data-randorder="none" id="randorder"></div>
  <div data-playback-ended="false" id="audio-playback-ended"></div>

M test_mousikofidi.py => test_mousikofidi.py +6 -6
@@ 2138,7 2138,7 @@ def test_dir_detail_found(client):
    assert bytes('<div class="center" id="player">', "utf8") in rv.data
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            "utf8",
        )
        in rv.data


@@ 2873,7 2873,7 @@ def test_playlist_with_audio_and_video(client):
    assert bytes('<div class="center" id="player">', "utf8") in rv.data
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            "utf8",
        )
        in rv.data


@@ 3194,7 3194,7 @@ def test_playlist_with_audio_no_video(client):
    assert bytes('<div class="center" id="player">', "utf8") in rv.data
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            "utf8",
        )
        in rv.data


@@ 3516,7 3516,7 @@ def test_playlist_no_audio_with_video(client):
    assert bytes('<div class="center" id="player">', "utf8") not in rv.data
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            "utf8",
        )
        not in rv.data


@@ 3771,7 3771,7 @@ def test_playlist_detail_real_with_bad(client):
    )
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            "utf8",
        )
        in rv.data


@@ 3957,7 3957,7 @@ def test_playlist_detail_real(client):
    )
    assert (
        bytes(
            '<p id="now-playing" title="The status of the current track.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            '<p id="now-playing" title="The status of the current track.  Click the track title to jump to it in the playlist.">Paused: <span class="bold" id="playing-title" title="The title of the current track."></span></p>',
            "utf8",
        )
        in rv.data