uke 5 start

This commit is contained in:
Geir Okkenhaug Jerstad 2024-09-02 09:06:12 +02:00
parent 3460b9ca70
commit 4c29c3222d
2 changed files with 18 additions and 19 deletions

View file

@ -1,35 +1,41 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MVC Skjemaer</title> <title>MVC Skjemaer</title>
</head> </head>
<body> <body>
<div id="app"> <div id="app">
</div> </div>
<script> <script>
// model // model
let message = null;// = 'Alt gikk bra'; let message = 'Alt gikk bra';
// view // view
updateView() updateView()
function updateView(){ function updateView() {
if (message == null){ messageBoxHtml = /*HTML*/ `<p>${message}</p>`;
} else { document.getElementById('app').innerHTML = /*HTML*/ `
document.getElementById('app').innerHTML = /*HTML*/ `
<h1>Min app</h1> <h1>Min app</h1>
${message} ${createMessageBoxHtml()}
<button>Vis sukksess</button> <button>Vis sukksess</button>
<button>Vis advarsel</button> <button>Vis advarsel</button>
<button></button> <button>Vis feil</button>
<button>1</button> <button>Vis info</button>
`; `;
}; function createMessageBoxHtml() {
if (message == null) return '';
return messageBoxHtml;
}
} }
// controller // controller
</script> </script>
</body> </body>
</html> </html>

View file

@ -19,16 +19,9 @@
let fontSize; let fontSize;
let isDarkMode = false; let isDarkMode = false;
// view // view
updateView() updateView()
function updateView() { function updateView() {
// let extraWord = '';
// if (number < 10){
// extraWord = 'ikke';
// } else {
// extraWord = '';
// }
document.getElementById('app').innerHTML = /*HTML*/ ` document.getElementById('app').innerHTML = /*HTML*/ `
<p>Hei ${aName ?? 'på deg!'}</p> <p>Hei ${aName ?? 'på deg!'}</p>
Navn:<br> Navn:<br>
@ -82,7 +75,7 @@
><br> ><br>
`; `;
let bodyStyle = document.body.style; let bodyStyle = document.body.style;
bodyStyle.fontFamily = fontFamily ?? serif; bodyStyle.fontFamily = fontFamily ?? 'serif';
if (isDarkMode){ if (isDarkMode){
bodyStyle.background = 'black'; bodyStyle.background = 'black';
bodyStyle.color = 'white'; bodyStyle.color = 'white';
@ -90,7 +83,7 @@
bodyStyle.background = 'white'; bodyStyle.background = 'white';
bodyStyle.color = 'black'; bodyStyle.color = 'black';
}; };
bodyStyle.fontSize = fontSize; bodyStyle.fontSize = fontSize;
} }