2024-08-26 13:59:21 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
2024-08-26 14:39:13 +02:00
|
|
|
|
2024-08-26 13:59:21 +02:00
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Intro</title>
|
|
|
|
</head>
|
2024-08-26 14:39:13 +02:00
|
|
|
|
2024-08-26 13:59:21 +02:00
|
|
|
<body>
|
2024-08-27 13:11:59 +02:00
|
|
|
<div id="app">
|
2024-08-26 13:59:21 +02:00
|
|
|
</div>
|
2024-08-27 13:11:59 +02:00
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
// Model
|
|
|
|
let firstName = "...her kommer et navn";
|
|
|
|
let place = "..her kommer et sted";
|
|
|
|
let food = "...her kommer en matrett";
|
|
|
|
// View
|
|
|
|
updateView();
|
|
|
|
function updateView() {
|
|
|
|
let html = `
|
|
|
|
<div class="group">
|
|
|
|
<div>Hei jeg heter</div>
|
|
|
|
<div id="namediv"> ${firstName}<br></div>
|
|
|
|
</div>
|
|
|
|
<div class="group">
|
|
|
|
<div>Jeg bor i</div>
|
|
|
|
<div id="placediv"> ${place}<br></div>
|
|
|
|
</div>
|
2024-08-26 13:59:21 +02:00
|
|
|
<div class="group">
|
|
|
|
<div>Min favorittmat er</div>
|
2024-08-27 13:11:59 +02:00
|
|
|
<div id="fooddiv"> ${food}<br></div>
|
2024-08-26 13:59:21 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<button onclick="setFields()">Klikk her for å sett inn verdier</button>
|
2024-08-26 14:39:13 +02:00
|
|
|
Navn: <input type="text" onchange="setName(this.value)">
|
|
|
|
Sted: <input type="text" onchange="setPlace(this.value)">
|
|
|
|
Mat: <input type="text" onchange="setFood(this.value)">
|
2024-08-27 13:11:59 +02:00
|
|
|
`;
|
|
|
|
document.getElementById('app').innerHTML = html;
|
2024-08-26 13:59:21 +02:00
|
|
|
}
|
2024-08-26 14:39:13 +02:00
|
|
|
// Controller
|
|
|
|
function setName(nameInput) {
|
|
|
|
firstName = nameInput;
|
2024-08-27 13:11:59 +02:00
|
|
|
updateView();
|
2024-08-26 14:39:13 +02:00
|
|
|
}
|
|
|
|
function setPlace(placeInput) {
|
|
|
|
place = placeInput;
|
2024-08-27 13:11:59 +02:00
|
|
|
updateView();
|
2024-08-26 14:39:13 +02:00
|
|
|
}
|
|
|
|
function setFood(foodInput) {
|
|
|
|
food = foodInput;
|
2024-08-27 13:11:59 +02:00
|
|
|
updateView();
|
2024-08-26 14:39:13 +02:00
|
|
|
}
|
2024-08-26 13:59:21 +02:00
|
|
|
</script>
|
|
|
|
<style>
|
2024-08-26 14:39:13 +02:00
|
|
|
.group {
|
2024-08-26 13:59:21 +02:00
|
|
|
display: flex;
|
2024-08-27 13:11:59 +02:00
|
|
|
padding: 3px;
|
2024-08-26 13:59:21 +02:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</body>
|
2024-08-26 14:39:13 +02:00
|
|
|
|
2024-08-26 13:59:21 +02:00
|
|
|
</html>
|