33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
(function () {
|
|
var boxTop = document.getElementById('BoxTop');
|
|
var logoIsSmall = false;
|
|
var rootPath = '';
|
|
function setClass (add) {
|
|
let spl = boxTop.className.split(' ');
|
|
for (let i = spl.length-1; i >= 0; i--)
|
|
if (spl[i] == 'smallLogo')
|
|
spl.splice(i, 1);
|
|
if (add) spl.push('smallLogo');
|
|
boxTop.className = spl.join(' ');
|
|
}
|
|
let spl = document.cookie.split(';');
|
|
for (let i = 0; i < spl.length; i++) {
|
|
spl[i] = spl[i].split('=');
|
|
if (spl[i][0] == 'headerLogoState' && spl[i].length > 1) {
|
|
logoIsSmall = spl[i][1] == 'small';
|
|
break;
|
|
}
|
|
}
|
|
setClass(logoIsSmall);
|
|
let selfScript = document.getElementsByTagName('script')[document.getElementsByTagName('script').length-1];
|
|
if (selfScript.getAttribute('rootpath'))
|
|
rootPath = selfScript.getAttribute('rootpath');
|
|
let sitePath = window.location.href.split('#')[0];
|
|
var logoShouldBeSmall = !(rootPath != '' && sitePath.indexOf(rootPath) == 0 && sitePath.length - rootPath.length <= 2);
|
|
if (logoShouldBeSmall != logoIsSmall) window.setTimeout(function () {
|
|
setClass(logoShouldBeSmall);
|
|
if (logoShouldBeSmall) document.cookie = 'headerLogoState=small;path=/';
|
|
else document.cookie = 'headerLogoState=big;path=/';
|
|
}, 1000);
|
|
})();
|