From f207a46e8ed6c8da6994e9adeafe753f6c470501 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 7 Sep 2024 18:38:47 +0200 Subject: [PATCH] Prefer `const` over `let` --- eslint.config.mjs | 1 + htdocs/cahier/cahier.js | 78 ++++++------ htdocs/cahier/methods.js | 79 +++++++------ htdocs/cahier/pop-booking.js | 86 +++++++------- htdocs/cahier/top-list.js | 10 +- htdocs/cahier/top.js | 14 +-- htdocs/equipment/categories.js | 16 +-- htdocs/equipment/choice.js | 14 +-- htdocs/equipment/elements.js | 32 ++--- htdocs/equipment/pop-bookable-history.js | 89 +++++++------- htdocs/equipment/pop-bookable.js | 24 ++-- htdocs/general/home.js | 56 ++++----- htdocs/general/pop-alert.js | 144 +++++++++++------------ htdocs/general/screen.js | 6 +- htdocs/general/server-requests.js | 132 ++++++++++----------- htdocs/infos/infos.js | 14 +-- htdocs/infos/pop-infos.js | 33 +++--- htdocs/member/login.js | 13 +- htdocs/member/user.js | 33 +++--- htdocs/page/bottom.js | 14 +-- htdocs/page/pop-stats.js | 59 +++++----- htdocs/page/top.js | 7 +- live-server.js | 2 +- 23 files changed, 474 insertions(+), 482 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 6dc8d9e..f2df12f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -8,6 +8,7 @@ export default [ rules: { 'no-var': 'error', 'no-unexpected-multiline': 'off', // Prettier disagrees + 'prefer-const': 'error', }, }, ]; diff --git a/htdocs/cahier/cahier.js b/htdocs/cahier/cahier.js index 420af72..fb1aa7d 100644 --- a/htdocs/cahier/cahier.js +++ b/htdocs/cahier/cahier.js @@ -21,7 +21,7 @@ export function loadActualBookings(_actualBookings) { $('divTabCahierTableActualBookings').previousElementSibling.title = bookableNbr + ' embarcations, ' + participantNbr + ' personnes'; - let children = $('divTabCahierTables').children; + const children = $('divTabCahierTables').children; for (let j = 0; j < children.length; j++) { if ( children[j].id != 'divTabCahierTableActualBookings' && @@ -52,7 +52,7 @@ function coloring(booking) { } function actualizeActualBookings(_actualBookings) { - let all = $('divTabCahierTableActualBookings').getElementsByClassName('TableEntries'); + const all = $('divTabCahierTableActualBookings').getElementsByClassName('TableEntries'); for (let i = 0; i < all.length; i++) { if (all[i].id != 'divTabCahierTableActualBookingsTopBar') { all[i].parentNode.removeChild(all[i]); @@ -61,14 +61,14 @@ function actualizeActualBookings(_actualBookings) { } if (_actualBookings.length == 0) { - let entry = div($('divTabCahierTableActualBookings')); + const entry = div($('divTabCahierTableActualBookings')); entry.classList.add('TableEntries'); entry.classList.add('TableEntriesHover'); div(entry); } for (let j = 0; j < _actualBookings.length; j++) { - let container = div($('divTabCahierTableActualBookings')); + const container = div($('divTabCahierTableActualBookings')); container.id = j; container.classList.add('TableEntries'); container.classList.add('TableEntriesHover'); @@ -96,11 +96,11 @@ function actualizeActualBookings(_actualBookings) { } }); - let divDate = div(container); + const divDate = div(container); - let maxHours = 24; + const maxHours = 24; if (Date.now() - new Date(_actualBookings[j].startDate).getTime() > (maxHours / 6) * 60 * 60 * 1000) { - let d = div(divDate); + const d = div(divDate); d.classList.add('TableEntriesAlert'); d.style.filter = 'grayscale(1) invert(1)'; d.title = '+ de 4 heures'; @@ -123,7 +123,7 @@ function actualizeActualBookings(_actualBookings) { divDate.id = 'SORTING' + new Date(_actualBookings[j].startDate).toISOString(); // for the sorting divDate.innerHTML += new Date(_actualBookings[j].startDate).getNiceTime(':', true); - let participantCount = div(container); + const participantCount = div(container); participantCount.innerHTML = _actualBookings[j].participantCount; participantCount.title = Cahier.getSingularOrPlural(_actualBookings[j].participantCount); @@ -132,7 +132,7 @@ function actualizeActualBookings(_actualBookings) { if (_actualBookings[j].bookables.length == 0) { createBookingBookableBox(div(container)); } else { - let c = div(container); + const c = div(container); for (let k = 0; k < _actualBookings[j].bookables.length; k++) { createBookingBookableBox(c, _actualBookings[j].bookables[k]); } @@ -142,9 +142,9 @@ function actualizeActualBookings(_actualBookings) { div(container).innerHTML = getStartCommentFromBooking(_actualBookings[j]).shorten(200, 16); - let d = div(container); + const d = div(container); d.title = 'Terminer ou modifier cette sortie'; - let btn = div(d); + const btn = div(d); btn.classList.add('Buttons'); } sortTable($('divTabCahierTableActualBookings')); @@ -153,11 +153,11 @@ function actualizeActualBookings(_actualBookings) { // new search system export function bookingTableSearch(_table) { let bookings; - let txts = _table.previousElementSibling.previousElementSibling.value.split(' '); + const txts = _table.previousElementSibling.previousElementSibling.value.split(' '); // means finishedBookings if (_table != $('divTabCahierTableActualBookings')) { let i; - let all = document.getElementsByClassName('BookingsTable'); + const all = document.getElementsByClassName('BookingsTable'); for (i = 1; i < all.length; i++) { if (all[i] == _table) { break; @@ -168,7 +168,7 @@ export function bookingTableSearch(_table) { // means actualBookings bookings = Cahier.actualBookings; } - let result = []; + const result = []; for (let t = 0; t < txts.length; t++) { result[t] = []; @@ -208,7 +208,7 @@ export function bookingTableSearch(_table) { } // merge but only take the bookings which are in every search result ! - let send = result.mergeAND(); + const send = result.mergeAND(); if (_table == $('divTabCahierTableActualBookings')) { actualizeActualBookings(send); } else { @@ -217,15 +217,15 @@ export function bookingTableSearch(_table) { } function createBookingBookableBox(elem, bookable = {code: 'ZZZ'}) { - let d = div(elem); + const d = div(elem); if (bookable.code != null) { d.id = bookable.code; } else { d.id = '999'; } - let img = div(d); - let code = div(d); + const img = div(d); + const code = div(d); if (bookable == Cahier.personalBookable) { img.style.backgroundImage = 'url(img/icons/own-sail.png)'; @@ -245,7 +245,7 @@ function createBookingBookableBox(elem, bookable = {code: 'ZZZ'}) { if (bookable.code != null) { code.innerHTML = bookable.code; - let codeLength = bookable.code.pixelLength(20); + const codeLength = bookable.code.pixelLength(20); div(d).innerHTML = bookable.name.shorten(170 - codeLength, 18); } else { code.innerHTML = ''; @@ -257,8 +257,8 @@ function createBookingBookableBox(elem, bookable = {code: 'ZZZ'}) { export function loadTableTopBars(allTables = document.getElementsByClassName('BookingsTable')) { for (let u = 0; u < allTables.length; u++) { - let table = allTables[u]; - let top = table.getElementsByClassName('TableTopBar')[0]; + const table = allTables[u]; + const top = table.getElementsByClassName('TableTopBar')[0]; const all = top.getElementsByTagName('div'); for (let i = 0; i < all.length; i = i + 2) { @@ -277,7 +277,7 @@ export function loadTableTopBars(allTables = document.getElementsByClassName('Bo this.getElementsByTagName('div')[0].style.backgroundImage = 'url(img/icons/sort-desc.png)'; } - let allButtons = this.parentElement.getElementsByTagName('div'); + const allButtons = this.parentElement.getElementsByTagName('div'); for (let k = 0; k < all.length; k = k + 2) { if (allButtons[k] != this) { allButtons[k].classList.remove('BookingsTopBarSorted'); @@ -295,8 +295,8 @@ export function loadTableTopBars(allTables = document.getElementsByClassName('Bo } function sortTable(table) { - let field = parseInt(table.getElementsByClassName('BookingsTopBarSorted')[0].id); - let order = function () { + const field = parseInt(table.getElementsByClassName('BookingsTopBarSorted')[0].id); + const order = function () { if ( table.getElementsByClassName('BookingsTopBarSorted')[0].getElementsByTagName('div')[0].style .backgroundImage == 'url("img/icons/sort-desc.png")' @@ -307,7 +307,7 @@ function sortTable(table) { } }; - let all = table.getElementsByClassName('TableEntries'); + const all = table.getElementsByClassName('TableEntries'); let switching = true; while (switching) { switching = false; @@ -343,32 +343,32 @@ export function newBookingTable(date, title = '?') { } export function createBookingsTable(date, title) { - let input = document.createElement('input'); + const input = document.createElement('input'); input.type = 'text'; input.value = ''; input.spellcheck = false; input.placeholder = 'Rechercher'; $('divTabCahierTables').appendChild(input); - let t = div($('divTabCahierTables')); + const t = div($('divTabCahierTables')); t.classList.add('BookingsTableText'); if (title == '?') { title = date.getNiceDate(); } t.innerHTML = title; - let table = div($('divTabCahierTables')); + const table = div($('divTabCahierTables')); input.onkeyup = function () { bookingTableSearch(table); }; table.id = date.toISOString(); table.classList.add('BookingsTable'); - let topBar = div(table); + const topBar = div(table); topBar.classList.add('TableEntries'); topBar.classList.add('TableTopBar'); - let fields = [ + const fields = [ '', '', '', @@ -378,7 +378,7 @@ export function createBookingsTable(date, title) { 'Commentaire de départ', "Commentaire d'arrivée", ]; - let images = [ + const images = [ 'icons/start', 'icons/end', 'icons/participant-count', @@ -390,10 +390,10 @@ export function createBookingsTable(date, title) { ]; for (let i = 0; i < fields.length; i++) { - let d = div(topBar); + const d = div(topBar); d.id = i; div(d); - let img = document.createElement('img'); + const img = document.createElement('img'); img.src = 'img/' + images[i] + '.png'; img.alt = '?'; d.appendChild(img); @@ -402,7 +402,7 @@ export function createBookingsTable(date, title) { topBar.getElementsByTagName('div')[0].classList.add('BookingsTopBarSorted'); - let b = div(table); + const b = div(table); b.style.position = 'absolute'; b.style.width = '100%'; b.style.height = '2px'; @@ -415,13 +415,13 @@ export function createBookingsTable(date, title) { } export function createNoBookingMessage(date) { - let t = div($('divTabCahierTables')); + const t = div($('divTabCahierTables')); t.classList.add('BookingsTableTextNoBooking'); t.innerHTML = 'Aucune sortie le ' + date.getNiceDate(); } export function actualizeFinishedBookingListForDay(bookings, table) { - let all = table.getElementsByClassName('TableEntries'); + const all = table.getElementsByClassName('TableEntries'); for (let i = 0; i < all.length; i++) { if (all[i].classList.contains('TableTopBar') === false) { all[i].parentNode.removeChild(all[i]); @@ -438,13 +438,13 @@ export function actualizeFinishedBookingListForDay(bookings, table) { table.previousElementSibling.title = bookableNbr + ' embarcations, ' + participantNbr + ' personnes'; if (bookings.length === 0) { - let ent = div(table); + const ent = div(table); ent.classList.add('TableEntries'); ent.classList.add('TableEntriesHover'); div(ent); } else { for (let i = 0; i < bookings.length; i++) { - let entry = div(table); + const entry = div(table); entry.id = i; entry.classList.add('TableEntries'); entry.classList.add('TableEntriesHover'); @@ -471,7 +471,7 @@ export function actualizeFinishedBookingListForDay(bookings, table) { if (bookings[i].bookables.length === 0) { createBookingBookableBox(div(entry)); } else { - let c = div(entry); + const c = div(entry); for (let k = 0; k < bookings[i].bookables.length; k++) { createBookingBookableBox(c, bookings[i].bookables[k]); } diff --git a/htdocs/cahier/methods.js b/htdocs/cahier/methods.js index 77b0ed1..53775df 100644 --- a/htdocs/cahier/methods.js +++ b/htdocs/cahier/methods.js @@ -101,7 +101,7 @@ export const Cahier = { // cancel - clearData cancel: function () { // #divCahierInfos - let allTabCahierFields = document.getElementsByClassName('TabCahierFields'); + const allTabCahierFields = document.getElementsByClassName('TabCahierFields'); for (let i = 0; i < allTabCahierFields.length - 1; i++) { // -1 POUR EVITER LA TEXTAREA @@ -172,11 +172,11 @@ export const Cahier = { ); } else { // licences check - for (let bookable of Cahier.bookings[0].bookables) { + for (const bookable of Cahier.bookings[0].bookables) { if (bookable.licenses != undefined) { - for (let license of bookable.licenses) { + for (const license of bookable.licenses) { let foundLicense = false; - for (let ownerLicense of Cahier.bookings[0].owner.licenses) { + for (const ownerLicense of Cahier.bookings[0].owner.licenses) { if (ownerLicense.id == license.id) { foundLicense = true; } @@ -200,22 +200,22 @@ export const Cahier = { // receive bookings that are still using the bookables and those who have been terminated in the last minutes // the bookings that will have to be terminated before creating the actual booking - let bookingsIdToFinish = []; + const bookingsIdToFinish = []; // find all the bookables that are now unavailable - let bAreNotAvailable = []; + const bAreNotAvailable = []; for (let i = 0; i < _bookings.length; i++) { if (_bookings[i].endDate == null) { // check which bookables are being used - let bookableElement = Object.assign({}, _bookings[i].bookable); + const bookableElement = Object.assign({}, _bookings[i].bookable); bookableElement.lastBooking = _bookings[i].clone(); bAreNotAvailable.push(bookableElement); // bookingsIdToFinish.push(_bookings[i].id); } } - let isNowAvailable = function (_bookable) { + const isNowAvailable = function (_bookable) { if (_bookable.id == 0) return true; // matériel personnel - for (let bNotAvailable of bAreNotAvailable) { + for (const bNotAvailable of bAreNotAvailable) { if (bNotAvailable.id == _bookable.id) { return false; } @@ -223,8 +223,8 @@ export const Cahier = { return true; }; // get the owner of the last booking that isn't finished yet - let getLastBooking = function (_bookable) { - for (let bNotAvailable of bAreNotAvailable) { + const getLastBooking = function (_bookable) { + for (const bNotAvailable of bAreNotAvailable) { if (bNotAvailable.id == _bookable.id) { return bNotAvailable.lastBooking; } @@ -232,10 +232,10 @@ export const Cahier = { return false; }; - let bookablesHaveJustBeenBooked = []; // or have changed owner ! + const bookablesHaveJustBeenBooked = []; // or have changed owner ! // loop through all the chosen bookables - for (let bookable of Cahier.bookings[0].bookables) { + for (const bookable of Cahier.bookings[0].bookables) { // the bookable is supposed to be unavailable if (bookable.available == false) { // but is now available ! @@ -247,14 +247,14 @@ export const Cahier = { } // and is still unavailable else { - let itsLastBooking = getLastBooking(bookable); + const itsLastBooking = getLastBooking(bookable); if (itsLastBooking.owner.id == bookable.lastBooking.owner.id) { // console.log("owner hasn't changed"); bookingsIdToFinish.push(bookable.lastBooking.id); } else { // console.log("owner has changed !"); Cahier.actualizeAvailability(bookable.id, [itsLastBooking]); // has changed owner - let bookableElement = bookable.clone(); + const bookableElement = bookable.clone(); bookableElement.lastBooking = itsLastBooking.clone(); bookablesHaveJustBeenBooked.push(bookableElement); } @@ -269,20 +269,20 @@ export const Cahier = { // but isn't available anymore, so has just been booked (or is in edit mode) ! else { // console.log("has just been booked !"); - let itsLastBooking = getLastBooking(bookable); + const itsLastBooking = getLastBooking(bookable); // 1.4 // not in edit mode, so someone has just booked the bookable, will make an alert if (Cahier.bookings[0].currentlyEditing == undefined) { Cahier.actualizeAvailability(bookable.id, [itsLastBooking]); // has changed owner - let bookableElement = bookable.clone(); + const bookableElement = bookable.clone(); bookableElement.lastBooking = itsLastBooking.clone(); bookablesHaveJustBeenBooked.push(bookableElement); } // was in edit mode else { let bookableWasInTheEditedBooking = false; - for (let id of Cahier.editedBooking.ids) { + for (const id of Cahier.editedBooking.ids) { if (itsLastBooking.id == id) { bookableWasInTheEditedBooking = true; break; @@ -297,7 +297,7 @@ export const Cahier = { // someone has indeed just booked the bookable, will make an alert else { Cahier.actualizeAvailability(bookable.id, [itsLastBooking]); // has changed owner - let bookableElement = bookable.clone(); + const bookableElement = bookable.clone(); bookableElement.lastBooking = itsLastBooking.clone(); bookablesHaveJustBeenBooked.push(bookableElement); // console.log("indeed someone has booked it!"); @@ -336,16 +336,16 @@ export const Cahier = { let idsToUpdate = []; let inputsToUpdate = []; - let currentDate = new Date().toISOString(); - let bookingsInputs = Requests.getServerInputsForBookingCreating(Cahier.bookings[0], currentDate); + const currentDate = new Date().toISOString(); + const bookingsInputs = Requests.getServerInputsForBookingCreating(Cahier.bookings[0], currentDate); // If >0: more bookables than before --> need to create some new // If <0: less bookable than before -->, need to delete some - let nBookablesDifference = Cahier.bookings[0].bookables.length - Cahier.editedBooking.ids.length; + const nBookablesDifference = Cahier.bookings[0].bookables.length - Cahier.editedBooking.ids.length; // Strictly fewer bookables as the (old) original booking --> Need to finish/delete a few bookings if (nBookablesDifference < 0) { - let nBookingsToFinish = -nBookablesDifference; + const nBookingsToFinish = -nBookablesDifference; // ToFinish // idsToFinish = Cahier.editedBooking.ids.slice(-nBookingsToFinish); @@ -357,10 +357,15 @@ export const Cahier = { inputsToUpdate = bookingsInputs; // ToUpdate (set end date to start date) - let extraIdsToUpdate = Cahier.editedBooking.ids.slice(-nBookingsToFinish); - let extraInputsToUpdate = []; + const extraIdsToUpdate = Cahier.editedBooking.ids.slice(-nBookingsToFinish); + const extraInputsToUpdate = []; // Note: need to update startDate again since otherwise it gets automatically set to the current time - let input = {startDate: currentDate, endDate: currentDate, bookable: null, endComment: '(Editée)'}; + const input = { + startDate: currentDate, + endDate: currentDate, + bookable: null, + endComment: '(Editée)', + }; extraInputsToUpdate.fillArray(extraIdsToUpdate.length, input); // append @@ -401,7 +406,7 @@ export const Cahier = { // First add the bookings to finish because used by someone else idsToFinish = idsToFinish.concat(bookingsIdToFinish); - let comments = []; + const comments = []; comments.fillArray(bookingsIdToFinish.length, 'Terminée automatiquement'); commentsToFinish = commentsToFinish.concat(comments); console.log('Need to terminate', bookingsIdToFinish.length, 'booking(s) due to unavailable bookables.'); @@ -418,7 +423,7 @@ export const Cahier = { // Not in edit mode else { // bookings to terminate to free the bookables - let commentsToFinish = []; + const commentsToFinish = []; commentsToFinish.fillArray(bookingsIdToFinish.length, 'Terminée automatiquement'); // there are no bookings to termiante @@ -437,8 +442,8 @@ export const Cahier = { // 1.4 updateBookablesLicenses: function (_bookables) { - for (let _bookable of _bookables) { - for (let bookable of Cahier.bookings[0].bookables) { + for (const _bookable of _bookables) { + for (const bookable of Cahier.bookings[0].bookables) { if (bookable.id == _bookable.id) { bookable.licenses = _bookable.licenses.clone(); // bookable <-> Cahier.bookings[0].bookables[x] by reference break; // one loop @@ -448,7 +453,7 @@ export const Cahier = { }, actualizeProgressBar: function () { - let allDivTabCahierProgressTexts = document.getElementsByClassName('divTabCahierProgressText'); + const allDivTabCahierProgressTexts = document.getElementsByClassName('divTabCahierProgressText'); for (let i = 0; i < allDivTabCahierProgressTexts.length; i++) { if (i < currentProgress - 1) { switch (i) { @@ -485,7 +490,7 @@ export const Cahier = { } else { $('divTabCahierProgressReturn').style.visibility = 'visible'; $('divTabCahierProgressReturn').onclick = function () { - let newTabName = progessionTabNames[currentProgress - 1]; + const newTabName = progessionTabNames[currentProgress - 1]; if (newTabName != 'divTabCahierMember' || !$('divTabCahierProgress').classList.contains('editing')) { newTab(newTabName); } @@ -567,7 +572,7 @@ export const Cahier = { // 1.4 : make fake availability if the actual bookable was in the edited booking if (Cahier.bookings[0].currentlyEditing != undefined) { - for (let bookingId of Cahier.editedBooking.ids) { + for (const bookingId of Cahier.editedBooking.ids) { if (_lastBooking.id == bookingId) { Cahier.bookings[nbr].bookables[Cahier.bookings[nbr].bookables.length - 1].available = true; break; @@ -589,14 +594,14 @@ export const Cahier = { } if (bookings.length !== 0) { - let lastBooking = Object.assign({}, bookings[0]); + const lastBooking = Object.assign({}, bookings[0]); Cahier.bookings[0].bookables[u].available = bookings[0].endDate == null ? false : true; Cahier.bookings[0].bookables[u].lastBooking = lastBooking; // 1.4 : make fake availability (actually already used in the current booking that is being edited...) if (Cahier.bookings[0].currentlyEditing != undefined) { - for (let bookingId of Cahier.editedBooking.ids) { + for (const bookingId of Cahier.editedBooking.ids) { if (lastBooking.id == bookingId) { Cahier.bookings[0].bookables[u].available = true; break; @@ -687,11 +692,11 @@ function transformComment(txt, fill) { } export function getStartCommentFromBooking(booking, fill = false) { - let txt = booking.startComment; + const txt = booking.startComment; return transformComment(txt, fill); } export function getEndCommentFromBooking(booking, fill = false) { - let txt = booking.endComment; + const txt = booking.endComment; return transformComment(txt, fill); } diff --git a/htdocs/cahier/pop-booking.js b/htdocs/cahier/pop-booking.js index 5b585cc..ed32d58 100644 --- a/htdocs/cahier/pop-booking.js +++ b/htdocs/cahier/pop-booking.js @@ -7,31 +7,31 @@ import {popBookable} from '../equipment/pop-bookable.js'; // popBookings export function loadConfirmation() { - let elem = $('divTabConfirmationOneBookingContainer'); + const elem = $('divTabConfirmationOneBookingContainer'); openBooking('confirmation', elem); } export function popBooking(_booking) { // without all bookables... so if the booking is not complete - let elem = openPopUp(); + const elem = openPopUp(); openBooking('infos', elem); Requests.getBookingWithBookablesInfos(_booking, 'infos', elem); } export function popBookingInfos(_booking) { - let elem = openPopUp(); + const elem = openPopUp(); openBooking('infos', elem); actualizePopBooking(_booking, 'infos', elem); } export function popBookingFinish(_booking) { - let elem = openPopUp(); + const elem = openPopUp(); openBooking('finish', elem); actualizePopBooking(_booking, 'finish', elem); } function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBookingContainer')) { - let fields = [ + const fields = [ 'Responsable', 'Heure de départ', "Heure d'arrivée", @@ -41,7 +41,7 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook 'Commentaire dép.', 'Commentaire arr.', ]; - let images = [ + const images = [ 'icons/responsible', 'icons/start', 'icons/end', @@ -71,7 +71,7 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook container.innerHTML += '
Sortie en chargement...
'; - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); @@ -88,7 +88,7 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook c = 3; } for (let i = 0; i < c; i++) { - let d = div(container); + const d = div(container); d.classList.add('divConfirmationTexts'); div(div(d)).style.backgroundImage = 'url(img/' + images[i] + '.png)'; div(d).innerHTML = fields[i]; @@ -105,14 +105,14 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook div(d).innerHTML = fields[3]; div(d); - let embContainer = div(container); + const embContainer = div(container); embContainer.classList.add('divTabCahierConfirmationEmbarcationContainer'); - let emb = div(embContainer); + const emb = div(embContainer); emb.className = 'divTabCahierConfirmationEmbarcationBox'; div(div(emb)); - let texts = div(emb); + const texts = div(emb); texts.className = 'divTabCahierConfirmationContainerTextsContainer'; div(texts).innerHTML = '...'; @@ -121,10 +121,10 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook if (which == 'finish' && options.bookablesComment) { // desactivated - let radioContainer = div(emb); + const radioContainer = div(emb); radioContainer.className = 'radioContainer'; - let r1 = div(radioContainer); + const r1 = div(radioContainer); r1.classList.add('radioSelected'); r1.onclick = function () { this.classList.add('radioSelected'); @@ -135,7 +135,7 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook }; //this.parentElement.parentElement.getElementsByTagName("textarea")[0].style.opacity = 0; div(div(r1)); div(r1).innerHTML = 'En bon état'; - let r2 = div(radioContainer); + const r2 = div(radioContainer); r2.onclick = function () { this.classList.add('radioSelected'); this.previousElementSibling.classList.remove('radioSelected'); @@ -146,11 +146,11 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook div(div(r2)); div(r2).innerHTML = 'Endommagé'; - let areaContainer = div(emb); + const areaContainer = div(emb); areaContainer.style.width = '0px'; areaContainer.style.height = '0px'; areaContainer.style.opacity = 0.5; - let area = document.createElement('textarea'); + const area = document.createElement('textarea'); area.placeholder = "État de l'embarcation..."; area.spellcheck = false; area.style.left = '350px'; @@ -164,9 +164,9 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook } if (which == 'confirmation') { - let u = div(container); + const u = div(container); u.classList.add('divTabCahierConfirmationEmbarcationButtonContainer'); - let btn = div(u); + const btn = div(u); btn.innerHTML = 'Modifier'; btn.classList.add('Buttons'); btn.classList.add('ReturnButtons'); @@ -184,14 +184,14 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook d.style.backgroundColor = 'rgb(235,235,235)'; div(div(d)).style.backgroundImage = 'url(img/' + images[7] + '.png)'; div(d).innerHTML = fields[7]; - let area2 = document.createElement('textarea'); + const area2 = document.createElement('textarea'); area2.spellcheck = false; area2.placeholder = "Comment ça s'est passé..."; div(d).appendChild(area2); // 1.1 if (options.modifyBookablesButton) { - let btnModify = div(container); + const btnModify = div(container); btnModify.style.visibility = 'hidden'; btnModify.classList.add('Buttons', 'NormalButtons'); btnModify.id = 'btnModify'; @@ -201,7 +201,7 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook // 1.4 if (options.editBookingButton) { - let btnEditBooking = div(container); + const btnEditBooking = div(container); btnEditBooking.style.visibility = 'hidden'; btnEditBooking.classList.add('Buttons', 'NormalButtons'); btnEditBooking.id = 'btnEditBooking'; @@ -209,7 +209,7 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook btnEditBooking.title = 'Modifier la sortie entière'; } - let btnFinish = div(container); + const btnFinish = div(container); btnFinish.classList.add('Buttons', 'ValidateButtons', 'btnRed'); btnFinish.innerHTML = 'Terminer'; // for function see - actualizeBooking... @@ -239,16 +239,16 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook // EDIT BUTTON if (which == 'confirmation') { // INFOS - let bar = div(container); + const bar = div(container); bar.classList.add('divConfirmationTexts'); bar.style.height = '50px'; bar.style.backgroundColor = 'white'; div(bar); div(bar); - let u = div(bar); + const u = div(bar); u.style.height = '100%'; - let btn2 = div(u); + const btn2 = div(u); btn2.innerHTML = 'Modifier'; btn2.classList.add('Buttons'); btn2.classList.add('ReturnButtons'); @@ -264,8 +264,8 @@ function openBooking(which = 'confirmation', elem = $('divTabConfirmationOneBook } export function actualizePopBooking(booking, which, container = $('divTabCahierConfirmationContainer')) { - let allDiv = container.getElementsByClassName('divConfirmationTexts'); - let allDivTexts = []; + const allDiv = container.getElementsByClassName('divConfirmationTexts'); + const allDivTexts = []; for (let i = 0; i < allDiv.length; i++) { allDivTexts[i] = allDiv[i].getElementsByTagName('div')[3]; } @@ -304,13 +304,13 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC allDivTexts[1].innerHTML = new Date(booking.startDate).getNiceTime(); allDivTexts[2].innerHTML = new Date().getNiceTime(); - let btn = container.getElementsByClassName('ValidateButtons')[0]; + const btn = container.getElementsByClassName('ValidateButtons')[0]; btn.addEventListener('click', function () { if (options.bookablesComment) { - let comments = []; + const comments = []; for (let i = 0; i < booking.ids.length; i++) { - let area = container + const area = container .getElementsByClassName('divTabCahierConfirmationEmbarcationBox') [i].getElementsByTagName('textarea')[0]; if (typeof area != 'undefined') { @@ -338,7 +338,7 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC Requests.terminateBooking(booking.ids, comments); } else { - let comments = []; + const comments = []; comments.fillArray( booking.ids.length, container.getElementsByTagName('textarea')[container.getElementsByTagName('textarea').length - 1] @@ -361,8 +361,8 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC Cahier.bookings[0].currentlyEditing = true; Requests.getOwnerLicenses(Cahier.bookings[0].owner); // get licenses back ! - let bookableIds = []; - for (let bookable of Cahier.bookings[0].bookables) { + const bookableIds = []; + for (const bookable of Cahier.bookings[0].bookables) { if (bookable.id != 0) bookableIds.push(bookable.id); // not taking personal equipment } Requests.getBookablesLicenses(bookableIds); @@ -382,7 +382,7 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC } } - let embContainer = container.getElementsByClassName('divTabCahierConfirmationEmbarcationContainer')[0]; + const embContainer = container.getElementsByClassName('divTabCahierConfirmationEmbarcationContainer')[0]; if (booking.bookables.length == 0) { // should happen not anymore @@ -393,9 +393,9 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC embContainer.innerHTML = ''; let names = []; for (let i = 0; i < booking.bookables.length; i++) { - let emb = div(embContainer); + const emb = div(embContainer); emb.className = 'divTabCahierConfirmationEmbarcationBox'; - let img = div(emb); + const img = div(emb); img.style.backgroundImage = booking.bookables[i].available === false @@ -416,7 +416,7 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC // 1.1 if (which == 'finish' && options.modifyBookablesButton && booking.bookables.length > 1) { - let t = div(texts); + const t = div(texts); t.id = i; t.style.visibility = 'hidden'; t.classList.add('Buttons', 'NormalButtons', 'btnTerminateOneBookable'); @@ -442,7 +442,7 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC this.nextElementSibling.nextElementSibling.style.opacity = '0'; this.previousElementSibling.style.opacity = '0.4'; this.parentElement.getElementsByTagName('textarea')[0].disabled = 'true'; - let ts = document.getElementsByClassName('btnTerminateOneBookable'); + const ts = document.getElementsByClassName('btnTerminateOneBookable'); for (let i = 0; i < ts.length; i++) { ts[i].previousElementSibling.innerHTML = ts[i].previousElementSibling.innerHTML.shorten( 1 * 150, @@ -470,10 +470,10 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC if (booking.bookables[i].id != 0) { // matériel personnel - let radioContainer = div(emb); + const radioContainer = div(emb); radioContainer.className = 'radioContainer'; - let r1 = div(radioContainer); + const r1 = div(radioContainer); r1.classList.add('radioSelected'); r1.onclick = function () { this.classList.add('radioSelected'); @@ -484,7 +484,7 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC }; //this.parentElement.parentElement.getElementsByTagName("textarea")[0].style.opacity = 0; div(div(r1)); div(r1).innerHTML = 'En bon état'; - let r2 = div(radioContainer); + const r2 = div(radioContainer); r2.onclick = function () { this.classList.add('radioSelected'); this.previousElementSibling.classList.remove('radioSelected'); @@ -495,11 +495,11 @@ export function actualizePopBooking(booking, which, container = $('divTabCahierC div(div(r2)); div(r2).innerHTML = 'Endommagé'; - let areaContainer = div(emb); + const areaContainer = div(emb); areaContainer.style.width = '0px'; areaContainer.style.height = '0px'; areaContainer.style.opacity = 0.5; - let area = document.createElement('textarea'); + const area = document.createElement('textarea'); area.placeholder = "État de l'embarcation..."; area.spellcheck = false; area.style.left = '350px'; diff --git a/htdocs/cahier/top-list.js b/htdocs/cahier/top-list.js index ef8e7cc..0b40056 100644 --- a/htdocs/cahier/top-list.js +++ b/htdocs/cahier/top-list.js @@ -4,7 +4,7 @@ import {Cahier} from './methods.js'; import {tabs} from '../general/screen.js'; export function actualizeBookableList() { - let bookables = Cahier.bookings[0].bookables; + const bookables = Cahier.bookings[0].bookables; $('divTabCahierTopList').children[0].innerHTML = ''; $('divTabCahierTopList').children[0].style.opacity = '1'; @@ -15,7 +15,7 @@ export function actualizeBookableList() { .children[3].children[0].classList.remove('buttonNonActive'); for (let i = 0; i < bookables.length; i++) { - let d = div($('divTabCahierTopList').children[0]); + const d = div($('divTabCahierTopList').children[0]); d.id = i; if (Cahier.bookings[0].bookables[i].id != 0) { @@ -36,16 +36,16 @@ export function actualizeBookableList() { d.classList.add('PersonalSail'); } - let img = div(d); + const img = div(d); img.style.backgroundImage = Cahier.getImageUrl(Cahier.bookings[0].bookables[i]); - let close = div(d); + const close = div(d); close.id = i; close.onclick = function () { Cahier.removeBookable(0, Cahier.bookings[0].bookables[this.id]); }; - let code = div(d); + const code = div(d); if (bookables[i].code != null) { if (bookables[i].code.length > 4) { diff --git a/htdocs/cahier/top.js b/htdocs/cahier/top.js index 53d2620..29ca87a 100644 --- a/htdocs/cahier/top.js +++ b/htdocs/cahier/top.js @@ -13,11 +13,11 @@ export const progessionTabNames = [ export function createProgressBar() { for (let i = 0; i < 4; i++) { - let divStep = document.createElement('div'); + const divStep = document.createElement('div'); divStep.classList.add('divTabCahierProgressStep'); divStep.style.left = 6 + 26 * i + '%'; divStep.addEventListener('click', function () { - let c = (parseInt(this.style.left) - 6) / 26 + 1; + const c = (parseInt(this.style.left) - 6) / 26 + 1; if (c <= currentProgress) { if ( progessionTabNames[c] != 'divTabCahierMember' || @@ -31,27 +31,27 @@ export function createProgressBar() { $('divTabCahierProgress').appendChild(divStep); divStep.classList.add('divTabCahierProgressStepCompleted'); - let divNumber = document.createElement('div'); + const divNumber = document.createElement('div'); divNumber.classList.add('divTabCahierProgressNumber'); divNumber.innerHTML = i + 1; divStep.appendChild(divNumber); - let divCircle = document.createElement('div'); + const divCircle = document.createElement('div'); divCircle.classList.add('divTabCahierProgressCircle'); divStep.appendChild(divCircle); - let divText = document.createElement('div'); + const divText = document.createElement('div'); divText.classList.add('divTabCahierProgressText'); divText.innerHTML = Cahier.ProgressBarTexts[i]; divStep.appendChild(divText); } - let divBar = document.createElement('div'); + const divBar = document.createElement('div'); divBar.id = 'divTabCahierProgressBar'; divBar.style.left = 11 + 26 * 0 + '%'; $('divTabCahierProgress').appendChild(divBar); - let divBarBlue = document.createElement('div'); + const divBarBlue = document.createElement('div'); divBarBlue.id = 'divTabCahierProgressBarBlue'; divBarBlue.style.left = 11 + 26 * 0 + '%'; $('divTabCahierProgress').appendChild(divBarBlue); diff --git a/htdocs/equipment/categories.js b/htdocs/equipment/categories.js index 6f8f217..1fec1d0 100644 --- a/htdocs/equipment/categories.js +++ b/htdocs/equipment/categories.js @@ -15,29 +15,29 @@ export const categories = [ export function loadMateriel(container = $('divTabCahierEquipmentCategoriesContainer')) { for (let i = 0; i < categories.length; i++) { - let d = document.createElement('div'); + const d = document.createElement('div'); d.id = categories[i].name; d.classList.add('BoxesContainer'); container.appendChild(d); - let d1 = div(d); + const d1 = div(d); d1.id = i; d1.classList.add('Boxes'); - let dTop = div(d1); + const dTop = div(d1); dTop.classList.add('BoxesTop'); dTop.style.backgroundImage = 'url(img/icons/chose.png),' + 'url(img/categorie/' + categories[i].image + ')'; - let dBottom = document.createElement('div'); + const dBottom = document.createElement('div'); dBottom.classList.add('BoxesBottom'); d1.appendChild(dBottom); - let dBottomText1 = document.createElement('div'); + const dBottomText1 = document.createElement('div'); dBottomText1.classList.add('BoxesBottomText1'); dBottom.appendChild(dBottomText1); dBottomText1.innerHTML = categories[i].name; - let dBottomText2 = document.createElement('div'); + const dBottomText2 = document.createElement('div'); dBottomText2.classList.add('BoxesBottomText2'); dBottom.appendChild(dBottomText2); Requests.getBookableNbrForBookableTag(categories[i].value, dBottomText2, '', ' ' + categories[i].plural); @@ -62,13 +62,13 @@ export function loadMateriel(container = $('divTabCahierEquipmentCategoriesConta }); } - let opt = document.createElement('option'); + const opt = document.createElement('option'); opt.innerHTML = categories[i].name; opt.value = categories[i].value; $('divTabCahierEquipmentElementsSelectCategorie').getElementsByTagName('select')[0].appendChild(opt); } - let opt = document.createElement('option'); + const opt = document.createElement('option'); opt.innerHTML = 'Toutes les catégories'; opt.value = 'all'; $('divTabCahierEquipmentElementsSelectCategorie').getElementsByTagName('select')[0].appendChild(opt); diff --git a/htdocs/equipment/choice.js b/htdocs/equipment/choice.js index 17ad5a6..bbcb26e 100644 --- a/htdocs/equipment/choice.js +++ b/htdocs/equipment/choice.js @@ -12,13 +12,13 @@ export function loadCahierEquipmentChoice( isTab = false; } - let container = div(loc); + const container = div(loc); container.classList.add('divTabCahierEquipmentChoiceContainer'); - let c = div(container); + const c = div(container); c.classList.add('divTabCahierEquipmentChoiceInputCodeContainer'); - let i = input(c, 'Taper un code...'); + const i = input(c, 'Taper un code...'); i.onkeyup = function (event) { if (event.keyCode == 13) { Requests.getBookableByCode(this, nbr); @@ -36,7 +36,7 @@ export function loadCahierEquipmentChoice( div(c); - let btn = div(div(c)); + const btn = div(div(c)); btn.classList.add('ValidateButtons', 'Buttons'); btn.title = 'Choisir cette embarcation'; btn.onclick = function () { @@ -47,9 +47,9 @@ export function loadCahierEquipmentChoice( div(container).innerHTML = 'Ou'; - let btnContainer = div(container); + const btnContainer = div(container); - let btn1 = div(btnContainer); + const btn1 = div(btnContainer); btn1.innerHTML = 'Prendre du matériel personnel'; btn1.title = 'Prendre du matériel personnel'; btn1.style.fontSize = '19px'; @@ -77,7 +77,7 @@ export function loadCahierEquipmentChoice( btn1.classList.add('NormalButtons', 'Buttons'); - let btn2 = div(btnContainer); + const btn2 = div(btnContainer); btn2.innerHTML = 'Voir la liste du matériel'; if (isTab) { btn2.onclick = function () { diff --git a/htdocs/equipment/elements.js b/htdocs/equipment/elements.js index b2bc456..966452c 100644 --- a/htdocs/equipment/elements.js +++ b/htdocs/equipment/elements.js @@ -10,18 +10,18 @@ export function loadElements(bookables, nbr = 0) { document.getElementsByClassName('divTabCahierEquipmentElementsContainer')[0].innerHTML = ''; - let codes = []; + const codes = []; for (let i = 0; i < Cahier.bookings[nbr].bookables.length; i++) { codes.push(Cahier.bookings[nbr].bookables[i].id); } for (let j = 0; j < bookables.length; j++) { - let container = document.createElement('div'); + const container = document.createElement('div'); container.id = j; // 1.4 : make fake no used (actually already used in the current booking that is being edited...) if (bookables[j].used === true && Cahier.bookings[0].currentlyEditing != undefined) { - for (let bookingId of Cahier.editedBooking.ids) { + for (const bookingId of Cahier.editedBooking.ids) { if (bookables[j].lastBooking.id == bookingId) { bookables[j].used = false; break; @@ -37,7 +37,7 @@ export function loadElements(bookables, nbr = 0) { bookables[j].lessThan13Minutes = dT.time < 13 ? true : false; } else bookables[j].lessThan13Minutes = false; - let x = codes.findIndex(bookables[j].id); + const x = codes.findIndex(bookables[j].id); if (x !== -1) { // found something @@ -74,10 +74,10 @@ export function loadElements(bookables, nbr = 0) { document.getElementsByClassName('divTabCahierEquipmentElementsContainer')[0].appendChild(container); - let secondContainer = document.createElement('div'); + const secondContainer = document.createElement('div'); container.appendChild(secondContainer); - let size = document.createElement('div'); + const size = document.createElement('div'); if (bookables[j].code != null) { size.innerHTML = bookables[j].code; @@ -90,18 +90,18 @@ export function loadElements(bookables, nbr = 0) { secondContainer.appendChild(size); - let bottom = document.createElement('div'); + const bottom = document.createElement('div'); secondContainer.appendChild(bottom); - let brand = div(bottom); + const brand = div(bottom); brand.innerHTML = bookables[j].name.shorten(160 * 2, 20); - let background = div(secondContainer); + const background = div(secondContainer); background.style.backgroundImage = Cahier.getImageUrl(bookables[j]); div(secondContainer); - let info = div(secondContainer); + const info = div(secondContainer); info.id = bookables[j].id; info.classList.add('infoJS'); info.onclick = function () { @@ -118,27 +118,27 @@ export function loadElements(bookables, nbr = 0) { } } if (bookables.length == 0) { - let d = div(document.getElementsByClassName('divTabCahierEquipmentElementsContainer')[0]); + const d = div(document.getElementsByClassName('divTabCahierEquipmentElementsContainer')[0]); d.innerHTML = 'Aucun résultat'; } } export function actualizeElements() { - let bookables = currentBookables; + const bookables = currentBookables; - let codes = []; + const codes = []; for (let i = 0; i < Cahier.bookings[0].bookables.length; i++) { codes.push(Cahier.bookings[0].bookables[i].id); } - let containers = document.getElementsByClassName('divTabCahierEquipmentElementsContainer')[0].children; + const containers = document.getElementsByClassName('divTabCahierEquipmentElementsContainer')[0].children; for (let j = 0; j < containers.length; j++) { containers[j].classList.remove('selected'); } for (let k = 0; k < containers.length; k++) { - let container = containers[k]; + const container = containers[k]; if (codes.findIndex(bookables[k].id) !== -1) { // found something @@ -185,7 +185,7 @@ export function clickSortIcon(elem) { export function changeSelectCategorie(elem) { let image = 'url(img/icons/no-result.png)'; - for (let category of categories) { + for (const category of categories) { if (category.value == elem.value) { image = 'url(img/categorie/' + category.image + ')'; break; diff --git a/htdocs/equipment/pop-bookable-history.js b/htdocs/equipment/pop-bookable-history.js index 4febdd6..97e7abf 100644 --- a/htdocs/equipment/pop-bookable-history.js +++ b/htdocs/equipment/pop-bookable-history.js @@ -12,12 +12,11 @@ export function popBookableHistory(bookableId) { currentMonth = -1; currentDay = -1; - let modal = openPopUp(); + const modal = openPopUp(); Requests.getBookableHistory(bookableId, modal, new Date()); - let container; - container = div(modal); + const container = div(modal); container.classList.add('Boxes'); container.style.position = 'absolute'; container.style.width = '700px'; @@ -31,30 +30,30 @@ export function popBookableHistory(bookableId) { container.innerHTML += '
Historique
'; grayBar(container, 5); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: modal}, modal); }; - let scroll = div(container); + const scroll = div(container); scroll.className = 'PopUpBookableHistoryContainerScroll'; } export function actualizePopBookableHistory(bookings, elem) { - let lastDate = new Date(bookings[bookings.length - 1].startDate); // avant changeDaySorting ! + const lastDate = new Date(bookings[bookings.length - 1].startDate); // avant changeDaySorting ! bookings = changeDaySorting(bookings); - let bookableId = bookings[0].bookable.id; + const bookableId = bookings[0].bookable.id; - let container = elem.getElementsByTagName('div')[0]; + const container = elem.getElementsByTagName('div')[0]; container.getElementsByTagName('div')[0].innerHTML = ('Historique de ' + bookings[0].bookable.name).shorten( 600, 25, ); - let scroll = container.getElementsByClassName('PopUpBookableHistoryContainerScroll')[0]; + const scroll = container.getElementsByClassName('PopUpBookableHistoryContainerScroll')[0]; if (scroll.getElementsByClassName('Buttons').length == 1) { scroll.removeChild(scroll.getElementsByClassName('Buttons')[0]); @@ -62,34 +61,34 @@ export function actualizePopBookableHistory(bookings, elem) { } for (let i = 0; i < bookings.length; i++) { - let d = new Date(bookings[i].startDate); + const d = new Date(bookings[i].startDate); - let newYear = d.getFullYear(); + const newYear = d.getFullYear(); if (newYear != currentYear) { - let year = popUpYear(scroll, newYear); + const year = popUpYear(scroll, newYear); - let start = new Date(d.getFullYear(), 0, 1, 0, 0, 1); - let end = new Date(d.getFullYear() + 1, 0, 1, 0, 0, 0, 1); + const start = new Date(d.getFullYear(), 0, 1, 0, 0, 1); + const end = new Date(d.getFullYear() + 1, 0, 1, 0, 0, 0, 1); Requests.getBookingsNbrBetween(start.toISOString(), end.toISOString(), bookableId, year); } - let newMonth = d.getMonth(); + const newMonth = d.getMonth(); if (newMonth != currentMonth || newYear != currentYear) { - let month = popUpMonth(scroll, Mois[newMonth]); + const month = popUpMonth(scroll, Mois[newMonth]); - let start = new Date(d.getFullYear(), newMonth, 1, 0, 0, 0, 1); - let end = new Date(d.getFullYear(), newMonth + 1, 1, 0, 0, 0, 1); + const start = new Date(d.getFullYear(), newMonth, 1, 0, 0, 0, 1); + const end = new Date(d.getFullYear(), newMonth + 1, 1, 0, 0, 0, 1); Requests.getBookingsNbrBetween(start.toISOString(), end.toISOString(), bookableId, month); } - let newDay = d.getDate(); + const newDay = d.getDate(); if (newDay != currentDay || newMonth != currentMonth || newYear != currentYear) { - let all = scroll.getElementsByClassName('PopUpMonth'); + const all = scroll.getElementsByClassName('PopUpMonth'); - let day = popUpDay(all[all.length - 1], d.getNiceDate(true)); + const day = popUpDay(all[all.length - 1], d.getNiceDate(true)); - let start = new Date(d.getFullYear(), newMonth, newDay, 0, 0, 0, 1); - let end = new Date(d.getFullYear(), newMonth, newDay + 1, 0, 0, 0, 1); + const start = new Date(d.getFullYear(), newMonth, newDay, 0, 0, 0, 1); + const end = new Date(d.getFullYear(), newMonth, newDay + 1, 0, 0, 0, 1); Requests.getBookingsNbrBetween(start.toISOString(), end.toISOString(), bookableId, day, false); } @@ -97,16 +96,16 @@ export function actualizePopBookableHistory(bookings, elem) { currentMonth = newMonth; currentDay = newDay; - let all = scroll.getElementsByClassName('PopUpDay'); + const all = scroll.getElementsByClassName('PopUpDay'); - let sortie = div(all[all.length - 1]); + const sortie = div(all[all.length - 1]); sortie.id = i; sortie.classList.add('PopUpSortie'); sortie.onclick = function () { popBooking(bookings[this.id]); }; div(sortie).innerHTML = d.getNiceTime(); - let c = div(sortie); + const c = div(sortie); div(c).innerHTML = Cahier.getOwner(bookings[i], true, {length: 240, fontSize: 20}, true); @@ -114,10 +113,10 @@ export function actualizePopBookableHistory(bookings, elem) { div(c).innerHTML = getStartCommentFromBooking(bookings[i]).shorten(150, 15); } - let space = document.createElement('br'); + const space = document.createElement('br'); scroll.appendChild(space); - let plus = div(scroll); + const plus = div(scroll); plus.classList.add('Buttons'); plus.classList.add('NormalButtons'); plus.innerHTML = 'Afficher plus'; @@ -135,19 +134,19 @@ function changeDaySorting(bookings) { let oldDate = new Date(bookings[0].startDate).getDate(); let oldMonth = new Date(bookings[0].startDate).getMonth(); - let result = bookings; + const result = bookings; let c = 0; for (i = 1; i < result.length; i++) { - let newDate = new Date(result[i].startDate).getDate(); - let newMonth = new Date(result[i].startDate).getMonth(); + const newDate = new Date(result[i].startDate).getDate(); + const newMonth = new Date(result[i].startDate).getMonth(); if (oldDate == newDate && oldMonth == newMonth) { c++; //console.log("i:" + i, "c++"); } else if (c != 0) { //c!=0 - let i1 = i - 1 - c; - let i2 = i - 1; + const i1 = i - 1 - c; + const i2 = i - 1; c = 0; //console.log("i:" + i,"switch - " + i1 + "to" + i2); result.inverse(i1, i2); @@ -157,8 +156,8 @@ function changeDaySorting(bookings) { oldMonth = newMonth; } if (c != 0) { - let i1 = i - 1 - c; - let i2 = i - 1; + const i1 = i - 1 - c; + const i2 = i - 1; result.inverse(i1, i2); //console.log("switch",i1, i2); } @@ -166,37 +165,37 @@ function changeDaySorting(bookings) { } function popUpYear(container, txt) { - let c = div(container); + const c = div(container); c.className = 'PopUpYear'; div(c); - let inner = div(c); + const inner = div(c); inner.innerHTML = txt; - let nbr = div(div(c)); + const nbr = div(div(c)); return nbr; } function popUpMonth(container, txt) { - let c = div(container); + const c = div(container); c.className = 'PopUpMonth'; div(c); - let inner = div(c); + const inner = div(c); inner.innerHTML = txt; - let nbr = div(div(c)); + const nbr = div(div(c)); return nbr; } function popUpDay(container, txt) { - let c = div(container); + const c = div(container); c.className = 'PopUpDay'; - let infos = div(c); + const infos = div(c); div(infos); - let inner = div(infos); + const inner = div(infos); inner.innerHTML = txt; - let nbr = div(div(infos)); + const nbr = div(div(infos)); return nbr; } diff --git a/htdocs/equipment/pop-bookable.js b/htdocs/equipment/pop-bookable.js index b2406bc..7218581 100644 --- a/htdocs/equipment/pop-bookable.js +++ b/htdocs/equipment/pop-bookable.js @@ -12,12 +12,12 @@ export function popBookable(bookableId, justPreview = true, nbr = 0, modal = ope modal.innerHTML = ''; } - let pop = div(modal); + const pop = div(modal); pop.classList.add('Boxes'); pop.classList.add('divTabCahierEquipmentElementsPopUp'); if (modal != $('divTabCahierEquipmentBookableContainer')) { - let close = div(pop); + const close = div(pop); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: modal}, modal); @@ -29,19 +29,19 @@ export function popBookable(bookableId, justPreview = true, nbr = 0, modal = ope div(pop); // imgContainer - let descriptionTitle = div(pop); + const descriptionTitle = div(pop); descriptionTitle.innerHTML = 'Description'; div(pop); // description box - let btn2 = div(pop); + const btn2 = div(pop); btn2.classList.add('Buttons'); btn2.classList.add('ReturnButtons'); btn2.style.visibility = 'hidden'; btn2.innerHTML = 'Historique'; if (!justPreview) { - let btn = div(pop); + const btn = div(pop); btn.classList.add('Buttons', 'ValidateButtons'); btn.innerHTML = 'Choisir'; btn.setAttribute('tabindex', '0'); @@ -50,7 +50,7 @@ export function popBookable(bookableId, justPreview = true, nbr = 0, modal = ope // description.style.width = "660px"; } - let textsContainer = div(pop); + const textsContainer = div(pop); textsContainer.className = 'divTabCahierEquipmentElementsContainerTextsContainer'; div(textsContainer); @@ -65,7 +65,7 @@ export function actualizePopBookable(nbr, bookable, bookings, elem) { elem.getElementsByClassName('divTabCahierEquipmentElementsPopUp')[0].getElementsByTagName('div')[3].innerHTML = bookable.description; - let textsContainer = elem.getElementsByClassName('divTabCahierEquipmentElementsContainerTextsContainer')[0]; + const textsContainer = elem.getElementsByClassName('divTabCahierEquipmentElementsContainerTextsContainer')[0]; if (bookable.code != null) { textsContainer.getElementsByTagName('div')[0].innerHTML = bookable.code; @@ -78,7 +78,7 @@ export function actualizePopBookable(nbr, bookable, bookings, elem) { else div(textsContainer); for (let i = 0; i < bookable.licenses.length; i++) { - let lic = div(textsContainer); + const lic = div(textsContainer); lic.innerHTML = "License requise: " + bookable.licenses[i].name; } @@ -93,7 +93,7 @@ export function actualizePopBookable(nbr, bookable, bookings, elem) { // 1.4 : don't show warning if editing the current booking if (Cahier.bookings[0].currentlyEditing != undefined) { - for (let bookingId of Cahier.editedBooking.ids) { + for (const bookingId of Cahier.editedBooking.ids) { if (bookings.items[0].id == bookingId) { bookableUsedWarning = false; break; @@ -104,11 +104,11 @@ export function actualizePopBookable(nbr, bookable, bookings, elem) { if (bookableUsedWarning) { let usedTxt = Cahier.getOwner(bookings.items[0], false); - let dT = deltaTime(new Date(bookings.items[0].startDate)); + const dT = deltaTime(new Date(bookings.items[0].startDate)); usedTxt += ' est parti ' + dT.text + ' avec cette embarcation !'; deltaT = dT.time; - let div2 = elem + const div2 = elem .getElementsByClassName('divTabCahierEquipmentElementsContainerTextsContainer')[0] .getElementsByTagName('div')[2]; div2.innerHTML = usedTxt; @@ -148,7 +148,7 @@ export function actualizePopBookable(nbr, bookable, bookings, elem) { if (elem.getElementsByClassName('ValidateButtons').length == 1) { // if !justPreview - let choseFunction = function () { + const choseFunction = function () { Cahier.addBookable(nbr, bookable, Object.assign({}, bookings.items[0])); newTab('divTabCahierEquipmentChoice'); diff --git a/htdocs/general/home.js b/htdocs/general/home.js index 907148f..37a3210 100644 --- a/htdocs/general/home.js +++ b/htdocs/general/home.js @@ -35,13 +35,13 @@ export function $(id) { // createElements export function div(loc) { - let x = document.createElement('div'); + const x = document.createElement('div'); loc.appendChild(x); return x; } export function input(loc, _placeholder = '') { - let x = document.createElement('input'); + const x = document.createElement('input'); x.autocomplete = 'off'; x.type = 'text'; x.spellcheck = false; @@ -65,7 +65,7 @@ export function load() { loadCahierEquipmentChoice(); loadEscListener(); - let version = '1.5'; + const version = '1.5'; if (window.location.hostname === 'navigations.ichtus.club') { console.warn('Version de production ' + version); $('divTopBarText').innerHTML = tabs[0].title; @@ -106,7 +106,7 @@ document.onmousemove = function () { }; // could be improved... -let Time = { +const Time = { getActualMinutes: function (m = date.getMinutes()) { let x; if (m < 10) { @@ -141,13 +141,13 @@ Date.prototype.getNiceDate = function (substr = false, year = false) { }; Date.prototype.getPreviousDate = function () { - let yesterday = new Date(this); + const yesterday = new Date(this); yesterday.setDate(this.getDate() - 1); return yesterday; }; export function deltaTime(d1, d2 = new Date(), bold = true) { - let delta = Math.abs(d2.getTime() - d1.getTime()) / 1000 / 60; // in minutes + const delta = Math.abs(d2.getTime() - d1.getTime()) / 1000 / 60; // in minutes let t = ''; if (delta < 1) t = "à l'instant"; @@ -230,7 +230,7 @@ function actualizeTime() { //} function loadReturnButtons() { - let allReturnButtons = document.getElementsByClassName('ReturnButtons'); + const allReturnButtons = document.getElementsByClassName('ReturnButtons'); for (let i = 0; i < allReturnButtons.length; i++) { allReturnButtons[i].title = 'Retour'; } @@ -240,7 +240,7 @@ function loadReturnButtons() { let lastModals = 0; export function openPopUp() { - let modal = div(document.body); + const modal = div(document.body); modal.onclick = function (event) { closePopUp(event); }; @@ -268,7 +268,7 @@ export function closePopUp(e) { t = true; } if (t) { - let modal = $('divModal' + lastModals); + const modal = $('divModal' + lastModals); modal.style.opacity = 0; setTimeout(function () { modal.style.display = 'none'; @@ -303,11 +303,11 @@ export function stopWaiting() { } String.prototype.pixelLength = function (_fontSize = 20) { - let c = document.createElement('span'); + const c = document.createElement('span'); document.body.appendChild(c); c.innerHTML = this; c.style.fontSize = _fontSize + 'px'; - let length = c.offsetWidth; + const length = c.offsetWidth; document.body.removeChild(c); return length; }; @@ -324,7 +324,7 @@ String.prototype.shorten = function (maxLength, _fontSize = 20) { }; export function grayBar(elem, marginTop = 10, marginBottom = 15) { - let d = div(elem); + const d = div(elem); d.style.backgroundColor = 'lightgray'; d.style.height = '2px'; d.style.marginBottom = marginBottom + 'px'; @@ -335,10 +335,10 @@ export function grayBar(elem, marginTop = 10, marginBottom = 15) { String.prototype.replaceTxtByTxt = function (replace = '', by = '', caseSensitive = false) { let i = 0; - let where = []; + const where = []; - let txt = caseSensitive ? this : this.toUpperCase(); - let replaceTxt = caseSensitive ? replace : replace.toUpperCase(); + const txt = caseSensitive ? this : this.toUpperCase(); + const replaceTxt = caseSensitive ? replace : replace.toUpperCase(); while (txt.indexOf(replaceTxt, i) !== -1) { where.push(txt.indexOf(replaceTxt, i)); @@ -347,12 +347,12 @@ String.prototype.replaceTxtByTxt = function (replace = '', by = '', caseSensitiv let r = ''; for (let k = 0; k <= where.length; k++) { - let start = k === 0 ? 0 : where[k - 1]; - let end = k === where.length ? this.length : where[k]; - let s = this.slice(start, end); - let sTxt = caseSensitive ? s : s.toUpperCase(); - let x = sTxt.indexOf(replaceTxt); - let t = x !== -1 ? s.slice(0, x) + by + s.slice(x + replace.length) : s; + const start = k === 0 ? 0 : where[k - 1]; + const end = k === where.length ? this.length : where[k]; + const s = this.slice(start, end); + const sTxt = caseSensitive ? s : s.toUpperCase(); + const x = sTxt.indexOf(replaceTxt); + const t = x !== -1 ? s.slice(0, x) + by + s.slice(x + replace.length) : s; r += t; } return r; @@ -360,7 +360,7 @@ String.prototype.replaceTxtByTxt = function (replace = '', by = '', caseSensitiv // ARRAY PROTOTYPES Array.prototype.switch = function (i1, i2) { - let content_i1 = this[i1]; + const content_i1 = this[i1]; this.splice(i1, 1, this[i2]); this.splice(i2, 1, content_i1); return this; @@ -384,7 +384,7 @@ Array.prototype.findIndex = function (x) { }; Array.prototype.deleteMultiples = function () { - let r = []; + const r = []; for (let i = 0; i < this.length; i++) { if (r.findIndex(this[i]) === -1) { r.push(this[i]); @@ -427,9 +427,9 @@ Array.prototype.fillArray = function (length, what = 0) { // merge and only takes the elements which are in every array Array.prototype.mergeAND = function () { - let send = []; + const send = []; for (let b = 0; b < this[0].length; b++) { - let item = this[0][b]; + const item = this[0][b]; let c = 0; for (let r2 = 1; r2 < this.length; r2++) { if (this[r2].findIndex(item) != -1) { @@ -487,17 +487,17 @@ export function mergeBookings(bookings) { } function mergeComments(c1, c2) { - let meaninglessComments = ['', 'Terminée automatiquement']; + const meaninglessComments = ['', 'Terminée automatiquement']; if (!meaninglessComments.includes(c1)) return c1; if (!meaninglessComments.includes(c2)) return c2; if (c1 != '') return c1; return c2; } - let resultingBookings = []; + const resultingBookings = []; while (bookings.length > 0) { - let booking = bookings.pop(); + const booking = bookings.pop(); // should not be kept if (!displayBooking(booking)) continue; diff --git a/htdocs/general/pop-alert.js b/htdocs/general/pop-alert.js index 564342d..6c50057 100644 --- a/htdocs/general/pop-alert.js +++ b/htdocs/general/pop-alert.js @@ -4,61 +4,59 @@ import {Cahier} from '../cahier/methods.js'; import {popCahierInfos} from '../infos/pop-infos.js'; export function popAlert(txt = 'haha ahah ahah ') { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpAlertContainer'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = '!'; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = txt; } export function popAlertLate() { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpAlertContainer', 'booking'); container.classList.add('Boxes'); container.style.width = '495px'; container.style.height = '180px'; - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = 'Heures tardives'; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = 'Pour ta sécurité, pense à rentrer avant le coucher du soleil.'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; - let btn = div(btnContainer); + const btn = div(btnContainer); btn.classList.add('Buttons'); btn.style.display = 'inline-block'; btn.innerHTML = 'Ok'; @@ -69,30 +67,29 @@ export function popAlertLate() { } export function popAlertAlreadyHavingABooking(_owner) { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpAlertContainer', 'booking'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = '!'; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = 'Il semblerait que vous ayez déjà une sortie en cours'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; @@ -116,31 +113,30 @@ export function popAlertAlreadyHavingABooking(_owner) { } export function popAlertNoWelcomeSession(_owner) { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpAlertContainer', 'booking'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = "Pas suivi de séance d'accueil"; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = "Il semblerait que vous n'ayez pas encore suivi de séance d'accueil."; t.style.minHeight = '60px'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; @@ -167,9 +163,9 @@ export function popAlertNoWelcomeSession(_owner) { } export function popAlertLessThan13Minutes(_bookable, _booking, _choseFunction) { - let elem = openPopUp(); + const elem = openPopUp(); - let txt = + const txt = '' + Cahier.getOwner(_booking, false) + ' est parti ' + @@ -179,30 +175,29 @@ export function popAlertLessThan13Minutes(_bookable, _booking, _choseFunction) { _bookable.code + ' !'; - let container; - container = div(elem); + const container = div(elem); container.style.height = '215px'; container.classList.add('PopUpAlertContainer', 'booking'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = 'Embarcation déjà utilisée'; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = txt + "
Êtes-vous sûr que l'embarcation est disponible ?"; t.style.minHeight = '80px'; - let a = div(container); + const a = div(container); a.style.position = 'absolute'; a.style.left = '12px'; a.style.top = '10px'; @@ -211,7 +206,7 @@ export function popAlertLessThan13Minutes(_bookable, _booking, _choseFunction) { a.style.width = '30px'; a.style.height = '30px'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; @@ -239,13 +234,13 @@ export function popAlertLessThan13Minutes(_bookable, _booking, _choseFunction) { } export function popAlertBookablesHaveJustBeenBooked(_bookablesNotAvailable) { - let elem = openPopUp(); + const elem = openPopUp(); //console.log("_bookablesNotAvailable", _bookablesNotAvailable); let txt = ''; - for (let b of _bookablesNotAvailable) { + for (const b of _bookablesNotAvailable) { txt += '' + Cahier.getOwner(b.lastBooking, false) + @@ -261,8 +256,7 @@ export function popAlertBookablesHaveJustBeenBooked(_bookablesNotAvailable) { ? "Êtes-vous sûr que l'embarcation est disponible ?" : 'Êtes-vous sûr que les embarcations sont disponibles ?'; - let container; - container = div(elem); + const container = div(elem); container.style.height = 'auto'; container.style.minHeight = '215px'; container.style.maxHeight = '80%'; @@ -271,24 +265,24 @@ export function popAlertBookablesHaveJustBeenBooked(_bookablesNotAvailable) { container.classList.add('PopUpAlertContainer', 'booking'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = _bookablesNotAvailable.length == 1 ? 'Embarcation utilisée !' : 'Embarcations utilisées !'; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = txt; t.style.minHeight = '80px'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; btnContainer.style.marginTop = '5px'; @@ -316,27 +310,26 @@ export function popAlertBookablesHaveJustBeenBooked(_bookablesNotAvailable) { } export function popAlertMoreBookablesThanParticipants(bookables, participants) { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpAlertContainer', 'bookable'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = "Trop d'embarcations"; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = 'Vous avez choisi ' + bookables + @@ -344,11 +337,11 @@ export function popAlertMoreBookablesThanParticipants(bookables, participants) { Cahier.getSingularOrPlural(participants, ' participant') + ' !'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; - let btn = div(btnContainer); + const btn = div(btnContainer); btn.classList.add('Buttons', 'ValidateButtons'); btn.style.display = 'inline-block'; btn.innerHTML = 'Modifier le nbr de participants'; @@ -359,34 +352,33 @@ export function popAlertMoreBookablesThanParticipants(bookables, participants) { } export function popAlertTooManyParticipants() { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpAlertContainer', 'bookable'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = 'Trop de participants'; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = 'Vous pouvez au maximum annoncer 15 participants en une sortie !'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; - let btn = div(btnContainer); + const btn = div(btnContainer); btn.classList.add('Buttons', 'ValidateButtons'); btn.style.display = 'inline-block'; btn.innerHTML = 'Modifier le nbr de participants'; @@ -397,34 +389,33 @@ export function popAlertTooManyParticipants() { } export function popAlertTooManyBookables() { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpAlertContainer', 'bookable'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = "Trop d'embarcations"; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = 'Vous pouvez au maximum annoncer 10 embarcations en une sortie !'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; - let btn = div(btnContainer); + const btn = div(btnContainer); btn.classList.add('Buttons', 'ValidateButtons'); btn.style.width = '250px'; btn.style.display = 'inline-block'; @@ -436,27 +427,26 @@ export function popAlertTooManyBookables() { } export function popAlertMissingLicense(_license, _bookable) { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpAlertContainer', 'booking'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = 'Certification manquante !'; grayBar(container, 5); - let t = div(container); + const t = div(container); t.innerHTML = "Il semblerait que vous n'ayez pas la certification " + _license.name + @@ -465,11 +455,11 @@ export function popAlertMissingLicense(_license, _bookable) { ''; t.style.minHeight = '60px'; - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; - let btn = div(btnContainer); + const btn = div(btnContainer); btn.classList.add('Buttons', 'ValidateButtons'); btn.style.width = '250px'; btn.style.display = 'inline-block'; diff --git a/htdocs/general/screen.js b/htdocs/general/screen.js index 0036689..80933dc 100644 --- a/htdocs/general/screen.js +++ b/htdocs/general/screen.js @@ -8,7 +8,7 @@ import {Requests} from './server-requests.js'; let stillMoving = false; export let currentTabElement; //see load for the first element = divtabcahier -let changeTime = 0.3; +const changeTime = 0.3; export function setCurrentTabElement(element) { currentTabElement = element; @@ -197,8 +197,8 @@ tabs.push({ let OldElement = tabs[0]; let NewElement = tabs[0]; window.onhashchange = function () { - let newLocation = window.location.toString(); - let res = newLocation.substr(newLocation.indexOf('#') + 1); + const newLocation = window.location.toString(); + const res = newLocation.substr(newLocation.indexOf('#') + 1); if (res != currentTabElement.id) { //onload refresh diff --git a/htdocs/general/server-requests.js b/htdocs/general/server-requests.js index ed48aac..2c5bad8 100644 --- a/htdocs/general/server-requests.js +++ b/htdocs/general/server-requests.js @@ -94,7 +94,7 @@ export const Requests = { // getUsersList FOR user.js getUsersList: function (text = '') { let filter; - let texts = []; + const texts = []; for (let i = 0; i < text.split(' ').length; i++) { if (text.split(' ')[i] != '') { @@ -102,7 +102,7 @@ export const Requests = { } } - let nbr = texts.length; + const nbr = texts.length; if (nbr == 1) { filter = { filter: { @@ -282,7 +282,7 @@ export const Requests = { }, ]; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.userService.getAll(variables).subscribe(result => { @@ -310,7 +310,7 @@ export const Requests = { whichField = 'id'; } - let txt = elem.value; + const txt = elem.value; let categorie = $('divTabCahierEquipmentElementsSelectCategorie').getElementsByTagName('select')[0].value; if (categorie == 'all') { @@ -323,7 +323,7 @@ export const Requests = { categorie = 'Voile lestée'; } - let f = { + const f = { filter: { groups: [ { @@ -415,7 +415,7 @@ export const Requests = { }); } - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', f); Server.bookableService.getAll(variables).subscribe(result => { @@ -425,14 +425,14 @@ export const Requests = { console.log('NOTHING'); loadElements([]); } else { - let ids = []; + const ids = []; result = mutable(result); for (let i = 0; i < result.items.length; i++) { result.items[i].used = false; ids.push(result.items[i].id); } - let filter = { + const filter = { filter: { groups: [ { @@ -463,12 +463,12 @@ export const Requests = { ], }, }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables).subscribe(r => { let bookables = result.items; - let bookings = r.items; + const bookings = r.items; // Make mutable bookables = mutable(bookables); @@ -498,7 +498,7 @@ export const Requests = { bookableTag = 'Voile lestée'; } - let filter = { + const filter = { filter: { groups: [ { @@ -551,11 +551,11 @@ export const Requests = { }); } - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookableService.getAll(variables).subscribe(result => { - let txt = before + result.length + after; + const txt = before + result.length + after; elem.innerHTML = txt; }); }, @@ -583,7 +583,7 @@ export const Requests = { if (!t) { popAlert('Vous avez déjà choisi cette embarcation'); } else { - let filter = { + const filter = { filter: { groups: [ { @@ -607,7 +607,7 @@ export const Requests = { }, }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookableService.getAll(variables).subscribe(result => { @@ -639,7 +639,7 @@ export const Requests = { // getBookableInfos getBookableInfos: function (nbr, bookableId, elem) { - let filter = { + const filter = { filter: { groups: [{conditions: [{id: {like: {value: bookableId}}}]}], }, @@ -649,12 +649,12 @@ export const Requests = { }, }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookableService.getAll(variables).subscribe(result => { //console.log("getBookableInfos(): ", result); - let filter = { + const filter = { filter: { groups: [ { @@ -686,19 +686,19 @@ export const Requests = { ], }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables).subscribe(bookings => { //console.log("getBookableInfos()_getLastBooking: ", bookings); - let bookable = Object.assign({}, result.items[0]); + const bookable = Object.assign({}, result.items[0]); actualizePopBookable(nbr, bookable, bookings, elem, []); }); }); }, getBookableLastBooking: function (bookableId) { - let filter = { + const filter = { filter: { groups: [ { @@ -730,7 +730,7 @@ export const Requests = { ], }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables).subscribe(bookings => { @@ -741,9 +741,9 @@ export const Requests = { // 1.3 checksBookablesAvailabilityBeforeConfirming: function (_bookables) { - let d = new Date(Cahier.bookingStartDate.getTime() - 10 * 60 * 1000); // subtract 1 minute $$ + const d = new Date(Cahier.bookingStartDate.getTime() - 10 * 60 * 1000); // subtract 1 minute $$ - let f = { + const f = { filter: { groups: [ { @@ -782,10 +782,10 @@ export const Requests = { }, }; - for (let bookable of _bookables) { + for (const bookable of _bookables) { if (bookable.id != 0) { // Matériel personnel - let condition = { + const condition = { id: { equal: { value: bookable.id, @@ -802,7 +802,7 @@ export const Requests = { return; } - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', f); Server.bookingService.getAll(variables).subscribe(result => { @@ -815,7 +815,7 @@ export const Requests = { getActualBookingList: function () { //console.log("GET ACTUAL BOOKING LIST"); - let filter = { + const filter = { filter: { groups: [ { @@ -892,7 +892,7 @@ export const Requests = { ], }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables, true).subscribe(result => { @@ -904,9 +904,9 @@ export const Requests = { // getFinishedBookingListForDay() getFinishedBookingListForDay: function (d = new Date(), table = '?', title) { - let start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0); - let end = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1, 0, 0, 0, 0); - let filter = { + const start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0); + const end = new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1, 0, 0, 0, 0); + const filter = { filter: { groups: [ { @@ -999,13 +999,13 @@ export const Requests = { ], }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables, true).subscribe(result => { // force = true); //console.log("getFinishedBookingListForDay(): ", result); - let transformedBoookings = mergeBookings(mutable(result.items)); + const transformedBoookings = mergeBookings(mutable(result.items)); if (result.length == 0) { createNoBookingMessage(d); } else { @@ -1020,7 +1020,7 @@ export const Requests = { getBookableHistory: function (bookableId, elem, lastDate, Size = 10) { //console.log("getbookableHistory", bookableId, "lastDate:", lastDate, "Size",Size); - let filter = { + const filter = { filter: { groups: [ { @@ -1063,13 +1063,13 @@ export const Requests = { ], }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables).subscribe(first => { //console.log("getBookableHistory(): ", first); - let bookings = first.items; + const bookings = first.items; if (first.items.length == 0) { if (elem.getElementsByClassName('Buttons').length == 1) { @@ -1077,13 +1077,13 @@ export const Requests = { elem.getElementsByClassName('Buttons')[0], ); elem.getElementsByTagName('br')[0].parentElement.removeChild(elem.getElementsByTagName('br')[0]); - let t = div(elem.getElementsByClassName('PopUpBookableHistoryContainerScroll')[0]); + const t = div(elem.getElementsByClassName('PopUpBookableHistoryContainerScroll')[0]); t.innerHTML = 'Toutes les sorties ont été chargées !
'; t.style.textAlign = 'center'; } } else { let end = new Date(bookings[bookings.length - 1].startDate); - let start = new Date(end.getFullYear(), end.getMonth(), end.getDate(), 0, 0, 0, 1); + const start = new Date(end.getFullYear(), end.getMonth(), end.getDate(), 0, 0, 0, 1); end = new Date( end.getFullYear(), end.getMonth(), @@ -1094,7 +1094,7 @@ export const Requests = { 0, ); - let filter = { + const filter = { filter: { groups: [ { @@ -1138,12 +1138,12 @@ export const Requests = { ], }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables).subscribe(addition => { //console.log("getBookableHistory()_Addition: ", addition); - let total = bookings.concat(addition.items); + const total = bookings.concat(addition.items); actualizePopBookableHistory(total, elem); }); } @@ -1152,7 +1152,7 @@ export const Requests = { // getBookingsNbrBetween getBookingsNbrBetween: function (start, end, bookableId = '%', elem = document.body, writeIfOne = true) { - let filter = { + const filter = { filter: { groups: [ { @@ -1190,7 +1190,7 @@ export const Requests = { }, }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables).subscribe(result => { @@ -1206,7 +1206,7 @@ export const Requests = { getMonthlyBookingsNbr: function (start, end) { end = new Date(end.getFullYear(), end.getMonth(), end.getDate(), 23, 59, 59, 99); - let filter = { + const filter = { filter: { groups: [ { @@ -1269,13 +1269,13 @@ export const Requests = { }, }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables).subscribe(result => { // console.log("getMonthlyBookingsNbr(): ", result.length + " sorties", result); - let all = document.getElementsByClassName('divBottoms'); + const all = document.getElementsByClassName('divBottoms'); for (let i = 0; i < all.length; i++) { if (result.length == 0) { all[i].children[0].innerHTML = 'Aucune sortie ce mois'; @@ -1288,7 +1288,7 @@ export const Requests = { // getStats getStats: function (start, end, elem) { - let f = { + const f = { filter: { groups: [ { @@ -1351,19 +1351,19 @@ export const Requests = { ], }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', f); Server.bookingService.getAll(variables).subscribe(result => { //console.log("getStats(): ", result); - let send = mergeBookings(mutable(result.items)); + const send = mergeBookings(mutable(result.items)); actualizeStats(start, end, elem, send); }); }, // getBookingWithBookablesInfos getBookingWithBookablesInfos: function (_booking, which, elem) { - let filter = { + const filter = { filter: { groups: [ { @@ -1380,11 +1380,11 @@ export const Requests = { }, }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookingService.getAll(variables).subscribe(result => { - let send = mergeBookings(result.items); + const send = mergeBookings(result.items); actualizePopBooking(send[0], which, elem); // should only give one booking }); }, @@ -1427,7 +1427,7 @@ export const Requests = { ' booking(s) to terminate, create and update respectively.', ); - let finished = function () { + const finished = function () { Requests.createAndUpdateBookings(inputsToCreate, idsToUpdate, inputsToUpdate); }; @@ -1448,8 +1448,8 @@ export const Requests = { // createAndUpdateBookings createAndUpdateBookings: function (inputsToCreate = [], idsToUpdate = [], inputsToUpdate = []) { // filter the input to only keep the allowed fields, append the id to it, and the actual startDate - let extendInput = function (id, input) { - let inputFiltered = {id: id, startDate: new Date().toISOString()}; + const extendInput = function (id, input) { + const inputFiltered = {id: id, startDate: new Date().toISOString()}; const keys = [ 'bookable', 'participantCount', @@ -1465,7 +1465,7 @@ export const Requests = { return inputFiltered; }; - let finished = function () { + const finished = function () { console.log('Successfully terminated, created and updated the bookings.'); newTab('divTabCahier'); ableToSkipAnimation(); @@ -1473,7 +1473,7 @@ export const Requests = { }; let c = 0; // counter variable - let total = inputsToCreate.length + inputsToUpdate.length; + const total = inputsToCreate.length + inputsToUpdate.length; // ToCreate for (let i = 0; i < inputsToCreate.length; i++) { @@ -1514,7 +1514,7 @@ export const Requests = { ); } - let extended_input = Object.assign({id: id}, input); + const extended_input = Object.assign({id: id}, input); console.log(extended_input); Server.bookingService.updateNow(extended_input).subscribe(result => { console.log('updateBooking():', result); @@ -1523,9 +1523,9 @@ export const Requests = { // getServerInputsForBookingCreating getServerInputsForBookingCreating: function (booking = Cahier.bookings[0], startDate = null) { - let bookingInputs = []; + const bookingInputs = []; for (let i = 0; i < booking.bookables.length; i++) { - let input = { + const input = { owner: booking.owner.id, participantCount: i == 0 ? booking.participantCount - booking.bookables.length + 1 : 1, destination: booking.destination, @@ -1543,9 +1543,9 @@ export const Requests = { // createBooking2 createBooking: function () { let c = 0; - let bookingInputs = Requests.getServerInputsForBookingCreating(Cahier.bookings[0]); + const bookingInputs = Requests.getServerInputsForBookingCreating(Cahier.bookings[0]); for (let i = 0; i < bookingInputs.length; i++) { - let input = bookingInputs[i]; + const input = bookingInputs[i]; Server.bookingService.create(input).subscribe(() => { c++; if (c == bookingInputs.length) { @@ -1560,13 +1560,13 @@ export const Requests = { getOwnerLicenses: function (_owner) { Server.userService.getOne(_owner.id).subscribe(result => { // console.log("getOwnerLicenses(): ", result); - let owner = Object.assign({}, result); + const owner = Object.assign({}, result); Cahier.setOwnerLicenses(owner); }); }, getBookablesLicenses: function (_bookableIds) { - let filter = { + const filter = { filter: { groups: [ { @@ -1588,7 +1588,7 @@ export const Requests = { }, }; - let variables = new Server.QueryVariablesManager(); + const variables = new Server.QueryVariablesManager(); variables.set('variables', filter); Server.bookableService.getAll(variables).subscribe(result => { diff --git a/htdocs/infos/infos.js b/htdocs/infos/infos.js index a0b88bb..b01b2ec 100644 --- a/htdocs/infos/infos.js +++ b/htdocs/infos/infos.js @@ -18,7 +18,7 @@ export function writeNbrInvites(elem) { } export function createAllPropositions(location = $('divTabCahierInfos')) { - let allDestinationPropositions = location + const allDestinationPropositions = location .getElementsByClassName('divTabCahierInfosDestinationPropositions')[0] .getElementsByTagName('div'); for (let i = 0; i < allDestinationPropositions.length; i++) { @@ -31,7 +31,7 @@ export function createAllPropositions(location = $('divTabCahierInfos')) { }); } - let allNbrInvitesPropositions = location + const allNbrInvitesPropositions = location .getElementsByClassName('divTabCahierInfosNbrInvitesPropositions')[0] .getElementsByTagName('div'); for (let i = 0; i < allNbrInvitesPropositions.length; i++) { @@ -53,7 +53,7 @@ export function createAllPropositions(location = $('divTabCahierInfos')) { } export function focusInOrOut(elem, focus) { - let allPropositions = elem.parentElement + const allPropositions = elem.parentElement .getElementsByClassName('PropositionsContainer')[0] .getElementsByTagName('div'); for (let i = 0; i < allPropositions.length; i++) { @@ -87,7 +87,7 @@ function DenyInfos(elem) { } export function checkInfos(location = $('divTabCahierInfos'), nbr = 0) { - let allTabCahierFields = location.getElementsByClassName('TabCahierFields'); + const allTabCahierFields = location.getElementsByClassName('TabCahierFields'); let allInfosOkay = true; for (let i = 0; i < allTabCahierFields.length - 1; i++) { //POUR EVITER LE TEXTAREA... @@ -101,13 +101,13 @@ export function checkInfos(location = $('divTabCahierInfos'), nbr = 0) { } } if (allInfosOkay == true) { - let _participantCount = parseInt( + const _participantCount = parseInt( location.getElementsByClassName('divTabCahierInfosNbrInvites')[0].getElementsByTagName('input')[0].value, ); - let _destination = location + const _destination = location .getElementsByClassName('divTabCahierInfosDestination')[0] .getElementsByTagName('input')[0].value; - let _startComment = location + const _startComment = location .getElementsByClassName('divTabCahierInfosStartComment')[0] .getElementsByTagName('textarea')[0].value; diff --git a/htdocs/infos/pop-infos.js b/htdocs/infos/pop-infos.js index ecbd610..4c2e651 100644 --- a/htdocs/infos/pop-infos.js +++ b/htdocs/infos/pop-infos.js @@ -3,36 +3,35 @@ import {Cahier} from '../cahier/methods.js'; import {checkInfos, createAllPropositions, focusInOrOut, writeDestination, writeNbrInvites} from './infos.js'; export function popCahierInfos(nbr = 0) { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.id = nbr; container.classList.add('PopUpCahierInfosContainer'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = 'Informations'; grayBar(container, 5); - let c = div(container); + const c = div(container); c.classList.add('divTabCahierFieldsContainer'); - let divParticipantCount = div(c); + const divParticipantCount = div(c); divParticipantCount.classList.add('TabCahierFields'); divParticipantCount.classList.add('divTabCahierInfosNbrInvites'); divParticipantCount.innerHTML += 'Nbr de participants'; - let i = input(divParticipantCount); + const i = input(divParticipantCount); i.type = 'number'; i.min = '1'; i.value = Cahier.bookings[nbr].participantCount; @@ -57,7 +56,7 @@ export function popCahierInfos(nbr = 0) { div(divParticipantCount); - let p = div(divParticipantCount); + const p = div(divParticipantCount); p.classList.add('PropositionsContainer'); p.classList.add('divTabCahierInfosNbrInvitesPropositions'); div(p).innerHTML = '1'; @@ -68,7 +67,7 @@ export function popCahierInfos(nbr = 0) { div(p).innerHTML = '8'; div(p).innerHTML = '10'; - let info = div(divParticipantCount); + const info = div(divParticipantCount); info.innerHTML = '(Vous inclu / minimum 1)'; info.style.position = 'absolute'; info.style.marginTop = '110px'; @@ -78,12 +77,12 @@ export function popCahierInfos(nbr = 0) { writeNbrInvites(i); - let divDestination = div(c); + const divDestination = div(c); divDestination.classList.add('TabCahierFields'); divDestination.classList.add('divTabCahierInfosDestination'); divDestination.innerHTML += 'Destination'; - let ii = input(divDestination); + const ii = input(divDestination); ii.value = Cahier.bookings[nbr].destination; ii.placeholder = 'Destination'; ii.addEventListener('keyup', function () { @@ -100,7 +99,7 @@ export function popCahierInfos(nbr = 0) { div(divDestination); - let pp = div(divDestination); + const pp = div(divDestination); pp.classList.add('PropositionsContainer'); pp.classList.add('divTabCahierInfosDestinationPropositions'); div(pp).innerHTML = 'Baie'; @@ -111,12 +110,12 @@ export function popCahierInfos(nbr = 0) { writeDestination(ii); - let divStartComment = div(c); + const divStartComment = div(c); divStartComment.classList.add('TabCahierFields'); divStartComment.classList.add('divTabCahierInfosStartComment'); divStartComment.innerHTML += 'Commentaire'; - let area = document.createElement('textarea'); + const area = document.createElement('textarea'); divStartComment.appendChild(area); area.value = Cahier.bookings[nbr].startComment; area.spellcheck = false; @@ -126,11 +125,11 @@ export function popCahierInfos(nbr = 0) { createAllPropositions(c); - let btnContainer = div(container); + const btnContainer = div(container); btnContainer.style.position = 'relative'; btnContainer.style.textAlign = 'center'; - let btn = div(btnContainer); + const btn = div(btnContainer); btn.classList.add('Buttons'); btn.classList.add('ValidateButtons'); btn.style.display = 'inline-block'; diff --git a/htdocs/member/login.js b/htdocs/member/login.js index 9aa1289..7c4ed0f 100644 --- a/htdocs/member/login.js +++ b/htdocs/member/login.js @@ -2,20 +2,19 @@ import {closePopUp, div, grayBar, input, openPopUp, options} from '../general/ho import {Requests} from '../general/server-requests.js'; export function popLogin() { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpLoginContainer'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = 'Connexion'; @@ -24,7 +23,7 @@ export function popLogin() { div(container); - let i = input(container); + const i = input(container); i.type = 'password'; i.placeholder = 'Mot de passe'; i.addEventListener('keyup', function (event) { @@ -33,7 +32,7 @@ export function popLogin() { } }); - let b = div(container); + const b = div(container); b.classList.add('Buttons'); b.classList.add('ValidateButtons'); b.innerHTML = 'Connexion'; diff --git a/htdocs/member/user.js b/htdocs/member/user.js index 0b2aa5e..204a224 100644 --- a/htdocs/member/user.js +++ b/htdocs/member/user.js @@ -5,19 +5,18 @@ import {Requests} from '../general/server-requests.js'; let lastPeople = []; export function popUser(nbr = 0, elem = openPopUp()) { - let container; - container = div(elem); + const container = div(elem); container.id = nbr; container.classList.add('PopUpUserContainer'); if (elem != $('divTabCahierMemberContainer')) { container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = 'Nom et prénom du membre'; @@ -25,7 +24,7 @@ export function popUser(nbr = 0, elem = openPopUp()) { grayBar(container, 5); } - let i1 = document.createElement('input'); + const i1 = document.createElement('input'); i1.autocomplete = 'off'; i1.id = 'inputTabCahierSearch'; i1.title = 'Veuillez écrire votre nom et prénom'; @@ -58,19 +57,19 @@ export function popUser(nbr = 0, elem = openPopUp()) { i1.focus(); } - let dd = div(container); + const dd = div(container); dd.id = 'divTabCahierSearchResult'; } let enterSearchPosition = 0; function Search(e) { - let text = $('inputTabCahierSearch').value.toUpperCase(); + const text = $('inputTabCahierSearch').value.toUpperCase(); if (e.keyCode == 13) { - let all = document.getElementsByClassName('divTabCahierResultEntry'); + const all = document.getElementsByClassName('divTabCahierResultEntry'); for (let i = 0; i < all.length; i++) { if (typeof all[i].getElementsByTagName('img')[0] != 'undefined') { - let nbr = parseInt(document.getElementsByClassName('PopUpUserContainer')[0].id); // modifier problem si plusieurs popUp ouverts... + const nbr = parseInt(document.getElementsByClassName('PopUpUserContainer')[0].id); // modifier problem si plusieurs popUp ouverts... Cahier.setOwner(nbr, lastPeople[all[i].id]); } @@ -93,14 +92,14 @@ function SearchDown(e) { } if (lastPeople.length != 0) { for (let i = 0; i < lastPeople.length; i++) { - let elem = document.getElementsByClassName('divTabCahierResultEntry')[i]; + const elem = document.getElementsByClassName('divTabCahierResultEntry')[i]; elem.style.backgroundColor = ''; if (typeof elem.getElementsByTagName('img')[0] != 'undefined') { elem.removeChild(elem.getElementsByTagName('img')[0]); } if (i == ((enterSearchPosition % lastPeople.length) + lastPeople.length) % lastPeople.length) { - let img = document.createElement('img'); + const img = document.createElement('img'); img.id = 'imgTabCahierSearchEnter'; img.src = 'img/icons/enter.png'; elem.appendChild(img); @@ -119,11 +118,11 @@ export function createSearchEntries(PeopleCorresponding) { $('divTabCahierSearchResult').innerHTML = ''; if (PeopleCorresponding.length == 0) { - let divResult = document.createElement('div'); + const divResult = document.createElement('div'); divResult.classList.add('divTabCahierResultEntry'); $('divTabCahierSearchResult').appendChild(divResult); - let span1 = document.createElement('span'); + const span1 = document.createElement('span'); span1.classList.add('spanTabCahierSurName'); span1.innerHTML = 'Aucun résultat'; //. Cliquez pour vous rendre sur ichtus.ch "; divResult.appendChild(span1); @@ -133,12 +132,12 @@ export function createSearchEntries(PeopleCorresponding) { lastPeople = []; } else { for (let i = 0; i < PeopleCorresponding.length; i++) { - let divResult = document.createElement('div'); + const divResult = document.createElement('div'); // divResult.id = PeopleCorresponding[i].id; divResult.classList.add('divTabCahierResultEntry'); $('divTabCahierSearchResult').appendChild(divResult); - let nbr = parseInt(document.getElementsByClassName('PopUpUserContainer')[0].id); // modifier problem si plusieurs popUp ouverts... + const nbr = parseInt(document.getElementsByClassName('PopUpUserContainer')[0].id); // modifier problem si plusieurs popUp ouverts... divResult.id = i; @@ -146,13 +145,13 @@ export function createSearchEntries(PeopleCorresponding) { Cahier.setOwner(nbr, PeopleCorresponding[this.id]); }); - let span1 = document.createElement('span'); + const span1 = document.createElement('span'); span1.classList.add('spanTabCahierSurName'); span1.innerHTML = PeopleCorresponding[i].name; //.split(" ")[0]; //changed ! --> div names are false $$ divResult.appendChild(span1); if (i == 0) { - let img = document.createElement('img'); + const img = document.createElement('img'); img.id = 'imgTabCahierSearchEnter'; img.src = 'img/icons/enter.png'; divResult.appendChild(img); diff --git a/htdocs/page/bottom.js b/htdocs/page/bottom.js index 2c080d5..0acd3ef 100644 --- a/htdocs/page/bottom.js +++ b/htdocs/page/bottom.js @@ -3,7 +3,7 @@ import {Requests} from '../general/server-requests.js'; import {popStats} from './pop-stats.js'; export function loadBottoms() { - let allDivTabs = document.getElementsByClassName('divTab'); + const allDivTabs = document.getElementsByClassName('divTab'); while (document.getElementsByClassName('divSpacers').length !== 0) { deleteObjects(document.getElementsByClassName('divSpacers')[0]); @@ -14,25 +14,25 @@ export function loadBottoms() { // new bars for (let i = 0; i < allDivTabs.length; i++) { - let s = div(allDivTabs[i]); + const s = div(allDivTabs[i]); s.className = 'divSpacers'; - let b = div(allDivTabs[i]); + const b = div(allDivTabs[i]); b.className = 'divBottoms'; - let divMonth = div(b); + const divMonth = div(b); divMonth.onclick = function () { popStats(); }; } if (options.statsButtonTextActive) { - let end = new Date(Date.now()); - let start = new Date(end.getFullYear(), end.getMonth(), 1, 0, 0, 0, 1); + const end = new Date(Date.now()); + const start = new Date(end.getFullYear(), end.getMonth(), 1, 0, 0, 0, 1); Requests.getMonthlyBookingsNbr(start, end); } else { - let all = document.getElementsByClassName('divBottoms'); + const all = document.getElementsByClassName('divBottoms'); for (let j = 0; j < all.length; j++) { all[j].children[0].innerHTML = 'Voir les statistiques du mois'; } diff --git a/htdocs/page/pop-stats.js b/htdocs/page/pop-stats.js index e61d673..7139a65 100644 --- a/htdocs/page/pop-stats.js +++ b/htdocs/page/pop-stats.js @@ -3,20 +3,19 @@ import {Requests} from '../general/server-requests.js'; import {Cahier} from '../cahier/methods.js'; export function popStats() { - let elem = openPopUp(); + const elem = openPopUp(); - let container; - container = div(elem); + const container = div(elem); container.classList.add('PopUpStatsContainer'); container.classList.add('Boxes'); - let close = div(container); + const close = div(container); close.className = 'divPopUpClose'; close.onclick = function () { closePopUp({target: elem}, elem); }; - let d = div(container); + const d = div(container); d.style.textAlign = 'center'; d.style.fontSize = '25px'; d.innerHTML = 'Statistiques'; @@ -26,28 +25,28 @@ export function popStats() { div(container).innerHTML = 'Sorties'; div(container).innerHTML = 'Jour'; - let t = div(container); + const t = div(container); t.classList.add('PopUpStatsContainerTitle'); div(t); - let c = div(container); + const c = div(container); c.classList.add('divStatsContainer'); loadStats(); } function loadStats(end = new Date()) { - let start = new Date(end.getFullYear(), end.getMonth(), 1, 0, 0, 0, 1); + const start = new Date(end.getFullYear(), end.getMonth(), 1, 0, 0, 0, 1); - let t = document.getElementsByClassName('PopUpStatsContainerTitle')[0]; + const t = document.getElementsByClassName('PopUpStatsContainerTitle')[0]; t.innerHTML = ''; - let btn = div(t); + const btn = div(t); btn.onclick = function () { loadStats(new Date(start.getFullYear(), start.getMonth(), 0, 23, 59, 59, 99)); // day 0 }; - let btn2 = div(t); + const btn2 = div(t); if (new Date(end.getFullYear(), end.getMonth() + 1, 0, 0, 0, 0, 1) > new Date()) { btn2.style.visibility = 'hidden'; } else { @@ -58,12 +57,12 @@ function loadStats(end = new Date()) { div(t).innerHTML = Mois[start.getMonth()]; - let c = document.getElementsByClassName('divStatsContainer')[0]; + const c = document.getElementsByClassName('divStatsContainer')[0]; c.innerHTML = ''; - let scale = div(c); + const scale = div(c); div(c); // center - let legend = div(c); + const legend = div(c); div(scale); div(scale); @@ -76,19 +75,19 @@ function loadStats(end = new Date()) { } export function actualizeStats(start, end, elem, bookings) { - let stats = []; + const stats = []; - let elapsedTime = Math.abs(end.getTime() - start.getTime()); - let daysNbr = parseInt(elapsedTime / (1000 * 3600 * 24)); + const elapsedTime = Math.abs(end.getTime() - start.getTime()); + const daysNbr = parseInt(elapsedTime / (1000 * 3600 * 24)); for (let i = 0; i < daysNbr + 1; i++) { stats.push(0); } for (let i = 0; i < bookings.length; i++) { - let date = new Date(bookings[i].startDate); + const date = new Date(bookings[i].startDate); - let elapsedTime = Math.abs(date.getTime() - start.getTime()); - let daysNbr = parseInt(elapsedTime / (1000 * 3600 * 24)); + const elapsedTime = Math.abs(date.getTime() - start.getTime()); + const daysNbr = parseInt(elapsedTime / (1000 * 3600 * 24)); stats[daysNbr]++; } @@ -96,27 +95,27 @@ export function actualizeStats(start, end, elem, bookings) { div(elem.parentElement.getElementsByClassName('PopUpStatsContainerTitle')[0]).innerHTML = Cahier.getSingularOrPlural(bookings.length, ' sortie'); - let scale = elem.children[0]; - let center = elem.children[1]; - let legend = elem.children[2]; + const scale = elem.children[0]; + const center = elem.children[1]; + const legend = elem.children[2]; - let max = maxValue(stats); + const max = maxValue(stats); for (let i = 0; i < stats.length; i++) { - let d = div(center); + const d = div(center); d.style.width = 100 / stats.length + '%'; - let bar = div(d); + const bar = div(d); bar.style.height = (stats[i] / max) * 90 + '%'; - let nbr = div(d); + const nbr = div(d); nbr.innerHTML = stats[i]; - let l = div(legend); + const l = div(legend); l.style.width = 100 / stats.length + '%'; if (i % parseInt(stats.length / 10) == 0 || stats.length / 10 < 1) { - let date = new Date(start); + const date = new Date(start); date.setDate(start.getDate() + i); div(l).innerHTML = date.getDate(); @@ -138,7 +137,7 @@ export function actualizeStats(start, end, elem, bookings) { } for (let i = 1; i < count + 1; i++) { - let s = div(scale); + const s = div(scale); s.style.top = 100 - ((i * step) / max) * 90 + '%'; s.innerHTML = i * step; div(s); diff --git a/htdocs/page/top.js b/htdocs/page/top.js index 092b930..1121bae 100644 --- a/htdocs/page/top.js +++ b/htdocs/page/top.js @@ -11,6 +11,7 @@ export function ableToSkipAnimation() { info.innerHTML = "Cliquer pour passer l'animation"; info.id = 'info'; } + export function animate() { running = true; @@ -21,9 +22,9 @@ export function animate() { }, 500); }; - let b, c, w, f, r; + let c, w, f, r; - b = div(document.body); + const b = div(document.body); b.id = 'black'; setTimeout(function () { @@ -116,7 +117,7 @@ function addSvgClass(elem) { function newLetter(i) { if (running) { - let d = div(document.body); + const d = div(document.body); d.classList.add('svgLetters'); d.classList.add('svg'); d.id = i; diff --git a/live-server.js b/live-server.js index a2c5e54..d324d3e 100644 --- a/live-server.js +++ b/live-server.js @@ -1,6 +1,6 @@ import liveServer from 'live-server'; -let params = { +const params = { port: 8181, // Set the server port. Defaults to 8080. host: '0.0.0.0', // Set the address to bind to. Defaults to 0.0.0.0 or process.env.IP. root: './htdocs/', // Set root directory that's being served. Defaults to cwd.