diff --git a/core/client.js b/core/client.js index cb1bfed..5c6d9df 100644 --- a/core/client.js +++ b/core/client.js @@ -39,7 +39,7 @@ socket.addEventListener('message', (event) => { // Configuration and translation switchTheme.checked = message.config.themeDark - buttonClose.title = translateElements.home.close + buttonClose.title = translateElements.home.close || 'n/a' textVersion.textContent = message.config.version if (message.config.version !== 'Error' && message.config.versionRelease !== 'Error' && compareVersions(message.config.version, message.config.versionRelease) === 1) { const link = document.createElement('a') @@ -48,12 +48,12 @@ socket.addEventListener('message', (event) => { link.id = 'link-newVersion' const button = document.createElement('button') button.className = 'button-versionRelease' - button.title = translateElements.home.newVersionTitle - button.textContent = translateElements.home.newVersion + message.config.versionRelease + button.title = translateElements.home.newVersionTitle || 'n/a' + button.textContent = (translateElements.home.newVersion || 'n/a') + (message.config.versionRelease || 'n/a') link.appendChild(button) leftButtons.appendChild(link) } - buttonWiki.title = translateElements.home.wiki + buttonWiki.title = translateElements.home.wiki || 'n/a' if (message.config.themeDark) { document.body.classList.remove('light-theme') document.body.classList.add('dark-theme') @@ -76,11 +76,11 @@ socket.addEventListener('message', (event) => { ? message.config.lang : 'en' - titleCrono.textContent = translateElements.home.cronoTitle - titleCdown.textContent = translateElements.home.cdownTitle - titleCdowntime.textContent = translateElements.home.cdowntimeTitle - titleExtensible.textContent = translateElements.home.extensibleTitle - titleTime.textContent = translateElements.home.timeTitle + titleCrono.textContent = translateElements.home.cronoTitle || 'n/a' + titleCdown.textContent = translateElements.home.cdownTitle || 'n/a' + titleCdowntime.textContent = translateElements.home.cdowntimeTitle || 'n/a' + titleExtensible.textContent = translateElements.home.extensibleTitle || 'n/a' + titleTime.textContent = translateElements.home.timeTitle || 'n/a' if (elementVariables && typeof elementVariables === 'object') { // console.log('Variables loaded from the server.') @@ -148,7 +148,7 @@ buttonContainer.addEventListener('click', (event) => { copyTextToClipboard(copyText) // Display a notification message - showNotification(translateElements.home.notycopy, button) + showNotification(translateElements.home.notycopy || 'n/a', button) } } else if (data[1] === 'copyButtonCrono') { // Get the text to copy from the "data-copy-text" attribute @@ -158,7 +158,7 @@ buttonContainer.addEventListener('click', (event) => { copyTextToClipboard(copyText) // Display a notification message - showNotification(translateElements.home.notycopy, button) + showNotification(translateElements.home.notycopy || 'n/a', button) } } else if (data[1] === 'copyButtonCdown') { // Get the text to copy from the "data-copy-text" attribute @@ -168,7 +168,7 @@ buttonContainer.addEventListener('click', (event) => { copyTextToClipboard(copyText) // Display a notification message - showNotification(translateElements.home.notycopy, button) + showNotification(translateElements.home.notycopy || 'n/a', button) } } else if (data[1] === 'removeButton') { socket.send(JSON.stringify({ action: 'removeData', remove: data[0] })) diff --git a/core/template/cdown/control/control.js b/core/template/cdown/control/control.js index 13ac834..61ccf72 100644 --- a/core/template/cdown/control/control.js +++ b/core/template/cdown/control/control.js @@ -82,8 +82,8 @@ socket.addEventListener('message', (event) => { ? message.config.lang : 'en' - controlButton.textContent = translateElements.timer.buttons.start - resetButton.textContent = translateElements.timer.buttons.reset + controlButton.textContent = translateElements.timer.buttons.start || 'n/a' + resetButton.textContent = translateElements.timer.buttons.reset || 'n/a' if (elementVariables && typeof elementVariables === 'object') { checkTextTime = MsToText(elementVariables.textMilliseconds) @@ -101,7 +101,7 @@ socket.addEventListener('message', (event) => { // Perform necessary actions with the variables here textMsg.textContent = elementVariables.msgEnd if (elementVariables.msgEnd === '') { - textMsg.textContent = translateElements.timer.phMsgEnd + textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a' textMsg.style.color = '#555' } else { textMsg.style.color = '#000' } timeText.value = MsToText(elementVariables.textMilliseconds) @@ -122,7 +122,7 @@ socket.addEventListener('message', (event) => { if (message[classElement].status !== 'started') { textMsg.textContent = message[classElement].msgEnd if (message[classElement].msgEnd === '') { - textMsg.textContent = translateElements.timer.phMsgEnd + textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a' textMsg.style.color = '#555' } else { textMsg.style.color = '#000' } timeText.value = MsToText(message[classElement].textMilliseconds) @@ -157,7 +157,7 @@ selectorLang.addEventListener('change', () => { }) controlButton.addEventListener('click', () => { - if (controlButton.textContent === translateElements.timer.buttons.start) { + if (controlButton.textContent === translateElements.timer.buttons.start || 'n/a') { socket.send(JSON.stringify({ action: 'startTimer', classElement })) } else { socket.send(JSON.stringify({ action: 'pauseCdown', classElement })) @@ -218,7 +218,7 @@ subContainer.addEventListener('click', (event) => { }) textMsg.addEventListener('focus', () => { - if (textMsg.textContent === translateElements.timer.phMsgEnd) { + if (textMsg.textContent === translateElements.timer.phMsgEnd || 'n/a') { textMsg.textContent = '' textMsg.style.color = '#000' } @@ -227,7 +227,7 @@ textMsg.addEventListener('focus', () => { textMsg.addEventListener('blur', () => { socket.send(JSON.stringify({ action: 'editMsg', msg: textMsg.textContent, classElement })) if (textMsg.textContent === '') { - textMsg.textContent = translateElements.timer.phMsgEnd + textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a' textMsg.style.color = '#555' } else { textMsg.style.color = '#000' } }) @@ -328,9 +328,9 @@ function updateControlButton (status) { controlButton.style.width = maxWidth if (status === 'started') { - controlButton.textContent = translateElements.timer.buttons.pause + controlButton.textContent = translateElements.timer.buttons.pause || 'n/a' } else { - controlButton.textContent = translateElements.timer.buttons.start + controlButton.textContent = translateElements.timer.buttons.start || 'n/a' } } @@ -338,7 +338,7 @@ function getMaxButtonWidth () { const widths = [] Object.keys(translateElements.timer.buttons).forEach((value) => { - controlButton.textContent = translateElements.timer.buttons[value] + controlButton.textContent = translateElements.timer.buttons[value] || 'n/a' widths.push(parseFloat(window.getComputedStyle(controlButton).getPropertyValue('width'))) }) // Get the maximum of the two widths diff --git a/core/template/cdowntime/control/control.js b/core/template/cdowntime/control/control.js index 621070f..042eaa5 100644 --- a/core/template/cdowntime/control/control.js +++ b/core/template/cdowntime/control/control.js @@ -107,7 +107,7 @@ socket.addEventListener('message', (event) => { // Perform necessary actions with the variables here textMsg.textContent = elementVariables.msgEnd if (elementVariables.msgEnd === '') { - textMsg.textContent = translateElements.timer.phMsgEnd + textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a' textMsg.style.color = '#555' } else { textMsg.style.color = '#000' } timeData.value = new Date(elementVariables.endDatetime).toLocaleString('en-CA', { timeZone: elementVariables.timezone, hour12: false }).replace(/,\s/, 'T') @@ -189,7 +189,7 @@ subContainer.addEventListener('click', (event) => { }) textMsg.addEventListener('focus', () => { - if (textMsg.textContent === translateElements.timer.phMsgEnd) { + if (textMsg.textContent === translateElements.timer.phMsgEnd || 'n/a') { textMsg.textContent = '' textMsg.style.color = '#000' } @@ -198,7 +198,7 @@ textMsg.addEventListener('focus', () => { textMsg.addEventListener('blur', () => { socket.send(JSON.stringify({ action: 'editMsg', msg: textMsg.textContent, classElement })) if (textMsg.textContent === '') { - textMsg.textContent = translateElements.timer.phMsgEnd + textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a' textMsg.style.color = '#555' } else { textMsg.style.color = '#000' } }) diff --git a/core/template/crono/control/control.js b/core/template/crono/control/control.js index ea78d3f..ac832e3 100644 --- a/core/template/crono/control/control.js +++ b/core/template/crono/control/control.js @@ -80,8 +80,8 @@ socket.addEventListener('message', (event) => { ? message.config.lang : 'en' - controlButton.textContent = translateElements.timer.buttons.start - resetButton.textContent = translateElements.timer.buttons.reset + controlButton.textContent = translateElements.timer.buttons.start || 'n/a' + resetButton.textContent = translateElements.timer.buttons.reset || 'n/a' if (elementVariables && typeof elementVariables === 'object') { checkHexColor = elementVariables.colorText @@ -139,7 +139,7 @@ languageSelector.addEventListener('change', () => { }) controlButton.addEventListener('click', () => { - if (controlButton.textContent === translateElements.timer.buttons.start) { + if (controlButton.textContent === translateElements.timer.buttons.start || 'n/a') { socket.send(JSON.stringify({ action: 'startTimer', classElement })) } else { socket.send(JSON.stringify({ action: 'pauseCrono', classElement })) @@ -265,9 +265,9 @@ function updateControlButton (status) { controlButton.style.width = maxWidth if (status === 'started') { - controlButton.textContent = translateElements.timer.buttons.pause + controlButton.textContent = translateElements.timer.buttons.pause || 'n/a' } else { - controlButton.textContent = translateElements.timer.buttons.start + controlButton.textContent = translateElements.timer.buttons.start || 'n/a' } } @@ -275,7 +275,7 @@ function getMaxButtonWidth () { const widths = [] Object.keys(translateElements.timer.buttons).forEach((value) => { - controlButton.textContent = translateElements.timer.buttons[value] + controlButton.textContent = translateElements.timer.buttons[value] || 'n/a' widths.push(parseFloat(window.getComputedStyle(controlButton).getPropertyValue('width'))) }) diff --git a/core/template/extensible/control/control.js b/core/template/extensible/control/control.js index a147b05..a9e277d 100644 --- a/core/template/extensible/control/control.js +++ b/core/template/extensible/control/control.js @@ -87,10 +87,10 @@ socket.addEventListener('message', (event) => { ? message.config.lang : 'en' - controlButton.textContent = translateElements.timer.buttons.start - resetButton.textContent = translateElements.timer.buttons.reset - checkboxLabelStopAdd.textContent = translateElements.timer.enableStopAdd - checkboxLabelPauseAdd.textContent = translateElements.timer.enablePauseAdd + controlButton.textContent = translateElements.timer.buttons.start || 'n/a' + resetButton.textContent = translateElements.timer.buttons.reset || 'n/a' + checkboxLabelStopAdd.textContent = translateElements.timer.enableStopAdd || 'n/a' + checkboxLabelPauseAdd.textContent = translateElements.timer.enablePauseAdd || 'n/a' if (elementVariables && typeof elementVariables === 'object') { checkTextTime = MsToText(elementVariables.textMilliseconds) @@ -116,7 +116,7 @@ socket.addEventListener('message', (event) => { // Perform necessary actions with the variables here textMsg.textContent = elementVariables.msgEnd if (elementVariables.msgEnd === '') { - textMsg.textContent = translateElements.timer.phMsgEnd + textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a' textMsg.style.color = '#555' } else { textMsg.style.color = '#000' } timeText.value = MsToText(elementVariables.textMilliseconds) @@ -140,7 +140,7 @@ socket.addEventListener('message', (event) => { if (message[classElement].status !== 'started') { textMsg.textContent = message[classElement].msgEnd if (message[classElement].msgEnd === '') { - textMsg.textContent = translateElements.timer.phMsgEnd + textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a' textMsg.style.color = '#555' } else { textMsg.style.color = '#000' } timeText.value = MsToText(message[classElement].textMilliseconds) @@ -179,7 +179,7 @@ selectorLang.addEventListener('change', () => { }) controlButton.addEventListener('click', () => { - if (controlButton.textContent === translateElements.timer.buttons.start) { + if (controlButton.textContent === translateElements.timer.buttons.start || 'n/a') { socket.send(JSON.stringify({ action: 'startTimer', classElement })) } else { socket.send(JSON.stringify({ action: 'pauseExtensible', classElement })) @@ -248,7 +248,7 @@ checkboxPauseAdd.addEventListener('change', () => { }) textMsg.addEventListener('focus', () => { - if (textMsg.textContent === translateElements.timer.phMsgEnd) { + if (textMsg.textContent === translateElements.timer.phMsgEnd || 'n/a') { textMsg.textContent = '' textMsg.style.color = '#000' } @@ -257,7 +257,7 @@ textMsg.addEventListener('focus', () => { textMsg.addEventListener('blur', () => { socket.send(JSON.stringify({ action: 'editMsg', msg: textMsg.textContent, classElement })) if (textMsg.textContent === '') { - textMsg.textContent = translateElements.timer.phMsgEnd + textMsg.textContent = translateElements.timer.phMsgEnd || 'n/a' textMsg.style.color = '#555' } else { textMsg.style.color = '#000' } }) @@ -362,9 +362,9 @@ function updateControlButton (status) { controlButton.style.width = maxWidth if (status === 'started') { - controlButton.textContent = translateElements.timer.buttons.pause + controlButton.textContent = translateElements.timer.buttons.pause || 'n/a' } else { - controlButton.textContent = translateElements.timer.buttons.start + controlButton.textContent = translateElements.timer.buttons.start || 'n/a' } } @@ -372,7 +372,7 @@ function getMaxButtonWidth () { const widths = [] Object.keys(translateElements.timer.buttons).forEach((value) => { - controlButton.textContent = translateElements.timer.buttons[value] + controlButton.textContent = translateElements.timer.buttons[value] || 'n/a' widths.push(parseFloat(window.getComputedStyle(controlButton).getPropertyValue('width'))) }) // Get the maximum of the two widths