Question: Someone please help me fix this code. Bird images /* Two color palettes */ :root { --primary-color: rgb(255, 255, 255); --secondary-color: rgb(255, 255, 255); --bg-color:

Someone please help me fix this code.

Bird images

/* Two color palettes */

:root {

--primary-color: rgb(255, 255, 255);

--secondary-color: rgb(255, 255, 255);

--bg-color: rgb(255, 255, 255);

--font-color: rgb(0, 0, 0);

--heading-color: rgb(0, 0, 0);

}

[data-theme="dark"] {

--primary-color: rgb(0, 0, 0);

--secondary-color: rgb(0, 0, 0);

--bg-color: rgb(0, 0, 0);

--font-color: rgb(255, 255, 255);

--heading-color: rgb(255, 255, 255);

}

function updateHeading() {

// Get the value of the 'user_name' parameter from the query string

const urlParams = new URLSearchParams(window.location.search);

let userName = urlParams.get('user_name');

if (!userName) {

// If the query string does not contain the 'user_name' field, check local storage

userName = localStorage.getItem('user_name');

} else {

// If the query string contains the 'user_name' field, store it in local storage

localStorage.setItem('user_name', userName);

}

// Update the heading to say 'Hello, '

if (userName) {

document.getElementById('heading').innerHTML = `Hello, ${userName}`;

}

}

function toggleTheme() {

// Get the current value of the 'data-theme' attribute

const currentTheme = document.documentElement.getAttribute('data-theme');

// Set the value of the 'data-theme' attribute to the opposite value

if (currentTheme === 'light') {

document.documentElement.setAttribute('data-theme', 'dark');

localStorage.setItem('theme', 'dark');

} else {

document.documentElement.setAttribute('data-theme', 'light');

localStorage.setItem('theme', 'light');

}

}

window.onload = function() {

// Check if there's a theme preference stored in local storage

const theme = localStorage.getItem('theme');

if (theme === 'dark') {

document.documentElement.setAttribute('data-theme', 'dark');

}

updateHeading();

}

Header

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!