mirror of
https://gitlab.aliens-lyon.fr/savrillo/gpens.git
synced 2026-09-11 19:20:46 +02:00
Move scripts
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
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 putWaitNetworkScreen()
|
||||
{
|
||||
outputDiv.innerHTML = "Récupération des informations auprès du serveur...";
|
||||
}
|
||||
|
||||
function salleInfosToHtml(salle)
|
||||
{
|
||||
titres = "<h2>"+salle.nom+"</h2>"+((salle.aliaz.length!=0)?(" ou <h2>"+salle.aliaz.join("</h2> ou <h2>")+"</h2>"):"");
|
||||
locataires = salle.locataires.join(", ");
|
||||
return titres + ((salle.description!=null)?("\n<br/>\n" + salle.description):"") + ((salle.locataires.length!=0)?("\n<br/>\n<b>Locataires</b>: " + locataires):"");
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
console.log(salles.length);
|
||||
|
||||
function selectSalle(e) {
|
||||
if(document.lastSelectedSalle != null) {
|
||||
document.lastSelectedSalle.style.fill = document.lastSelectedSalleFColor;
|
||||
document.lastSelectedSalle.style.fill_opacity = document.lastSelectedSalleFOpacity;
|
||||
}
|
||||
|
||||
document.lastSelectedSalle = e.target;
|
||||
window.clearTimeout(document.wnsTimeout);
|
||||
document.wnsTimeout = window.setTimeout(putWaitNetworkScreen, 400);
|
||||
|
||||
httpGetAsync("https://perso.ens-lyon.fr/samy.avrillon/gpens/api/salles.php?salle="+e.target.id.substring("path-salle-".length), function (s,errcode){
|
||||
window.clearTimeout(document.wnsTimeout);
|
||||
try{
|
||||
if (s=="404") {
|
||||
outputDiv.innerHTML = "Aucune information disponible pour cette salle. Si vous en avez, indiquez-les à l'adresse <a href=mailto:samy.avrillon@ens-lyon.fr>samy.avrillon@ens-lyon.fr</a> en indiquant l'identifiant de la salle : "+document.lastSelectedSalle.id.substring("path-salle-".length);
|
||||
return;
|
||||
}
|
||||
ss = JSON.parse(s)
|
||||
if (document.lastSelectedSalle.id==("path-salle-"+ss["id"])) {
|
||||
if (errcode==200) {
|
||||
outputDiv.innerHTML = salleInfosToHtml(ss);
|
||||
} else {
|
||||
outputDiv.innerHTML = "Erreur lors de l'appel à l'interface php: ERREUR "+errcode;
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
console.error("Les données récupéréés de cette salle ne sont pas valides.");
|
||||
console.error(err)
|
||||
}
|
||||
});
|
||||
|
||||
document.lastSelectedSalleFColor = e.target.style.fill;
|
||||
document.lastSelectedSalleFOpacity = e.target.style.fill_opacity;
|
||||
|
||||
e.target.style.fill = tinycolor(e.target.style.fill).saturate(100).brighten(50).toHexString();
|
||||
}
|
||||
|
||||
for (var i = 0; i < salles.length; i++) {
|
||||
salles[i].addEventListener('click', selectSalle);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user