mirror of
https://github.com/BeardedTek/flowbite-beardedtek.com.git
synced 2025-12-06 05:31:52 +00:00
Modify cookie banner update javascript bundle with webpack
This commit is contained in:
@@ -4,4 +4,6 @@ import 'flowbite';
|
||||
import './dark-mode';
|
||||
import './navbar';
|
||||
import './current-year';
|
||||
import './contact-form';
|
||||
import './contact-form';
|
||||
import './plausible-banner';
|
||||
import './set-dark-mode';
|
||||
36
src/plausible-banner.js
Normal file
36
src/plausible-banner.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// Plausible Exclude
|
||||
window.addEventListener('load', function(){
|
||||
var plausibleSwitch = document.getElementById('plausible-switch');
|
||||
var plausibleStatus = window.localStorage.getItem('plausible_ignore');
|
||||
if (plausibleStatus === null || plausibleStatus === undefined || plausibleStatus === false ){
|
||||
plausibleSwitch.checked = true;
|
||||
} else {
|
||||
plausibleSwitch.checked = false;
|
||||
}
|
||||
})
|
||||
|
||||
window.addEventListener('load', function(){
|
||||
var hidePlausibleBanner = window.localStorage.getItem('hidePlausibleBanner');
|
||||
var bannerEl = document.getElementById('plausible-banner');
|
||||
|
||||
if ( hidePlausibleBanner ){
|
||||
bannerEl.classList.add('hidden');
|
||||
} else {
|
||||
bannerEl.classList.remove('hidden');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
document.getElementById('plausible-switch').addEventListener('change', function(){
|
||||
if (this.checked) {
|
||||
window.localStorage.removeItem('plausible_ignore');
|
||||
} else {
|
||||
window.localStorage.setItem('plausible_ignore', 'true');
|
||||
}
|
||||
})
|
||||
|
||||
document.getElementById('plausible-ok').addEventListener('click', function() {
|
||||
var bannerEl = document.getElementById('plausible-banner');
|
||||
window.localStorage.setItem('hidePlausibleBanner', 'true');
|
||||
bannerEl.classList.add('hidden');
|
||||
})
|
||||
4
src/set-dark-mode.js
Normal file
4
src/set-dark-mode.js
Normal file
@@ -0,0 +1,4 @@
|
||||
colorTheme = window.localStorage.getItem('color-theme');
|
||||
if (!colorTheme){
|
||||
window.localStorage.setItem('color-theme', 'dark');
|
||||
}
|
||||
Reference in New Issue
Block a user