summaryrefslogtreecommitdiffstats
path: root/layouts/partials/scripts-front.html
blob: 59c3bb0829d95f1864eabbd12bc7d2d0d48d6f73 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<script data-cfasync="false">
    // detect theme data in localStorage
    // change the data-theme attribute of body
    var fujiThemeData = localStorage.getItem('fuji_theme');
    if (fujiThemeData) {
        if ($('body').attr('data-theme') !== fujiThemeData) {
            $('body').attr('data-theme', (index, attr) => {
                if (fujiThemeData === 'dark') {
                    return 'dark';
                } else {
                    return 'light';
                }
            });
        }
    } else {
        localStorage.setItem('fuji_theme', $('body').attr('data-theme'));
    }
</script>
<script data-cfasync="false">
    // ie
    var ua = window.navigator.userAgent;

    function browserDetection() {
        if (ua.indexOf('MSIE ') > 0 || ua.indexOf('Trident/') > 0 || ua.indexOf('Edge/') > 0) {
            return true;
        }
        return false;
    }

    if (browserDetection()) {
        window.location.href('{{ "/ie/" | absURL }}');
    }
</script>