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
|
import React, { Component } from "react";
import { Dropdown, Checkbox, Modal, Header, Input } from "semantic-ui-react";
const notificationSounds = [
{ key: "bed", value: "bed", text: "Bed squeak" },
{ key: "bongchime", value: "bongchime", text: "Bongchime" },
{ key: "boombang", value: "boombang", text: "Boom bang!" },
{ key: "chime", value: "chime", text: "Chime" },
{ key: "cuack", value: "cuack", text: "Cuack" },
{ key: "dootdoot", value: "dootdoot", text: "Mr Skeltal - Doot doot" },
{ key: "iqc", value: "iqc", text: "Notificación IQC" },
{ key: "msn", value: "msn", text: "Notificación MSN" },
{ key: "manscream", value: "manscream", text: "Man Scream (Loud)" },
{
key: "messageforme",
value: "messageforme",
text: "IT Crowd - Message for me!"
},
{ key: "nootnoot", value: "nootnoot", text: "Pengu - noot noot" },
{ key: "ohwahahahahah", value: "ohwahahahahah", text: "Oh wah ah ah ah!" },
{ key: "pincheputita", value: "pincheputita", text: "Pinche putita" },
{ key: "idk", value: "idk", text: "??? Pájaro" },
{ key: "whoa", value: "whoa", text: "Woow" }
];
class SettingsModal extends Component {
constructor(props) {
super(props);
this.state = {
homeSound: "msn",
threadSound: "dootdoot",
nightMode: true,
notifyOnHome: true,
notifyOnThread: true,
autoUpdateThreads: true,
showAvatars: true,
postPassword: ""
};
this.handleChange = this.handleChange.bind(this);
this.toggleSetting = this.toggleSetting.bind(this);
}
componentDidMount() {
let settings = JSON.parse(localStorage.getItem("settings"));
this.setState({
homeSound: settings.homeSound,
threadSound: settings.threadSound,
nightMode: settings.nightMode,
notifyOnHome: settings.notifyOnHome,
notifyOnThread: settings.notifyOnThread,
autoUpdateThreads: settings.autoUpdateThreads,
showAvatars: settings.showAvatars,
postPassword: settings.postPassword
});
}
handleChange(e, { name, value }) {
this.setState({ [name]: value }, () => {
new Audio(
`https://bienvenidoainternet.org/static/sfx/${
name === "threadSound" ? this.state.threadSound : this.state.homeSound
}.ogg`
).play();
this.saveSettings();
});
}
toggleSetting(e, { name, checked }) {
this.setState({ [name]: checked }, () => {
this.props.handler(this.state.nightMode);
this.saveSettings();
});
}
saveSettings() {
localStorage.setItem("settings", JSON.stringify(this.state));
}
render() {
const {
homeSound,
threadSound,
nightMode,
autoUpdateThreads,
notifyOnHome,
notifyOnThread,
postPassword,
showAvatars
} = this.state;
return (
<Modal trigger={this.props.trigger} size="tiny" centered={false}>
<Modal.Header>Configuración</Modal.Header>
<Modal.Content>
<Modal.Description>
<Header as="h4" dividing>
Apariencia
</Header>
<Checkbox
label="Modo nocturno"
checked={nightMode}
name="nightMode"
onChange={this.toggleSetting}
className="settingCheckbox"
/>
<Checkbox
label="Mostrar avatares"
checked={showAvatars}
name="showAvatars"
onChange={this.toggleSetting}
className="settingCheckbox"
/>
<Header as="h4" dividing>
Comportamiento
</Header>
<Checkbox
label="Actualizar automáticamente hilos"
checked={autoUpdateThreads}
name="autoUpdateThreads"
onChange={this.toggleSetting}
className="settingCheckbox"
/>
<Checkbox
label="Notificar cuando existan nuevas respuestas"
checked={notifyOnHome}
name="notifyOnHome"
onChange={this.toggleSetting}
className="settingCheckbox"
/>
<div className="select">
Sonido de notificación:{" "}
<Dropdown
inline
select
scrolling
options={notificationSounds}
value={homeSound}
onChange={this.handleChange}
name="homeSound"
/>
</div>
<Checkbox
label="Notificar cuando un hilo reciba nuevas respuestas"
checked={notifyOnThread}
name="notifyOnThread"
onChange={this.toggleSetting}
className="settingCheckbox"
/>
<div className="select">
Sonido de notificación :{" "}
<Dropdown
inline
select
scrolling
options={notificationSounds}
value={threadSound}
onChange={this.handleChange}
name="threadSound"
/>
</div>
<Header as="h4" dividing>
Posteo
</Header>
<Input label="Contraseña" value={postPassword} type="password" />
</Modal.Description>
</Modal.Content>
</Modal>
);
}
}
export default SettingsModal;
|