-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex-video3.html
More file actions
476 lines (404 loc) · 15.5 KB
/
index-video3.html
File metadata and controls
476 lines (404 loc) · 15.5 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>JavaScript Loops & Events – Full Demo</title>
<style>
:root {
--primary: #0078ff;
--muted: #666;
--card-bg: #fff;
--page-bg: #f4f4f4;
}
body {
font-family: Arial, Helvetica, sans-serif;
background: var(--page-bg);
margin: 0;
padding: 20px;
color: #222;
line-height: 1.5;
}
h1 {
text-align: center;
margin: 8px 0 20px;
}
.container {
max-width: 980px;
margin: 0 auto;
}
.card {
background: var(--card-bg);
border-radius: 10px;
padding: 18px;
margin: 18px 0;
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
/* Social */
.social-section {
text-align: center;
}
.social-title {
font-size: 20px;
font-weight: 700;
margin-bottom: 12px;
}
.social-icons {
display: flex;
justify-content: center;
gap: 18px;
flex-wrap: wrap;
align-items: center;
}
.social-icons a {
text-decoration: none;
color: #111;
display: flex;
flex-direction: column;
align-items: center;
font-size: 13px;
transition: transform .15s ease, color .15s ease;
}
.social-icons a:hover {
transform: translateY(-4px);
color: var(--primary);
}
.social-icons img {
width: 40px;
height: 40px;
margin-bottom: 6px;
}
/* small UI */
.controls {
display: flex;
gap: 10px;
align-items: center;
flex-wrap: wrap;
}
input[type="number"],
input[type="text"],
select {
padding: 8px 10px;
border-radius: 6px;
border: 1px solid #dcdcdc;
width: 150px;
}
button {
padding: 8px 14px;
border-radius: 8px;
border: none;
background: var(--primary);
color: #fff;
cursor: pointer;
}
button.secondary {
background: #5a5a5a;
}
pre.output {
background: #fafafa;
border: 1px solid #e6e6e6;
padding: 12px;
border-radius: 6px;
white-space: pre-wrap;
max-height: 240px;
overflow: auto;
font-family: monospace;
font-size: 13px;
}
/* Events demo box */
.box {
width: 240px;
height: 84px;
border-radius: 8px;
background: #eee;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 8px;
user-select: none;
}
.small {
font-size: 13px;
color: var(--muted);
}
.muted {
color: var(--muted);
}
/* layout helpers */
.row {
display: flex;
gap: 16px;
align-items: flex-start;
flex-wrap: wrap;
}
.col {
flex: 1;
min-width: 260px;
}
</style>
</head>
<body>
<div class="container">
<h1>JavaScript Loops & Events – Full Demo</h1>
<!-- ⭐ SOCIAL MEDIA LINKS -->
<div class="card social-section">
<div class="social-title">Follow Us on Social Media</div>
<div class="social-icons">
<a href="http://einzigartige.in/" target="_blank" rel="noopener">
<img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/internetarchive.svg" alt="Website">
Website
</a>
<a href="https://www.youtube.com/@einzigartige_/" target="_blank" rel="noopener">
<img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/youtube.svg" alt="YouTube">
YouTube
</a>
<a href="https://www.linkedin.com/company/einzigartige/" target="_blank" rel="noopener">
<img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/linkedin.svg" alt="LinkedIn">
LinkedIn
</a>
<a href="https://www.facebook.com/einzigartige" target="_blank" rel="noopener">
<img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/facebook.svg" alt="Facebook">
Facebook
</a>
<a href="https://www.instagram.com/einzigartige.it/" target="_blank" rel="noopener">
<img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/instagram.svg" alt="Instagram">
Instagram
</a>
<a href="https://twitter.com/einzigartigetec" target="_blank" rel="noopener">
<img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/x.svg" alt="Twitter">
Twitter
</a>
<a href="https://einzigartige.medium.com/" target="_blank" rel="noopener">
<img src="https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/medium.svg" alt="Medium">
Medium
</a>
</div>
</div>
<!-- ROW: DO-WHILE + Loop Demos -->
<div class="row">
<div class="col card">
<h2>Do / While Loop - Step-by-Step</h2>
<p class="small">A <code>do...while</code> loop executes the body at least once, then evaluates the
condition. Use controls to step or auto-run.</p>
<div class="controls" style="margin:8px 0 6px;">
<label class="small muted">Start:
<input id="dwStart" type="number" value="1">
</label>
<label class="small muted">Limit (<code>i <= limit</code>):
<input id="dwLimit" type="number" value="5">
</label>
<label class="small muted">Increment:
<input id="dwInc" type="number" value="1">
</label>
<button id="dwStepBtn">Step</button>
<button id="dwRunBtn">Run</button>
<button id="dwResetBtn" class="secondary">Reset</button>
<button id="dwClearBtn" class="secondary">Clear</button>
</div>
<pre id="dwOutput" class="output" aria-live="polite"></pre>
<p class="small muted">Output shows: variable before body, body action, variable after body, condition
result.</p>
</div>
<div class="col card">
<h2>Loop Quick Demos</h2>
<div style="display:flex; gap:10px; flex-wrap:wrap; margin-bottom:10px;">
<button onclick="runDoWhileDemo()">Run Simple do...while</button>
<button onclick="runWhile()">Run while</button>
<button onclick="runFor()">Run for</button>
<button onclick="runForIn()">Run for...in</button>
<button onclick="runForOf()">Run for...of</button>
</div>
<pre id="loopsOutput" class="output"></pre>
<p class="small muted">The "Quick Demos" run small examples and append to the output area.</p>
</div>
</div>
<footer style="text-align:center; color:var(--muted); font-size:13px; margin:18px 0 0;">
Built for demo • Supports loops & events • Copy / reuse freely
<br><br>
© Copyright 2019 - <span id="year"></span>
<a href="https://einzigartige.in/" target="_blank" style="color:inherit; text-decoration:none;">
Einzigartige - Web & App Development
</a>
| All Rights Reserved.
</footer>
</div>
<script>
document.getElementById("year").textContent = new Date().getFullYear();
</script>
<script>
/* =========================
DO / WHILE — Step-by-step logic
(interactive UI)
========================= */
(function () {
const startInput = document.getElementById('dwStart');
const limitInput = document.getElementById('dwLimit');
const incInput = document.getElementById('dwInc');
const out = document.getElementById('dwOutput');
const stepBtn = document.getElementById('dwStepBtn');
const runBtn = document.getElementById('dwRunBtn');
const resetBtn = document.getElementById('dwResetBtn');
const clearBtn = document.getElementById('dwClearBtn');
let state = {
i: 1,
limit: 5,
inc: 1,
stepCount: 0,
running: false,
autoInterval: null,
initialized: false
};
function initState() {
const s = parseInt(startInput.value, 10);
const l = parseInt(limitInput.value, 10);
const inc = parseInt(incInput.value, 10);
state.i = Number.isFinite(s) ? s : 1;
state.limit = Number.isFinite(l) ? l : 5;
state.inc = (Number.isFinite(inc) && inc !== 0) ? inc : 1;
state.stepCount = 0;
state.running = false;
state.initialized = true;
}
function appendLine(line) {
out.textContent += line + '\n';
out.scrollTop = out.scrollHeight;
}
function resetOutput() {
out.textContent = '';
appendLine('do {');
appendLine(' // body executes at least once');
appendLine('} while (i <= limit);');
appendLine('-----------------------------');
appendLine(`Initial values -> i: ${state.i}, limit: ${state.limit}, inc: ${state.inc}`);
appendLine('-----------------------------');
}
function stepOnce() {
if (!state.initialized) initState();
const before = state.i;
appendLine(`Step ${state.stepCount + 1}:`);
appendLine(` before body -> i = ${before}`);
// Body action (demo)
appendLine(` body: console.log("Processing i =", ${before})`);
// Apply body effect: increment
state.i = state.i + state.inc;
appendLine(` after body -> i = ${state.i}`);
// Evaluate condition after body (JS semantics)
const condEval = (state.i <= state.limit);
appendLine(` condition -> (i <= limit) => (${state.i} <= ${state.limit}) is ${condEval}`);
appendLine(` loop ${condEval ? 'will continue' : 'will stop'}`);
appendLine('-----------------------------');
state.stepCount += 1;
return condEval;
}
stepBtn.addEventListener('click', function () {
if (state.running) return;
if (!state.initialized) initState();
const shouldContinue = stepOnce();
if (!shouldContinue) appendLine('Loop finished (manual).');
});
runBtn.addEventListener('click', function () {
if (state.running) {
// stop
state.running = false;
if (state.autoInterval) {
clearInterval(state.autoInterval);
state.autoInterval = null;
appendLine('Auto-run stopped by user.');
}
runBtn.textContent = 'Run';
return;
}
if (!state.initialized) initState();
resetOutput();
state.running = true;
runBtn.textContent = 'Stop';
function runStep() {
const cont = stepOnce();
if (!cont || !state.running) {
state.running = false;
if (state.autoInterval) {
clearInterval(state.autoInterval);
state.autoInterval = null;
}
appendLine('Auto-run finished.');
runBtn.textContent = 'Run';
}
}
// run first step immediately
runStep();
if (state.running) {
state.autoInterval = setInterval(runStep, 600);
}
});
resetBtn.addEventListener('click', function () {
if (state.autoInterval) {
clearInterval(state.autoInterval);
state.autoInterval = null;
}
state.running = false;
state.initialized = false;
initState();
resetOutput();
appendLine('State reset. Click Step or Run to start again.');
runBtn.textContent = 'Run';
});
clearBtn.addEventListener('click', function () {
out.textContent = '';
});
// initialize display
initState();
resetOutput();
})();
/* =========================
Quick loop demos appended to loopsOutput
========================= */
function appendToLoopsOutput(text, clear = false) {
const out = document.getElementById('loopsOutput');
if (clear) out.textContent = '';
out.textContent += text + '\n';
out.scrollTop = out.scrollHeight;
}
function runDoWhileDemo() {
let i = 1;
let result = 'Simple do...while demo:\n';
do {
result += ` do iteration i = ${i}\n`;
i++;
} while (i <= 3);
appendToLoopsOutput(result);
}
function runWhile() {
let i = 1;
let result = 'While loop demo:\n';
while (i <= 5) {
result += ` while i = ${i}\n`;
i++;
}
appendToLoopsOutput(result);
}
function runFor() {
let result = 'For loop demo:\n';
for (let i = 1; i <= 5; i++) {
result += ` for i = ${i}\n`;
}
appendToLoopsOutput(result);
}
function runForIn() {
const person = { name: "Harry", age: 25, city: "Ahmedabad" };
let result = 'For...in (object) demo:\n';
for (let key in person) {
result += ` ${key}: ${person[key]}\n`;
}
appendToLoopsOutput(result);
}
function runForOf() {
const animals = ["Cat", "Dog", "Lion", "Tiger"];
let result = 'For...of (array) demo:\n';
for (let animal of animals) {
result += ` ${animal}\n`;
}
appendToLoopsOutput(result);
}
</script>
</body>
</html>