1(function ($) { 2 "use strict"; 3 function _kiwikiChangeAdminLabels(label, level, title) { 4 $(label) 5 .parent() 6 .parent() 7 .html( 8 '<td colspan="2" class="kiwiki-styles"><' + 9 level + 10 ">" + 11 title + 12 "</" + 13 level + 14 "></td>" 15 ); 16 } 17 18 19 20 21 console.log($.cookie("theme")); 22 var colorscheme = "lightmode"; 23 if($.cookie("theme")=="system-color"){ 24 if ( 25 window.matchMedia && 26 window.matchMedia("(prefers-color-scheme: dark)").matches 27 ) { 28 colorscheme = "darkmode"; 29 document.cookie = "theme=darkmode;path=/;"; 30 $("body").removeClass("lightmode"); 31 $("body").addClass("darkmode"); 32 }else{ 33 document.cookie = "theme=lightmode;path=/;"; 34 $("body").removeClass("darkmode"); 35 $("body").addClass("lightmode"); 36 } 37 } 38 39 $(document).on("click", function (event) { 40 var trigger = $("nav.tools>div"); 41 var search = $("div#open-search"); 42 var thememode = $("div#theme-mode"); 43 var fullscreen = $("div#full-screen"); 44 45 var menu = $( 46 "#kiwiki #dokuwiki__site #dokuwiki__content__wrapper #dokuwiki__aside .kiwiki-main-menu h3" 47 ); 48 49 if ($(event.target).is(trigger)) { 50 if (!$(event.target).hasClass("active")) { 51 $(trigger).removeClass("active"); 52 $(event.target).addClass("active"); 53 } 54 } else { 55 $(trigger).removeClass("active"); 56 } 57 58 if ($(event.target).is(search)) { 59 $( 60 "#dokuwiki__header > .dokuwiki__header__wrapper #dw__search" 61 ).toggleClass("open"); 62 } 63 if ($(event.target).is(fullscreen)) { 64 $("body").toggleClass("fullscreen"); 65 } 66 if ($(event.target).is(menu)) { 67 $(menu).parent().toggleClass("open"); 68 } 69 if ($(event.target).is(thememode)) { 70 if (!!$.cookie("theme")) { 71 if (!$("body").hasClass("darkmode")) { 72 $("body").removeClass("lightmode"); 73 $("body").addClass("darkmode"); 74 document.cookie = "theme=darkmode;path=/;"; 75 } else { 76 $("body").removeClass("darkmode"); 77 $("body").addClass("lightmode"); 78 document.cookie = "theme=lightmode;path=/;"; 79 } 80 } else { 81 if (colorscheme == "darkmode") { 82 $("body").addClass("lightmode"); 83 document.cookie = "theme=lightmode;path=/;"; 84 } else { 85 $("body").addClass("darkmode"); 86 document.cookie = "theme=darkmode;path=/;"; 87 } 88 } 89 90 /**/ 91 } 92 }); 93 94 95 _kiwikiChangeAdminLabels( 96 'label[for="tpl____kiwiki_color__"]', 97 "h3", 98 "Kiwiki" 99 ); 100 _kiwikiChangeAdminLabels( 101 'label[for="tpl____kiwiki_light_colors__"]', 102 "h4", 103 "Light mode colors" 104 ); 105 _kiwikiChangeAdminLabels( 106 'label[for="tpl____kiwiki_dark_colors__"]', 107 "h4", 108 "Dark mode colors" 109 ); 110})(jQuery); 111