all repos — retro-website @ 14ae5050e4af0abca7d90b5f7eb55ddfda7cc680

more tidying up
Marco Andronaco andronacomarco@gmail.com
Mon, 19 Sep 2022 10:48:10 +0200
commit

14ae5050e4af0abca7d90b5f7eb55ddfda7cc680

parent

725dd15288ec413c60ffc5eb98544da79381ef06

3 files changed, 57 insertions(+), 54 deletions(-)

jump to
M index.htmlindex.html

@@ -71,15 +71,16 @@ <div id="music-player-song" style="top: 100%;">

<span id="song-text">Jay Tholen - Awesome Rap Beat (Hypnospace Outlaw Original Soundtrack, Vol. 2)</span> </div> </div> - + <audio loop id="music"><source id="music-source" src="#"></audio> <audio id="loadelement1"><source src="res/sfx/os/loadelement1.ogg"></audio> <audio id="loadelement2"><source src="res/sfx/os/loadelement2.ogg"></audio> <audio id="loadelement3"><source src="res/sfx/os/loadelement3.ogg"></audio> <audio id="loadelement4"><source src="res/sfx/os/loadelement4.ogg"></audio> + <script src="res/js/music.js"></script> <script src="res/js/slow_load.js"></script> - <script src="res/js/script.js"></script> + <script src="res/js/main.js"></script> <script src="res/js/frame-link.js"></script> </body>
A res/js/main.js

@@ -0,0 +1,53 @@

+const iframe = document.getElementById("mainframe"); + +const loadSpeed = 2; + +let first = false; +let play = false; +let controlsEnabled = false; +let currentPage = "about"; + +function firstPlay(){ + if(first) return; + document.getElementById("music-player").style.bottom = "0"; + music.volume = 0.1; + controlsEnabled = true; + playPause(false, page_tracks[currentPage]); + first = true; +} + +function loadIFrame(callback){ + iframe.contentWindow.start_loading(speed=loadSpeed, not_allowed, callback); +} + +function firstClickPlay(element) { + const overlay = document.getElementById("overlay"); + if(overlay) { + overlay.remove(); + hide_all(); + start_loading(speed=loadSpeed, not_allowed, () => { loadIFrame(firstPlay) }); + //slow_load(speed=loadSpeed, not_allowed, () => { loadIFrame(firstPlay) }); + } + + click1 = clickAudio1 || parent.clickAudio1; + click2 = clickAudio2 || parent.clickAudio2; + + playAudio(click1) + element.onmousedown = () => playAudio(click1); + element.onmouseup = () => playAudio(click2); +} + +function frameLoadedCallback() { + controlsEnabled = true; + playPause(!play, page_tracks[currentPage]); +} + +function goToPage(page) { + if (!controlsEnabled || currentPage == page) return + + music.pause() + controlsEnabled = false; + iframe.src = "pages/" + page + ".html"; + currentPage = page; + +}
M res/js/script.jsres/js/music.js

@@ -1,4 +1,3 @@

-const iframe = document.getElementById("mainframe"); const music = document.getElementById("music"); const source = document.getElementById("music-source"); const music_base = document.getElementById("music-player-base");

@@ -6,7 +5,6 @@ const music_song = document.getElementById("music-player-song");

const music_song_text = document.getElementById("song-text"); const clickAudio1 = new Audio(url="res/sfx/os/click2.ogg"); const clickAudio2 = new Audio(url="res/sfx/os/click1.ogg"); -const loadSpeed = 2; const tracks = { "awesome": {

@@ -57,58 +55,9 @@ "indies": "earmint",

"zelda": "forest", } -let first = false; -let play = false; -let controlsEnabled = false; -let currentPage = "about"; let currentTrack = ""; let showTimeout, hideTimeout; -function firstPlay(){ - if(first) return; - document.getElementById("music-player").style.bottom = "0"; - music.volume = 0.1; - controlsEnabled = true; - playPause(false, page_tracks[currentPage]); - first = true; -} - -function loadIFrame(callback){ - iframe.contentWindow.start_loading(speed=loadSpeed, not_allowed, callback); -} - -function firstClickPlay(element) { - const overlay = document.getElementById("overlay"); - if(overlay) { - overlay.remove(); - hide_all(); - start_loading(speed=loadSpeed, not_allowed, () => { loadIFrame(firstPlay) }); - //slow_load(speed=loadSpeed, not_allowed, () => { loadIFrame(firstPlay) }); - } - - click1 = clickAudio1 || parent.clickAudio1; - click2 = clickAudio2 || parent.clickAudio2; - - playAudio(click1) - element.onmousedown = () => playAudio(click1); - element.onmouseup = () => playAudio(click2); -} - -function frameLoadedCallback() { - controlsEnabled = true; - playPause(!play, page_tracks[currentPage]); -} - -function goToPage(page) { - if (!controlsEnabled || currentPage == page) return - - music.pause() - controlsEnabled = false; - iframe.src = "pages/" + page + ".html"; - currentPage = page; - -} - function formatTrack(track) { return `${track.track_author} - ${track.track_name} (${track.track_from})`; }

@@ -155,4 +104,4 @@ if(changed)

showTitle(); play = true } -} +}