From 8f895dc4d7dbef4d037194bfe92894cd4e04d111 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Wed, 12 May 2021 18:03:44 +0200 Subject: [PATCH] note: use native selector rather than Query --- apps/note/static/note/js/consos.js | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/note/static/note/js/consos.js b/apps/note/static/note/js/consos.js index b149dafe..1366eb88 100644 --- a/apps/note/static/note/js/consos.js +++ b/apps/note/static/note/js/consos.js @@ -28,7 +28,7 @@ $(document).ready(function () { // Switching in double consumptions mode should update the layout $('#double_conso').change(function () { - $('#consos_list_div').removeClass('d-none') + document.getElementById('consos_list_div').classList.remove('d-none') $('#infos_div').attr('class', 'col-sm-5 col-xl-6') const note_list_obj = $('#note_list') @@ -37,7 +37,7 @@ $(document).ready(function () { note_list_obj.html('') buttons.forEach(function (button) { - $('#conso_button_' + button.id).click(function () { + document.getElementById(`conso_button_${button.id}`).addEventListener('click', () => { if (LOCK) { return } removeNote(button, 'conso_button', buttons, 'consos_list')() }) @@ -46,7 +46,7 @@ $(document).ready(function () { }) $('#single_conso').change(function () { - $('#consos_list_div').addClass('d-none') + document.getElementById('consos_list_div').classList.add('d-none') $('#infos_div').attr('class', 'col-sm-5 col-md-4') const consos_list_obj = $('#consos_list') @@ -68,9 +68,9 @@ $(document).ready(function () { }) // Ensure we begin in single consumption. Fix issue with TurboLinks and BootstrapJS - $("label[for='double_conso']").removeClass('active') + document.querySelector("label[for='double_conso']").classList.remove('active') - $('#consume_all').click(consumeAll) + document.getElementById("consume_all").addEventListener('click', consumeAll) }) notes = [] @@ -127,11 +127,10 @@ function addConso (dest, amount, type, category_id, category_name, template_id, html += li('conso_button_' + button.id, button.name + '' + button.quantity + '') }) + document.getElementById(list).innerHTML = html - $('#' + list).html(html) - - buttons.forEach(function (button) { - $('#conso_button_' + button.id).click(function () { + buttons.forEach((button) => { + document.getElementById(`conso_button_${button.id}`).addEventListener('click', () => { if (LOCK) { return } removeNote(button, 'conso_button', buttons, list)() }) @@ -146,12 +145,13 @@ function reset () { notes_display.length = 0 notes.length = 0 buttons.length = 0 - $('#note_list').html('') - $('#consos_list').html('') - $('#note').val('') - $('#note').attr('data-original-title', '').tooltip('hide') - $('#profile_pic').attr('src', '/static/member/img/default_picture.png') - $('#profile_pic_link').attr('href', '#') + document.getElementById('note_list').innerHTML = '' + document.getElementById('consos_list').innerHTML = '' + document.getElementById('note').value = '' + document.getElementById('note').dataset.originTitle = '' + $('#note').tooltip('hide') + document.getElementById('profile_pic').src = '/static/member/img/default_picture.png' + document.getElementById('profile_pic_link').href = '#' refreshHistory() refreshBalance() LOCK = false @@ -168,7 +168,7 @@ function consumeAll () { let error = false if (notes_display.length === 0) { - $('#note').addClass('is-invalid') + document.getElementById('note').classList.add('is-invalid') $('#note_list').html(li('', 'Ajoutez des émetteurs.', 'text-danger')) error = true }