This commit is contained in:
239
03_dom/uebungen/u08-09_newsboard/assets/css/main.css
Normal file
239
03_dom/uebungen/u08-09_newsboard/assets/css/main.css
Normal file
@@ -0,0 +1,239 @@
|
||||
* {
|
||||
margin: 0;
|
||||
}
|
||||
html {
|
||||
font-size: 100%;
|
||||
padding: 0;
|
||||
background-attachment: fixed;
|
||||
background-image: -webkit-linear-gradient(top, #eef0f2, #d3d5d9);
|
||||
background-image: -moz-linear-gradient(top, #eef0f2, #d3d5d9);
|
||||
background-image: linear-gradient(to bottom, #eef0f2, #d3d5d9);
|
||||
}
|
||||
body {
|
||||
color: #333;
|
||||
font-size: 1em;
|
||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
text-align: left;
|
||||
margin: 1em;
|
||||
padding: 0;
|
||||
}
|
||||
p,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
p {
|
||||
line-height: 1.5em;
|
||||
-webkit-hyphens: auto;
|
||||
-moz-hyphens: auto;
|
||||
hyphens: auto;
|
||||
}
|
||||
p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
a {
|
||||
color: #2f83e8;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
strong,
|
||||
b {
|
||||
font-weight: bold;
|
||||
}
|
||||
em,
|
||||
i {
|
||||
font-style: italic;
|
||||
}
|
||||
.float_left {
|
||||
float: left;
|
||||
}
|
||||
.float_right {
|
||||
float: right;
|
||||
}
|
||||
.disabled {
|
||||
opacity: 0.4;
|
||||
cursor: default;
|
||||
}
|
||||
.message_number {
|
||||
color: #fff;
|
||||
font-size: 0.8em;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
line-height: 1em;
|
||||
position: absolute;
|
||||
top: -0.5em;
|
||||
left: -0.5em;
|
||||
display: block;
|
||||
padding-top: 0.3em;
|
||||
min-width: 2em;
|
||||
height: 2em;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
cursor: default;
|
||||
background-color: #ea2314;
|
||||
background-image: -webkit-linear-gradient(top, #f78f91, #c50404);
|
||||
background-image: -moz-linear-gradient(top, #f78f91, #c50404);
|
||||
background-image: linear-gradient(to bottom, #f78f91, #c50404);
|
||||
border: 2px solid #fff;
|
||||
-webkit-border-radius: 1em;
|
||||
-moz-border-radius: 1em;
|
||||
border-radius: 1em;
|
||||
-webkit-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
|
||||
-moz-box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
|
||||
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.newsboard_wrapper {
|
||||
margin: 0 auto 2em auto;
|
||||
padding: 13px 0 0 17px;
|
||||
max-width: 550px;
|
||||
position: relative;
|
||||
background: url('../img/sheets.png') no-repeat;
|
||||
}
|
||||
.newsboard_wrapper:before {
|
||||
content: url('../img/paperclip.png');
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 35px;
|
||||
z-index: 1;
|
||||
}
|
||||
.newsboard_wrapper .newsboard {
|
||||
padding: 29px 1.25rem 4rem 1.25rem;
|
||||
min-height: 20em;
|
||||
position: relative;
|
||||
border: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
background-image: -webkit-linear-gradient(#dddddd, #ffffff 1px);
|
||||
background-image: -moz-linear-gradient(#dddddd, #ffffff 1px);
|
||||
background-image: linear-gradient(#dddddd, #ffffff 1px);
|
||||
background-position: 0 1.3em;
|
||||
-webkit-background-size: 100% 1.5em;
|
||||
-moz-background-size: 100% 1.5em;
|
||||
background-size: 100% 1.5em;
|
||||
-webkit-box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.3);
|
||||
-moz-box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.3);
|
||||
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.newsboard_wrapper .newsboard .close_button {
|
||||
color: #777;
|
||||
font-size: 1.2em;
|
||||
text-decoration: none;
|
||||
line-height: 1em;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 14px;
|
||||
display: block;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .close_button:hover {
|
||||
color: #444;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .newsboard_footer {
|
||||
color: #999;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar {
|
||||
font-size: 1.8em;
|
||||
padding: 0 1.25rem;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 1rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar .float_left a,
|
||||
.newsboard_wrapper .newsboard .paging_bar .float_right a {
|
||||
color: #777;
|
||||
text-decoration: none;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar .float_left a {
|
||||
margin-right: 0.3em;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar .float_right a {
|
||||
margin-left: 0.3em;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar .progressbar {
|
||||
display: block;
|
||||
width: 40%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar progress {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
vertical-align: 0;
|
||||
line-height: normal;
|
||||
color: #2f83e8;
|
||||
width: 100%;
|
||||
height: 0.6rem;
|
||||
border-style: none;
|
||||
padding: 0;
|
||||
background-color: #eee;
|
||||
-webkit-border-radius: 0.3rem;
|
||||
-moz-border-radius: 0.3rem;
|
||||
border-radius: 0.3rem;
|
||||
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
|
||||
-moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
|
||||
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar progress::-webkit-progress-bar {
|
||||
padding: 0;
|
||||
border-style: none;
|
||||
background-color: transparent;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar progress::-webkit-progress-value {
|
||||
-webkit-border-radius: 0.3rem;
|
||||
border-radius: 0.3rem;
|
||||
background-color: #2f83e8;
|
||||
background-image: -webkit-linear-gradient(top, #8bbaf2, #176acd);
|
||||
background-image: linear-gradient(to bottom, #8bbaf2, #176acd);
|
||||
}
|
||||
.newsboard_wrapper .newsboard .paging_bar progress::-moz-progress-bar {
|
||||
-moz-border-radius: 0.3rem;
|
||||
border-radius: 0.3rem;
|
||||
background-color: #2f83e8;
|
||||
background-image: -moz-linear-gradient(top, #8bbaf2, #176acd);
|
||||
background-image: linear-gradient(to bottom, #8bbaf2, #176acd);
|
||||
}
|
||||
.newsboard_wrapper .newsboard .newsboard_content h1,
|
||||
.newsboard_wrapper .newsboard .newsboard_content h2 {
|
||||
font-weight: normal;
|
||||
font-family:
|
||||
'Helvetica Neue Light', 'HelveticaNeue-Light', 'Helvetica Light', 'Helvetica-Light', Helvetica, Arial, sans-serif;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .newsboard_content h1 {
|
||||
font-size: 1.75em;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .newsboard_content h2 {
|
||||
color: #2f83e8;
|
||||
font-size: 1.2em;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .newsboard_content:empty {
|
||||
color: #999;
|
||||
font-size: 1.15em;
|
||||
text-align: center;
|
||||
padding-top: 10.5rem;
|
||||
background: url('../img/empty.png') no-repeat center 3.75rem;
|
||||
}
|
||||
.newsboard_wrapper .newsboard .newsboard_content:empty:after {
|
||||
content: 'Keine neuen Mitteilungen.';
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
padding: 0 !important;
|
||||
margin: -1px !important;
|
||||
overflow: hidden !important;
|
||||
clip: rect(0, 0, 0, 0) !important;
|
||||
white-space: nowrap !important;
|
||||
border: 0 !important;
|
||||
display: inline-block !important;
|
||||
}
|
||||
BIN
03_dom/uebungen/u08-09_newsboard/assets/img/empty.png
Normal file
BIN
03_dom/uebungen/u08-09_newsboard/assets/img/empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
BIN
03_dom/uebungen/u08-09_newsboard/assets/img/paperclip.png
Normal file
BIN
03_dom/uebungen/u08-09_newsboard/assets/img/paperclip.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
03_dom/uebungen/u08-09_newsboard/assets/img/sheets.png
Normal file
BIN
03_dom/uebungen/u08-09_newsboard/assets/img/sheets.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.5 KiB |
73
03_dom/uebungen/u08-09_newsboard/assets/js/main.js
Normal file
73
03_dom/uebungen/u08-09_newsboard/assets/js/main.js
Normal file
@@ -0,0 +1,73 @@
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
// === DOM & VARS =======
|
||||
const module = document.querySelector('.newsboard') || console.error('newsboard not found');
|
||||
const DOM = {
|
||||
messageNumber: module.querySelector('.message_number'),
|
||||
newsboardContent: module.querySelector('.newsboard_content'),
|
||||
buttonNext: module.querySelector('.button-next'),
|
||||
buttonLast: module.querySelector('.button-last'),
|
||||
buttonPrev: module.querySelector('.button-prev'),
|
||||
buttonFirst: module.querySelector('.button-first'),
|
||||
progressBar: module.querySelector('.progressbar progress'),
|
||||
};
|
||||
|
||||
console.log(DOM);
|
||||
|
||||
// === INIT =============
|
||||
const init = () => {
|
||||
// Funktionaufrufe zu beginn der Anwendung
|
||||
showMessageByNumber(1);
|
||||
initProgressbar();
|
||||
|
||||
// Eventlauscher zu beginn der Anwendung
|
||||
DOM.buttonNext.addEventListener('click', onClickNext);
|
||||
DOM.buttonPrev.addEventListener('click', onClickPrev);
|
||||
window.addEventListener('keyup', onKeyUp);
|
||||
};
|
||||
|
||||
// === EVENTHANDLER =====
|
||||
const onKeyUp = (e) => {
|
||||
// Übung 8.3 && 8.4 Tastatursteuerung
|
||||
};
|
||||
|
||||
const onClickNext = (e) => {
|
||||
showMessageByNumber((DOM.progressBar.value += 1));
|
||||
};
|
||||
const onClickPrev = (e) => {
|
||||
showMessageByNumber((DOM.progressBar.value -= 1));
|
||||
};
|
||||
// === XHR/FETCH ========
|
||||
|
||||
// === FUNCTIONS ========
|
||||
const showMessageByNumber = (n) => {
|
||||
DOM.newsboardContent.innerHTML = MESSAGES[n - 1];
|
||||
};
|
||||
|
||||
const initProgressbar = () => {
|
||||
DOM.progressBar.max = MESSAGES.length;
|
||||
DOM.progressBar.value = 1;
|
||||
};
|
||||
|
||||
init();
|
||||
})();
|
||||
|
||||
// Übung 8: Newsboard: Das geht noch besser
|
||||
// Das Newsboard wartet noch auf das Vervollständigen seiner Funktionen.
|
||||
|
||||
// 1. Belege die Links » und « mit Funktionalität. Der Link mit der Aufschrift « soll es erlauben, zur ersten Nachricht zu springen, der Link » zur letzten.
|
||||
|
||||
// 2. Der bisher eher sinnlose rote Kreis in der linken oberen Ecke soll nun die Gesamtanzahl der Nachrichten anzeigen. Schreibe eine Funktion, die diese Anzahl ausliest und in das <span> mit der Klasse message_number einträgt.
|
||||
|
||||
// 3. Unterstütze ab sofort das Navigieren durch die News mit der Tastatur. Die Pfeiltasten nach links und rechts sollen dabei jeweils die gleiche Funktionalität wie die Buttons < und > ermöglichen.
|
||||
|
||||
// 4. Auch das Springen auf die erste bzw. letzte Position soll nun mit Tastatur möglich sein. Die Tastenkombination dafür ist alt und die Pfeiltaste nach links (zur ersten Nachricht) bzw. rechts (zur letzten Nachricht).
|
||||
|
||||
// Übung 9: Newsboard: Jetzt ist aber Schluss!
|
||||
|
||||
// Die neuen Features des Newsboards sind schon fast fertig. Problematisch ist aber, dass die Vorwärts- und Rückwärts-Buttons auch aktiv sind, wenn es keine vorige bzw. nächste Nachricht mehr gibt. Dies führt zu einem sehr unschönen Fehler.
|
||||
|
||||
// 2. Sorge dafür, dass die Vor- und Rückwärts-Buttons jeweils deaktiviert werden, sobald der Anwender am Anfang bzw. Ende der Nachrichtenliste angekommen ist.
|
||||
|
||||
// 3. Auch die Buttons, die den Anwender zur ersten bzw. zur letzten Nachricht führen, sollen deaktiviert sein, sobald sich der Anwender bei der ersten bzw. letzten Nachricht befindet.
|
||||
19
03_dom/uebungen/u08-09_newsboard/assets/js/messages.js
Normal file
19
03_dom/uebungen/u08-09_newsboard/assets/js/messages.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// Konfigurationsvariablen
|
||||
|
||||
const MESSAGES = [
|
||||
`<h1>Tutors are on a strike!!!</h1>
|
||||
<h2>All assignmnent are automatically graded with 0 points</h2>
|
||||
<p>Duis pretium ornare odio nec cursus. Nulla quis dolor vitae nulla condimentum maximus nec vitae purus. Curabitur ut mi non nulla molestie porta. Curabitur dignissim lacinia condimentum. In hac habitasse platea dictumst. Mauris ut urna magna. Mauris venenatis eu quam nec posuere. Nulla facilisi. Donec convallis sodales massa, et consequat nunc vehicula malesuada.</p>
|
||||
<p class="newsboard_footer">9/25/2015 by N. O'body</p>`,
|
||||
|
||||
`<h1>Madness!</h1>
|
||||
<h2>How to earn a fortune, with a complete stupid idea</h2>
|
||||
<p>Ut molestie elementum risus, eget rutrum dui tristique id. Duis ac elit a mi convallis lacinia. Sed at ultricies magna. Pellentesque nisl est, mattis eget porta eu, rhoncus in urna. Integer faucibus lectus nec malesuada tempus. Duis consectetur sollicitudin ultricies. Cras massa nulla, aliquet vitae interdum quis, venenatis at quam.</p>
|
||||
<p class="newsboard_footer">08/13/2019 by Dr. Ken Hurt</p>`,
|
||||
|
||||
`<h1>I did something, and you will never guess what happened next...</h1>
|
||||
<h2>Donec tristique, leo at suscipit pellentesque, mauris neque congue leo!</h2>
|
||||
<p>Aenean egestas mauris at neque egestas hendrerit id ut erat. Donec iaculis ornare gravida. Vestibulum condimentum, tortor nec eleifend consectetur, justo lacus dignissim ante, eget commodo enim urna sollicitudin arcu. Odio eu leo pulvinar rutrum sed a turpis. Nunc dui tortor, rutrum vitae gravida quis, hendrerit a massa. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas</p>
|
||||
<p>Integer non venenatis tellus. Phasellus tellus leo, suscipit ac vulputate non, varius nec eros. Etiam scelerisque nisi arcu, interdum tempus dui volutpat vel. Donec eget posuere nulla. Etiam ornare dapibus tortor, ac sollicitudin nisi porta a. Donec tristique, leo at suscipit pellentesque, mauris neque congue leo, sed tempor massa justo a ligula. Curabitur vitae rhoncus lacus, quis varius felis. Ut tincidunt sit amet nisl finibus tempus. Curabitur mollis sit amet leo a sagittis.</p>
|
||||
<p class="newsboard_footer">2015/06/02 by Chris P. Bacon</p>`,
|
||||
];
|
||||
54
03_dom/uebungen/u08-09_newsboard/index.html
Normal file
54
03_dom/uebungen/u08-09_newsboard/index.html
Normal file
@@ -0,0 +1,54 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<title>Newsboard</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="assets/css/main.css" />
|
||||
<script src="assets/js/messages.js"></script>
|
||||
<script src="assets/js/main.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="newsboard_wrapper">
|
||||
<div class="newsboard">
|
||||
<span class="message_number">X</span>
|
||||
|
||||
<a href="#" class="close_button" title="Delete message">×</a>
|
||||
|
||||
<div class="newsboard_content"></div>
|
||||
|
||||
<div class="paging_bar">
|
||||
<span class="float_left">
|
||||
<button class="button-first" title="first" aria-label="First News">
|
||||
<i class="fa-solid fa-angles-left"></i>
|
||||
<span class="sr-only">First News</span>
|
||||
</button>
|
||||
<button class="button-prev" title="prev" aria-label="Previous News">
|
||||
<i class="fa-solid fa-angle-left"></i>
|
||||
<span class="sr-only">Previous News</span>
|
||||
</button>
|
||||
</span>
|
||||
|
||||
<span class="float_right">
|
||||
<button class="button-next" title="next" aria-label="Next News">
|
||||
<i class="fa-solid fa-angle-right"></i>
|
||||
<span class="sr-only">Next News</span>
|
||||
</button>
|
||||
<button class="button-last" title="last" aria-label="Last News">
|
||||
<i class="fa-solid fa-angles-right"></i>
|
||||
<span class="sr-only">Last News</span>
|
||||
</button>
|
||||
</span>
|
||||
|
||||
<span class="progressbar">
|
||||
<progress max="" value="" id="messages_progress"></progress>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
4
03_dom/uebungen/u10_running-lights/assets/css/main.css
Normal file
4
03_dom/uebungen/u10_running-lights/assets/css/main.css
Normal file
@@ -0,0 +1,4 @@
|
||||
.light-bulbs{
|
||||
padding: 1rem;
|
||||
border: 2px solid #555;
|
||||
}
|
||||
BIN
03_dom/uebungen/u10_running-lights/assets/img/light_off.png
Normal file
BIN
03_dom/uebungen/u10_running-lights/assets/img/light_off.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.0 KiB |
BIN
03_dom/uebungen/u10_running-lights/assets/img/light_on.png
Normal file
BIN
03_dom/uebungen/u10_running-lights/assets/img/light_on.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
92
03_dom/uebungen/u10_running-lights/assets/js/libs/helpers.js
Normal file
92
03_dom/uebungen/u10_running-lights/assets/js/libs/helpers.js
Normal file
@@ -0,0 +1,92 @@
|
||||
// Helper DOM Selektion mit $ & $$
|
||||
const $ = (qs) => document.querySelector(qs);
|
||||
const $$ = (qs) => Array.from(document.querySelectorAll(qs));
|
||||
|
||||
Node.prototype.on = function(name, fn) {
|
||||
this.addEventListener(name, fn);
|
||||
return this;
|
||||
};
|
||||
|
||||
// // anstatt
|
||||
// document.querySelector('button').addEventListener('click', (event) => { });
|
||||
// // wird zu:
|
||||
// document.querySelector('button').on('click', (event) => { });
|
||||
|
||||
Array.prototype.on = Array.prototype.addEventListener = function(name, fn) {
|
||||
this.forEach((elem) => elem.on(name, fn));
|
||||
return this;
|
||||
};
|
||||
|
||||
// anstatt
|
||||
// Array.from(document.querySelectorAll('.menu-main li a')).forEach((elem) =>
|
||||
// elem.addEventListener('click', (event) => {
|
||||
// console.log(event);
|
||||
// })
|
||||
// );
|
||||
// // wird zu
|
||||
// Array.from(document.querySelectorAll('.menu-main li a')).on(
|
||||
// 'click',
|
||||
// (event) => {
|
||||
// console.log(event);
|
||||
// }
|
||||
// );
|
||||
|
||||
|
||||
|
||||
// helper
|
||||
const $on = (el, ev, fn) => {
|
||||
Array.isArray(el) ? el.forEach(ae => $on(ae, ev, fn)) :
|
||||
el.addEventListener(ev, fn);
|
||||
return el;
|
||||
};
|
||||
|
||||
// times - funktion
|
||||
function times(n, fn) {
|
||||
const result = Array(n);
|
||||
for (let i = 0; i < n; i++) {
|
||||
result[i] = fn(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// oder von lodash
|
||||
function baseTimes(n, iteratee) {
|
||||
var index = -1,
|
||||
result = Array(n);
|
||||
|
||||
while (++index < n) {
|
||||
result[index] = iteratee(index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* range(zahl bis wohin array befüllt werden soll) : array
|
||||
* - array von 0 bis
|
||||
parameterzahl (nicht inklusive)
|
||||
*
|
||||
* range(anfangswert, endwert) : array
|
||||
* - array von anfangswert bis endwert (nicht inklusive)
|
||||
*
|
||||
* range(nfangswert, endwert, übersprungswert) : : array
|
||||
* - array von anfangswert bis endwert (nicht inklusive), zwischenwerte durch übersprungswert entfallen
|
||||
*/
|
||||
function rangeFromStartToEnd(start, end, step = 1) {
|
||||
const length = Math.max(Math.ceil((end - start) / step), 0);
|
||||
const result = new Array(length);
|
||||
const sign = step / Math.abs(step);
|
||||
|
||||
let index = 0;
|
||||
for (let value = start; value * sign < end * sign; value += step) {
|
||||
result[index++] = value;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
function range(startOrEnd, end, step) {
|
||||
if (end) {
|
||||
return rangeFromStartToEnd(startOrEnd, end, step);
|
||||
} else {
|
||||
return rangeFromStartToEnd(0, startOrEnd);
|
||||
}
|
||||
};
|
||||
2
03_dom/uebungen/u10_running-lights/assets/js/libs/jquery.min.js
vendored
Normal file
2
03_dom/uebungen/u10_running-lights/assets/js/libs/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
20
03_dom/uebungen/u10_running-lights/assets/js/main.js
Normal file
20
03_dom/uebungen/u10_running-lights/assets/js/main.js
Normal file
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
(() => {
|
||||
// === DOM & VARS =======
|
||||
const DOM = {};
|
||||
|
||||
const LIGHT_PATH_ON = 'assets/img/light_on.png';
|
||||
const LIGHT_PATH_OFF = 'assets/img/light_off.png';
|
||||
|
||||
// === INIT =============
|
||||
const init = () => {};
|
||||
|
||||
// === EVENTHANDLER =====
|
||||
|
||||
// === XHR/FETCH ========
|
||||
|
||||
// === FUNCTIONS ========
|
||||
|
||||
init();
|
||||
})();
|
||||
41
03_dom/uebungen/u10_running-lights/index.html
Normal file
41
03_dom/uebungen/u10_running-lights/index.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Übung 10 - Chasing Lights</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link rel="stylesheet" href="assets/css/main.css" />
|
||||
<script src="assets/js/main.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container py-5">
|
||||
<div class="alert alert-primary">
|
||||
<h2>Übung 10 - Chasing Lights</h2>
|
||||
|
||||
<p>
|
||||
Eine erste Variante sind die chasing Lights. Dabei muss der Anwender das Lauflicht mit der Maus »jagen«. Immer
|
||||
wenn der Mauszeiger sich über einer Glühbirne befindet, schaltet sich die nächste Birne ein und die aktuelle
|
||||
aus. Versucht der Benutzer, mit dem Mauszeiger die leuchtende Glühbirne zu berühren, springt das Licht auf die
|
||||
nächste über. Er »jagt« quasi das Lauflicht. Bei der letzten Lampe beginnt das Spiel wieder von vorn!
|
||||
</p>
|
||||
<p>
|
||||
Programmiere ein weiteres Lauflicht. Diesmal soll das Lauflicht weiterspringen, wenn der Benutzer auf eine der
|
||||
Lampen klickt. Auch hier gilt: Nach der letzten Lampe fängt das Licht wieder von vorn an zu laufen.
|
||||
</p>
|
||||
</div>
|
||||
<div class="light-bulbs">
|
||||
<img src="assets/img/light_on.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_off.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_off.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_off.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_off.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_off.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_on.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_off.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_off.png" alt="lightbulb" />
|
||||
<img src="assets/img/light_off.png" alt="lightbulb" />
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
BIN
03_dom/uebungen/uebungen-8-10.zip
Normal file
BIN
03_dom/uebungen/uebungen-8-10.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user