Better statistic for pro version

This commit is contained in:
Amauri CHAMPEAUX 2015-01-08 20:08:11 +01:00
parent 4e8bf994b8
commit 686a290028
1 changed files with 40 additions and 19 deletions

View File

@ -29,9 +29,7 @@ var tarteaucitron = {
var cdn = tarteaucitron.cdn,
language = tarteaucitron.getLanguage(),
pathToLang = cdn + 'lang/tarteaucitron.' + language + '.js',
timestamp = new Date().getTime(),
pathToServices = cdn + 'tarteaucitron.services.js',
parametersCom = '?uuid=' + tarteaucitron.uuid + '&c=' + encodeURIComponent(tarteaucitron.cookie.read()) + '&_' + timestamp,
linkElement = document.createElement('link'),
defaults = {
"grayArea": false,
@ -42,11 +40,6 @@ var tarteaucitron = {
"showAlertSmall": true
};
// is the commercial version ?
if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined) {
pathToServices = pathToServices + parametersCom;
}
// Step 0: get params
if (params !== undefined) {
tarteaucitron.extend(defaults, params);
@ -107,18 +100,8 @@ var tarteaucitron = {
return 0;
});
// if bypass: load all services and exit
// for example, set tarteaucitron.user.bypass = true;
// if the user is not in europa
if (tarteaucitron.user.bypass === true) {
for (index = 0; index < tarteaucitron.job.length; index += 1) {
service = s[tarteaucitron.job[index]];
service.js();
}
return;
}
// Step 3: prepare the html
html += '<div id="tarteaucitronPremium"></div>';
html += '<div id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();"></div>';
html += '<div id="tarteaucitron">';
html += ' <div id="tarteaucitronClosePanel" onclick="tarteaucitron.userInterface.closePanel();">';
@ -241,6 +224,12 @@ var tarteaucitron = {
isAllowed = (cookie.indexOf(service.key + '=true') >= 0) ? true : false;
isResponded = (cookie.indexOf(service.key) >= 0) ? true : false;
// allow by default for non EU
if (isResponded === false && tarteaucitron.user.bypass === true) {
isAllowed = true;
tarteaucitron.cookie.create(service.key, true);
}
if ((!isResponded && (isAutostart || isNavigating) && !defaults.highPrivacy) || isAllowed) {
if (!isAllowed) {
tarteaucitron.cookie.create(service.key, true);
@ -422,6 +411,10 @@ var tarteaucitron = {
cookie = tarteaucitron.cookie.read().replace(regex, ""),
value = 'tarteaucitron=' + cookie + '!' + key + '=' + status;
if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
tarteaucitron.pro('!' + key + '=' + status);
}
d.setTime(expireTime);
document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;';
},
@ -559,5 +552,33 @@ var tarteaucitron = {
a[prop] = b[prop];
}
}
},
"proTemp": '',
"proTimer": function () {
"use strict";
setTimeout(tarteaucitron.proPing, 1000);
},
"pro": function (list) {
"use strict";
tarteaucitron.proTemp += list;
clearTimeout(tarteaucitron.proTimer);
tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
},
"proPing": function () {
"use strict";
if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
var div = document.getElementById('tarteaucitronPremium'),
timestamp = new Date().getTime(),
url = '//opt-out.ferank.eu/premium.php?';
url += 'domain=' + tarteaucitron.domain + '&';
url += 'uuid=' + tarteaucitron.uuid + '&';
url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
url += '_' + timestamp;
div.innerHTML = '<img src="' + url + '" style="display:none" />';
tarteaucitron.proTemp = '';
}
}
};