function GECCV2() { }; GECCV2.prototype.Init = function (isCheckoutPage) { try { // var groups = @GROUPS; this.ConsentCheckRequired = false; this.RunOnCheckoutPage = false; if (isCheckoutPage && !this.RunOnCheckoutPage) { return; } var defaultVal = this.GetDefaultCookieValue() var customValue = !this.ConsentCheckRequired ? defaultVal : this.RunCustomScript(defaultVal); GlobalE.SetCookie(GlobalE.GE_CONSENT_COOKIE, customValue, null, true, null, true); } catch (ex) {} } // Returns default value for the consent cookie // If feature enabled - only Essentials will be allowed // If feature not enabled - all groups will be allowed GECCV2.prototype.GetDefaultCookieValue = function () { var self = this; var cookieValue = { required: this.ConsentCheckRequired, groups: {} }; Object.keys(GlobalE.MandatoryConsentGroups).forEach(function (key) { var permission = self.ConsentCheckRequired ? GlobalE.ConsentPermissions.NotAllowed : GlobalE.ConsentPermissions.Allowed; if (GlobalE.MandatoryConsentGroups[key] === GlobalE.MandatoryConsentGroups.Essentials) { permission = GlobalE.ConsentPermissions.Allowed; } cookieValue.groups[GlobalE.MandatoryConsentGroups[key]] = permission; }); return cookieValue; } // Default value should be updated by custom script execution // If nothing configured - default values will be used GECCV2.prototype.RunCustomScript = function (defaultVal) { var self = this; try { var customValue = defaultVal; // custom script ==> // <== custom script return customValue; }catch(ex) { return defaultVal; } };