+function theme_select(theme, init) {
+ const theme_system = $('#theme-system');
+ const theme_light = $('#theme-light');
+ const theme_dark = $('#theme-dark');
+
+ theme_system.className = theme == 'system' ? 'selected' : '';
+ theme_light.className = theme == 'light' ? 'selected' : '';
+ theme_dark.className = theme == 'dark' ? 'selected' : '';
+
+ if (init) {
+ theme_system.onclick = theme_click;
+ theme_light.onclick = theme_click;
+ theme_dark.onclick = theme_click;
+ }
+}
+
+function theme_click() {
+ const theme = this.textContent.toLowerCase();
+ theme_select(theme);
+ storage.set({theme});
+}
+