-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy paththemebox.js
75 lines (66 loc) · 1.69 KB
/
themebox.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
// Copyright (c) 2025 Arjun Jayan
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the The GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// You should have received a copy of the GNU Affero General Public
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA
//A dropdown for selecting theme
/*
global _
*/
/* exported ThemeBox */
class ThemeBox {
/**
* @constructor
*/
constructor(activity) {
this.activity = activity;
this._theme = activity.storage.themePreference;
}
/**
* @public
* @returns {void}
*/
light_onclick() {
this._theme = "light";
this.setPreference();
}
/**
* @public
* @returns {void}
*/
dark_onclick() {
this._theme = "dark";
this.setPreference();
}
// /**
// * @public
// * @returns {void}
// */
// custom_onclick() {
// this._theme = "custom";
// this.setPreference();
// }
/**
* @public
* @returns {void}
*/
reload() {
window.location.reload();
}
setPreference() {
if (localStorage.getItem("themePreference") === this._theme) {
this.activity.textMsg(_("Music Blocks is already set to this theme."));
} else {
this.activity.storage.themePreference = this._theme;
this.reload();
}
}
}
if (typeof module !== "undefined" && module.exports) {
module.exports = ThemeBox;
}