~hristoast/mousikofidi

007c00d476e6ab972a91933087155fd3382e96f1 — Hristos N. Triantafillou 9 months ago 0ec0336
Fix several more problems with repeat and shuffle (#71, #72)

* Handle when the play function is called with a null play arrow,
  which can happen when a playlist ends (whether repeat or shuffle are
  enabled or not).
* Randomize a play order based on the play arrow count, not the
  'track' count.
* Better detection of the state of random and shuffle overall.  This
  results in simpler conditions in the endedTrackListener function.
* The status of playback being ended or not is stored in a div and
  manipulated as needed as a means to communicate it a playlist is
  done or not between track play attempts.
* Javascript tests have been improved a little bit to try and detect
  some of the issue seen with randomization.
M mousikofidi/static/js/player.js => mousikofidi/static/js/player.js +75 -34
@@ 19,6 19,8 @@
var audio = document.getElementById("audio");
var audioNowPlayingTextP = document.getElementById("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");


@@ 62,7 64,11 @@ function playAudio(targetArrow, dontPlay) {
    /*
      Play the selected track.
    */
    var browse = targetArrow.getAttribute("data-browse");
    if (targetArrow) {
        var browse = targetArrow.getAttribute("data-browse");
    } else {
        return false;
    }
    var serve = browse.replace("browse", "serve");
    var siteName = pageTitle.getAttribute("data-sitename");
    var thisTrackNum = targetArrow.getAttribute("data-num");


@@ 87,6 93,7 @@ function playAudio(targetArrow, dontPlay) {
}

function playAudioClickListener() {
    audioPlaybackEndedDiv.setAttribute("data-playback-ended", "false");
    playAudio(this);
}



@@ 94,7 101,11 @@ function playVideo(targetArrow, dontPlay) {
    /*
      Play the selected track.
    */
    var browse = targetArrow.getAttribute("data-browse");
    if (targetArrow) {
        var browse = targetArrow.getAttribute("data-browse");
    } else {
        return false;
    }
    var serve = browse.replace("browse", "serve");
    var shuffle = videoShuffleBtn.getAttribute("data-stat");
    var shuffleMobile = videoShuffleBtnMobile.getAttribute("data-stat");


@@ 112,12 123,13 @@ function playVideo(targetArrow, dontPlay) {
}

function playVideoClickListener() {
    videoPlaybackEndedDiv.setAttribute("data-playback-ended", "false");
    playVideo(this);
}

function randInt(max) {
    // Thank you MDN
    return Math.floor(Math.random() * Math.floor(max));
    return Math.floor(Math.random() * max);
}

function setRandomOrder(trackType) {


@@ 125,16 137,14 @@ function setRandomOrder(trackType) {
        var arrows = playArrows;
        var oldRandString = randomOrderHolder.getAttribute("data-randorder");
        var orderHolder = randomOrderHolder;
        var t = tracks;

    } else if (trackType === "video") {
        var arrows = videoArrows;
        var oldRandString = videoRandomOrderHolder.getAttribute("data-randorder");
        var orderHolder = videoRandomOrderHolder;
        var t = videoTracks;
    }

    var newRandArray = randomizeTrackOrder(t.length, trackType);
    var newRandArray = randomizeTrackOrder(arrows.length, trackType);
    var newRandString = randomStringFromArray(newRandArray);

    if (oldRandString === "none") {


@@ 142,7 152,7 @@ function setRandomOrder(trackType) {

    } else if (oldRandString === newRandString) {
        while (oldRandString === newRandString) {
            var newArray = randomizeTrackOrder(t.length, trackType);
            var newArray = randomizeTrackOrder(arrows.length, trackType);
            newRandString = randomStringFromArray(newArray);
        }



@@ 156,59 166,89 @@ function endedTrackListener(_, trackType) {
        var arrows = playArrows;
        var currentTrack = nowPlayingNumDiv.getAttribute("data-nowplaying-num");
        var orderHolder = randomOrderHolder;
        var playbackEndedDiv = audioPlaybackEndedDiv;
        var playFn = playAudio;
        var repeat = repeatBtn.getAttribute("data-stat");
        var repeatNormal = repeatBtn.getAttribute("data-stat");
        var repeatMobile = repeatBtnMobile.getAttribute("data-stat");
        var shuffle = shuffleBtn.getAttribute("data-stat");
        var repeatOne = ((repeatNormal == "one") || (repeatMobile == "one"));
        var repeatAll = ((repeatNormal == "all") || (repeatMobile == "all"));
        var shuffleNormal = shuffleBtn.getAttribute("data-stat");
        var shuffleMobile = shuffleBtnMobile.getAttribute("data-stat");
        var shuffle = ((shuffleNormal == "on") || (shuffleMobile == "on"));

    } else if (trackType === "video") {
        var arrows = videoArrows;
        var currentTrack = videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");
        var orderHolder = videoRandomOrderHolder;
        var playbackEndedDiv = videoPlaybackEndedDiv;
        var playFn = playVideo;
        var repeat = videoRepeatBtn.getAttribute("data-stat");
        var repeatNormal = videoRepeatBtn.getAttribute("data-stat");
        var repeatMobile = videoRepeatBtnMobile.getAttribute("data-stat");
        var shuffle = videoShuffleBtn.getAttribute("data-stat");
        var repeat = ((repeatNormal == "on") || (repeatMobile == "on"));
        var shuffleNormal = videoShuffleBtn.getAttribute("data-stat");
        var shuffleMobile = videoShuffleBtnMobile.getAttribute("data-stat");
        var shuffle = ((shuffleNormal == "on") || (shuffleMobile == "on"));
    }

    var playbackEnded = (playbackEndedDiv.getAttribute("data-playback-ended") === "true");
    var trackCount = arrows.length - 1;

    if ((repeat === "one") || (repeatMobile == "one")) {
    if (repeatOne) {
        playFn(arrows[currentTrack]);

    } else {
        if ((shuffle === "on") || (shuffleMobile === "on")) {
            var randOrderString = orderHolder.getAttribute("data-randorder");
            var randOrderArray = randOrderString.split(",");
        if (shuffle) {

            var nextTrack = randOrderArray.shift();
            if ((randOrderArray != "") && (nextTrack !== 'undefined')) {
                playFn(arrows[nextTrack]);
                var newOrderString = randomStringFromArray(randOrderArray);
                orderHolder.setAttribute("data-randorder", newOrderString);

            } else if (((repeat === "all") || (repeatMobile == "all"))
                       && (nextTrack === 'undefined')) {
                var newStartTrack = randInt(trackCount);
                playFn(arrows[newStartTrack]);
                setRandomOrder(trackType);
            if (playbackEnded) {
                // console.log("Playback is ended...");
                return;

            } else {
                // console.log("Shuffled playback has ended.");
            }
                var randOrderString = orderHolder.getAttribute("data-randorder");
                var randOrderArray = randOrderString.split(",");
                var nextTrack = randOrderArray.shift();

        } else if ((shuffle === "off") && (shuffleMobile === "off")) {
                if ((randOrderArray != "") && (nextTrack !== 'undefined')) {
                    playFn(arrows[nextTrack]);

                    var newOrderString = randomStringFromArray(randOrderArray);
                    orderHolder.setAttribute("data-randorder", newOrderString);

                } else if ((repeatAll) && (nextTrack === 'undefined')) {
                    var newStartTrack = randInt(trackCount);

                    playFn(arrows[newStartTrack]);

                    setRandomOrder(trackType);

                } else {
                    var _play = playFn(arrows[nextTrack]);

                    if (repeatAll) {
                        // console.log("Shuffled playlist is empty and will be recalculated...");
                        setRandomOrder(trackType);

                        var _randOrderString = orderHolder.getAttribute("data-randorder");
                        var _randOrderArray = _randOrderString.split(",");

                        playFn(arrows[_randOrderArray[0]]);

                    } else {
                        // console.log("Shuffled playlist is empty, playback will stop...");
                        playbackEndedDiv.setAttribute("data-playback-ended", "true");
                    }
                }
            }

        } else if (shuffle === false) {
            if (currentTrack < trackCount) {
                currentTrack++;
                playFn(arrows[currentTrack]);

            } else if ((repeat === "all") || (repeatMobile === "all")) {
            } else if (repeatAll) {
                playFn(arrows[0]);

            } else if ((repeat === "off") && (repeatMobile === "off")) {
            } else if ((repeatOne === false) && repeatAll === false) {
                // console.log("Playback has ended.");
            }
        }


@@ 327,15 367,16 @@ function randomizeTrackOrder(totalCount, trackType) {
    } else if (trackType === "video") {
        var nowPlayingTrackNum = videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");
    }
    

    var randCount = 0;
    var trackList = [];

    while (trackList.length < totalCount - 1) {
        var rand = randInt(totalCount);
        while (rand == nowPlayingTrackNum) {

        while (rand == nowPlayingTrackNum)
            rand = randInt(totalCount);
        }

        if (trackList.indexOf(rand) === -1)
            trackList.push(rand);
    }

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 nowPlayingNumDiv=document.getElementById("now-playing-num");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 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");function playAudio(a,b){var f=a.getAttribute("data-browse");var k=f.replace("browse","serve");var e=pageTitle.getAttribute("data-sitename");var j=a.getAttribute("data-num");var g=a.getAttribute("data-title");var h="Now Playing: "+g+" | "+e;var d=shuffleBtn.getAttribute("data-stat");var i=shuffleBtnMobile.getAttribute("data-stat");if(audio.src.endsWith(k)!==true){audio.src=k}if(typeof b==="undefined"){audio.play()}nowPlayingNumDiv.setAttribute("data-nowplaying-num",j);playingTitleSpan.textContent=g;pageTitle.textContent=h;if((d==="on")||(i==="on")){setRandomOrder("audio")}}function playAudioClickListener(){playAudio(this)}function playVideo(g,a){var f=g.getAttribute("data-browse");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);if((e==="on")||(d==="on")){setRandomOrder("video")}}function playVideoClickListener(){playVideo(this)}function randInt(a){return Math.floor(Math.random()*Math.floor(a))}function setRandomOrder(f){if(f==="audio"){var b=playArrows;var g=randomOrderHolder.getAttribute("data-randorder");var h=randomOrderHolder;var e=tracks}else{if(f==="video"){var b=videoArrows;var g=videoRandomOrderHolder.getAttribute("data-randorder");var h=videoRandomOrderHolder;var e=videoTracks}}var i=randomizeTrackOrder(e.length,f);var d=randomStringFromArray(i);if(g==="none"){h.setAttribute("data-randorder",d)}else{if(g===d){while(g===d){var a=randomizeTrackOrder(e.length,f);d=randomStringFromArray(a)}}else{h.setAttribute("data-randorder",d)}}}function endedTrackListener(o,i){if(i==="audio"){var p=playArrows;var f=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var k=randomOrderHolder;var m=playAudio;var d=repeatBtn.getAttribute("data-stat");var n=repeatBtnMobile.getAttribute("data-stat");var j=shuffleBtn.getAttribute("data-stat");var q=shuffleBtnMobile.getAttribute("data-stat")}else{if(i==="video"){var p=videoArrows;var f=videoNowPlayingNumDiv.getAttribute("data-nowplaying-num");var k=videoRandomOrderHolder;var m=playVideo;var d=videoRepeatBtn.getAttribute("data-stat");var n=videoRepeatBtnMobile.getAttribute("data-stat");var j=videoShuffleBtn.getAttribute("data-stat");var q=videoShuffleBtnMobile.getAttribute("data-stat")}}var h=p.length-1;if((d==="one")||(n=="one")){m(p[f])}else{if((j==="on")||(q==="on")){var l=k.getAttribute("data-randorder");var g=l.split(",");var b=g.shift();if((g!="")&&(b!=="undefined")){m(p[b]);var a=randomStringFromArray(g);k.setAttribute("data-randorder",a)}else{if(((d==="all")||(n=="all"))&&(b==="undefined")){var e=randInt(h);m(p[e]);setRandomOrder(i)}else{}}}else{if((j==="off")&&(q==="off")){if(f<h){f++;m(p[f])}else{if((d==="all")||(n==="all")){m(p[0])}else{if((d==="off")&&(n==="off")){}}}}}}}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"}else{if(a==="one"){b.setAttribute("data-stat","all");b.textContent="Repeat All"}else{if(a==="all"){b.setAttribute("data-stat","off");b.textContent="No Repeat"}}}}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"}else{if(a==="on"){d.setAttribute("data-stat","off");d.textContent="Shuffle Off"}}}function toggleShuffleAudioListener(){toggleShuffle(this,"audio")}function toggleShuffleVideoListener(){toggleShuffle(this,"video")}function paused(b,e){var a=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var d=playArrows[a].getAttribute("data-title");var f=pageTitle.getAttribute("data-sitename");if(e==="playing"){pageTitle.textContent="Now Playing: "+d+" | "+f;audioNowPlayingTextP.textContent="Now Playing: ";audioNowPlayingTextP.appendChild(document.createElement("span"));audioNowPlayingTextP.childNodes[1].style.fontWeight="bold";audioNowPlayingTextP.childNodes[1].textContent=d}else{if(e==="paused"){pageTitle.textContent="Paused: "+d+" | "+f;audioNowPlayingTextP.textContent="Paused: ";audioNowPlayingTextP.appendChild(document.createElement("span"));audioNowPlayingTextP.childNodes[1].style.fontWeight="bold";audioNowPlayingTextP.childNodes[1].textContent=d}}}function playingAudioHandler(){paused(this,"playing")}function pausedAudioHandler(){paused(this,"paused")}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 setUp(){var h=0;if(nowPlayingNumDiv){var d=nowPlayingNumDiv.getAttribute("data-nowplaying-num")}var g=pageTitle.getAttribute("data-sitename");if(playArrows.length>0){var e=playArrows[0].getAttribute("data-title");var a="Paused: "+e+" | "+g}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[h].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(video){video.src=videoArrows[h].getAttribute("data-browse").replace("browse","serve");video.addEventListener("ended",endedVideoListener);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()}}window.onload=setUp();
\ No newline at end of file
var audio=document.getElementById("audio");var audioNowPlayingTextP=document.getElementById("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 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");function playAudio(a,b){if(a){var f=a.getAttribute("data-browse")}else{return false}var k=f.replace("browse","serve");var e=pageTitle.getAttribute("data-sitename");var j=a.getAttribute("data-num");var g=a.getAttribute("data-title");var h="Now Playing: "+g+" | "+e;var d=shuffleBtn.getAttribute("data-stat");var i=shuffleBtnMobile.getAttribute("data-stat");if(audio.src.endsWith(k)!==true){audio.src=k}if(typeof b==="undefined"){audio.play()}nowPlayingNumDiv.setAttribute("data-nowplaying-num",j);playingTitleSpan.textContent=g;pageTitle.textContent=h;if((d==="on")||(i==="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);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"}else{if(a==="one"){b.setAttribute("data-stat","all");b.textContent="Repeat All"}else{if(a==="all"){b.setAttribute("data-stat","off");b.textContent="No Repeat"}}}}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"}else{if(a==="on"){d.setAttribute("data-stat","off");d.textContent="Shuffle Off"}}}function toggleShuffleAudioListener(){toggleShuffle(this,"audio")}function toggleShuffleVideoListener(){toggleShuffle(this,"video")}function paused(b,e){var a=nowPlayingNumDiv.getAttribute("data-nowplaying-num");var d=playArrows[a].getAttribute("data-title");var f=pageTitle.getAttribute("data-sitename");if(e==="playing"){pageTitle.textContent="Now Playing: "+d+" | "+f;audioNowPlayingTextP.textContent="Now Playing: ";audioNowPlayingTextP.appendChild(document.createElement("span"));audioNowPlayingTextP.childNodes[1].style.fontWeight="bold";audioNowPlayingTextP.childNodes[1].textContent=d}else{if(e==="paused"){pageTitle.textContent="Paused: "+d+" | "+f;audioNowPlayingTextP.textContent="Paused: ";audioNowPlayingTextP.appendChild(document.createElement("span"));audioNowPlayingTextP.childNodes[1].style.fontWeight="bold";audioNowPlayingTextP.childNodes[1].textContent=d}}}function playingAudioHandler(){paused(this,"playing")}function pausedAudioHandler(){paused(this,"paused")}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 setUp(){var h=0;if(nowPlayingNumDiv){var d=nowPlayingNumDiv.getAttribute("data-nowplaying-num")}var g=pageTitle.getAttribute("data-sitename");if(playArrows.length>0){var e=playArrows[0].getAttribute("data-title");var a="Paused: "+e+" | "+g}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[h].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(video){video.src=videoArrows[h].getAttribute("data-browse").replace("browse","serve");video.addEventListener("ended",endedVideoListener);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()}}window.onload=setUp();
\ No newline at end of file

M mousikofidi/static/js/tests.js => mousikofidi/static/js/tests.js +313 -19
@@ 41,9 41,13 @@ if (videoPlaylist) {

var repeatButton = document.getElementById("repeat");

var nowPlayingAudioNum = nowPlayingNumDiv.getAttribute("data-nowplaying-num");
var nowPlayingVideoNum = nowPlayingNumDiv.getAttribute("data-nowplaying-num");

function testSetRandomOrderAudio() {
    console.log("Begin: testSetRandomOrderAudio()");

    var trackCount = audioArrows.length;
    var startOrder = audioRandomOrderHolder.getAttribute("data-randorder")
    setRandomOrder("audio");



@@ 53,42 57,84 @@ function testSetRandomOrderAudio() {
    }

    var randOrder1 = audioRandomOrderHolder.getAttribute("data-randorder")
    // +1 below because the start track isn't in the order
    var randLen1 = randOrder1.split(",").length + 1;

    setRandomOrder("audio");

    var randOrder2 = audioRandomOrderHolder.getAttribute("data-randorder")
    // +1 below because the start track isn't in the order
    var randLen2 = randOrder2.split(",").length + 1;

    if (typeof(randOrder1) != "string") {
        console.log("End: testSetRandomOrderVideo()");
    var n1_1 = Number(randOrder1.split(",")[0])
    var n1_2 = Number(randOrder1.split(",")[1])

    var n2_1 = Number(randOrder2.split(",")[0])
    var n2_2 = Number(randOrder2.split(",")[1])

    console.log("trackCount: " + trackCount);

    console.log("startOrder: " + startOrder);

    console.log("randOrder1: " + randOrder1);
    console.log("randLen1: " + randLen1);
    console.log("randOrder2: " + randOrder2);
    console.log("randLen2: " + randLen2);

    console.log("typeof(randOrder1): " + typeof(randOrder1));
    console.log("typeof(randOrder2): " + typeof(randOrder2));

    console.log("n1_1: " + n1_1);
    console.log("n1_2: " + n1_2);
    console.log("n2_1: " + n2_1);
    console.log("n2_2: " + n2_2);

    console.log("typeof n1_1: " + typeof n1_1);
    console.log("typeof n1_2: " + typeof n1_2);
    console.log("typeof n2_1: " + typeof n2_1);
    console.log("typeof n2_2: " + typeof n2_2);

    if (randLen1 !== trackCount) {
        console.log("TEST FAILED");
        console.log("randLen1 did not equal trackCount!!");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (typeof(randOrder2) != "string") {
        console.log("End: testSetRandomOrderVideo()");
    if (randLen2 !== trackCount) {
        console.log("TEST FAILED");
        console.log("randLen2 did not equal trackCount!!");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    var n1_1 = Number(randOrder1.split(",")[0])
    var n1_2 = Number(randOrder1.split(",")[1])
    if (typeof(randOrder1) != "string") {
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    var n2_1 = Number(randOrder2.split(",")[0])
    var n2_2 = Number(randOrder2.split(",")[1])
    if (typeof(randOrder2) != "string") {
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (typeof n1_1 != "number") {
        console.log("End: testSetRandomOrderVideo()");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (typeof n1_2 != "number") {
        console.log("End: testSetRandomOrderVideo()");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (typeof n2_1 != "number") {
        console.log("End: testSetRandomOrderVideo()");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (typeof n2_2 != "number") {
        console.log("End: testSetRandomOrderVideo()");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }



@@ 97,10 143,52 @@ function testSetRandomOrderAudio() {
        return false;
    }

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

function testSetRandomOrderAudioNotZeroStart() {
    console.log("Begin: testSetRandomOrderAudioNotZeroStart()");

    var trackCount = audioArrows.length;
    var startOrder = audioRandomOrderHolder.getAttribute("data-randorder")

    var newStart = randInt(trackCount);

    while (newStart === 0)
        newStart = randInt(trackCount);

    nowPlayingNumDiv.setAttribute("data-nowplaying-num", newStart);
    setRandomOrder("audio");

    var randOrder1 = audioRandomOrderHolder.getAttribute("data-randorder")
    // +1 below because the start track isn't in the order
    var randLen1 = randOrder1.split(",").length + 1;

    setRandomOrder("audio");

    var randOrder2 = audioRandomOrderHolder.getAttribute("data-randorder")
    // +1 below because the start track isn't in the order
    var randLen2 = randOrder2.split(",").length + 1;

    var n1_1 = Number(randOrder1.split(",")[0])
    var n1_2 = Number(randOrder1.split(",")[1])

    var n2_1 = Number(randOrder2.split(",")[0])
    var n2_2 = Number(randOrder2.split(",")[1])

    console.log("trackCount: " + trackCount);

    console.log("startOrder: " + startOrder);

    console.log("newStart: " + newStart);

    console.log("randOrder1: " + randOrder1);
    console.log("typeof(randOrder1): " + typeof(randOrder1));
    console.log("randLen1: " + randLen1);
    console.log("randOrder2: " + randOrder2);
    console.log("randLen2: " + randLen2);

    console.log("typeof(randOrder1): " + typeof(randOrder1));
    console.log("typeof(randOrder2): " + typeof(randOrder2));

    console.log("n1_1: " + n1_1);


@@ 113,13 201,63 @@ function testSetRandomOrderAudio() {
    console.log("typeof n2_1: " + typeof n2_1);
    console.log("typeof n2_2: " + typeof n2_2);

    console.log("End: testSetRandomOrderAudio()");
    if (randLen1 !== trackCount) {
        console.log("TEST FAILED");
        console.log("randLen1 did not equal trackCount!!");
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

    if (randLen2 !== trackCount) {
        console.log("TEST FAILED");
        console.log("randLen2 did not equal trackCount!!");
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

    if (typeof(randOrder1) != "string") {
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

    if (typeof(randOrder2) != "string") {
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

    if (typeof n1_1 != "number") {
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

    if (typeof n1_2 != "number") {
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

    if (typeof n2_1 != "number") {
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

    if (typeof n2_2 != "number") {
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

    if (randOrder1 === randOrder2) {
        console.log("End: testSetRandomOrderAudioNotZeroStart()");
        return false;
    }

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

function testSetRandomOrderVideo() {
    console.log("Begin: testSetRandomOrderVideo()");

    var trackCount = videoArrows.length;
    var startOrder = videoRandomOrderHolder.getAttribute("data-randorder")
    setRandomOrder("video");



@@ 129,8 267,50 @@ function testSetRandomOrderVideo() {
    }

    var randOrder1 = videoRandomOrderHolder.getAttribute("data-randorder")
    // +1 below because the start track isn't in the order
    var randLen1 = randOrder1.split(",").length + 1;

    setRandomOrder("video");

    var randOrder2 = videoRandomOrderHolder.getAttribute("data-randorder")
    // +1 below because the start track isn't in the order
    var randLen2 = randOrder2.split(",").length + 1;

    console.log("trackCount: " + trackCount);

    console.log("startOrder: " + startOrder);

    console.log("randOrder1: " + randOrder1);
    console.log("randLen1: " + randLen1);
    console.log("randOrder2: " + randOrder2);
    console.log("randLen2: " + randLen2);

    console.log("typeof(randOrder1): " + typeof(randOrder1));
    console.log("typeof(randOrder2): " + typeof(randOrder2));

    console.log("n1_1: " + n1_1);
    console.log("n1_2: " + n1_2);
    console.log("n2_1: " + n2_1);
    console.log("n2_2: " + n2_2);

    console.log("typeof n1_1: " + typeof n1_1);
    console.log("typeof n1_2: " + typeof n1_2);
    console.log("typeof n2_1: " + typeof n2_1);
    console.log("typeof n2_2: " + typeof n2_2);

    if (randLen1 !== trackCount) {
        console.log("TEST FAILED");
        console.log("randLen1 did not equal trackCount!!");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (randLen2 !== trackCount) {
        console.log("TEST FAILED");
        console.log("randLen2 did not equal trackCount!!");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (typeof(randOrder1) != "string") {
        console.log("End: testSetRandomOrderVideo()");


@@ 173,10 353,45 @@ function testSetRandomOrderVideo() {
        return false;
    }

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

function testSetRandomOrderVideoNotZeroStart() {
    console.log("Begin: testSetRandomOrderVideoNotZeroStart()");

    var trackCount = videoArrows.length;
    var startOrder = videoRandomOrderHolder.getAttribute("data-randorder")
    setRandomOrder("video");

    var newStart = randInt(trackCount);

    while (newStart === 0)
        newStart = randInt(trackCount);

    videoNowPlayingNumDiv.setAttribute("data-nowplaying-num", newStart);
    setRandomOrder("audio");

    var randOrder1 = videoRandomOrderHolder.getAttribute("data-randorder")
    // +1 below because the start track isn't in the order
    var randLen1 = randOrder1.split(",").length + 1;

    setRandomOrder("video");

    var randOrder2 = videoRandomOrderHolder.getAttribute("data-randorder")
    // +1 below because the start track isn't in the order
    var randLen2 = randOrder2.split(",").length + 1;

    console.log("trackCount: " + trackCount);

    console.log("startOrder: " + startOrder);

    console.log("randOrder1: " + randOrder1);
    console.log("typeof(randOrder1): " + typeof(randOrder1));
    console.log("randLen1: " + randLen1);
    console.log("randOrder2: " + randOrder2);
    console.log("randLen2: " + randLen2);

    console.log("typeof(randOrder1): " + typeof(randOrder1));
    console.log("typeof(randOrder2): " + typeof(randOrder2));

    console.log("n1_1: " + n1_1);


@@ 189,7 404,62 @@ function testSetRandomOrderVideo() {
    console.log("typeof n2_1: " + typeof n2_1);
    console.log("typeof n2_2: " + typeof n2_2);

    console.log("End: testSetRandomOrderVideo()");
    if (randLen1 !== trackCount) {
        console.log("TEST FAILED");
        console.log("randLen1 did not equal trackCount!!");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (randLen2 !== trackCount) {
        console.log("TEST FAILED");
        console.log("randLen2 did not equal trackCount!!");
        console.log("End: testSetRandomOrderAudio()");
        return false;
    }

    if (typeof(randOrder1) != "string") {
        console.log("End: testSetRandomOrderVideoNotZeroStart()");
        return false;
    }

    if (typeof(randOrder2) != "string") {
        console.log("End: testSetRandomOrderVideoNotZeroStart()");
        return false;
    }

    var n1_1 = Number(randOrder1.split(",")[0])
    var n1_2 = Number(randOrder1.split(",")[1])

    var n2_1 = Number(randOrder2.split(",")[0])
    var n2_2 = Number(randOrder2.split(",")[1])

    if (typeof n1_1 != "number") {
        console.log("End: testSetRandomOrderVideoNotZeroStart()");
        return false;
    }

    if (typeof n1_2 != "number") {
        console.log("End: testSetRandomOrderVideoNotZeroStart()");
        return false;
    }

    if (typeof n2_1 != "number") {
        console.log("End: testSetRandomOrderVideoNotZeroStart()");
        return false;
    }

    if (typeof n2_2 != "number") {
        console.log("End: testSetRandomOrderVideoNotZeroStart()");
        return false;
    }

    if (randOrder1 === randOrder2) {
        console.log("End: testSetRandomOrderVideoNotZeroStart()");
        return false;
    }

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



@@ 816,17 1086,17 @@ function testFidiJs() {
    console.log("BEGIN: MousikóFídi Javascript Test Suite");

    failed.style.color = "red";
    failed.style.fontSize = "2.5em";
    failed.style.fontSize = "1.5em";
    failed.style.fontWeight = "bolder";
    failed.style.textAlign = "center";

    passed.style.color = "green";
    passed.style.fontSize = "2em";
    passed.style.fontSize = "1.1em";
    passed.style.fontWeight = "bolder";
    passed.style.textAlign = "center";

    results.style.color = "blue";
    results.style.fontSize = "3em";
    results.style.fontSize = "2em";
    results.style.fontWeight = "bolder";
    results.style.textAlign = "center";



@@ 1013,6 1283,30 @@ function testFidiJs() {
        fail += 1;
    }

    var result16 = testSetRandomOrderAudioNotZeroStart();
    if (result16) {
        passed.appendChild(document.createElement("div"));
        passed.childNodes[pass].textContent = "PASS: testSetRandomOrderAudioNotZeroStart()";
        pass += 1;

    } else {
        failed.appendChild(document.createElement("div"));
        failed.childNodes[fail].textContent = "FAIL: testSetRandomOrderAudioNotZeroStart()";
        fail += 1;
    }

    var result17 = testSetRandomOrderVideoNotZeroStart();
    if (result17) {
        passed.appendChild(document.createElement("div"));
        passed.childNodes[pass].textContent = "PASS: testSetRandomOrderVideoNotZeroStart()";
        pass += 1;

    } else {
        failed.appendChild(document.createElement("div"));
        failed.childNodes[fail].textContent = "FAIL: testSetRandomOrderVideoNotZeroStart()";
        fail += 1;
    }

    results.textContent = "--  Passed: " + pass + ", Failed: " + fail + " --";
    console.log("END: MousikóFídi Javascript Test Suite");
}

M mousikofidi/templates/audio_player.html => mousikofidi/templates/audio_player.html +1 -0
@@ 2,6 2,7 @@
  <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>
  <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>
  <audio{% if autoplay %} autoplay{% endif %}{% if preload_audio %} preload="auto"{% endif %} id="audio" controls>
    Your browser does not support the <code>audio</code> element.
  </audio>

M mousikofidi/templates/video_player.html => mousikofidi/templates/video_player.html +1 -0
@@ 1,5 1,6 @@
<div data-nowplaying-num="0" id="video-now-playing-num"></div>
<div data-randorder="none" id="vid-randorder"></div>
<div data-playback-ended="false" id="video-playback-ended"></div>
<div class="center">
  <video id="video"{% if autoplay %} autoplay{% endif %}{% if preload_video %} preload="auto"{% endif %} controls>
    <source>