PageSourceSearch

https://metropublik.com/wp-content/themes/wpberita/js/darkmode.js?ver=2.1.7

js metropublik.com collected 2026-10-02 17:01:10 UTC 1,699 bytes, 45 lines download raw bytes

1/**
2 * Darkmode Button
3 * Copyright (c) 2020 Gian MR
4 * Gian MR Theme Custom Javascript
5 *
6 * @package wpberita
7 */
8
9/* Dark Mode */
10(function(){
11
12	var root = document.body;
13	var btn  = document.querySelector( '.darkmode-button' );
14
15	var nightBtn = '<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="currentColor"><path d="M12 16a4 4 0 0 0 0-8v8Z"/><path fill-rule="evenodd" d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10s10-4.477 10-10S17.523 2 12 2Zm0 2v4a4 4 0 1 0 0 8v4a8 8 0 1 0 0-16Z" clip-rule="evenodd"/></g></svg>';
16
17	var sunBtn = '<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M5 5l1.5 1.5m11 11L19 19M2 12h2m16 0h2M5 19l1.5-1.5m11-11L19 5"/></g></svg>';
18
19	var currentTheme = localStorage.getItem( 'theme' );
20	if ( currentTheme == 'dark' ) {
21		root.classList.toggle( 'dark-theme' );
22		btn.innerHTML = sunBtn;
23	} else if ( currentTheme == 'light' ) {
24		btn.innerHTML = nightBtn;
25	}
26
27	if ( btn ) {
28		btn.addEventListener(
29			'click',
30			function( e ) {
31				e.preventDefault();
32				/* root.classList.toggle( 'dark-theme' ); */
33				root.classList.toggle( 'dark-theme' );
34				if ( root.classList.contains( 'dark-theme' ) ) {
35					btn.innerHTML = sunBtn;
36					var theme     = 'dark';
37				} else {
38					btn.innerHTML = nightBtn;
39					var theme     = 'light';
40				}
41				localStorage.setItem( 'theme', theme );
42			}
43		);
44	}
45})();

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.