diff --git a/assets/synth.download/sharkey/roundify.js b/assets/synth.download/sharkey/roundify.js index 419f569..42608c6 100644 --- a/assets/synth.download/sharkey/roundify.js +++ b/assets/synth.download/sharkey/roundify.js @@ -6,10 +6,10 @@ // try and see if user has a session const hasAuthToken = localStorage.getItem('account'); - // check if we have visitor-root + // check if we have visitor-root-* const isWelcomePage = document.querySelector('[class*="visitor-root-"]'); - // compared both values to execute + // compare both values to execute const isLoggedOut = !hasAuthToken && isWelcomePage; 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) { 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') || mutation.type === 'childList') { 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, { attributes: true, attributeFilter: ['class'],