2017-07-22 12:17:31 +02:00
|
|
|
if (window.location.href.indexOf('/client/') >= 0) {
|
2017-09-16 17:49:14 +02:00
|
|
|
window.window.addEventListener('load', function () {
|
2018-01-21 16:58:27 +01:00
|
|
|
function setCookie(name, value) {
|
|
|
|
document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + "; path=/";
|
|
|
|
}
|
2019-01-26 22:25:49 +01:00
|
|
|
|
2017-07-22 12:17:31 +02:00
|
|
|
function getParameterByName(name) {
|
|
|
|
var match = RegExp('[?#&]' + name + '=([^&]*)').exec(window.location.hash);
|
|
|
|
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
|
|
|
|
}
|
2019-01-26 22:25:49 +01:00
|
|
|
|
2017-07-22 12:17:31 +02:00
|
|
|
/* Store URL variables in cookies */
|
|
|
|
if (getParameterByName('host')) {
|
2018-01-21 16:58:27 +01:00
|
|
|
setCookie("host", getParameterByName('host'));
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
|
|
|
if (getParameterByName('email')) {
|
|
|
|
var email = getParameterByName('email');
|
2018-01-21 16:58:27 +01:00
|
|
|
setCookie("email", email);
|
|
|
|
setCookie("domain", email.substring(email.indexOf('@') + 1));
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
|
|
|
if (getParameterByName('name')) {
|
2018-01-21 16:58:27 +01:00
|
|
|
setCookie("name", getParameterByName('name'));
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
2019-01-26 22:25:49 +01:00
|
|
|
if (getParameterByName('ui')) {
|
|
|
|
setCookie("ui", getParameterByName('ui'));
|
|
|
|
}
|
2017-07-22 12:17:31 +02:00
|
|
|
if (getParameterByName('port')) {
|
2018-01-21 16:58:27 +01:00
|
|
|
setCookie("port", getParameterByName('port'));
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
|
|
|
if (getParameterByName('integrator')) {
|
2018-01-21 16:58:27 +01:00
|
|
|
setCookie("integrator", getParameterByName('integrator'));
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
|
|
|
if (getParameterByName('outlookEAS')) {
|
2018-01-21 16:58:27 +01:00
|
|
|
setCookie("outlookEAS", getParameterByName('outlookEAS'));
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
2017-09-16 17:49:14 +02:00
|
|
|
});
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
|
|
|
|
2017-09-16 15:08:54 +02:00
|
|
|
if (window.location.href.indexOf('/client') >= 0) {
|
2017-09-16 17:49:14 +02:00
|
|
|
window.window.addEventListener('load', function () {
|
2017-07-22 12:17:31 +02:00
|
|
|
function getCookie(cn) {
|
2018-01-21 16:58:27 +01:00
|
|
|
var fixedcn = encodeURIComponent(cn);
|
2017-07-22 12:17:31 +02:00
|
|
|
var cs = document.cookie.split(';');
|
|
|
|
for (var i = 0; i < cs.length; i++) {
|
|
|
|
var c = cs[i];
|
|
|
|
while (c.charAt(0) == ' ') {
|
|
|
|
c = c.substring(1);
|
|
|
|
}
|
2018-01-21 16:58:27 +01:00
|
|
|
if (c.indexOf(fixedcn + "=") == 0) {
|
|
|
|
return decodeURIComponent(c.substring(cn.length + 1, c.length));
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
2019-01-26 22:25:49 +01:00
|
|
|
|
2017-07-22 12:17:31 +02:00
|
|
|
/* Hide variable fields if no values are available */
|
|
|
|
if (!getCookie('host')) {
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_variables_available'), function(el) {
|
|
|
|
el.style.display = 'none';
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_variables_unavailable'), function(el) {
|
|
|
|
el.style.display = 'none';
|
|
|
|
});
|
|
|
|
}
|
2019-01-26 22:25:49 +01:00
|
|
|
|
2017-07-22 12:17:31 +02:00
|
|
|
/* Hide the TOC, which might contain hidden content */
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('md-sidebar--secondary'), function(el) {
|
|
|
|
el.style.display = 'none';
|
|
|
|
});
|
2019-01-26 22:25:49 +01:00
|
|
|
|
2017-07-22 12:17:31 +02:00
|
|
|
/* Substitute variables */
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_var_host'), function(el) {
|
|
|
|
el.innerText = getCookie('host');
|
|
|
|
});
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_var_link'), function(el) {
|
2019-01-26 22:25:49 +01:00
|
|
|
if (!getCookie('ui')) {
|
2017-07-22 12:17:31 +02:00
|
|
|
el.href = '#';
|
|
|
|
} else if (getCookie('port') != '443') {
|
2019-01-26 22:25:49 +01:00
|
|
|
el.href = 'https://' + getCookie('ui') + ':' + getCookie('port') + '/' + el.getAttribute("href");
|
2017-07-22 12:17:31 +02:00
|
|
|
} else {
|
2019-01-26 22:25:49 +01:00
|
|
|
el.href = 'https://' + getCookie('ui') + '/' + el.getAttribute("href");
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_var_email'), function(el) {
|
|
|
|
el.innerText = getCookie('email');
|
|
|
|
});
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_var_name'), function(el) {
|
|
|
|
el.innerText = getCookie('name');
|
|
|
|
});
|
|
|
|
if (getCookie('port') != '443') {
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_var_port'), function(el) {
|
|
|
|
el.innerText = ':' + getCookie('port');
|
|
|
|
});
|
|
|
|
}
|
2019-01-26 22:25:49 +01:00
|
|
|
|
2017-07-22 12:17:31 +02:00
|
|
|
/* Hide those sections that are not applicable because useOutlookForEAS is disabled or SOGo integrator is not available */
|
|
|
|
if (getCookie('integrator')) {
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_var_integrator_link'), function(el) {
|
|
|
|
el.href = el.href.replace('__DOMAIN__', getCookie('domain')).replace('__VERSION__', getCookie('integrator'));
|
|
|
|
});
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_integrator_disabled'), function(el) {
|
|
|
|
el.style.display = 'none';
|
|
|
|
});
|
|
|
|
} else if (getCookie('host')) {
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_integrator_enabled'), function(el) {
|
|
|
|
el.style.display = 'none';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (getCookie('outlookEAS') || !getCookie('host')) {
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_outlookEAS_disabled'), function(el) {
|
|
|
|
el.style.display = 'none';
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
Array.prototype.forEach.call(document.getElementsByClassName('client_outlookEAS_enabled'), function(el) {
|
|
|
|
el.style.display = 'none';
|
|
|
|
});
|
|
|
|
}
|
2017-09-16 17:49:14 +02:00
|
|
|
});
|
2017-07-22 12:17:31 +02:00
|
|
|
}
|