1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
var monAdresse = "800 Chemin de Chez Leclerc, 74160 Neydens, France";
// Tablaux por stoquer les différentes parties d'adresse
var tabPays = new Array();
var tabVille = new Array();
var tabNumeroRue = new Array();
var tabRue = new Array();
var adresseIterator = 0;
var html = "";
html += "<table cellspacing='0' cellpadding='5' border='0'>";
// Séparation des monAdresse à chaque virgule
var separateurVirgule = new RegExp('[,]+','g');
var adressePart = monAdresse.split(separateurVirgule);
if(adressePart == null){
html += "<tr><td>Aucun élémént trouvé ! ...</td></tr>";
} else {
// Sépration de la rue de 2 parties séparées par un espace
var separateurEspace = new RegExp('[ ]+','g');
var ruePart = adressePart[0].split(separateurEspace);
for (g = 1 ; g < ruePart.length; g++){
if (tabRue[adresseIterator] != null){
tabRue[adresseIterator]=(tabRue[adresseIterator]+" "+ruePart[g]);
} else{
tabRue[adresseIterator]=ruePart[g];
}
}
// On place des différentes parties dans les tableaux correspondant
tabNumeroRue[adresseIterator]=ruePart[0];
tabVille[adresseIterator]=adressePart[1];
tabPays[adresseIterator]=adressePart[2];
adresseIterator ++;
}
// Factorisation et Affichage
for (var f = 0; f < tabRue.length; f++ ){
if (tabPays[f] != null){
// Si le pays n'est pas identique à celui de l'adresse précédente
if (tabPays[f] != tabPays[f-1]){
html += "<tr><td nowrap>" + tabPays[f] +"</td></tr>";
if (f > 0 ){
// Si la ville n'est pas identique à celle de l'adresse précédente
if (tabVille[f] != tabVille[f-1]){
html += "<tr><td nowrap>---" + tabVille[f] +"</td></tr>";
// Si l'adresse n'est pas identique à celle de l'adresse précédente
if (tabRue[f] != tabRue[f-1]){
html += "<tr><td nowrap>------" + tabRue[f] +"</td></tr>";
html += "<tr><td nowrap>----------------" + tabNumeroRue[f] +"</td></tr>";
} else{
html += "<tr><td nowrap>----------------" + tabNumeroRue[f] +"</td></tr>";
}
}else{
// Si l'adresse n'est pas identique à celle de l'adresse précédente
if (tabRue[f] != tabRue[f-1]){
html += "<tr><td nowrap>------" + tabRue[f] +"</td></tr>";
html += "<tr><td nowrap>----------------" + tabNumeroRue[f] +"</td></tr>";
} else{
html += "<tr><td nowrap>----------------" + tabNumeroRue[f] +"</td></tr>";
}
}
} else{
html += "<tr><td nowrap>---" + tabVille[f] +"</td></tr>";
}
} else {
if (f > 0 ){
if (tabVille[f] != tabVille[f-1]){
html += "<tr><td nowrap>---" + tabVille[f] +"</td></tr>";
// Si l'adresse n'est pas identique à celle de l'adresse précédente
if (tabRue[f] != tabRue[f-1]){
html += "<tr><td nowrap>------" + tabRue[f] +"</td></tr>";
html += "<tr><td nowrap>----------------" + tabNumeroRue[f] +"</td></tr>";
} else{
html += "<tr><td nowrap>----------------" + tabNumeroRue[f] +"</td></tr>";
}
}else{
// Si l'adresse n'est pas identique à celle de l'adresse précédente
if (tabRue[f] != tabRue[f-1]){
html += "<tr><td nowrap>------" + tabRue[f] +"</td></tr>";
html += "<tr><td nowrap>----------------" + tabNumeroRue[f] +"</td></tr>";
} else{
html += "<tr><td nowrap>----------------" + tabNumeroRue[f] +"</td></tr>";
}
}
} else{
html += "<tr><td nowrap>---" + tabVille[f] +"</td></tr>";
}
}
}
}
html += "</table>";
tableDiv.innerHTML = html; |
Partager