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