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