1(function ($) { 2 'use strict'; 3 // Variables 4 5 var wnmCookies = { 6 setCookie: function setCookie(key, value, time, path) { 7 var expires = new Date(); 8 expires.setTime(expires.getTime() + time); 9 var pathValue = ''; 10 11 if (typeof path !== 'undefined') { 12 pathValue = 'path=' + path + ';'; 13 } 14 15 document.cookie = key + '=' + value + ';' + pathValue + 'expires=' + expires.toUTCString(); 16 }, 17 getCookie: function getCookie(key) { 18 var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); 19 return keyValue ? keyValue[2] : null; 20 } 21 }; 22 23 // Call Functions 24 document.addEventListener("DOMContentLoaded", function(event) { 25 // wp_night_mode_turn_on_time(); 26 wp_night_mode_default(); 27 wp_night_mode_element_to_button(); 28 wp_night_mode_button_click(); 29 wp_night_mode_load_cookie(); 30 }); 31 32 function wp_night_mode_default() { 33 if ('1' === wpnmObject.default && null === wnmCookies.getCookie('wpNightMode')) { 34 wnmCookies.setCookie('wpNightMode', 'true', 2628000000, '/'); 35 } 36 } 37 38 // Functions 39 function wp_night_mode_turn_on_time() { 40 var server_time = wpnmObject.server_time; 41 var turn_on_time = wpnmObject.turn_on_time; 42 var turn_off_time = wpnmObject.turn_off_time; 43 // var h = new Date().getHours(); 44 // var m = new Date().getMinutes(); 45 // var time = h + ':' + m; 46 // console.log(wpnmObject); 47 // console.log(server_time); 48 49 // turn on 50 if ( server_time >= turn_on_time && server_time <= turn_off_time ) { 51 wnmCookies.setCookie('wpNightMode', 'true', 2628000000, '/'); 52 } 53 // turn off 54 // if ( server_time >= turn_off_time && server_time <= turn_on_time ) { 55 // wnmCookies.setCookie('wpNightMode', 'false', 2628000000, '/'); 56 // } 57 } 58 59 function wp_night_mode_element_to_button() { 60 var buttonHtml = ''; 61 var buttonClass = document.querySelectorAll('.wp-night-mode'); 62 63 buttonHtml = wpnmObject.button_html; 64 65 for (var i = 0; i < buttonClass.length; i++) { 66 buttonClass[i].innerHTML = buttonHtml; 67 } 68 } 69 70 function wp_night_mode_button_click() { 71 var nightModeButton = document.querySelectorAll('.wpnm-button'); 72 73 for (var i = 0; i < nightModeButton.length; i++) { 74 nightModeButton.item(i).onclick = function (event) { 75 event.preventDefault(); 76 document.body.classList.toggle('wp-night-mode-on'); 77 for (var i = 0; i < nightModeButton.length; i++) { 78 nightModeButton[i].classList.toggle('active'); 79 } 80 81 if (this.classList.contains('active')) { 82 wnmCookies.setCookie('wpNightMode', 'true', 2628000000, '/'); 83 } else { 84 wnmCookies.setCookie('wpNightMode', 'false', 2628000000, '/'); 85 } 86 }; 87 } 88 } 89 90 function wp_night_mode_load_cookie() { 91 var nightModeButton = document.querySelectorAll('.wpnm-button'); 92 93 if ('true' === wnmCookies.getCookie('wpNightMode')) { 94 document.body.classList.add('wp-night-mode-on'); 95 for (var i = 0; i < nightModeButton.length; i++) { 96 nightModeButton[i].classList.add('active'); 97 } 98 } else { 99 document.body.classList.remove('wp-night-mode-on'); 100 for (var i = 0; i < nightModeButton.length; i++) { 101 nightModeButton[i].classList.remove('active'); 102 } 103 } 104 } 105})(jQuery);
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.