-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
221 lines (192 loc) · 7.95 KB
/
Copy pathindex.html
File metadata and controls
221 lines (192 loc) · 7.95 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Full Course</title>
<style>
.subscribe-button
{
border: none;
background-color: black;
color: #fff;
padding: 15px 25px;
font-weight: bold;
border-radius: 50px;
cursor: pointer;
font-size: 11pt;
margin-bottom: 30px;
}
.is-subscribed
{
background-color: rgb(240, 240, 240);
color: black;
}
.cost-input
{
font-size: 14pt;
padding: 10px;
}
.calculate-button
{
background-color: green;
border: none;
color: #fff;
font-size: 15px;
padding: 14px 15px;
cursor: pointer;
}
</style>
</head>
<body>
<button onclick="welcomeMessage()">Show Alert Message</button>
<button onclick="input()">Show Input</button>
<!--
<script>
function welcomeMessage()
{
alert('Welcome to the WebSite')
}
</script>
-->
<button style="height: 4rem; font-size: 12pt; padding: 25px; margin-right: 5px;"
onclick="console.log(`Cart Quantity: ${cartQuantity}`)"
>Show Quantity</button>
<button style="height: 4rem; font-size: 12pt; padding: 25px; margin-right: 5px"
onclick="console.log(`${cartQuantity}`); add()"
>Add to Cart</button>
<button style="height: 4rem; font-size: 12pt; padding: 25px; margin-right: 5px"
onclick="cartQuantity += 2; console.log(`+2 Card = ${cartQuantity}`)"
>+2</button>
<button style="height: 4rem; font-size: 12pt; padding: 25px; margin-right: 5px"
onclick="cartQuantity +=3; console.log(`+3 Card = ${cartQuantity}`)"
>+3</button>
<button style="height: 4rem; font-size: 12pt; padding: 25px;"
onclick="cartQuantity = 0; console.log('Cart was reset.'); console.log(`Cart Quantity: ${cartQuantity}`)"
>Reset Cart</button>
<script>
let cartQuantity = 0;
function add() {
cartQuantity++;
}
//Boolean
console.log(typeof true)
if(false) { console.log('hello') }
else { console.log('friend') }
age = 15
let check = (age >= 16) ? 'You can drive' : 'You can not drive'
console.log(check)
</script>
<script src="./scripts/main.js"></script>
<hr style="margin-top: 45px; margin-bottom: 45px;">
<h1>ROCK PAPER SCISSORS (mini-game)</h1>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGame('rock')">Rock</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGame('paper')">Paper</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGame('scissors')">Scissors</button>
<script>
let computerMove = ''
let result = ''
function pickComputerMove()
{
const randomNumber = Math.random();
if(randomNumber >= 0 && randomNumber < 1/3) { computerMove = 'rock' }
else if(randomNumber >= 1/3 && randomNumber < 2/3) { computerMove = 'paper' }
else if(randomNumber >= 2/3 && randomNumber < 1) { computerMove = 'scissors' }
//return; // return undefined
console.log(computerMove)
}
function calculateTax(parameter1) {
console.log(parameter1 * 0.1)
}
calculateTax(5000);
function user(name, lastName, age)
{
console.log(`Name: ${name} \nLastName: ${lastName} \nAge: ${age} years old`)
}
user('Ramadan', 'Ismael', '57')
function playGame(playerMode)
{
if(playerMode === 'rock')
{
pickComputerMove();
if(computerMove === 'rock') { result = 'Tie.' }
else if(computerMove === 'paper') { result = 'You lose.' }
else if(computerMove === 'scissors') { result = 'You win.' }
alert(`You picked rock. Computer picked ${computerMove}. ${result}`)
}
else if(playerMode === 'paper')
{
pickComputerMove()
if(computerMove === 'rock') { result = 'You win.' }
else if(computerMove === 'paper') { result = 'Tie.' }
else if(computerMove === 'scissors') { result = 'You lose.' }
alert(`You picked paper. Computer picked ${computerMove}. ${result}`)
}
else if(playerMode === 'scissors')
{
pickComputerMove()
if(computerMove === 'rock') { result = 'You lose.' }
else if(computerMove === 'paper') { result = 'You win.' }
else if(computerMove === 'scissors') { result = 'Tie.' }
alert(`You picked scissors. Computer picked ${computerMove}. ${result}`)
}
}
</script>
<hr style="margin-top: 45px; margin-bottom: 45px;">
<h1>Objects (ROCK PAPER SCISSORS)</h1>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGameObject('rock')">Rock</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGameObject('paper')">Paper</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGameObject('scissors')">Scissors</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="resetObject()">Reset Score</button>
<p style="margin-top: 45px; margin-bottom: 45px;"></p>
<h1>LocalStorage (Rock Paper Scissors)</h1>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGameLocal('rock')">Rock</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGameLocal('paper')">Paper</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="playGameLocal('scissors')">Scissors</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="resetLocal()">Reset Score</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;"
onclick="showResult()">Show Result</button>
<script src="./scripts/objects.js"></script>
<hr style="margin-top: 45px; margin-bottom: 45px;">
<h1>Document Object Model (DOM)</h1>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;">hello</button>
<button style="height: 4rem; font-size: 12pt; width: 9rem; margin-right: 5px;" class="js-button">Second button</button>
<h1 style="margin-top: 45px; margin-bottom: 45px;">--------------------------</h1>
<p style="font-size: 14pt;">Youtube Subscribe Button</p>
<button class="js-subscribe-button subscribe-button" onclick="btnSubscribe()">Subscribe</button>
<p style="font-size: 14pt;">Amazon Shipping Calculator</p>
<!--
<input type="text" placeholder="Cost of order" class="js-cost-input"
onkeydown="/*console.log('typing')*/ console.log(event.key)
if(event.key === 'Enter') { btnCalculateTotal() }"
>
-->
<input type="text" placeholder="Cost of order" class="js-cost-input cost-input"
onkeydown="handleCostKeyDown(event)"
>
<button onclick="btnCalculateTotal()" class="calculate-button">Calculate</button>
<p class="js-total-cost" style="font-size: 14pt;"></p>
<!-- EVENT LISTENERS
! onlick = click
! onkeydown = key press
! onscroll = scrolling
! onmouseenter = hovering over
! onmouseleave = stop hovering over
! ...
!... and many more
-->
<script src="./scripts/dom.js"></script>
</body>
</html>