{"size": 785, "ext": "js", "max_stars_repo_path": "src/lesson_13/components/garland/garland.js", "max_stars_repo_name": "coptup4ik/wa_homework_pavel_lebedev", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/lesson_13/components/garland/garland.js", "max_issues_repo_name": "coptup4ik/wa_homework_pavel_lebedev", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/lesson_13/components/garland/garland.js", "max_forks_repo_name": "coptup4ik/wa_homework_pavel_lebedev", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.4, "max_line_length": 72, "alphanum_fraction": 0.5388535032}
export class Garland {
    constructor(targetElement, bulbs){
        this.targetEl = targetElement;
        this.bulbs = bulbs;
        // this.lampsOutput = document.querySelector('.garland__lamps')
        this.control = targetElement.querySelector('.garland__control');
        this.control.addEventListener('click', () => this.toggleAll())

    }
    toggleAll() {
        const enabledElements = this.bulbs.filter((bulb) => {
            return bulb.isEnabled === true;
        });
        console.log(enabledElements);
        if (enabledElements.length > 0 ) {
            this.bulbs.forEach((bulb) => {
                bulb.switchOff();
            })
        }else {
            this.bulbs.forEach((bulb) => {
                bulb.switchOn();
            })
        }
    }
}