Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2-ui/1-document/07-modifying-document/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ Så hvis vi har brug for at tilføje en masse tekst til HTML dynamisk, OG vi er

Alle disse metoder returnerer `node`.

- Givet nogle HTML i `html`, indsætter `elem.insertAdjacentHTML(where, html)` det afhængigt af værdien af `where`:
- Givet noget HTML i `html`, indsætter `elem.insertAdjacentHTML(where, html)` det afhængigt af værdien af `where`:
- `"beforebegin"` -- indsætter `html` lige før `elem`,
- `"afterbegin"` -- indsætter `html` inde i `elem`, i begyndelsen,
- `"beforeend"` -- indsætter `html` inde i `elem`, i slutningen,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
<!DOCTYPE HTML>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="index.css">
</head>
<head>
<link rel="stylesheet" href="index.css" />
</head>

<body>
<body>
<h2>Notifikationen er til højre</h2>

<h2>Notification is on the right</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorum aspernatur quam ex eaque inventore quod voluptatem adipisci omnis nemo nulla fugit iste numquam ducimus cumque minima porro ea quidem maxime necessitatibus beatae labore soluta voluptatum magnam consequatur sit laboriosam velit excepturi laborum sequi eos placeat et quia deleniti? Corrupti velit impedit autem et obcaecati fuga debitis nemo ratione iste veniam amet dicta hic ipsam unde cupiditate incidunt aut iure ipsum officiis soluta temporibus. Tempore dicta ullam delectus numquam consectetur quisquam explicabo culpa excepturi placeat quo sequi molestias reprehenderit hic at nemo cumque voluptates quidem repellendus maiores unde earum molestiae ad.</p>

<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorum aspernatur quam ex eaque inventore quod voluptatem adipisci omnis nemo nulla fugit iste numquam ducimus cumque minima porro ea quidem maxime necessitatibus beatae labore soluta voluptatum
magnam consequatur sit laboriosam velit excepturi laborum sequi eos placeat et quia deleniti? Corrupti velit impedit autem et obcaecati fuga debitis nemo ratione iste veniam amet dicta hic ipsam unde cupiditate incidunt aut iure ipsum officiis soluta
temporibus. Tempore dicta ullam delectus numquam consectetur quisquam explicabo culpa excepturi placeat quo sequi molestias reprehenderit hic at nemo cumque voluptates quidem repellendus maiores unde earum molestiae ad.
</p>
<script>
function showNotification({ top = 0, right = 0, className, html }) {
let notification = document.createElement('div');
notification.className = 'notification';
if (className) {
notification.classList.add(className);
}

<script>
function showNotification({top = 0, right = 0, className, html}) {
notification.style.top = top + 'px';
notification.style.right = right + 'px';

let notification = document.createElement('div');
notification.className = "notification";
if (className) {
notification.classList.add(className);
}

notification.style.top = top + 'px';
notification.style.right = right + 'px';

notification.innerHTML = html;
document.body.append(notification);

setTimeout(() => notification.remove(), 1500);
}

// test it
let i = 1;
setInterval(() => {
showNotification({
top: 10,
right: 10,
html: 'Hello ' + i++,
className: "welcome"
});
}, 2000);
</script>
notification.innerHTML = html;
document.body.append(notification);

setTimeout(() => notification.remove(), 1500);
}

</body>
// test it
let i = 1;
setInterval(() => {
showNotification({
top: 10,
right: 10,
html: 'Hejsa! ' + i++,
className: 'welcome',
});
}, 2000);
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<body>

<h2>Notification is on the right</h2>
<h2>Notifikationen er til højre</h2>

<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorum aspernatur quam ex eaque inventore quod voluptatem adipisci omnis nemo nulla fugit iste numquam ducimus cumque minima porro ea quidem maxime necessitatibus beatae labore soluta voluptatum
Expand All @@ -16,16 +16,16 @@ <h2>Notification is on the right</h2>

<script>
function showNotification({top = 0, right = 0, className, html}) {
/* your code */
/* din kode */
}

// test it
// test det
let i = 1;
setInterval(() => {
showNotification({
top: 10,
right: 10,
html: 'Hello ' + i++,
html: 'Hejsa! ' + i++,
className: "welcome"
});
}, 2000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ importance: 5

---

# Create a notification
# Opret en notifikation

Write a function `showNotification(options)` that creates a notification: `<div class="notification">` with the given content. The notification should automatically disappear after 1.5 seconds.
Skriv en funktion `showNotification(options)` der opretter en notifikation: `<div class="notification">` med det givne indhold. Notifikationen skal automatisk forsvinde efter 1.5 sekunder.

The options are:
Mulighederne er:

```js
// shows an element with the text "Hello" near the right-top of the window
// vis et element med teksten "Hejsa!" nær det højre øverste hjørne af vinduet
showNotification({
top: 10, // 10px from the top of the window (by default 0px)
right: 10, // 10px from the right edge of the window (by default 0px)
html: "Hello!", // the HTML of notification
className: "welcome" // an additional class for the div (optional)
top: 10, // 10px fra toppen af vinduet (standard 0px)
right: 10, // 10px fra den højre side af vinduet (standard 0px)
html: "Hejsa!", // den HTML som skal vises i notifikationen
className: "welcome" // en ekstra klasse for div-elementet (valgfrit)
});
```

[demo src="solution"]


Use CSS positioning to show the element at given top/right coordinates. The source document has the necessary styles.
Brug CSS positioning til at vise elementet ved de givne top/right koordinater. Det originale dokument har de nødvendige styles.
Loading