235 lines
10 KiB
HTML
235 lines
10 KiB
HTML
<!doctype html>
|
|
|
|
<html lang="fr">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
<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.3.1.slim.min.js"
|
|
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" 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>
|
|
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.6/dist/autoComplete.min.js"></script>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.6/dist/css/autoComplete.02.min.css">
|
|
|
|
<title>Aquilenet: Éligibilité FTTH</title>
|
|
<style>
|
|
{% include 'style.css'%}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<h1 class="text-center">
|
|
<a href="https://www.aquilenet.fr/" id="aquilenet-title">AQUILENET</a>
|
|
</h1>
|
|
<div id="mainContainer" class="container">
|
|
|
|
<div class="row d-flex justify-content-between align-items-center" data-parent="#mainContainer">
|
|
|
|
<div class="col-12 text-intro">
|
|
<div id="methodPto" class="collapse show testMethods">
|
|
|
|
<h2 class="text-center form-title">Test d'éligibilité par PTO</h2>
|
|
<form id="formPtoTest" method="post" action="/test/pto">
|
|
<div class="form-group" id="ptoForm">
|
|
<label class="form-label" for="pto-number">Numéro PTO</label>
|
|
<input autofocus required type="text" class="form-control" name="pto" id="pto-number" aria-describedby="ptoHelp"
|
|
placeholder="OOOO-XXXX-XXXX" oninvalid="this.setCustomValidity('Veuillez renseigner le PTO')"
|
|
oninput="setCustomValidity('')">
|
|
|
|
<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>
|
|
<div id="ptoInfo" class="collapse" aria-labelledby="ptoForm" data-parent="#ptoForm">
|
|
<div class="card-body">
|
|
PTO (Point de terminaison optique) est un numéro unique que vous pouvez trouver sur le boîtier de
|
|
raccordement de la fibre.
|
|
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>
|
|
</div>
|
|
<button id="buttonPtoTest" type="submit" class="btn btn-sable">Tester le PTO</button>
|
|
</form>
|
|
|
|
<br>
|
|
<button id="buttonNoPto" type="button" data-toggle="collapse" data-target=".testMethods"
|
|
class="btn btn-link page-nav-btn" aria-expanded="false" aria-controls="methodPto methodAddress">Je n'ai pas/ne trouve
|
|
pas le PTO, tester autrement</button>
|
|
</div>
|
|
|
|
<div id="methodAddress" class="collapse testMethods">
|
|
<h2 class="text-center form-title">Test d'éligibilité par adresse</h2>
|
|
<form id="formAddressTest" method="post" action="/test/address">
|
|
<div class="form-group row" id="communeForm">
|
|
<label class="form-label col-sm-2 my-1" for="commune-autocomplete">Commune</label>
|
|
<input id="commune-autocomplete" class="col-sm-9" type="search" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" class="form-control" autocapitalize="off"/>
|
|
</div>
|
|
<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-7 my-1">
|
|
<label class="form-label" for="fantoir-autocomplete">Nom de voie</label>
|
|
<input id="fantoir-autocomplete" class="form-control" type="search" dir="ltr" spellcheck=false autocorrect="off" autocomplete="off" autocapitalize="off"/>
|
|
</div>
|
|
</div>
|
|
<br>
|
|
<button id="btnTestAdresse" type="submit" class="btn btn-sable collapse">Tester l'adresse</button>
|
|
</form>
|
|
<br>
|
|
<button id="buttonReturnPto" type="button" data-toggle="collapse" data-target=".testMethods"
|
|
class="btn btn-link page-nav-btn" aria-expanded="false" aria-controls="methodPto methodAddress">Revenir au test par
|
|
PTO</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
$(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 codeRivoli = ""
|
|
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 setButtonSpinner(buttonSelector, buttonText) {
|
|
// disable button
|
|
$(buttonSelector).prop("disabled", true);
|
|
// add spinner to button
|
|
$(buttonSelector).html(
|
|
`<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>${buttonText}`
|
|
);
|
|
}
|
|
|
|
$('#methodAddress').on('show.bs.collapse', function () {
|
|
$('#communeInput').trigger('input')
|
|
$('#communeInput').trigger('keyup')
|
|
});
|
|
$('#methodAddress').on('shown.bs.collapse', function () {
|
|
$('#communeInput').focus();
|
|
});
|
|
$('#voieForm').on('show.bs.collapse', function () {
|
|
$('#voieInput').trigger('input')
|
|
$('#voieInput').trigger('keyup')
|
|
});
|
|
$('#voieForm').on('shown.bs.collapse', function () {
|
|
$('#numeroVoieInput').focus();
|
|
});
|
|
|
|
const autoCompleteCommune = new autoComplete({
|
|
selector: "#commune-autocomplete",
|
|
placeHolder: "Code postal/nom de commune...",
|
|
data: {
|
|
src: async (query) => {
|
|
const api = "addresses/communes?limit=100";
|
|
const reqUrl = query === '' ? api : api + "&s=" + query
|
|
const source = await fetch(reqUrl, { signalCommunes });
|
|
const data = await source.json();
|
|
return data;
|
|
},
|
|
keys: [ "codeZip", "nom" ],
|
|
},
|
|
resultList: {
|
|
element: (list, data) => {
|
|
}
|
|
},
|
|
resultItem: {
|
|
highlight: true
|
|
},
|
|
debounce: 300,
|
|
events: {
|
|
input: {
|
|
selection: (event) => {
|
|
const selection = event.detail.selection.value;
|
|
autoCompleteCommune.input.value = selection.codeZip + " - " + selection.nom ;
|
|
codeInsee = selection.codeInsee;
|
|
$("#voieForm").collapse("show");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
const autoCompleteFantoir = new autoComplete({
|
|
selector: "#fantoir-autocomplete",
|
|
placeHolder: "Nom de la voie...",
|
|
data: {
|
|
src: async (query) => {
|
|
const api = "addresses/fantoirvoies/" + codeInsee + "?limit=100";
|
|
const reqUrl = query === '' ? api : api + "&s=" + query
|
|
const source = await fetch(reqUrl, { signalVoies });
|
|
const data = await source.json();
|
|
return Object.entries(data).map(e => {return {"name": e[0], "value": e[1]}; });
|
|
},
|
|
keys: [ "name" ],
|
|
},
|
|
resultList: {
|
|
element: (list, data) => {
|
|
}
|
|
},
|
|
resultItem: {
|
|
highlight: true
|
|
},
|
|
debounce: 300,
|
|
events: {
|
|
input: {
|
|
selection: (event) => {
|
|
const selection = event.detail.selection.value;
|
|
autoCompleteFantoir.input.value = selection.name;
|
|
codeRivoli = selection.value;
|
|
$('#btnTestAdresse').collapse('show');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$('#formAddressTest').submit(function(eventObj) {
|
|
setButtonSpinner("#btnTestAdresse", "Test...");
|
|
$('#formAddressTest').append(`<input type="hidden" class="form-control" name="codeInsee" value="${codeInsee}" />`);
|
|
$('#formAddressTest').append(`<input type="hidden" class="form-control" name="codeRivoli" value="${codeRivoli}" />`);
|
|
return true;
|
|
});
|
|
$('#formPtoTest').submit(function(eventObj) {
|
|
setButtonSpinner("#buttonPtoTest", "Test...");
|
|
return true;
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|