Added code to remember the last background color and load it on page load
This commit is contained in:
		
							parent
							
								
									9a306fcfd4
								
							
						
					
					
						commit
						3dc3ae4fb2
					
				| 
						 | 
					@ -88,6 +88,7 @@ bgColour.addEventListener("input", () => {
 | 
				
			||||||
    const G = parseInt(bgColour.value.substring(3, 5), 16);
 | 
					    const G = parseInt(bgColour.value.substring(3, 5), 16);
 | 
				
			||||||
    const B = parseInt(bgColour.value.substring(5, 7), 16);
 | 
					    const B = parseInt(bgColour.value.substring(5, 7), 16);
 | 
				
			||||||
    changeBackground(R, G, B);
 | 
					    changeBackground(R, G, B);
 | 
				
			||||||
 | 
					    localStorage.setItem("bgColour", bgColour.value);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function transitionBackground(newUrl, blackwhite) {
 | 
					function transitionBackground(newUrl, blackwhite) {
 | 
				
			||||||
| 
						 | 
					@ -202,7 +203,13 @@ function initCarousel() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// INITIALIZATION
 | 
					// INITIALIZATION
 | 
				
			||||||
 | 
					// Set background colour to last saved value
 | 
				
			||||||
transitionBackground("assets/photos/fog-8519076-nordseher.jpg", "black")
 | 
					const bgColor = document.getElementById("bgColour");
 | 
				
			||||||
 | 
					bgColor.value = localStorage.getItem("bgColour") || "#ffffff";
 | 
				
			||||||
 | 
					const initR = parseInt(bgColour.value.substring(1, 3), 16);
 | 
				
			||||||
 | 
					const initG = parseInt(bgColour.value.substring(3, 5), 16);
 | 
				
			||||||
 | 
					const initB = parseInt(bgColour.value.substring(5, 7), 16);
 | 
				
			||||||
 | 
					changeBackground(initR, initG, initB);
 | 
				
			||||||
 | 
					// Initialize carousel
 | 
				
			||||||
initCarousel();
 | 
					initCarousel();
 | 
				
			||||||
carouselExpand(1);
 | 
					carouselExpand(1);
 | 
				
			||||||
		Loading…
	
		Reference in New Issue