osm-commerces/assets/app.js
2025-05-28 17:05:34 +02:00

38 lines
1.2 KiB
JavaScript

/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.css';
console.log('Hello World de app.js');
function labourer() {
window.location.href = '/admin/labourer/' + document.getElementById('app_admin_labourer').value;
}
// Attendre le chargement du DOM
document.addEventListener('DOMContentLoaded', () => {
// Générer une couleur pastel aléatoire
const genererCouleurPastel = () => {
// Utiliser des valeurs plus claires (180-255) pour obtenir des tons pastel
const r = Math.floor(Math.random() * 75 + 180);
const g = Math.floor(Math.random() * 75 + 180);
const b = Math.floor(Math.random() * 75 + 180);
return `rgb(${r}, ${g}, ${b})`;
};
const randombg = genererCouleurPastel();
// Appliquer la couleur au body
document.body.style.backgroundColor = randombg;
// Appliquer le style pour .body-landing
const bodyLanding = document.querySelector('.body-landing');
if (bodyLanding) {
bodyLanding.style.backgroundColor = randombg;
}
});