Changelog
+
+ 1.2.2 Patch:
+ - Cleaned up javascript code
+ - Fixed issue with doubly loading wallpaper
+ - Added version query string to css and javascript urls to prevent cache issues
+
1.2.1 Patch:
- Set a default background image for the no-javascript crowd
diff --git a/script.js b/script.js
index f85a504..1c428e8 100644
--- a/script.js
+++ b/script.js
@@ -1,9 +1,5 @@
-console.debug('load');
-
(function (){
-
- console.debug('anonymous');
-
+ var comfiture = {};
var activeLink;
var activeContent;
var wallpapers = [
@@ -15,6 +11,13 @@ console.debug('load');
'9.png',
];
+ //Function to set the wallpaper
+ comfiture.setupWallpaper = function () {
+ let wallpaper = wallpapers[Math.floor(Math.random() * wallpapers.length)];
+ document.querySelector('.background').style.backgroundImage = 'url("backgrounds/'+wallpaper+'")';
+ };
+
+ //Onload
window.addEventListener('load', function(){
//Hide all content
let contents = document.querySelectorAll('.content');
@@ -27,10 +30,6 @@ console.debug('load');
if(!hash) hash = '#home';
switchActiveContent(hash);
- //Set random wallpaper
- let wallpaper = wallpapers[Math.floor(Math.random() * wallpapers.length)];
- document.querySelector('.background').style.backgroundImage = 'url("backgrounds/'+wallpaper+'")';
-
//Add click event handlers for header/footer links
window.addEventListener("click", event => {
var elements = document.querySelectorAll('header a, footer a');
@@ -62,4 +61,7 @@ console.debug('load');
}
}
+ //Expose comfiture object to document
+ window.comfiture = comfiture;
+
})();
\ No newline at end of file