2021-10-18 19:44:26 +02:00
|
|
|
<!doctype html>
|
|
|
|
|
|
|
|
<html lang="fr">
|
2022-02-12 20:04:05 +01:00
|
|
|
|
2021-10-18 19:44:26 +02:00
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
2022-01-26 10:00:01 +01:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
2022-02-12 20:04:05 +01:00
|
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
|
|
|
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
|
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
|
|
|
|
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
|
|
|
|
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
|
|
|
crossorigin="anonymous"></script>
|
|
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
|
|
|
|
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
|
|
|
|
crossorigin="anonymous"></script>
|
2022-01-26 10:00:01 +01:00
|
|
|
|
2021-10-18 19:44:26 +02:00
|
|
|
<title>Aquilenet: Éligibilité FTTH</title>
|
|
|
|
<style>
|
2022-02-12 20:04:05 +01:00
|
|
|
{% include 'style.css'%}
|
2021-10-18 19:44:26 +02:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2022-01-26 10:00:01 +01:00
|
|
|
<h1 class="text-center" id="aquilenet-title">AQUILENET</h1>
|
|
|
|
<div id="mainContainer" class="container">
|
2022-02-12 11:50:57 +01:00
|
|
|
|
2022-01-26 10:00:01 +01:00
|
|
|
<div class="row d-flex justify-content-between align-items-center" data-parent="#mainContainer">
|
2022-02-12 11:50:57 +01:00
|
|
|
|
2022-01-26 10:00:01 +01:00
|
|
|
<div class="col-12 text-intro">
|
|
|
|
<div id="methodPto" class="collapse show testMethods">
|
2022-02-12 11:50:57 +01:00
|
|
|
|
2022-02-12 20:04:05 +01:00
|
|
|
<h2 class="text-center form-title">Test d'éligibilité par PTO</h2>
|
2022-01-27 23:53:19 +01:00
|
|
|
<form method="post" action="/test/pto">
|
2022-01-26 10:00:01 +01:00
|
|
|
<div class="form-group" id="ptoForm">
|
|
|
|
<label class="form-label" for="pto-number">Numéro PTO</label>
|
2022-02-12 21:31:23 +01:00
|
|
|
<input autofocus required type="text" class="form-control" name="pto" id="pto-number" aria-describedby="ptoHelp"
|
2022-02-12 20:04:05 +01:00
|
|
|
placeholder="OOOO-XXXX-XXXX" oninvalid="this.setCustomValidity('Veuillez renseigner le PTO')"
|
|
|
|
oninput="setCustomValidity('')">
|
2022-02-12 11:50:57 +01:00
|
|
|
|
2022-02-12 20:04:05 +01:00
|
|
|
<small id="ptoHelp" class="form-text btn btn-link" data-toggle="collapse" data-target="#ptoInfo"
|
|
|
|
aria-expanded="true" aria-controls="ptoInfo">Où trouver mon numéro de PTO ?</small>
|
2022-01-26 10:00:01 +01:00
|
|
|
<div id="ptoInfo" class="collapse" aria-labelledby="ptoForm" data-parent="#ptoForm">
|
|
|
|
<div class="card-body">
|
2022-02-12 20:04:05 +01:00
|
|
|
PTO (Point de terminaison optique) est un numéro unique que vous pouvez trouver sur le boîtier de
|
|
|
|
raccordement de la fibre.
|
2022-01-26 10:00:01 +01:00
|
|
|
C'est un petit boîtier blanc installé dans la maison
|
|
|
|
<br>
|
|
|
|
<img src="{{url_for('static', filename='find_pto.jpg')}}" class="img-fluid" alt="Responsive image">
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-02-12 11:50:57 +01:00
|
|
|
</div>
|
2022-01-26 10:00:01 +01:00
|
|
|
<button type="submit" class="btn btn-sable">Tester le PTO</button>
|
|
|
|
</form>
|
2022-02-12 11:50:57 +01:00
|
|
|
|
2022-01-26 15:57:46 +01:00
|
|
|
<br>
|
2022-02-12 20:04:05 +01:00
|
|
|
<button id="buttonNoPto" type="button" data-toggle="collapse" data-target=".testMethods"
|
|
|
|
class="btn btn-link" aria-expanded="false" aria-controls="methodPto methodAddress">Je n'ai pas/ne trouve
|
|
|
|
pas le PTO, tester autrement</button>
|
2022-01-26 10:00:01 +01:00
|
|
|
</div>
|
|
|
|
|
2022-01-26 15:57:46 +01:00
|
|
|
<div id="methodAddress" class="collapse testMethods">
|
2022-02-12 20:04:05 +01:00
|
|
|
<h2 class="text-center form-title">Test d'éligibilité par adresse</h2>
|
|
|
|
<form id="formAddressTest" method="post" action="/test/address">
|
|
|
|
<div class="form-group" id="communeForm">
|
|
|
|
<label class="form-label" for="communeInput">Commune</label>
|
|
|
|
<input autocomplete="off" type="text" list="communes" name="commune" class="form-control"
|
|
|
|
id="communeInput" ondblclick="this.focus();this.select()" aria-describedby="communeHelp"
|
|
|
|
placeholder="Nom de la commune ou code postal">
|
|
|
|
<datalist id="communes">
|
2022-02-12 11:50:57 +01:00
|
|
|
</datalist>
|
2022-01-26 10:00:01 +01:00
|
|
|
</div>
|
2022-02-12 20:04:05 +01:00
|
|
|
<div class="form-row collapse" id="voieForm">
|
|
|
|
<div class="col-sm-3 my-1">
|
|
|
|
<label class="form-label" for="numeroVoieInput">Numéro de voie</label>
|
|
|
|
<input required type="text" name="numeroVoie" class="form-control" id="numeroVoieInput"
|
|
|
|
aria-describedby="numeroVoieHelp" placeholder="Numéro de voie"
|
|
|
|
oninvalid="this.setCustomValidity('Veuillez renseigner le numéro de voie')"
|
|
|
|
oninput="setCustomValidity('')">
|
|
|
|
</div>
|
|
|
|
<div class="col-sm-9 my-1">
|
|
|
|
<label class="form-label" for="voieInput">Nom de voie</label>
|
|
|
|
<input autocomplete="off" type="text" name="voie" list="voies" class="form-control" id="voieInput"
|
|
|
|
aria-describedby="voieHelp" placeholder="Nom de voie">
|
|
|
|
<datalist id="voies">
|
|
|
|
</datalist>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<button id="btnTestAdresse" type="submit" class="btn btn-sable collapse">Tester l'adresse</button>
|
|
|
|
</form>
|
2022-01-26 15:57:46 +01:00
|
|
|
<br>
|
2022-02-12 20:04:05 +01:00
|
|
|
<button id="buttonReturnPto" type="button" data-toggle="collapse" data-target=".testMethods"
|
|
|
|
class="btn btn-link" aria-expanded="false" aria-controls="methodPto methodAddress">Revenir au test par
|
|
|
|
PTO</button>
|
2022-01-26 10:00:01 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-26 15:57:46 +01:00
|
|
|
|
|
|
|
<script>
|
2022-02-12 20:04:05 +01:00
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
// AbortController allows to cancel promises
|
|
|
|
const controllerCommunes = new AbortController();
|
|
|
|
const { signalCommunes } = controllerCommunes;
|
|
|
|
const controllerVoies = new AbortController();
|
|
|
|
const { signalVoies } = controllerVoies;
|
|
|
|
|
|
|
|
// Global variables
|
|
|
|
var communes = []
|
|
|
|
var codeInsee = 0
|
|
|
|
var voies = []
|
|
|
|
var voie = ""
|
|
|
|
|
|
|
|
function sanitizeInputStr(inputStr) {
|
|
|
|
|
|
|
|
inputStr = inputStr.replace(/[ÀÁÂÃÄÅàáâãäå]/g, "a");
|
|
|
|
inputStr = inputStr.replace(/[Ææ]/g, "ae");
|
|
|
|
inputStr = inputStr.replace(/[Çç]/g, "c");
|
|
|
|
inputStr = inputStr.replace(/[ÈÉÊËèéêë]/g, "e");
|
|
|
|
inputStr = inputStr.replace(/[ÌÍÎÏìíîï]/g, "i");
|
|
|
|
inputStr = inputStr.replace(/[Ññ]/g, "n");
|
|
|
|
inputStr = inputStr.replace(/[ÒÓÔÕÖòóôõö]/g, "o");
|
|
|
|
inputStr = inputStr.replace(/[ÙÚÛÜùúûü]/g, "u");
|
|
|
|
inputStr = inputStr.replace(/[Ýý]/g, "y");
|
|
|
|
inputStr = inputStr.replace(/[ß]/g, "ss");
|
|
|
|
|
|
|
|
return inputStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function to update list of communes (calls backend API)
|
|
|
|
function updateCommunes(search = '') {
|
|
|
|
var api = "addresses/communes?limit=15";
|
2022-01-26 15:57:46 +01:00
|
|
|
if (search != '') {
|
2022-02-12 20:04:05 +01:00
|
|
|
api += "&s=" + search;
|
2022-01-26 15:57:46 +01:00
|
|
|
}
|
2022-02-12 20:04:05 +01:00
|
|
|
fetch(api, { signalCommunes })
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
2022-02-12 21:31:23 +01:00
|
|
|
valueMatch=false;
|
2022-02-12 20:04:05 +01:00
|
|
|
if (JSON.stringify(data) !== JSON.stringify(communes)) {
|
2022-01-26 15:57:46 +01:00
|
|
|
$("#communes").empty();
|
2022-02-12 20:04:05 +01:00
|
|
|
communes = data
|
2022-01-28 15:42:08 +01:00
|
|
|
communes.forEach(commune => {
|
2022-02-12 21:31:23 +01:00
|
|
|
value=commune.codeZip + ' ' + commune.nom
|
2022-02-12 11:50:57 +01:00
|
|
|
$("#communes").append("<option codeInsee=" + commune.codeInsee + " value='" +
|
2022-02-12 21:31:23 +01:00
|
|
|
value + "'></option>");
|
|
|
|
if (value === search) {
|
|
|
|
valueMatch=true;
|
|
|
|
}
|
|
|
|
|
2022-01-28 15:42:08 +01:00
|
|
|
});
|
2022-01-27 23:53:19 +01:00
|
|
|
}
|
2022-02-12 21:31:23 +01:00
|
|
|
if (communes.length == 1 || valueMatch) {
|
2022-02-12 20:04:05 +01:00
|
|
|
codeInsee = communes[0].codeInsee;
|
2022-01-27 23:53:19 +01:00
|
|
|
$('#voieForm').collapse('show');
|
|
|
|
} else {
|
|
|
|
$('#voieInput').val('');
|
|
|
|
$('#voieForm').collapse('hide');
|
|
|
|
}
|
2022-02-12 20:04:05 +01:00
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.error("Error fetching communes:", err)
|
|
|
|
})
|
2022-01-27 23:53:19 +01:00
|
|
|
}
|
|
|
|
|
2022-02-12 20:04:05 +01:00
|
|
|
// Function to update list of voies (calls backend API)
|
2022-02-12 23:32:32 +01:00
|
|
|
function updateVoies(search = '') {
|
2022-02-12 20:04:05 +01:00
|
|
|
var api = "addresses/fantoirvoies/" + codeInsee + '?limit=15';
|
2022-01-27 23:53:19 +01:00
|
|
|
if (search != '') {
|
2022-02-12 20:04:05 +01:00
|
|
|
api += "&s=" + search;
|
2022-01-27 23:53:19 +01:00
|
|
|
}
|
2022-02-12 20:04:05 +01:00
|
|
|
fetch(api, { signalVoies })
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
2022-02-12 21:31:23 +01:00
|
|
|
valueMatch=false;
|
2022-02-12 20:04:05 +01:00
|
|
|
if (JSON.stringify(data) !== JSON.stringify(voies)) {
|
2022-01-27 23:53:19 +01:00
|
|
|
$("#voies").empty();
|
2022-02-12 20:04:05 +01:00
|
|
|
voies = Object.entries(data);
|
|
|
|
let voie;
|
|
|
|
for (i in voies) {
|
|
|
|
voie = voies[i]
|
2022-02-12 23:50:33 +01:00
|
|
|
$("#voies").append("<option value='" +
|
|
|
|
voie[1] + "'>" + voie[0] + "</option>");
|
2022-02-12 21:31:23 +01:00
|
|
|
if (voie[0] === search) {
|
|
|
|
valueMatch=true;
|
|
|
|
}
|
2022-02-12 11:50:57 +01:00
|
|
|
}
|
2022-02-12 21:31:23 +01:00
|
|
|
if (voies.length == 1 || valueMatch) {
|
2022-01-27 23:53:19 +01:00
|
|
|
$('#btnTestAdresse').collapse('show');
|
2022-02-12 20:04:05 +01:00
|
|
|
voie = voies[0]
|
2022-02-12 23:50:33 +01:00
|
|
|
$("#voieInput").val(voie[0]);
|
2022-02-12 21:31:23 +01:00
|
|
|
$('#btnTestAdresse').focus();
|
2022-01-26 15:57:46 +01:00
|
|
|
} else {
|
2022-01-27 23:53:19 +01:00
|
|
|
$('#btnTestAdresse').collapse('hide');
|
2022-01-26 15:57:46 +01:00
|
|
|
}
|
|
|
|
}
|
2022-02-12 20:04:05 +01:00
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.error("Error fetching communes:", err)
|
|
|
|
})
|
2022-01-26 15:57:46 +01:00
|
|
|
}
|
2022-02-12 23:32:32 +01:00
|
|
|
|
|
|
|
function fetchWithBackoff (fetchFn, timeout, input) {
|
|
|
|
if(timeout !== null) {
|
|
|
|
clearTimeout(timeout);
|
|
|
|
}
|
|
|
|
if (input.length < 3) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
timeout = setTimeout(() => {
|
|
|
|
const cleanInput = sanitizeInputStr(input);
|
|
|
|
fetchFn(cleanInput);
|
|
|
|
}, 100);
|
|
|
|
return timeout;
|
|
|
|
}
|
|
|
|
|
2022-01-27 23:53:19 +01:00
|
|
|
$('#methodAddress').on('show.bs.collapse', function () {
|
|
|
|
$('#communeInput').trigger('input')
|
|
|
|
$('#communeInput').trigger('keyup')
|
2022-01-26 15:57:46 +01:00
|
|
|
});
|
2022-02-12 21:31:23 +01:00
|
|
|
$('#methodAddress').on('shown.bs.collapse', function () {
|
|
|
|
$('#communeInput').focus();
|
|
|
|
});
|
2022-01-27 23:53:19 +01:00
|
|
|
$('#voieForm').on('show.bs.collapse', function () {
|
|
|
|
$('#voieInput').trigger('input')
|
|
|
|
$('#voieInput').trigger('keyup')
|
|
|
|
});
|
2022-02-12 21:31:23 +01:00
|
|
|
$('#voieForm').on('shown.bs.collapse', function () {
|
|
|
|
$('#numeroVoieInput').focus();
|
|
|
|
});
|
2022-02-12 11:50:57 +01:00
|
|
|
|
2022-02-12 23:32:32 +01:00
|
|
|
let timeoutCommune = null;
|
|
|
|
$('#communeInput').on('input', function () {
|
2022-02-12 20:04:05 +01:00
|
|
|
controllerCommunes.abort();
|
2022-02-12 23:32:32 +01:00
|
|
|
timeoutCommune = fetchWithBackoff(updateCommunes, timeoutCommune, $(this).val());
|
2022-01-26 15:57:46 +01:00
|
|
|
});
|
2022-02-12 11:50:57 +01:00
|
|
|
|
2022-02-12 20:04:05 +01:00
|
|
|
$('#communeInput').on('input', function () {
|
2022-01-26 15:57:46 +01:00
|
|
|
if ($(this).val() === '') {
|
2022-01-27 23:53:19 +01:00
|
|
|
$('#voieForm').collapse('hide');
|
2022-01-26 15:57:46 +01:00
|
|
|
}
|
|
|
|
});
|
2022-02-12 23:32:32 +01:00
|
|
|
|
|
|
|
let timeoutVoie = null;
|
|
|
|
$('#voieInput').on('input', function () {
|
2022-02-12 20:04:05 +01:00
|
|
|
controllerVoies.abort();
|
2022-02-12 23:32:32 +01:00
|
|
|
timeoutVoie = fetchWithBackoff(updateVoies, timeoutVoie, $(this).val());
|
2022-01-27 23:53:19 +01:00
|
|
|
});
|
|
|
|
$('#voieInput').on('input', function () {
|
|
|
|
if ($(this).val() === '') {
|
|
|
|
$('#btnTestAdresse').collapse('hide');
|
|
|
|
}
|
2022-01-26 15:57:46 +01:00
|
|
|
});
|
2022-02-12 11:50:57 +01:00
|
|
|
|
2022-02-12 20:04:05 +01:00
|
|
|
$('#formAddressTest').submit(function(eventObj) {
|
|
|
|
$('#formAddressTest').append(`<input type="hidden" class="form-control" name="codeInsee" value="${codeInsee}" />`);
|
|
|
|
return true;
|
|
|
|
});
|
2022-01-26 15:57:46 +01:00
|
|
|
});
|
|
|
|
</script>
|
2021-10-18 19:44:26 +02:00
|
|
|
</body>
|
2022-02-12 20:04:05 +01:00
|
|
|
|
2022-02-12 23:32:32 +01:00
|
|
|
</html>
|