PageSourceSearch

https://arbiscan.io/assets/js/theme-appearance.js?v=26.9.3.0

js arbiscan.io collected 2026-09-24 15:19:28 UTC 3,369 bytes, 116 lines download raw bytes

1/*!
2* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
3* Copyright 2011-2022 The Bootstrap Authors
4* Licensed under the Creative Commons Attribution 3.0 Unported License.
5*/
6
7const storedTheme = localStorage.getItem('theme')
8const themeCookieName = 'site_auto_theme'
9
10const getSystemTheme = () =>
11    window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dim' : 'light'
12
13const resolveAppliedTheme = (theme) =>
14  theme === 'auto' ? getSystemTheme() : theme
15
16const getCookieValue = (name) => {
17  const escapedName = name.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
18  const match = document.cookie.match(new RegExp(`(?:^|; )${escapedName}=([^;]*)`))
19  return match ? decodeURIComponent(match[1]) : null
20}
21
22const setCookieValue = (name, value) => {
23  document.cookie = `${name}=${encodeURIComponent(value)}; path=/`
24}
25
26const setThemeCookie = (theme) => {
27  const appliedTheme = resolveAppliedTheme(theme) || 'light'
28  setCookieValue(themeCookieName, appliedTheme)
29}
30
31if (!getCookieValue(themeCookieName)) {
32  setCookieValue(themeCookieName, 'light')
33}
34
35const getPreferredTheme = (isOnload = false) => {
36  if (storedTheme) {
37    return storedTheme
38  }
39
40  if(isOnload){
41    return 'light';
42  }
43
44  return getSystemTheme()
45}
46
47const setTheme = function (theme, isChangeFavicon = false) {
48  setThemeCookie(theme)
49
50  if(isChangeFavicon){
51    let favicon = document.querySelector('link[rel="shortcut icon"]');
52
53    if (favicon) {
54      if (window.matchMedia('(prefers-color-scheme: dark)').matches && !favicon.href.includes('light')) {
55        favicon.href = favicon.href.replace('favicon', 'favicon-light');
56      } else {
57        favicon.href = favicon.href.replace('favicon-light', 'favicon');
58      }
59    }
60  }
61
62  document.documentElement.setAttribute('data-bs-theme', resolveAppliedTheme(theme))
63}
64
65setTheme(getPreferredTheme(true), true)
66
67const showActiveTheme = theme => {
68  const activeThemeIcon = document.querySelector('.theme-icon-active')
69  const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`)
70
71  if (!activeThemeIcon || !btnToActive) {
72    return;
73  }
74
75  const iElement = btnToActive.querySelector('i');
76
77  if (!iElement) {
78    return;
79  }
80
81  const svgOfActiveBtn = iElement.getAttribute('data-href')
82
83  if (!svgOfActiveBtn) {
84      return;
85  }
86
87  document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
88    element.classList.remove('active')
89  })
90
91  btnToActive.classList.add('active')
92  activeThemeIcon.classList.remove(activeThemeIcon.getAttribute('data-href').slice(1))
93  activeThemeIcon.classList.add(svgOfActiveBtn.slice(1))
94  activeThemeIcon.setAttribute('data-href', svgOfActiveBtn)
95} 
96
97window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
98  if (localStorage.getItem('theme') === 'auto') {
99    setTheme('auto', true)
100  }
101})
102
103window.addEventListener('DOMContentLoaded', () => {
104  showActiveTheme(getPreferredTheme(true))
105
106  document.querySelectorAll('[data-bs-theme-value]')
107    .forEach(toggle => {
108      toggle.addEventListener('click', () => {
109        const theme = toggle.getAttribute('data-bs-theme-value')
110        localStorage.setItem('theme', theme)
111        setTheme(theme)
112        showActiveTheme(theme)
113      })
114    })
115})
116//End Dark Mode

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.