Skip to content

Commit

Permalink
Update asset line-width to 100 instead of 80
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Metzner <[email protected]>
Signed-off-by: Daniel Metzner <[email protected]>
  • Loading branch information
dmetzner committed Aug 30, 2024
1 parent 95c5192 commit 6585c23
Show file tree
Hide file tree
Showing 53 changed files with 605 additions and 1,358 deletions.
8 changes: 1 addition & 7 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ globals:
SharedArrayBuffer: readonly
parserOptions:
ecmaVersion: 2020
rules:
{
'no-new': 0,
'comma-dangle': 0,
'space-before-function-paren': 0,
'indent': 0,
}
rules: { 'no-new': 0, 'comma-dangle': 0, 'space-before-function-paren': 0, 'indent': 0 }
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"singleQuote": true,
"semi": false
"semi": false,
"printWidth": 100
}
12 changes: 3 additions & 9 deletions assets/Admin/PieChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export class PieChart {

add(elementId, dataArray, title) {
if (!this.isLoaded) {
console.warn(
'Google Charts is not loaded yet, queuing the chart rendering.',
)
console.warn('Google Charts is not loaded yet, queuing the chart rendering.')
this.queue.push({ elementId, dataArray, title }) // Queue the request
return
}
Expand All @@ -31,18 +29,14 @@ export class PieChart {

drawChart(elementId, dataArray, title) {
// eslint-disable-next-line new-cap
const dataSpace = new GoogleCharts.api.visualization.arrayToDataTable(
dataArray,
)
const dataSpace = new GoogleCharts.api.visualization.arrayToDataTable(dataArray)
const optionsSpace = {
title,
is3D: true,
}

// eslint-disable-next-line new-cap
const chart = new GoogleCharts.api.visualization.PieChart(
document.getElementById(elementId),
)
const chart = new GoogleCharts.api.visualization.PieChart(document.getElementById(elementId))
chart.draw(dataSpace, optionsSpace)
}
}
6 changes: 1 addition & 5 deletions assets/Admin/SystemManagement/Maintain.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ import './Maintain.scss'
import { PieChart } from '../PieChart'

const pieChart = new PieChart()
pieChart.add(
'piechart_3d',
data_space_values,
'Disk Space (' + wholeSpace + ')',
)
pieChart.add('piechart_3d', data_space_values, 'Disk Space (' + wholeSpace + ')')
pieChart.add('piechart_3d_mem', data_mem_values, 'RAM (' + wholeRam + ')')
61 changes: 13 additions & 48 deletions assets/Api/ApiHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export class ApiFetch {
if (response.ok) {
return Promise.resolve(data)
} else {
const errorMessage =
'ERROR ' + response.status + ': ' + JSON.stringify(data)
const errorMessage = 'ERROR ' + response.status + ': ' + JSON.stringify(data)
return Promise.reject(new Error(errorMessage))
}
}
Expand All @@ -69,14 +68,10 @@ export class ApiPutFetch {
this.url = url
this.data = data
this.componentName = componentName
if (
typeof unspecifiedErrorText === 'string' &&
unspecifiedErrorText.length > 0
) {
if (typeof unspecifiedErrorText === 'string' && unspecifiedErrorText.length > 0) {
this.unspecifiedErrorText = unspecifiedErrorText
} else {
this.unspecifiedErrorText =
globalConfiguration.messages.unspecifiedErrorText
this.unspecifiedErrorText = globalConfiguration.messages.unspecifiedErrorText
}
this.successCallback = successCallback
this.otherErrorMessages = otherErrorMessages
Expand All @@ -95,13 +90,8 @@ export class ApiPutFetch {
break
case 401:
// Invalid credentials
console.error(
this.componentName + ' ERROR 401: Invalid credentials',
response,
)
MessageDialogs.showErrorMessage(
globalConfiguration.messages.authenticationErrorText,
)
console.error(this.componentName + ' ERROR 401: Invalid credentials', response)
MessageDialogs.showErrorMessage(globalConfiguration.messages.authenticationErrorText)
break
case 422:
response.json().then((errors) => {
Expand All @@ -110,16 +100,8 @@ export class ApiPutFetch {
})
break
default:
console.error(
this.componentName + ' ERROR ' + response.status,
response,
)
if (
Object.prototype.hasOwnProperty.call(
this.otherErrorMessages,
response.status,
)
) {
console.error(this.componentName + ' ERROR ' + response.status, response)
if (Object.prototype.hasOwnProperty.call(this.otherErrorMessages, response.status)) {
const errorHandler = this.otherErrorMessages[response.status]
if (typeof errorHandler === 'function') {
errorHandler(response)
Expand Down Expand Up @@ -154,14 +136,10 @@ export class ApiDeleteFetch {
) {
this.url = url
this.componentName = componentName
if (
typeof unspecifiedErrorText === 'string' &&
unspecifiedErrorText.length > 0
) {
if (typeof unspecifiedErrorText === 'string' && unspecifiedErrorText.length > 0) {
this.unspecifiedErrorText = unspecifiedErrorText
} else {
this.unspecifiedErrorText =
globalConfiguration.messages.unspecifiedErrorText
this.unspecifiedErrorText = globalConfiguration.messages.unspecifiedErrorText
}
this.successCallback = successCallback
this.otherErrorMessages = otherErrorMessages
Expand All @@ -180,25 +158,12 @@ export class ApiDeleteFetch {
break
case 401:
// Invalid credentials
console.error(
this.componentName + ' ERROR 401: Invalid credentials',
response,
)
MessageDialogs.showErrorMessage(
globalConfiguration.messages.authenticationErrorText,
)
console.error(this.componentName + ' ERROR 401: Invalid credentials', response)
MessageDialogs.showErrorMessage(globalConfiguration.messages.authenticationErrorText)
break
default:
console.error(
this.componentName + ' ERROR ' + response.status,
response,
)
if (
Object.prototype.hasOwnProperty.call(
this.otherErrorMessages,
response.status,
)
) {
console.error(this.componentName + ' ERROR ' + response.status, response)
if (Object.prototype.hasOwnProperty.call(this.otherErrorMessages, response.status)) {
const errorHandler = this.otherErrorMessages[response.status]
if (typeof errorHandler === 'function') {
errorHandler(response)
Expand Down
27 changes: 6 additions & 21 deletions assets/Api/CustomTranslationApi.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
export class CustomTranslationApi {
constructor(programSection) {
this.programSection =
programSection === 'credits' ? 'credit' : programSection
this.programSection = programSection === 'credits' ? 'credit' : programSection
}

async getCustomTranslation(
programId,
language,
successCallback,
errorCallback = () => {},
) {
async getCustomTranslation(programId, language, successCallback, errorCallback = () => {}) {
try {
const response = await fetch(
`../translate/custom/project/${programId}?field=${this.programSection}&language=${language}`,
Expand Down Expand Up @@ -51,13 +45,7 @@ export class CustomTranslationApi {
})
}

saveCustomTranslation(
programId,
text,
language,
successCallback,
errorCallback,
) {
saveCustomTranslation(programId, text, language, successCallback, errorCallback) {
const self = this
return new Promise((resolve, reject) => {
fetch(
Expand All @@ -82,12 +70,9 @@ export class CustomTranslationApi {

async getCustomTranslationLanguages(programId) {
try {
const response = await fetch(
`../translate/custom/project/${programId}/list`,
{
method: 'GET',
},
)
const response = await fetch(`../translate/custom/project/${programId}/list`, {
method: 'GET',
})

if (!response.ok) {
throw new Error(`Error: ${response.status}`)
Expand Down
4 changes: 1 addition & 3 deletions assets/Api/ProjectApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export default class ProjectApi {
MessageDialogs.showErrorMessage(data.error)
})
.catch(function () {
MessageDialogs.showErrorMessage(
globalConfiguration.messages.unspecifiedErrorText,
)
MessageDialogs.showErrorMessage(globalConfiguration.messages.unspecifiedErrorText)
})
},
},
Expand Down
3 changes: 1 addition & 2 deletions assets/Components/MessageDialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export default class MessageDialogs {

return Swal.fire({
title: globalConfiguration.messages.errorTitle,
html:
'<ul class="text-start"><li>' + errors.join('</li><li>') + '</li></ul>',
html: '<ul class="text-start"><li>' + errors.join('</li><li>') + '</li></ul>',
icon: 'error',
customClass: {
confirmButton: 'btn btn-primary',
Expand Down
4 changes: 1 addition & 3 deletions assets/Components/TextFillDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import TextFill from 'textfilljs'

export default function (container) {
const containerElem =
typeof container === 'string'
? document.querySelector(container)
: container
typeof container === 'string' ? document.querySelector(container) : container

if (!containerElem) {
console.error('Container element not found.')
Expand Down
16 changes: 4 additions & 12 deletions assets/Index/MaintenanceHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export class MaintenanceHandler {
initCloseButtons() {
const closeButtons = document.querySelectorAll('.close-button')
closeButtons.forEach((closeButton) => {
closeButton.addEventListener('click', () =>
this.handleCloseButtonClick(closeButton),
)
closeButton.addEventListener('click', () => this.handleCloseButtonClick(closeButton))
})
}

Expand Down Expand Up @@ -47,23 +45,17 @@ export class MaintenanceHandler {
initExpandButtons() {
const expandButtons = document.querySelectorAll('.expand-button')
expandButtons.forEach((expandButton) => {
expandButton.addEventListener('click', () =>
this.handleExpandButtonClick(expandButton),
)
expandButton.addEventListener('click', () => this.handleExpandButtonClick(expandButton))
})
}

// Handle expand button click event
handleExpandButtonClick(expandButton) {
const dataId = expandButton.getAttribute('data-id')
const additionalInfoSection = document.getElementById(
`additional-info-${dataId}`,
)
const additionalInfoSection = document.getElementById(`additional-info-${dataId}`)
if (additionalInfoSection) {
const isCurrentlyVisible = additionalInfoSection.style.display === 'block'
additionalInfoSection.style.display = isCurrentlyVisible
? 'none'
: 'block'
additionalInfoSection.style.display = isCurrentlyVisible ? 'none' : 'block'
expandButton.classList.toggle('expanded')
}
}
Expand Down
14 changes: 5 additions & 9 deletions assets/Layout/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ if (bugsnagApiKey) {
BugsnagPerformance.start({ apiKey: bugsnagApiKey, appVersion })
}

const gtmContainerId =
document.getElementById('gtm-container-id').dataset.gtmContainerId
const gtmContainerId = document.getElementById('gtm-container-id').dataset.gtmContainerId
if (gtmContainerId) {
const analytics = Analytics({
app: 'share.catrob.at',
Expand All @@ -60,8 +59,7 @@ document.addEventListener('DOMContentLoaded', () => {
})

function showFlashSnackbar() {
const snackbarFlashMessages =
document.getElementsByClassName('js-flash-snackbar')
const snackbarFlashMessages = document.getElementsByClassName('js-flash-snackbar')
Array.from(snackbarFlashMessages).forEach((jsMsgObj) => {
showSnackbar('#share-snackbar', jsMsgObj.dataset.msg)
})
Expand All @@ -70,11 +68,9 @@ function showFlashSnackbar() {
function fitHeadingFontSizeToAvailableWidth() {
// Adjust heading font size or break word
;['h1', '.h1', 'h2', '.h2', 'h3', '.h3'].forEach(function (element) {
document
.querySelectorAll(element + ':not(.no-textfill)')
.forEach(function (el) {
textFillDefault(el)
})
document.querySelectorAll(element + ':not(.no-textfill)').forEach(function (el) {
textFillDefault(el)
})
})
}

Expand Down
29 changes: 6 additions & 23 deletions assets/Layout/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import './Sidebar.scss'
const sidebar = document.getElementById('sidebar')
const sidebarJs = document.querySelector('.js-sidebar')

const sidebarToggleBtn = document.getElementById(
'top-app-bar__btn-sidebar-toggle',
)
const sidebarToggleBtn = document.getElementById('top-app-bar__btn-sidebar-toggle')

document.addEventListener('DOMContentLoaded', () => {
initSidebarBadges()
Expand All @@ -16,9 +14,7 @@ document.addEventListener('DOMContentLoaded', () => {
})

function initSidebarBadges() {
if (
document.querySelector('.js-user-state').dataset.isUserLoggedIn === 'true'
) {
if (document.querySelector('.js-user-state').dataset.isUserLoggedIn === 'true') {
updateBadge(
sidebarJs.dataset.baseUrl + '/api/notifications/count',
'sidebar_badge--unseen-notifications',
Expand Down Expand Up @@ -53,10 +49,7 @@ function updateBadge(
const count = apiToCall === 'new' ? data.total : data.count
if (count > 0) {
if (badgeText === null) {
badge.innerHTML =
count <= maxAmountToFetch
? count.toString()
: maxAmountToFetch + '+'
badge.innerHTML = count <= maxAmountToFetch ? count.toString() : maxAmountToFetch + '+'
} else {
badge.innerHTML = badgeText
}
Expand Down Expand Up @@ -129,9 +122,7 @@ function setClickListener() {
}
})

document
.getElementById('sidebar-overlay')
.addEventListener('click', fnCloseSidebar)
document.getElementById('sidebar-overlay').addEventListener('click', fnCloseSidebar)
}

function initSidebarSwipe() {
Expand Down Expand Up @@ -215,12 +206,7 @@ function initSidebarSwipe() {
})

document.addEventListener('touchend', function (e) {
if (
e.changedTouches.length === 1 &&
(closing || opening) &&
!!curX &&
startTime
) {
if (e.changedTouches.length === 1 && (closing || opening) && !!curX && startTime) {
const touchX = e.changedTouches[0].pageX
const touchY = e.changedTouches[0].pageY
const timeDiff = Date.now() - startTime
Expand Down Expand Up @@ -287,10 +273,7 @@ document.addEventListener('DOMContentLoaded', function () {
const languageMenuOverlay = document.querySelector('.language-body-overlay')

languageButton.addEventListener('click', function () {
if (
languageMenu.style.display === 'none' ||
languageMenu.style.display === ''
) {
if (languageMenu.style.display === 'none' || languageMenu.style.display === '') {
languageMenu.style.display = 'block'
languageMenuOverlay.style.display = 'block'
document.body.style.overflow = 'hidden'
Expand Down
Loading

0 comments on commit 6585c23

Please sign in to comment.