@@ -55,7 +55,7 @@ socket.addEventListener('message', (event) => {
55
55
56
56
if ( message . action === 'sendVariables' && message . classElement === classElement ) {
57
57
// If the message contains variable data
58
- const ElementVariables = message . variables
58
+ const elementVariables = message . variables
59
59
translateElements = message . translateElements
60
60
61
61
// Config and translates
@@ -82,12 +82,12 @@ socket.addEventListener('message', (event) => {
82
82
? message . config . lang
83
83
: 'en'
84
84
85
- controlButton . textContent = translateElements . crono . buttons . start
86
- resetButton . textContent = translateElements . crono . buttons . reset
85
+ controlButton . textContent = translateElements . timer . buttons . start
86
+ resetButton . textContent = translateElements . timer . buttons . reset
87
87
88
- if ( ElementVariables && typeof ElementVariables === 'object' ) {
89
- checkTextTime = MsToText ( ElementVariables . textmilliseconds )
90
- checkHexColor = ElementVariables . colorText
88
+ if ( elementVariables && typeof elementVariables === 'object' ) {
89
+ checkTextTime = MsToText ( elementVariables . textmilliseconds )
90
+ checkHexColor = elementVariables . colorText
91
91
92
92
// Format selector options
93
93
formatSelector . innerHTML = ''
@@ -99,24 +99,32 @@ socket.addEventListener('message', (event) => {
99
99
} )
100
100
101
101
// Perform necessary actions with the variables here
102
- textMsg . textContent = ElementVariables . msgEnd
103
- timeText . value = MsToText ( ElementVariables . textmilliseconds )
104
- formatSelector . value = ElementVariables . formatTime
105
- fontSelect . value = ElementVariables . font
106
- fontSize . value = ElementVariables . size
107
- textFormat ( ElementVariables )
108
- formatAlign ( ElementVariables . align )
109
- colorPicker . value = ElementVariables . colorText
110
- colorHex . value = ElementVariables . colorText
102
+ textMsg . textContent = elementVariables . msgEnd
103
+ if ( elementVariables . msgEnd === '' ) {
104
+ textMsg . textContent = translateElements . timer . ph_msgend
105
+ textMsg . style . color = '#555'
106
+ } else { textMsg . style . color = '#000' }
107
+ timeText . value = MsToText ( elementVariables . textmilliseconds )
108
+ formatSelector . value = elementVariables . formatTime
109
+ fontSelect . value = elementVariables . font
110
+ fontSize . value = elementVariables . size
111
+ textFormat ( elementVariables )
112
+ formatAlign ( elementVariables . align )
113
+ colorPicker . value = elementVariables . colorText
114
+ colorHex . value = elementVariables . colorText
111
115
if ( translateElements ) {
112
- updateControlButton ( ElementVariables . status )
116
+ updateControlButton ( elementVariables . status )
113
117
}
114
118
} else {
115
119
console . log ( 'The server did not return valid data.' )
116
120
}
117
121
} else {
118
122
if ( message [ classElement ] . status !== 'started' ) {
119
123
textMsg . textContent = message [ classElement ] . msgEnd
124
+ if ( message [ classElement ] . msgEnd === '' ) {
125
+ textMsg . textContent = translateElements . timer . ph_msgend
126
+ textMsg . style . color = '#555'
127
+ } else { textMsg . style . color = '#000' }
120
128
timeText . value = MsToText ( message [ classElement ] . textmilliseconds )
121
129
formatSelector . value = message [ classElement ] . formatTime
122
130
fontSelect . value = message [ classElement ] . font
@@ -149,7 +157,7 @@ selectorLang.addEventListener('change', () => {
149
157
} )
150
158
151
159
controlButton . addEventListener ( 'click' , ( ) => {
152
- if ( controlButton . textContent === translateElements . crono . buttons . start ) {
160
+ if ( controlButton . textContent === translateElements . timer . buttons . start ) {
153
161
socket . send ( JSON . stringify ( { action : 'startCdown' , classElement } ) )
154
162
} else {
155
163
socket . send ( JSON . stringify ( { action : 'pauseCdown' , classElement } ) )
@@ -209,8 +217,19 @@ subContainer.addEventListener('click', (event) => {
209
217
}
210
218
} )
211
219
220
+ textMsg . addEventListener ( 'focus' , ( ) => {
221
+ if ( textMsg . textContent === translateElements . timer . ph_msgend ) {
222
+ textMsg . textContent = ''
223
+ textMsg . style . color = '#000'
224
+ }
225
+ } )
226
+
212
227
textMsg . addEventListener ( 'blur' , ( ) => {
213
228
socket . send ( JSON . stringify ( { action : 'editMsgCdown' , msg : textMsg . textContent , classElement } ) )
229
+ if ( textMsg . textContent === '' ) {
230
+ textMsg . textContent = translateElements . timer . ph_msgend
231
+ textMsg . style . color = '#555'
232
+ } else { textMsg . style . color = '#000' }
214
233
} )
215
234
216
235
formatSelector . addEventListener ( 'change' , ( ) => {
@@ -309,17 +328,17 @@ function updateControlButton (status) {
309
328
controlButton . style . width = maxWidth
310
329
311
330
if ( status === 'started' ) {
312
- controlButton . textContent = translateElements . crono . buttons . pause
331
+ controlButton . textContent = translateElements . timer . buttons . pause
313
332
} else {
314
- controlButton . textContent = translateElements . crono . buttons . start
333
+ controlButton . textContent = translateElements . timer . buttons . start
315
334
}
316
335
}
317
336
318
337
function getMaxButtonWidth ( ) {
319
338
const widths = [ ]
320
339
321
- Object . keys ( translateElements . crono . buttons ) . forEach ( ( value ) => {
322
- controlButton . textContent = translateElements . crono . buttons [ value ]
340
+ Object . keys ( translateElements . timer . buttons ) . forEach ( ( value ) => {
341
+ controlButton . textContent = translateElements . timer . buttons [ value ]
323
342
widths . push ( parseFloat ( window . getComputedStyle ( controlButton ) . getPropertyValue ( 'width' ) ) )
324
343
} )
325
344
// Get the maximum of the two widths
0 commit comments