78 lines
2.4 KiB
PHP
78 lines
2.4 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Link Page</title>
|
|
<style>
|
|
#loading {
|
|
display: none;
|
|
width: 50px;
|
|
height: 50px;
|
|
border: 5px solid #f3f3f3;
|
|
border-top: 5px solid #3498db;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<h1>Links</h1>
|
|
<form id="articleForm">
|
|
<label for="article_id">ID Articolo:</label>
|
|
<input type="text" id="article_id" name="id" value="21569"/>
|
|
<br>
|
|
<button type="button" data-action="search">Cerca Articolo</button>
|
|
<button type="button" data-action="checkPrevendita">E' in PreVendita?</button>
|
|
<button type="button" data-action="setPreOrder">Impostalo in PreVendita!</button>
|
|
<br><br>
|
|
|
|
<button type="button" data-action="inprevendita">Libri in Prevendita</button>
|
|
</form>
|
|
<div id="result"></div>
|
|
<div id="loading"></div>
|
|
|
|
<script>
|
|
const form = document.getElementById('articleForm');
|
|
const result = document.getElementById('result');
|
|
const loading = document.getElementById('loading');
|
|
|
|
const buttons = form.querySelectorAll('button');
|
|
buttons.forEach(button => button.addEventListener('click', handleButtonClick));
|
|
|
|
function handleButtonClick(event) {
|
|
const action = event.target.dataset.action;
|
|
const id = form.querySelector('input[name="id"]').value;
|
|
|
|
loading.style.display = 'block'; // Mostra la clessidra
|
|
|
|
let baseUrl = window.location.href;
|
|
baseUrl = baseUrl.slice(0, baseUrl.lastIndexOf('/'));
|
|
|
|
fetch(`${baseUrl}/handle-article-action-pao/${id}/${action}`)
|
|
.then(response => response.text())
|
|
.then(data => {
|
|
result.innerHTML = data;
|
|
loading.style.display = 'none'; // Nasconde la clessidra una volta completato
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|