-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
76 lines (74 loc) · 2.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="icon" href="image-removebg-preview.png" type="image/icon type" >
<title>Kal</title>
</head>
<body>
<div class="title-bar">
<h1><img src="Kal the Mathematician.svg" alt="title" ></h1>
</div>
<div id="kal-body">
<div id="kal-screen">
<div id="output">0</div>
</div>
<div class="num-row">
<ul>
<li><input type="button" id="1" value="1"></li>
<li><input type="button" id="2" value="2"></li>
<li><input type="button" id="3" value="3"></li>
<li><input type="button" id="+" value="+"></li>
</ul>
</div>
<div class="num-row">
<ul>
<li><input type="button" id="4" value="4"></li>
<li><input type="button" id="5" value="5"></li>
<li><input type="button" id="6" value="6"></li>
<li><input type="button" id="-" value="-"></li>
</ul>
</div>
<div class="num-row">
<ul>
<li><input type="button" id="7" value="7"></li>
<li><input type="button" id="8" value="8"></li>
<li><input type="button" id="9" value="9"></li>
<li><input type="button" id="*" value="*"></li>
</ul>
</div>
<div class="num-row">
<ul>
<li><input type="button" id="equal" value="="></li>
<li><input type="button" id="clear" value="C"></li>
<li><input type="button" id="ac" value="AC"></li>
<li><input type="button" id="/" value="/"></li>
</ul>
</div>
</div>
<script>
const div = document.getElementById('output');
const buttons = document.querySelectorAll('input[type="button"]');
buttons.forEach(button => {
button.addEventListener('click', function() {
const value = this.value;
if (value === "C") {
div.innerHTML = "0";
} else if (value === "AC") {
div.innerHTML = "No air conditioning I'm afraid!";
} else if (value === "=") {
div.innerHTML += " = who knows!";
} else {
if(div.innerHTML === "0"){
div.innerHTML = value;
}else{
div.innerHTML += value;
}
}
});
});
</script>
</body>
</html>