This commit is contained in:
parent
74d34e52e7
commit
ffd8927fed
1 changed files with 5 additions and 5 deletions
|
|
@ -6,10 +6,10 @@
|
||||||
// try and see if user has a session
|
// try and see if user has a session
|
||||||
const hasAuthToken = localStorage.getItem('account');
|
const hasAuthToken = localStorage.getItem('account');
|
||||||
|
|
||||||
// check if we have visitor-root
|
// check if we have visitor-root-*
|
||||||
const isWelcomePage = document.querySelector('[class*="visitor-root-"]');
|
const isWelcomePage = document.querySelector('[class*="visitor-root-"]');
|
||||||
|
|
||||||
// compared both values to execute
|
// compare both values to execute
|
||||||
const isLoggedOut = !hasAuthToken && isWelcomePage;
|
const isLoggedOut = !hasAuthToken && isWelcomePage;
|
||||||
|
|
||||||
if (isLoggedOut) {
|
if (isLoggedOut) {
|
||||||
|
|
@ -19,10 +19,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// watch and wait to execute once sharkey modifies the html element
|
// we watch and wait until modifications to the html document happen first to execute, otherwise it doesn't work
|
||||||
const observer = new MutationObserver(function(mutations) {
|
const observer = new MutationObserver(function(mutations) {
|
||||||
mutations.forEach(function(mutation) {
|
mutations.forEach(function(mutation) {
|
||||||
// check if html element changes or elements were added
|
// execute once both html class and new elements are loaded in
|
||||||
if ((mutation.type === 'attributes' && mutation.attributeName === 'class') ||
|
if ((mutation.type === 'attributes' && mutation.attributeName === 'class') ||
|
||||||
mutation.type === 'childList') {
|
mutation.type === 'childList') {
|
||||||
roundifyLoggedOut();
|
roundifyLoggedOut();
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// observe both html classes and body elements for changes
|
// observe both html classes (modified once sharkey initializes) and body elements for changes (when visitor-root-* loads in)
|
||||||
observer.observe(document.documentElement, {
|
observer.observe(document.documentElement, {
|
||||||
attributes: true,
|
attributes: true,
|
||||||
attributeFilter: ['class'],
|
attributeFilter: ['class'],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue