1(function ($) { 2 "use strict"; 3 var PENCI = PENCI || {}; 4 PENCI.darkmode = function () { 5 6 var logos = $('.penci-limg'), 7 autoby = penci_dark.auto_by, 8 darktheme = penci_dark.darktheme, 9 hr = (new Date()).getHours(), 10 lc = 'pclight-mode', 11 dc = 'pcdark-mode'; 12 13 if (darktheme !== '') { 14 lc = 'pclight-mode pcdm-enable'; 15 } else { 16 dc = 'pcdark-mode pcdm-enable'; 17 } 18 19 if (autoby === 'os' && !darktheme && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { 20 21 $('body') 22 .removeClass('pcdm-enable') 23 .removeClass('pclight-mode') 24 .addClass(dc); 25 document.cookie = "penci_mode=dark; path=/"; 26 logos.each(function (){ 27 var logo_dark = $(this).attr('data-darklogo'); 28 if ( logo_dark !== null){ 29 $(this).attr('src', logo_dark); 30 } 31 }); 32 33 } else if (autoby === 'os' && window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) { 34 $('body') 35 .removeClass('pcdark-mode') 36 .removeClass('pcdm-enable') 37 .addClass(lc); 38 document.cookie = "penci_mode=light; path=/"; 39 logos.each(function (){ 40 var logo_light = $(this).attr('data-lightlogo'); 41 if ( logo_light !== null){ 42 $(this).attr('src', logo_light); 43 } 44 }); 45 } 46 47 if (autoby === 'time' && hr > 18) { 48 $('body') 49 .removeClass('pcdm-enable') 50 .removeClass('pclight-mode') 51 .addClass(dc); 52 document.cookie = "penci_mode=dark; path=/"; 53 logos.each(function (){ 54 var logo_dark = $(this).attr('data-darklogo'); 55 if ( logo_dark !== null){ 56 $(this).attr('src', logo_dark); 57 } 58 }); 59 } else if (autoby === 'time') { 60 $('body').removeClass('pcdark-mode') 61 .removeClass('pcdm-enable') 62 .addClass(lc); 63 document.cookie = "penci_mode=light; path=/"; 64 logos.each(function (){ 65 var logo_light = $(this).attr('data-lightlogo'); 66 if ( logo_light !== null){ 67 $(this).attr('src', logo_light); 68 } 69 }); 70 } 71 72 $('.pc_dm_mode').each(function () { 73 74 $(this).find('.pc_dark_mode_toggle').attr("checked", !!$('body').hasClass('pcdark-mode')); 75 76 $(this).find('.slider').on('click', function () { 77 78 $('body').addClass('pcdm-loading'); 79 80 var t = $(this).closest('.pc_dm_mode'), 81 c = t.find('.pc_dark_mode_toggle'); 82 83 c.attr("checked", !c.attr("checked")); 84 t.toggleClass('active'); 85 if (c.attr("checked")) { 86 $('body') 87 .removeClass('pcdm-enable') 88 .removeClass('pclight-mode') 89 .addClass(dc); 90 document.cookie = "penci_mode=dark; path=/"; 91 logos.each(function (){ 92 var logo_dark = $(this).attr('data-darklogo'); 93 if ( logo_dark !== null){ 94 $(this).attr('src', logo_dark); 95 } 96 }); 97 } else { 98 $('body') 99 .removeClass('pcdark-mode') 100 .removeClass('pcdm-enable') 101 .addClass(lc); 102 document.cookie = "penci_mode=light; path=/"; 103 logos.each(function (){ 104 var logo_light = $(this).attr('data-lightlogo'); 105 if ( logo_light !== null){ 106 $(this).attr('src', logo_light); 107 } 108 }); 109 } 110 111 setTimeout(function () { 112 $('body').removeClass('pcdm-loading'); 113 }, 400); 114 }); 115 }); 116 }; 117 118 $(document).ready(function () { 119 PENCI.darkmode(); 120 }); 121})(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.