<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="app"> </div> <script> // Model let aName; let number; let fontFamily; let fontSize; let isDarkMode = false; // view updateView() function updateView() { document.getElementById('app').innerHTML = /*HTML*/ ` <p>Hei ${aName ?? 'på deg!'}</p> Navn:<br> <input type="text" oninput="aName=this.value" value="${aName ?? ''}"/> Tall:<br> <input type="range" min="1" max="100" step="1" oninput="number=this.valueAsNumber" value ="${number ?? ''}">${number ?? ''} <br> <input type="checkbox" oninput="isDarkMode=this.checked" ${isDarkMode ? 'checked' : ''} > Dark Mode: <br> <button onclick="selectFont('helvetica')">Font A</button> <button onclick="selectFont('courier')">Font B</button> <br> <button onclick="register()">Registrer</button><br> <b>Font-størrelse</b><br> Normal <input type="radio" name="fontSize" oninput="fontSize='100%'" ${fontSize == '100%' ? 'checked' : ''} /><br> 50% <input type="radio" name="fontSize" oninput="fontSize='50%'" ${fontSize == '50%' ? 'checked' : ''} /> <br> 200% <input type="radio" name="fontSize" oninput="fontSize='200%'" ${fontSize == '200%' ? 'checked' : ''} ><br> `; let bodyStyle = document.body.style; bodyStyle.fontFamily = fontFamily ?? 'serif'; if (isDarkMode){ bodyStyle.background = 'black'; bodyStyle.color = 'white'; } else { bodyStyle.background = 'white'; bodyStyle.color = 'black'; }; bodyStyle.fontSize = fontSize; } // Controller function register() { updateView(); } function selectFont(newFontFamily){ fontFamily = newFontFamily; updateView() } </script> </body> </html>