Add links to search results

This commit is contained in:
Adrien Vannson 2021-10-16 13:49:33 +02:00
parent b84bbb0673
commit e1d546a9f8
2 changed files with 50 additions and 20 deletions

View File

@ -156,7 +156,7 @@
</div>
<script src="https://cdn.jsdelivr.net/npm/svg-pan-zoom@3.6.1/dist/svg-pan-zoom.min.js" integrity="sha256-9GNxAyAInGHQ9XzsK4hsAt4E4h65Lr0i6qMn/fCmt8Y=" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="resources/script.js"></script>
</body>
</html>

View File

@ -1,15 +1,3 @@
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
callback(xmlHttp.responseText, xmlHttp.status);
}
}
xmlHttp.open("GET", theUrl, true);
xmlHttp.send(null);
}
function researchRoom()
{
var research = document.getElementById('research').value;
@ -26,13 +14,31 @@ function researchRoom()
res = JSON.parse(xhr.responseText);
for (var i=0; i<res.length; i++) {
table.innerHTML += '<tr><th scope="row">' + res[i].id + '</th><td>' + res[i].name + '</td></tr>';
table.innerHTML += '<tr>\
<th scope="row">\
<a href="#' + res[i].id + '">' + res[i].name + '</a>\
</th>\
<td>' + '??' + '</td>\
</tr>';
}
};
xhr.send(null);
}
// Update the current room based on the current anchor
function updateCurrentRoom()
{
// Hide room research modal
var modal = bootstrap.Modal.getInstance(document.getElementById('room-research-modal'));
if (modal != null) {
modal.hide();
}
var id = window.location.hash;
console.log(id);
}
function putWaitNetworkScreen()
{
outputDiv.innerHTML = "Récupération des informations auprès du serveur...";
@ -45,6 +51,18 @@ function salleInfosToHtml(salle)
return titres + ((salle.description!=null)?("\n<br/>\n" + salle.description):"") + ((salle.locataires.length!=0)?("\n<br/>\n<b>Locataires</b>: " + locataires):"");
}
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
callback(xmlHttp.responseText, xmlHttp.status);
}
}
xmlHttp.open("GET", theUrl, true);
xmlHttp.send(null);
}
function initSvgSupport()
{
var plan = document.getElementById('plan');
@ -93,9 +111,21 @@ function initSvgSupport()
}
// Initialisation du svg.
var plan = document.getElementById('plan');
if(plan.contentDocument==null)
plan.addEventListener('load', initSvgSupport);
else
initSvgSupport();
window.addEventListener("DOMContentLoaded", (event) => {
// Init SVG
var plan = document.getElementById('plan');
if (plan.contentDocument == null) {
plan.addEventListener('load', initSvgSupport);
} else {
initSvgSupport();
}
// Update the current room
if (window.location.hash != "") {
updateCurrentRoom();
}
window.onhashchange = function() {
updateCurrentRoom();
}
});