-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathjsDOM.html
206 lines (184 loc) · 5.94 KB
/
jsDOM.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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>
.box {
padding: 5px;
margin: 5px;
}
ul {
list-style-type: none;
}
/* These Styles are for the Grid */
.square {
width: 50%;
height: 50%;
display: inline-block;
float:left;
box-sizing: content-box
}
.parent {
width: 300px;
height: 300px;
box-sizing: content-box;
background: #fff;
box-shadow: 0px 0px 100px #eaeaea
}
.base-style-class {
display: inline-block;
float:left;
box-sizing: content-box
}
/* Styles for the calculator */
#screen {
width: 200px;
height: 50px;
border: 1px solid black;
margin: 10px;
text-align: right;
}
.btn {
width: 40px;
height: 40px;
margin: 5px;
}
</style>
<title>jsDOM</title>
</head>
<body>
<h1>Javascript Snippets for DOM Manipulation</h1>
<fieldset>
<legend>Menu Outputs Choice</legend>
<span>Choice: </span>
<select id="inFromUser">
<optgroup label="Swedish Cars">
<option value="Volvo">Volvo</option>
<option value="Saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="Mercedes">Mercedes</option>
<option value="Audi">Audi</option>
</optgroup>
</select>
<span>Output: <span id="output"></span></span>
</fieldset>
<div id="changeC" style="background-color: green; " class="box">
<span>Changing styles</span><br>
<label for="select">Color: </label>
<select id="colorIn">
<option value="green">Green</option>
<option value="yellow">Yellow</option>
<option value="purple">Purple</option>
<option value="cyan">Cyan</option>
</select>
</div>
<div class="list box" style="border: 1px solid #000;">
<h2>Add Items to List //only frontend</h2>
<p>If anyone wants to add a backend to this, please feel free to do that</p>
<form id="addForm">
<input type="text" id="item">
<input type="submit" value="Submit">
</form>
<h3>Items: </h3>
<ul id="items">
<li class="list-item">Item 1 <button class="delBtn">X</button></li>
<li class="list-item">Item 2 <button class="delBtn">X</button></li>
<li class="list-item">Item 3 <button class="delBtn">X</button></li>
<li class="list-item">Item 4 <button class="delBtn">X</button></li>
</ul>
</div>
<div class="search-container" style="border: 1px solid #000; margin-top: 10px; padding: 10px">
<h2>Type in the search box</h2>
<h3> Simple 2 way binding mechanism.</h3>
<input type="text" class="search-box" style="padding: 10px; font-size: 14px"/>
<span id="search-output"></span>
</div>
<div style="border: 1px solid #000; margin-top: 10px; padding: 10px">
<h2>Click anywhere on the square below and watch the split of divs</h2>
<div class="parent">
<div class="square"></div>
<div class="square"></div>
<div class="square"></div>
<div class="square"></div>
</div>
</div>
<div class = "calculator">
<h2>Calculator</h2>
<div id = "screen"></div>
<div id = "buttons">
<table>
<tr>
<td><button class = "btn" value = "7">7</button></td>
<td><button class = "btn" value = "8">8</button></td>
<td><button class = "btn" value = "9">9</button></td>
<td><button class = "btn" value = "+">+</button></td>
</tr>
<tr>
<td><button class = "btn" value = "4">4</button></td>
<td><button class = "btn" value = "5">5</button></td>
<td><button class = "btn" value = "6">6</button></td>
<td><button class = "btn" value = "-">-</button></td>
</tr>
<tr>
<td><button class = "btn" value = "1">1</button></td>
<td><button class = "btn" value = "2">2</button></td>
<td><button class = "btn" value = "3">3</button></td>
<td><button class = "btn" value = "*">*</button></td>
</tr>
<tr>
<td><button class = "btn" value = "0">0</button></td>
<td><button class = "btn" id = "end" value = "=">=</button></td>
<td><button class = "btn" value = "/">/</button></td>
<td><button class = "btn" id = "clear" value = "CE">CE</button></td>
</tr>
</table>
</div>
</div>
<div style="border: 1px solid #000">
<h2 style="padding-left: 5px;">Info Generator:</h2>
<label for="name" style="padding-left: 5px;">Name: </label>
<input type="text" class="name" id="name">
<p style="padding-left: 5px;">Are you a Cat or Dog person?</p>
<input name="lover" type="radio" id="dogs" value="dogs.">
<label for="dogs">Dog</label>
<br>
<input name="lover" type="radio" id="cats" value="cats.">
<label for="cats">Cat</label>
<br>
<input name="lover" type="radio" id="both" value="both cats and dogs.">
<label for="both">Both</label>
<br>
<input name="lover" type="radio" id="none" value="neither cats nor dogs.">
<label for="both">None</label>
<br>
<br>
<span id="finalInfo" style="padding-left: 10px;"></span>
</div>
<div style="border: 1px solid #000; margin-top: 10px; padding:10px;">
<h2>Button Clicker</h2>
<button onclick="clickStart()" id='startButton'>Start</button>
<h4>Time Left</h4>
<p id='timerem'>10</p>
<button id='click' onclick = "updateScore()" disabled>Click here</button>
<h4>Score: </h4><p id="score">0</p>
<h4>Clicks per second: </h4><p id = 'scoreps'>-</p>
</div>
<!-- RGB to Hex slider -->
<div id="slider" style="border: 1px solid #000; margin-top: 10px; padding:10px;">
<h2>RGB to Hex Slider</h2>
<input type="range" name="R" id="slider-r" min=0 max=250>
<div>R: 125</div>
<input type="range" name="G" id="slider-g" min=0 max=250>
<div>G: 125</div>
<input type="range" name="B" id="slider-b" min=0 max=250>
<div>B: 125</div>
<div id="color" style="display: inline-block; width: 80px; height: 30px; border: 1px solid #000; background-color: #7d7d7d;"></div>
<div id="color-code" style="display: inline">#7d7d7d</div>
</div>
<!-- End color slider -->
<script src="js/jsDOM.js"></script>
</body>
</html>