-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
152 lines (144 loc) · 7.31 KB
/
index.html
File metadata and controls
152 lines (144 loc) · 7.31 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Events Demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
</head>
<body onload="message()">
<div class="container py-4" id="main-container">
<header class="pb-3 mb-4 border-bottom">
<h1 class="display-5 fw-bold">JavaScript Events Demo</h1>
<button id="theme-toggle" class="btn btn-outline-primary mt-2">Dark Mode</button>
</header>
<div class="row g-4">
<!-- Dropdown with onchange event -->
<div class="col-md-6">
<div class="p-4 bg-light rounded-3 h-100">
<h2>Dropdown Event (onchange)</h2>
<select id="color-select" class="form-select mb-3" onchange="handleSelectChange()">
<option value="">Select a color</option>
<option value="primary">Blue</option>
<option value="success">Green</option>
<option value="danger">Red</option>
<option value="warning">Yellow</option>
<option value="info">Teal</option>
</select>
<div id="selected-color-display" class="p-3 rounded-3 text-white bg-secondary">
No color selected
</div>
</div>
</div>
<!-- Calculator with onclick events -->
<div class="col-md-6">
<div class="p-4 bg-light rounded-3 h-100">
<h2>Calculator (onclick)</h2>
<div class="mb-3">
<input type="number" id="num1" class="form-control mb-2" placeholder="First number">
<input type="number" id="num2" class="form-control" placeholder="Second number">
</div>
<div class="btn-group mb-3">
<button onclick="calculate('add')" class="btn btn-primary">+</button>
<button onclick="calculate('subtract')" class="btn btn-primary">−</button>
<button onclick="calculate('multiply')" class="btn btn-primary">×</button>
<button onclick="calculate('divide')" class="btn btn-primary">÷</button>
</div>
<div id="result" class="p-3 bg-secondary text-white rounded-3">
Result will appear here
</div>
</div>
</div>
<!-- Color box with mouseover/mouseout -->
<div class="col-md-6">
<div class="p-4 bg-light rounded-3 h-100">
<h2>Mouse Events</h2>
<div
id="color-box"
class="p-5 bg-primary text-white rounded-3 text-center"
onmouseover="changeBoxColor()"
onmouseout="resetBoxColor()">
Hover over me!
</div>
</div>
</div>
<!-- Input with keydown event -->
<div class="col-md-6">
<div class="p-4 bg-light rounded-3 h-100">
<h2>Keyboard Event (onkeydown)</h2>
<input
type="text"
id="key-input"
class="form-control mb-3"
placeholder="Type something..."
onkeydown="handleKeyDown(event)">
<div id="key-display" class="p-3 bg-secondary text-white rounded-3">
Press any key to see it here
</div>
</div>
</div>
</div>
<div class="row g-4 mt-2">
<!-- Form -->
<div class="col-md-12">
<div class="p-4 bg-light rounded-3">
<h2>Contact Form (onsubmit)</h2>
<form id="user-form" onsubmit="handleFormSubmit(event)">
<div class="row mb-3">
<div class="col-md-6 mb-3 mb-md-0">
<input type="text" id="name" class="form-control" placeholder="Your Name" required>
</div>
<div class="col-md-6">
<input type="email" id="email" class="form-control" placeholder="Your Email" required>
</div>
</div>
<div class="mb-3">
<textarea id="message" class="form-control" rows="3" placeholder="Your Message" required></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<div id="form-message" class="mt-3 p-3 rounded-3 d-none"></div>
</form>
</div>
</div>
<!-- Text Manipulator -->
<div class="col-md-6">
<div class="p-4 bg-light rounded-3 h-100">
<h2>Text Manipulator</h2>
<input type="text" id="text-input" class="form-control mb-3" placeholder="Enter some text...">
<div class="d-grid gap-2">
<button onclick="transformText('uppercase')" class="btn btn-primary">UPPERCASE</button>
<button onclick="transformText('lowercase')" class="btn btn-primary">lowercase</button>
<button onclick="transformText('reverse')" class="btn btn-primary">Reverse Text</button>
<button onclick="transformText('count')" class="btn btn-primary">Count Characters</button>
</div>
<div id="text-result" class="p-3 bg-secondary text-white rounded-3 mt-3">
Results will appear here
</div>
</div>
</div>
<!-- Simple Counter/Timer -->
<div class="col-md-6">
<div class="p-4 bg-light rounded-3 h-100">
<h2>Counter & Timer</h2>
<div class="mb-3">
<h3 id="counter-display" class="display-4 text-center">0</h3>
</div>
<div class="d-grid gap-2">
<button onclick="incrementCounter()" class="btn btn-success">Increment</button>
<button onclick="decrementCounter()" class="btn btn-danger">Decrement</button>
<button onclick="resetCounter()" class="btn btn-secondary">Reset</button>
</div>
<hr>
<div class="text-center">
<button id="timer-button" onclick="toggleTimer()" class="btn btn-primary">Start Timer</button>
<h4 id="timer-display" class="mt-3">00:00</h4>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="script.js"></script>
</body>
</html>