Room research

This commit is contained in:
Adrien Vannson 2021-10-16 16:24:33 +02:00
parent 664389333a
commit 8267dfca69

View File

@ -26,19 +26,6 @@ function researchRoom()
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 salleInfosToHtml(salle)
{
titres = ((salle.aliaz.length!=0)?("<h2>"+salle.aliaz.join("</h2> ou <h2>")+"</h2>"):"Aucun alias connu.");
@ -58,23 +45,23 @@ function httpGetAsync(theUrl, callback)
xmlHttp.send(null);
}
function initSvgSupport()
{
var plan = document.getElementById('plan');
svgPanZoom(plan, {zoomEnabled: true, controlIconsEnabled: true});
var salles = plan.contentDocument.getElementsByClassName('svg-salle');
var outputDiv = document.getElementById('selectedSalleInfos');
function selectSalle(e) {
if(document.lastSelectedSalle != null) {
function selectRoom(roomId) {
if (document.lastSelectedSalle != null) {
document.lastSelectedSalle.classList.remove('current-room');
}
document.lastSelectedSalle = e.target;
var svg = document.getElementById('plan');
var room = svg.contentDocument.getElementById('path-salle-' + roomId);
httpGetAsync("api/request.php?salle="+e.target.id.substring("path-salle-".length), function (s,errcode){
if (room == null) {
console.log('Error: the room does not exist');
return;
}
var outputDiv = document.getElementById('selectedSalleInfos');
document.lastSelectedSalle = room;
httpGetAsync("api/request.php?salle="+room.id.substring("path-salle-".length), function (s,errcode){
window.clearTimeout(document.wnsTimeout);
try{
if (s=="404") {
@ -95,11 +82,35 @@ function initSvgSupport()
}
});
e.target.classList.add('current-room');
room.classList.add('current-room');
}
// 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.substring(1); // Remove #
selectRoom(id);
}
function initSvgSupport()
{
var plan = document.getElementById('plan');
svgPanZoom(plan, {zoomEnabled: true, controlIconsEnabled: true});
var salles = plan.contentDocument.getElementsByClassName('svg-salle');
for (var i = 0; i < salles.length; i++) {
salles[i].addEventListener('click', selectSalle);
salles[i].addEventListener('click', function(e) {
var id = e.target.id.substring('path-salle-'.length); // Remove prefix
selectRoom(id);
});
}
}