Commit feef48ba authored by Stephen D's avatar Stephen D
Browse files

New features and added HTML stuff

parent c500ed94
<html>
<html lang="en">
<head>
<title>Buzz buzz</title>
<meta name="description" content="That's a lot of bees!">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<script src="script.js">
</script>
<style>
......@@ -21,6 +24,7 @@
<body>
<div id="container">
<button onclick="addBee()">Add bee</button>
<div id="numBeeText"></div>
</div>
</body>
</html>
function setNumBees() {
const numBeeDiv = document.getElementById("numBeeText");
const numBees = document.getElementsByClassName("bee").length;
numBeeDiv.innerHTML = `${numBees} bee${numBees == 1 ? '' : 's'}. `;
if(numBees >= 10)
{
numBeeDiv.innerHTML += " That's a lot of bees!";
}
}
function addBee() {
const rect = document.body.getBoundingClientRect();
const width = rect.width;
......@@ -16,9 +26,13 @@ function addBee() {
bee.style.left = `${bee.vars.x}px`;
document.body.appendChild(bee);
setNumBees();
}
window.onload = function() {
setNumBees();
const rect = document.body.getBoundingClientRect();
const width = rect.width;
const height = rect.height;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment