class Toolbar {
constructor(containerClass = 'toolbar') {
this.$container = $('
').addClass(containerClass);
this.clientMapping = [
{ label: 'Client A', value: 'clienta' },
{ label: 'Client B', value: 'clientb' },
{ label: 'Client C', value: 'clientc' }
];
this.injectStylesheet('assets/css/toolbar.css');
this.render();
this.activateExistingClient();
}
injectStylesheet(href) {
const $link = $('', { rel: 'stylesheet', href });
$('head').append($link);
}
setCookieValue(name, value, maxAgeSeconds = 86400) {
document.cookie = `${name}=${encodeURIComponent(value)}; path=/; max-age=${maxAgeSeconds}; SameSite=Lax`;
}
markActiveButton($button) {
this.$container.find('button').removeClass('active');
if ($button && $button.length) $button.addClass('active');
}
render() {
this.clientMapping.forEach(mapping => {
const $button = $('