- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
<script>
// lexia gdpr initializer
(function(){
// **************************************************
// COUNTRY CODE IP LOOKUP
// reference: https://en.wikipedia.org/wiki/ISO_3166-1#Officially_assigned_code_elements (see column: Alpha-2 code)
// **************************************************
function loadCountryCode(){
var api_url = 'https://www.rosettastone.com/gils';
function load(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
callback(xhr);
}
}
xhr.open('GET', url, true);
xhr.send();
}
function handler(data){
// this looks for https://www.rosettastone.com/gils/CC (where CC is the country code such as US, DE, FR, or whatever)
// if there's no country code available, the response will be /gils
var country_code = (data.responseURL.match(/gils\/(\w+)/i)||['',''])[1];
if(country_code){
window.gdpr && window.gdpr.change_country_code(country_code);
}
}
load(api_url, handler);
}
if( !getCookie('gdpr_country_code') ){
loadCountryCode();
}
// *******************************************************
// Initialize global gdpr variable
// *******************************************************
window.gdpr = window.gdpr || {
country_code: getCookie('gdpr_country_code') || '',
cookie_consent: getCookie('gdpr_cookie_consent') || null,
email_consent: null,
double_opt_in_countries: ['DE', 'CA'],
change_country_code: function(new_country_code){
window.gdpr.country_code = new_country_code;
setCookie('gdpr_country_code', new_country_code);
window.gdpr.trigger('changed_country_code');
return new_country_code;
},
max_wait_for_country_code: 500,
events: {},
on: function(event, callback){
this.events[event] = this.events[event] || [];
this.events[event].push(callback);
},
trigger: function(event){
if(this.events[event]){
this.events[event].forEach(function(callback){
callback();
});
}
}
};
// *******************************************************
// Cookie helper functions
// *******************************************************
// get cookie
function getCookie(cookie_name){
var regex = new RegExp('(^|;\\s)'+cookie_name+'=([^;]+)', 'i');
return (document.cookie.match(regex) || [])[2];
}
// set cookie for 30 days
function setCookie(name, value){
var exp = new Date(Date.parse(new Date()) + (30*24*60*60*1000));
var domain = window.location.hostname.replace(/www/i,''); // domain isolation is tricky, so this will cover the majority of use cases
document.cookie = name+'='+value+'; path=/; expires='+exp+'; domain='+domain;
}
// delete cookie
function deleteCookie(name) {
var domain = window.location.hostname.replace(/www/i,'');
document.cookie = name+'=; domain='+domain+'; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
})();
</script>