1
0
Fork 0

🐁🐛 Checkpoint

./index.html:7435365/1848
./style.css:7435365/834
./script.js:7435365/2247
This commit is contained in:
Glitch (hello-webpage) 2019-10-06 19:02:50 +00:00
parent 36109cf9be
commit e44cd7b3ad
3 changed files with 134 additions and 30 deletions

View File

@ -5,23 +5,22 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- import the webpage's stylesheet -->
<link rel="stylesheet" href="/style.css">
<!-- import the webpage's javascript file -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="/script.js" defer></script>
</head>
<body>
<h1>Hi there!</h1>
<p>
I'm your cool new webpage. Made with <a href="https://glitch.com">Glitch</a>!
</p>
<!-- include the Glitch button to show what the webpage is about and
to make it easier for folks to view source and remix -->
<!-- import the webpage's stylesheet -->
<link href="https://fonts.googleapis.com/css?family=Kanit:700i&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/style.css">
<!-- import the webpage's javascript file -->
<script src="/confetti.js" defer></script>
<script src="/script.js" defer></script>
</head>
<body>
<canvas id="confetti-holder"></canvas>
<div id="container">
<p id="isit"></p>
</div>
<div class="glitchButton" style="position:fixed;top:20px;right:20px;"></div>
<script src="https://button.glitch.me/button.js"></script>
</body>

View File

@ -1,9 +1,82 @@
/* If you're feeling fancy you can add interactivity
to your site with Javascript */
var birthday = {
now: null,
day: 25,
month: 6, // June
match: false,
check: function() {
this.now = new Date();
if (this.now.getDate() == this.day && this.now.getMonth() + 1 == this.month) this.activate()
else this.deactivate()
},
activate: function() {
document.getElementById('isit').innerHTML = "Yes!"
elementClass.remove(document.getElementById('isit'), 'nope')
elementClass.add(document.getElementById('isit'), 'yep')
confetti.render();
},
deactivate: function() {
document.getElementById('isit').innerHTML = "No"
elementClass.remove(document.getElementById('isit'), 'yep')
elementClass.add(document.getElementById('isit'), 'nope')
// prints "hi" in the browser's dev tools console
console.log("hi");
confetti.clear();
}
}
$(function() {
alert('Hello, world!')
})
var confetti = {
displayed: false,
confetti: null,
target: 'confetti-holder',
max: null,
size: 1,
animate: true,
props: ['circle', 'square', 'triangle', 'line'],
colors: [[165,104,246], [230,61,135], [0,199,228], [253,214,126]],
clock: 25,
rotate: true,
width: null,
height: null,
render: function() {
this.width = window.innerWidth
this.height = window.innerHeight
this.max = Math.floor(this.width * this.height / 1799.04)
if (this.confetti) this.confetti.clear();
this.confetti = new ConfettiGenerator(this)
this.confetti.render();
this.displayed = true;
},
clear: function() {
if (!this.displayed) return;
this.confetti.clear();
this.displayed = false;
}
}
var elementClass = {
has: function(e, c) {
return !!e.className.match(new RegExp('(\\s|^)' + c + '(\\s|$)'));
},
add: function(e, c) {
if (!this.has(e,c)) e.className += " " + c;
},
remove: function(e, c) {
if (this.has(e,c)) {
var r = new RegExp('(\\s|^)' + c + '(\\s|$)');
e.className=e.className.replace(r, ' ');
}
},
}
window.onload = function() {
birthday.check();
};
window.addEventListener('resize', function() {
if (confetti.displayed) confetti.render();
}, false);
window.setInterval(function(){
birthday.check();
}, 5000);

View File

@ -1,11 +1,43 @@
/* CSS files add styling rules to your content */
html,
body {
font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;
margin: 2em;
width: 100%;
height: 100%;
margin: 0;
background-color: #fff;
}
h1 {
font-style: italic;
color: #373fff;
#confetti {
position: fixed;
top:0;
left: 0;
z-index: 1;
}
#container {
position: fixed;
top: 0;
width: 100%;
height: 100%;
}
#container p {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
padding: 1vw;
font-family: 'Kanit', sans-serif;
font-size: 16vw;
}
p.nope {
color: #888888;
}
p.yep {
background-image: linear-gradient(to right, violet, indigo, blue, green, yellow, orange, red);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
}