-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex_tmpl.html
238 lines (221 loc) · 8.11 KB
/
index_tmpl.html
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!doctype html>
{{- define "struct"}}
<div class="col">
{{- if ne .Type "" }}
<div class="path" title="{{.Path}}">{{.Label}}</div>
<div class="typename">{{.Type}}</div>
<select id="{{.SelectID}}" multiple size="{{.SelectSize}}">
{{- range .Fields }}
<option value="{{.Key}}" title="{{ .Label }} : {{ .Type }}">
{{ .Padding }}{{ .Label }}: {{ .ValueString }}
</option>
{{- end }}
</select>
<script>
<!-- update visible size of select -->
{
const n = document.getElementById("{{.SelectID}}");
n.setAttribute("size", n.options.length);
}
</script>
{{- if not .NotLive }}
<div class="buttonbar">
<button
class="btn"
title="explore all selected in the row below"
onclick="javascript:explore({{.Row}},{{.Column}},getElementById('{{.SelectID}}'),'down');"
>
⇊
</button>
<button
class="btn"
title="explore all selected in columns on the right"
onclick="javascript:explore({{.Row}},{{.Column}},getElementById('{{.SelectID}}'),'right');"
>
⇉
</button>
<button
class="btn"
title="explore all selected in the row above"
onclick="javascript:explore({{.Row}},{{.Column}},getElementById('{{.SelectID}}'),'up');"
>
⇈
</button>
{{- if .HasZeros }}
<button
class="btn"
title="hide or show fields with zero values"
onclick="javascript:explore({{.Row}},{{.Column}},getElementById('{{.SelectID}}'),'toggleZeros');"
>
z
</button>
{{- end}} {{- if .IsRoot }}
<button
class="btn"
title="remove all objects except the roots"
onclick="javascript:explore({{.Row}},{{.Column}},getElementById('{{.SelectID}}'),'clear');"
>
c
</button>
{{- else }}
<button
class="btn"
title="remove the object from this page"
onclick="javascript:explore({{.Row}},{{.Column}},getElementById('{{.SelectID}}'),'remove');"
>
x
</button>
{{- end }}
</div>
{{- end}} {{- end }}
</div>
{{- end}}
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta name="color-scheme" content="light dark" />
<meta
name="theme-color"
media="(prefers-color-scheme: light)"
content="#ADD8E6FF"
/>
<meta
name="theme-color"
media="(prefers-color-scheme: dark)"
content="#21292c"
/>
<title>Struct Explorer</title>
<script>
{{.Script}}
</script>
<style>
{{.Style}}
</style>
</head>
<body>
<table>
{{- range .Rows }}
<tr>
{{- range .Cells}}
<td>{{ template "struct" . }}</td>
{{- end }}
</tr>
{{- end }}
</table>
<p style="font-size: x-small;margin-top:10px'">
© 2025
<a href="https://github.com/emicklei/structexplorer"
>structexplorer</a
>
<span id="theme-toggle" class="theme-toggle" title="Toggle Theme"
>🔄</span
>
</p>
<script>
(function () {
const toggleButton = document.getElementById("theme-toggle");
const THEME_KEY = "preferred-theme";
const themes = ["auto", "light", "dark"];
let currentThemeIndex = 0;
let mediaQueryList = window.matchMedia(
"(prefers-color-scheme: dark)",
);
let systemThemeChangeListener = null;
// Apply Theme
function applyTheme(theme) {
if (theme === "auto") {
applyAutoTheme();
addSystemThemeListener();
} else {
document.body.classList.remove("light", "dark");
if (theme === "light") {
document.body.classList.add("light");
} else if (theme === "dark") {
document.body.classList.add("dark");
}
removeSystemThemeListener();
}
updateToggleIcon(theme);
}
// Update Toggle Icon based on theme
function updateToggleIcon(theme) {
switch (theme) {
case "light":
toggleButton.textContent = "☀️";
toggleButton.title = "Light Theme";
break;
case "dark":
toggleButton.textContent = "🌙";
toggleButton.title = "Dark Theme";
break;
case "auto":
default:
toggleButton.textContent = "🔄";
toggleButton.title = "Auto Theme";
break;
}
}
// Get Preferred Theme from localStorage
function getPreferredTheme() {
return localStorage.getItem(THEME_KEY) || "auto";
}
// Set Preferred Theme to localStorage
function setPreferredTheme(theme) {
localStorage.setItem(THEME_KEY, theme);
}
// Initialize Theme
function initTheme() {
const preferredTheme = getPreferredTheme();
currentThemeIndex = themes.indexOf(preferredTheme);
applyTheme(preferredTheme);
}
// Toggle Theme on Click
toggleButton.addEventListener("click", () => {
currentThemeIndex = (currentThemeIndex + 1) % themes.length;
const selectedTheme = themes[currentThemeIndex];
setPreferredTheme(selectedTheme);
applyTheme(selectedTheme);
});
// Apply Auto Theme based on system preference
function applyAutoTheme() {
const prefersDark = mediaQueryList.matches;
document.body.classList.remove("light", "dark");
if (prefersDark) {
document.body.classList.add("dark");
} else {
document.body.classList.add("light");
}
}
// Add system theme change listener
function addSystemThemeListener() {
if (!systemThemeChangeListener) {
systemThemeChangeListener = (e) => {
applyAutoTheme();
};
mediaQueryList.addEventListener(
"change",
systemThemeChangeListener,
);
}
}
// Remove system theme change listener
function removeSystemThemeListener() {
if (systemThemeChangeListener) {
mediaQueryList.removeEventListener(
"change",
systemThemeChangeListener,
);
systemThemeChangeListener = null;
}
}
// Initialize on page load
initTheme();
})();
</script>
</body>
</html>