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">
|
<meta charset="UTF-8">
|
||||||
<title>Comfitu.re - Sweet and Cozy</title>
|
<title>Comfitu.re - Sweet and Cozy</title>
|
||||||
|
|
||||||
<link href="style.css" rel="stylesheet"/>
|
<link href="style.css?v=1.2.2" rel="stylesheet"/>
|
||||||
<script src="script.js" type="application/javascript"></script>
|
<script src="script.js?v=1.2.2" type="application/javascript"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="background"></div>
|
<div class="background"></div>
|
||||||
|
<script>comfiture.setupWallpaper();</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<header>
|
<header>
|
||||||
<pre>
|
<pre>
|
||||||
___ __ _ _
|
___ __ _ _
|
||||||
/ __|___ _ __ / _(_) |_ _ _ _ _ ___
|
/ __|___ _ __ / _(_) |_ _ _ _ _ ___
|
||||||
| (__/ _ \ ' \| _| | _| || |_| '_/ -_) <a href="#changelog">v1.2.1</a>
|
| (__/ _ \ ' \| _| | _| || |_| '_/ -_) <a href="#changelog">v1.2.2</a>
|
||||||
\___\___/_|_|_|_| |_|\__|\_,_(_)_| \___| by Fristi IN A CAN.
|
\___\___/_|_|_|_| |_|\__|\_,_(_)_| \___| by Fristi IN A CAN.
|
||||||
</pre>
|
</pre>
|
||||||
<a href="#home">Home</a>
|
<a href="#home">Home</a>
|
||||||
|
|
@ -180,6 +181,12 @@
|
||||||
|
|
||||||
<div class="content" id="changelog">
|
<div class="content" id="changelog">
|
||||||
<h1>Changelog</h1>
|
<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>
|
<p>
|
||||||
1.2.1 Patch:<br/>
|
1.2.1 Patch:<br/>
|
||||||
- Set a default background image for the no-javascript crowd<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 (){
|
(function (){
|
||||||
|
var comfiture = {};
|
||||||
console.debug('anonymous');
|
|
||||||
|
|
||||||
var activeLink;
|
var activeLink;
|
||||||
var activeContent;
|
var activeContent;
|
||||||
var wallpapers = [
|
var wallpapers = [
|
||||||
|
|
@ -15,6 +11,13 @@ console.debug('load');
|
||||||
'9.png',
|
'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(){
|
window.addEventListener('load', function(){
|
||||||
//Hide all content
|
//Hide all content
|
||||||
let contents = document.querySelectorAll('.content');
|
let contents = document.querySelectorAll('.content');
|
||||||
|
|
@ -27,10 +30,6 @@ console.debug('load');
|
||||||
if(!hash) hash = '#home';
|
if(!hash) hash = '#home';
|
||||||
switchActiveContent(hash);
|
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
|
//Add click event handlers for header/footer links
|
||||||
window.addEventListener("click", event => {
|
window.addEventListener("click", event => {
|
||||||
var elements = document.querySelectorAll('header a, footer a');
|
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