import { Controller } from '@hotwired/stimulus'; import { tmp } from '../services/theme_controller' export default class extends Controller { modes; currentState; connect() { this.modes = $(this.element).find('p'); this.currentState = localStorage.getItem('themeMode'); this.changeState() var tmp1 = new tmp(); tmp1.update(); } switch(event) { var mode = event.params.mode; this.changeState(mode); } changeState(newState) { if (typeof newState !== 'undefined') { localStorage.setItem("themeMode", newState); this.currentState = newState; } // $('html').attr('data-bs-theme', this.currentState); this.modes.filter((e,tmp)=>{ const obj = $(tmp); obj.toggle(!obj.hasClass(this.currentState)); }) } }