chore: initial import for test contour with k3s CI
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Controller } from 'stimulus';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
try {
|
||||
const region = Cookies.get('region');
|
||||
|
||||
if (!region) {
|
||||
console.warn('Region cookie not found, using default Jivo widget');
|
||||
}
|
||||
|
||||
const widgetUrl = this.getSource(region);
|
||||
|
||||
this.element.src = widgetUrl;
|
||||
} catch (error) {
|
||||
console.error('Failed to load Jivo widget:', error);
|
||||
}
|
||||
}
|
||||
|
||||
getSource(region) {
|
||||
const normalizedRegion = region ? String(region).trim() : '';
|
||||
|
||||
switch (normalizedRegion) {
|
||||
case '93': return 'https://code.jivo.ru/widget/EMlWlFXUZB'; // Воронеж
|
||||
case '94': return 'https://code.jivo.ru/widget/adPLvIW8rT'; // Краснодар
|
||||
default: return 'https://code.jivo.ru/widget/IPQcFAX6b5'; // Саратов, Волгоград
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user