fix: add missing window references

This commit is contained in:
Arvid Norlin
2024-04-02 15:05:34 +02:00
parent a19c32f903
commit 4c9998a254

View File

@@ -79,7 +79,7 @@ export default function VWOScript() {
b.src = a; b.src = a;
b.type = "text/javascript"; b.type = "text/javascript";
b.onerror = function () { b.onerror = function () {
_vwo_code.finish(); window._vwo_code.finish();
}; };
d.getElementsByTagName("head")[0].appendChild(b); d.getElementsByTagName("head")[0].appendChild(b);
} }
@@ -105,9 +105,9 @@ export default function VWOScript() {
if (d.URL.indexOf("__vwo_disable__") > -1) return; if (d.URL.indexOf("__vwo_disable__") > -1) return;
var sT = this.settings_tolerance(); var sT = this.settings_tolerance();
w._vwo_settings_timer = setTimeout(function () { w._vwo_settings_timer = setTimeout(function () {
_vwo_code.finish(); window._vwo_code.finish();
stT.removeItem(cK); stT.removeItem(cK);
_vwo_code.removeLoaderAndOverlay(); window._vwo_code.removeLoaderAndOverlay();
}, sT); }, sT);
var filterConfig = this.filterConfig; var filterConfig = this.filterConfig;
if (!filterConfig || filterConfig.filterTime === "balanced") { if (!filterConfig || filterConfig.filterTime === "balanced") {
@@ -147,7 +147,7 @@ export default function VWOScript() {
if (state === "1") { if (state === "1") {
// if cookie consent was already given and the cookies were already accepted, execute out normal flow // if cookie consent was already given and the cookies were already accepted, execute out normal flow
hide_element = "body"; hide_element = "body";
w._vwo_settings_timer = _vwo_code.init(); w._vwo_settings_timer = window._vwo_code.init();
return; return;
} else if (state === "2") { } else if (state === "2") {
return; return;
@@ -165,7 +165,7 @@ export default function VWOScript() {
} }
this.filterConfig = config; this.filterConfig = config;
var popupTimer = setInterval(function () { var popupTimer = setInterval(function () {
if (_vwo_code.applyFilters(config)) { if (window._vwo_code.applyFilters(config)) {
clearInterval(popupTimer); clearInterval(popupTimer);
} }
}, 100); }, 100);
@@ -173,12 +173,12 @@ export default function VWOScript() {
var state = config.isConsentGiven(); var state = config.isConsentGiven();
var shouldClearAllIntervals; var shouldClearAllIntervals;
if (state === "1") { if (state === "1") {
_vwo_code.showLoader(); window._vwo_code.showLoader();
w._vwo_settings_timer = _vwo_code.init(); w._vwo_settings_timer = window._vwo_code.init();
shouldClearAllIntervals = true; shouldClearAllIntervals = true;
} else if (state === "2") { } else if (state === "2") {
_vwo_code.filterConfig = undefined; window._vwo_code.filterConfig = undefined;
_vwo_code.removeLoaderAndOverlay(); window._vwo_code.removeLoaderAndOverlay();
shouldClearAllIntervals = true; shouldClearAllIntervals = true;
} }
if (shouldClearAllIntervals) { if (shouldClearAllIntervals) {
@@ -190,7 +190,7 @@ export default function VWOScript() {
// RECOMMENDED: When using Best Approach // RECOMMENDED: When using Best Approach
filterToleranceTimer = setTimeout(function () { filterToleranceTimer = setTimeout(function () {
_vwo_code.removeLoaderAndOverlay(); window._vwo_code.removeLoaderAndOverlay();
clearIntervals([timer, popupTimer]); clearIntervals([timer, popupTimer]);
}, config.filterTolerance); }, config.filterTolerance);
}, },
@@ -289,7 +289,7 @@ export default function VWOScript() {
}; };
w._vwo_code = code; w._vwo_code = code;
})(); })();
_vwo_code.setFilterConfigAndApplyFilter({ window._vwo_code.setFilterConfigAndApplyFilter({
popupSelector: "#CybotCookiebotDialog", popupSelector: "#CybotCookiebotDialog",
filterTime: "best", filterTime: "best",
isConsentGiven: function () { isConsentGiven: function () {