Deepsource JS issues

This commit is contained in:
Michał Gdula 2023-06-24 21:00:52 +00:00
parent bd379e2c02
commit b57f8a0f2a
3 changed files with 17 additions and 17 deletions

View file

@ -1,10 +1,10 @@
function addFlashMessage(message, type='success') { function addFlashMessage(message, type='success') {
let flask = document.createElement('p'); const flask = document.createElement('p');
flask.onclick = () => flask.remove(); flask.onclick = () => flask.remove();
flask.classList.add(type); flask.classList.add(type);
flask.innerHTML = message; flask.innerHTML = message;
let close = document.createElement('span'); const close = document.createElement('span');
close.innerHTML = '<i class="ph-bold ph-x"></i>'; close.innerHTML = '<i class="ph-bold ph-x"></i>';
flask.appendChild(close); flask.appendChild(close);

View file

@ -1,11 +1,13 @@
let typingTimer;
function showHint() { function showHint() {
let search = document.querySelector('#search'); const search = document.querySelector('#search');
let searchPos = search.getBoundingClientRect(); const searchPos = search.getBoundingClientRect();
let hint = document.querySelector('.search-hint'); let hint = document.querySelector('.search-hint');
hint.style.width = search.offsetWidth + 'px'; hint.style.width = `${search.offsetWidth}px`;
hint.style.left = searchPos.left + 'px'; hint.style.left = `${searchPos.left}px`;
hint.style.top = searchPos.bottom + 'px'; hint.style.top = `${searchPos.bottom}px`;
hint.style.display = 'flex'; hint.style.display = 'flex';
} }
@ -18,13 +20,13 @@ function hideHint() {
function updateHint() { function updateHint() {
let search = document.querySelector('#search'); const search = document.querySelector('#search');
let searchPos = search.getBoundingClientRect(); const searchPos = search.getBoundingClientRect();
let hint = document.querySelector('.search-hint'); let hint = document.querySelector('.search-hint');
hint.style.width = search.offsetWidth + 'px'; hint.style.width = `${search.offsetWidth}px`;
hint.style.left = searchPos.left + 'px'; hint.style.left = `${searchPos.left}px`;
hint.style.top = searchPos.bottom + 'px'; hint.style.top = `${searchPos.bottom}px`;
} }
@ -37,7 +39,7 @@ function getSearch() {
return; return;
} }
fetch('/api/search?q=' + search.toString(), { fetch(`/api/search?q=${search}`, {
method: 'GET', method: 'GET',
}) })
.then(response => response.json()) .then(response => response.json())
@ -54,8 +56,7 @@ function getSearch() {
el.innerHTML = user; el.innerHTML = user;
el.onmousedown = function (event) { el.onmousedown = function (event) {
event.preventDefault(); event.preventDefault();
search = document.querySelector('#search'); search = user.toString();
search.value = user.toString();
search.blur(); search.blur();
} }
hint.appendChild(el); hint.appendChild(el);
@ -68,7 +69,6 @@ function getSearch() {
window.onload = () => { window.onload = () => {
let typingTimer;
let search = document.querySelector('#search'); let search = document.querySelector('#search');
if (search === null) { if (search === null) {

View file

@ -1,6 +1,6 @@
function yeetSession(id) { function yeetSession(id) {
let form = new FormData(); let form = new FormData();
form.append('session_id', id); form.append('session', id);
fetch('/api/tokens', { fetch('/api/tokens', {
method: 'POST', method: 'POST',