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 var openmenu = $("#kiwiki-main-menu__open"); 45 var closemenu = $("#kiwiki-main-menu__close, .kiwiki-main-menu-overlay"); 46 47 var menu = $( 48 "#kiwiki #dokuwiki__site #dokuwiki__content__wrapper #dokuwiki__aside .kiwiki-main-menu h3" 49 ); 50 51 if ($(event.target).is(trigger)) { 52 if (!$(event.target).hasClass("active")) { 53 $(trigger).removeClass("active"); 54 $(event.target).addClass("active"); 55 } 56 } else { 57 $(trigger).removeClass("active"); 58 } 59 60 if ($(event.target).is(search)) { 61 $( 62 "#dokuwiki__header > .dokuwiki__header__wrapper #dw__search" 63 ).toggleClass("open"); 64 } 65 if ($(event.target).is(fullscreen)) { 66 $("body").toggleClass("fullscreen"); 67 } 68 if ($(event.target).is(menu)) { 69 $(menu).parent().toggleClass("open"); 70 } 71 if ($(event.target).is(openmenu)) { 72 $(".kiwiki-main-menu__wrapper").addClass("open"); 73 } 74 if ($(event.target).is(closemenu)) { 75 $(".kiwiki-main-menu__wrapper").removeClass("open"); 76 } 77 78 if ($(event.target).is(thememode)) { 79 if (!!$.cookie("theme")) { 80 if (!$("body").hasClass("darkmode")) { 81 $("body").removeClass("lightmode"); 82 $("body").addClass("darkmode"); 83 document.cookie = "theme=darkmode;path=/;"; 84 } else { 85 $("body").removeClass("darkmode"); 86 $("body").addClass("lightmode"); 87 document.cookie = "theme=lightmode;path=/;"; 88 } 89 } else { 90 if (colorscheme == "darkmode") { 91 $("body").addClass("lightmode"); 92 document.cookie = "theme=lightmode;path=/;"; 93 } else { 94 $("body").addClass("darkmode"); 95 document.cookie = "theme=darkmode;path=/;"; 96 } 97 } 98 99 /**/ 100 } 101 }); 102 103 104 _kiwikiChangeAdminLabels( 105 'label[for="tpl____kiwiki_color__"]', 106 "h3", 107 "Kiwiki" 108 ); 109 _kiwikiChangeAdminLabels( 110 'label[for="tpl____kiwiki_light_colors__"]', 111 "h4", 112 "Light mode colors" 113 ); 114 _kiwikiChangeAdminLabels( 115 'label[for="tpl____kiwiki_dark_colors__"]', 116 "h4", 117 "Dark mode colors" 118 ); 119})(jQuery); 120