Feature: Add possibility for user to specify a hour(s)/day(s) value as a custom expire value
This commit is contained in:
parent
780b651689
commit
fb2b675889
|
|
@ -9,7 +9,9 @@ var scripts = document.getElementsByTagName('script'),
|
||||||
tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
|
tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
|
||||||
tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
|
tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
|
||||||
tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
|
tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
|
||||||
timeExipre = 31536000000,
|
// tarteaucitronExpireInDay: true for day(s) value - false for hour(s) value
|
||||||
|
tarteaucitronExpireInDay = (tarteaucitronExpireInDay === undefined || !Boolean(tarteaucitronExpireInDay)) ? true : tarteaucitronExpireInDay,
|
||||||
|
timeExpire = 31536000000,
|
||||||
tarteaucitronProLoadServices,
|
tarteaucitronProLoadServices,
|
||||||
tarteaucitronNoAdBlocker = false;
|
tarteaucitronNoAdBlocker = false;
|
||||||
|
|
||||||
|
|
@ -1056,13 +1058,21 @@ var tarteaucitron = {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
if (tarteaucitronForceExpire !== '') {
|
if (tarteaucitronForceExpire !== '') {
|
||||||
// The number of day cann't be higher than 1 year
|
// The number of day can't be higher than 1 year
|
||||||
timeExipre = (tarteaucitronForceExpire > 365) ? 31536000000 : tarteaucitronForceExpire * 86400000; // Multiplication to tranform the number of days to milliseconds
|
if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
|
||||||
|
if (tarteaucitronExpireInDay) {
|
||||||
|
// Multiplication to tranform the number of days to milliseconds
|
||||||
|
timeExpire = tarteaucitronForceExpire * 86400000;
|
||||||
|
} else {
|
||||||
|
// Multiplication to tranform the number of hours to milliseconds
|
||||||
|
timeExpire = tarteaucitronForceExpire * 3600000;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var d = new Date(),
|
var d = new Date(),
|
||||||
time = d.getTime(),
|
time = d.getTime(),
|
||||||
expireTime = time + timeExipre, // 365 days
|
expireTime = time + timeExpire, // 365 days
|
||||||
regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
|
regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
|
||||||
cookie = tarteaucitron.cookie.read().replace(regex, ""),
|
cookie = tarteaucitron.cookie.read().replace(regex, ""),
|
||||||
value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
|
value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue