chore: initial import for test contour with k3s CI
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { Controller } from 'stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
if (!this.isCookieAccepted()) {
|
||||
this.element.classList = 'show';
|
||||
} else {
|
||||
this.element.classList = 'd-none';
|
||||
}
|
||||
}
|
||||
|
||||
accept() {
|
||||
// Устанавливаем куку на 1 год
|
||||
const date = new Date();
|
||||
date.setFullYear(date.getFullYear() + 1);
|
||||
document.cookie = `cookie_accepted=true; expires=${date.toUTCString()}; path=/`;
|
||||
|
||||
this.element.classList = 'd-none';
|
||||
}
|
||||
|
||||
isCookieAccepted() {
|
||||
return document.cookie.split(';').some(cookie =>
|
||||
cookie.trim().startsWith('cookie_accepted=true')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user