I think i need some more help with how to make the "snowstorm" active only when i click the calendars. I can give you my file if that helps.
I cant find a way to send the file here, so i will just copy/paste the code in here.
HTML:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Julekaldender</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans|Oswald|Roboto+Condensed" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js"></script>
<script type="text/javascript">
window.onload = oppstart;
function oppstart() {
function UrlExists(url, cb){
jQuery.ajax({
url: url,
dataType: 'text',
type: 'GET',
complete: function(xhr){
if(typeof cb === 'function')
cb.apply(this, [xhr.status]);
}
});
}
var tl = new TimelineMax;
var k = 1;
var datoluke = 1;
for (var j = 0; j < 4; j++) {
for (var w = 0; w < 6; w++) {
var ny_luke = document.createElement("div");
ny_luke.style.height = "70px";
ny_luke.style.width = "90px";
ny_luke.style.top = String(90 + 130 * j) + "px";
ny_luke.style.left = String(260 + 150 * w) + "px";
ny_luke.style.borderStyle = "solid";
ny_luke.style.borderColor = "red";
ny_luke.style.position = "absolute";
ny_luke.className = "lukefelles";
ny_luke.id = "luke" + k;
k++;
ny_luke.innerHTML = datoluke;
datoluke++;
document.getElementById("innpakning").appendChild(ny_luke);
}
}
var d = new Date();
for (var n = 1; n < 25; n++) {
localStorage.setItem("luke" + n, "true");
if (n < d.getDate()) {
localStorage.setItem("luke" + n, "false");
tl.set("#luke" + n, {borderColor: "black"});
tl.set(".lukefelles#luke" + n, {color: "black", boxShadow: "4px 4px 10px #000000", borderWidth: 3});
}
}
var r=1;
document.getElementById("innpakning").onclick = visbilde;
function visbilde (evt) {
var str = evt.target.id;
var res = str.substring(4);
var dagerigjen = 24 - res;
if (JSON.parse(localStorage.getItem(evt.target.id))=== true) {
document.getElementById("overskrift").innerHTML = "Det er " + dagerigjen + " dager igjen til jul";
document.getElementById("overskrift").style.fontSize= "40px";
var pic = evt.target.id + ".jpg";
UrlExists(pic, function(status){
if(status === 200){
document.getElementById("kroppen").style.backgroundImage = "url(" + pic + ")";
}
});
}
}
}
</script>
</head>
<body id="kroppen">
<h1 id="overskrift">Julekalender</h1>
<div id="innpakning">
</div>
</body>
</html>
CSS
Code:
html {
margin: 0;
}
body {
background-image: url("bakgrunn.jpg");
background-attachment: fixed;
background-size: cover;
}
body.newbg1 {
background-image: url("vinter.jpg");
background-attachment: fixed;
background-size: cover;
}
body.newbg2 {
background-image: url("hund.jpg");
background-attachment: fixed;
background-size: cover;
}
#innpakning {
margin-left: 50px;
}
.lukefelles {
color: red;
font-size: 30px;
box-shadow: 4px 4px 10px black;
border-width: 3px;
}
.lukefelles:hover {
box-shadow: 7px 7px 30px black;
border-width: 6px;
}
#overskrift {
color: red;
font-family: 'Roboto Condensed', sans-serif;
text-align: center;
font-size: 70px;
margin-top: 5px;
margin-bottom: 5px;
}
SetItems
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Set items</title>
<script>
window.onload = oppstart;
function oppstart() {
var d = new Date();
for (var n=1;n<25;n++) {
localStorage.setItem("luke"+n, "true");
if (n < d.getDate()) {
localStorage.setItem("luke"+n, "false")
}
}
alert("web storage er satt opp")
}
</script>
</head>
<body>
<p>Programmet er ferdig</p>
</body>
</html>
Bookmarks