Fixed wallpaper double-loading issue, cleaned up js
This commit is contained in:
parent
30b3f2695d
commit
4e1ebe6136
13
index.html
13
index.html
|
|
@ -4,19 +4,20 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>Comfitu.re - Sweet and Cozy</title>
|
||||
|
||||
<link href="style.css" rel="stylesheet"/>
|
||||
<script src="script.js" type="application/javascript"></script>
|
||||
<link href="style.css?v=1.2.2" rel="stylesheet"/>
|
||||
<script src="script.js?v=1.2.2" type="application/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="background"></div>
|
||||
<script>comfiture.setupWallpaper();</script>
|
||||
|
||||
<div class="container">
|
||||
<header>
|
||||
<pre>
|
||||
___ __ _ _
|
||||
/ __|___ _ __ / _(_) |_ _ _ _ _ ___
|
||||
| (__/ _ \ ' \| _| | _| || |_| '_/ -_) <a href="#changelog">v1.2.1</a>
|
||||
| (__/ _ \ ' \| _| | _| || |_| '_/ -_) <a href="#changelog">v1.2.2</a>
|
||||
\___\___/_|_|_|_| |_|\__|\_,_(_)_| \___| by Fristi IN A CAN.
|
||||
</pre>
|
||||
<a href="#home">Home</a>
|
||||
|
|
@ -180,6 +181,12 @@
|
|||
|
||||
<div class="content" id="changelog">
|
||||
<h1>Changelog</h1>
|
||||
<p>
|
||||
1.2.2 Patch:<br/>
|
||||
- Cleaned up javascript code<br/>
|
||||
- Fixed issue with doubly loading wallpaper<br/>
|
||||
- Added version query string to css and javascript urls to prevent cache issues
|
||||
</p>
|
||||
<p>
|
||||
1.2.1 Patch:<br/>
|
||||
- Set a default background image for the no-javascript crowd<br/>
|
||||
|
|
|
|||
20
script.js
20
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;
|
||||
|
||||
})();
|
||||
Loading…
Reference in a new issue