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') {
let flask = document.createElement('p');
const flask = document.createElement('p');
flask.onclick = () => flask.remove();
flask.classList.add(type);
flask.innerHTML = message;
let close = document.createElement('span');
const close = document.createElement('span');
close.innerHTML = '<i class="ph-bold ph-x"></i>';
flask.appendChild(close);

View file

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

View file

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