whatapp-go-pvnet/frontend/assets/js/index.js

86 lines
2.6 KiB
JavaScript
Raw Normal View History

2025-05-09 08:14:22 +00:00
console.log("la");
console.log("la");
async function validatePath() {
const pathInput = document.getElementById('path-input');
const statusIcon = document.getElementById('path-status-icon');
const validateBtn = document.getElementById('validate-btn');
const inputPath=document.getElementById('path');
const inputPathV=document.getElementById('namePath');
const path = pathInput.value;
if (!path) {
statusIcon.innerHTML = '<i class="fas fa-times has-text-danger"></i>';
validateBtn.disabled = true;
return;
}
statusIcon.innerHTML = '<i class="fas fa-circle-notch fa-spin"></i>'; // Loading icon
try {
const response = await fetch('/validate-path', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ path }),
});
if (response.ok) {
statusIcon.innerHTML = '<i class="fas fa-check-square"></i>';
validateBtn.disabled = false;
inputPath.value=path;
inputPathV.style.display="block";
} else {
const result = await response.json();
statusIcon.innerHTML = '<i class="fas fa-exclamation-triangle"></i>';
validateBtn.disabled = true;
console.error('Error:', result.error);
}
} catch (error) {
statusIcon.innerHTML = '<i class="fas fa-exclamation-triangle"></i>';
validateBtn.disabled = true;
console.error('Request failed:', error);
}
}
function disableAllInputPath(id){
console.log(this)
var inputs = document.querySelectorAll('#path-'+id+' .fff');
var btn =document.getElementById('btn-path-annuler-'+id)
btn.style.display = "none";
var btn2 =document.getElementById('btn-path-edit-'+id)
btn2.style.display = "block";
var btn3 =document.getElementById('btn-path-valider-'+id)
btn3.style.display = "none";
inputs.forEach(function(input) {
input.disabled = true;
});
}
function enableAllInputPath(id){
console.log(this)
var inputs = document.querySelectorAll('#path-'+id+' .fff');
var btn =document.getElementById('btn-path-annuler-'+id)
btn.style.display = "block";
var btn2 =document.getElementById('btn-path-edit-'+id)
btn2.style.display = "none";
var btn3 =document.getElementById('btn-path-valider-'+id)
btn3.style.display = "block";
inputs.forEach(function(input) {
input.disabled = false;
});
}
function setInputHidden(target,value){
document.getElementById(target).value = value;
}
function hide(target){
var btn =document.getElementById(target)
btn.style.display = "none";
}
document.addEventListener("htmx:afterOnLoad", function (event) {
console.log("Réponse du serveur :", event.detail.xhr.responseText);
});