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

View file

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