boutils 10 years ago
parent
commit
1b508d9668
2 changed files with 12 additions and 98 deletions
  1. 0 12
      index.html
  2. 12 86
      js/app.js

+ 0 - 12
index.html

@@ -134,18 +134,6 @@
 
 
           Aucun résultat trouvé!
           Aucun résultat trouvé!
         </div>
         </div>
-
-        <!--
-
-        <input
-          type="text"
-          class="form-control"
-          ng-model="asyncSelected"
-          placeholder="Locations loaded via $http"
-          uib-typeahead="address for address in getLocation($viewValue)"
-          typeahead-loading="loadingLocations"
-          typeahead-no-results="noResults" />
-          -->
       </div>
       </div>
 
 
       <md-button
       <md-button

+ 12 - 86
js/app.js

@@ -1,4 +1,3 @@
-// file:///Users/francoisbeaufils/Downloads/geocoder-demo-master/index.html
 var app = angular.module('application', ['ngMaterial', 'adaptive.detection', 'ui.bootstrap.typeahead']);
 var app = angular.module('application', ['ngMaterial', 'adaptive.detection', 'ui.bootstrap.typeahead']);
 
 
 app.directive('skrollr', function() {
 app.directive('skrollr', function() {
@@ -11,38 +10,10 @@ app.directive('skrollr', function() {
   return directiveDefinitionObject;
   return directiveDefinitionObject;
 });
 });
 
 
-
-navigator.sayswho = (function(){
-    var ua= navigator.userAgent, tem,
-    M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
-    if(/trident/i.test(M[1])){
-        tem=  /\brv[ :]+(\d+)/g.exec(ua) || [];
-        return 'IE '+(tem[1] || '');
-    }
-    if(M[1]=== 'Chrome'){
-        tem= ua.match(/\b(OPR|Edge)\/(\d+)/);
-        if(tem!== null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
-    }
-    M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
-    if((tem= ua.match(/version\/(\d+)/i))!== null) M.splice(1, 1, tem[1]);
-    return M.join(' ');
-})();
-
-if(navigator.sayswho === 'IE 6' || navigator.sayswho === 'IE 7' || navigator.sayswho === 'IE 8') {
-
-  $(document).ready(function() {
-    $('body').html('<div class="error-navigator">Votre navigateur ' + navigator.sayswho + " n'est pas supporté, vous devez avoir au minimum la version 9.</div>");
-  });
-}
-
-
-
 app.controller('mainController', function($scope, $detection, $http, $mdSidenav, $timeout, $sce, $mdToast) {
 app.controller('mainController', function($scope, $detection, $http, $mdSidenav, $timeout, $sce, $mdToast) {
   $scope.title = "Manche Numerique";
   $scope.title = "Manche Numerique";
   $scope.$sce  = $sce;
   $scope.$sce  = $sce;
 
 
-//DATE_DEB_ETUDES_PREV
-
   var getGeoCodeInProgress = false,
   var getGeoCodeInProgress = false,
       nbJoursFTTH          = 244,
       nbJoursFTTH          = 244,
       nbJoursInscription   = 60,
       nbJoursInscription   = 60,
@@ -449,7 +420,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       map.removeLayer(currentMarker);
       map.removeLayer(currentMarker);
     }
     }
 
 
-    currentMarker = L.marker([$scope.geoCode.y, $scope.geoCode.x], {draggable: true, title: "texst"}).addTo(map); //.bindPopup(data.locations[0].name).openPopup();
+    currentMarker = L.marker([$scope.geoCode.y, $scope.geoCode.x], {draggable: true, title: "texst"}).addTo(map);
 
 
     currentMarker.bindPopup("L'adresse que vous nous avez fournie est localisée sur la carte. Il se peut que la position réelle de votre logement soit un peu différente. Dans ce cas, merci de déplacer le pointeur sur la carte pour le positionner à l'emplacement de votre logement.").openPopup();
     currentMarker.bindPopup("L'adresse que vous nous avez fournie est localisée sur la carte. Il se peut que la position réelle de votre logement soit un peu différente. Dans ce cas, merci de déplacer le pointeur sur la carte pour le positionner à l'emplacement de votre logement.").openPopup();
 
 
@@ -463,7 +434,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
 
     currentMarker.on('dragend', function(event) {
     currentMarker.on('dragend', function(event) {
       var p = currentMarker.getLatLng();
       var p = currentMarker.getLatLng();
-      //console.log('dragend', p);
 
 
       $scope.magicKey = null;
       $scope.magicKey = null;
 
 
@@ -608,7 +578,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
     .error(function(err) {
     .error(function(err) {
       console.error('Oracle issue', err);
       console.error('Oracle issue', err);
 
 
-      //[{"ID_ZAPM_PARTIELLE":"119CP0","DATE_OUV_SERVICE_REEL":null,"DATE_OUV_SERVICE_PREV":null,"DATE_FIN_TRAV_PREV":null}]
       // Debug without Oracle access
       // Debug without Oracle access
       onResults('{"x":-1.1060984089996,"y":49.119046582,"ftth":[{"ID_ZAPM_PARTIELLE":"203AP0","DATE_OUV_SERVICE_REEL":null,"DATE_OUV_SERVICE_PREV":null,"DATE_FIN_TRAV_PREV":"04\/05\/16","DATE_DEB_ETUDES_PREV":"01\/12\/14"}],"adsl":[{"ID_FT_ADSL":"656","LEGENDE":"TV sur ADSL","NATURE":"0 - 37"}],"mimo":null}');
       onResults('{"x":-1.1060984089996,"y":49.119046582,"ftth":[{"ID_ZAPM_PARTIELLE":"203AP0","DATE_OUV_SERVICE_REEL":null,"DATE_OUV_SERVICE_PREV":null,"DATE_FIN_TRAV_PREV":"04\/05\/16","DATE_DEB_ETUDES_PREV":"01\/12\/14"}],"adsl":[{"ID_FT_ADSL":"656","LEGENDE":"TV sur ADSL","NATURE":"0 - 37"}],"mimo":null}');
     })
     })
@@ -639,7 +608,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
         */
         */
       }
       }
 
 
-      //console.log('$scope.results', results, '=>', $scope.results);
       $scope.$apply();
       $scope.$apply();
     };
     };
 
 
@@ -653,7 +621,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
 
     map.on('dblclick', function(e) {
     map.on('dblclick', function(e) {
       var p = e.latlng;
       var p = e.latlng;
-      //console.log('click', e.latlng); // e is an event object (MouseEvent in this case)
+
       $scope.geoCode = {
       $scope.geoCode = {
         x: p.lng,
         x: p.lng,
         y: p.lat
         y: p.lat
@@ -729,7 +697,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
 
       var i = 0, j = 0;
       var i = 0, j = 0;
       $scope.suggestLocation = function(val) {
       $scope.suggestLocation = function(val) {
-        //console.log('__suggestLocation', val);
+
         $scope.suggestionsReady = false;
         $scope.suggestionsReady = false;
         i++;
         i++;
         return $http.get(suggestURL, {
         return $http.get(suggestURL, {
@@ -750,7 +718,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       };
       };
     });
     });
 
 
-    //console.time('FTTH data');
     $http({method: 'POST', url: 'data/FTTH_zapm_partielle.json'}).success(function(data) {
     $http({method: 'POST', url: 'data/FTTH_zapm_partielle.json'}).success(function(data) {
       var style = {
       var style = {
         color    : $scope.colors.ftth,
         color    : $scope.colors.ftth,
@@ -765,15 +732,13 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       };
       };
 
 
       parseData('ftth', data, style, properties);
       parseData('ftth', data, style, properties);
-      //console.timeEnd('FTTH data');
-      //console.debug('Data for FTTH are ready', data);
+
       if($scope.data.mimo && $scope.data.adsl && $scope.data.ftth) {
       if($scope.data.mimo && $scope.data.adsl && $scope.data.ftth) {
         $scope.loaded = true;
         $scope.loaded = true;
       }
       }
       $scope.$evalAsync();
       $scope.$evalAsync();
     });
     });
 
 
-    //console.time('ADSL data');
     $http({method: 'POST', url: 'data/TEL_FT_ADSL.json'}).success(function(data) {
     $http({method: 'POST', url: 'data/TEL_FT_ADSL.json'}).success(function(data) {
       var style = {
       var style = {
         color    : $scope.colors.adsl,
         color    : $scope.colors.adsl,
@@ -787,15 +752,13 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       };
       };
 
 
       parseData('adsl', data, style, properties);
       parseData('adsl', data, style, properties);
-      //console.timeEnd('ADSL data');
-      //console.debug('Data for ADSL are ready', data);
+
       if($scope.data.mimo && $scope.data.adsl && $scope.data.ftth) {
       if($scope.data.mimo && $scope.data.adsl && $scope.data.ftth) {
        $scope.loaded = true;
        $scope.loaded = true;
       }
       }
       $scope.$evalAsync();
       $scope.$evalAsync();
     });
     });
 
 
-    //console.time('MiMo data');
     $http({method: 'POST', url: 'data/Couverture_mimo.json'}).success(function(data) {
     $http({method: 'POST', url: 'data/Couverture_mimo.json'}).success(function(data) {
       var style = {
       var style = {
         color    : $scope.colors.mimo,
         color    : $scope.colors.mimo,
@@ -809,8 +772,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       };
       };
 
 
       parseData('mimo', data, style, properties);
       parseData('mimo', data, style, properties);
-      //console.timeEnd('MiMo data');
-      //console.debug('Data for MIMO are ready', data);
+
       if($scope.data.mimo && $scope.data.adsl && $scope.data.ftth) {
       if($scope.data.mimo && $scope.data.adsl && $scope.data.ftth) {
        $scope.loaded = true;
        $scope.loaded = true;
       }
       }
@@ -829,8 +791,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
   };
   };
 
 
   var isInside = function(polygon, point) {
   var isInside = function(polygon, point) {
-    // ray-casting algorithm based on
-    // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
 
 
     var y = point.x ? point.x : point[0],
     var y = point.x ? point.x : point[0],
         x = point.y ? point.y : point[1];
         x = point.y ? point.y : point[1];
@@ -872,8 +832,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
         case "'":
         case "'":
         case "\\":
         case "\\":
         case "%":
         case "%":
-          return "\\"+char; // prepends a backslash to backslash, percent,
-                            // and double/single quotes
+          return "\\" + char;
       }
       }
     });
     });
   };
   };
@@ -952,14 +911,12 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
 
       }
       }
 
 
-      //console.debug('Reverse', geoCode, address, '=>', adresse, data.address);
       callback(adresse, data.address);
       callback(adresse, data.address);
       $scope.$evalAsync();
       $scope.$evalAsync();
     });
     });
   };
   };
 
 
   $scope.changeMap = function(value) {
   $scope.changeMap = function(value) {
-    //console.log('Goto', value);
     map.removeLayer(cLayer);
     map.removeLayer(cLayer);
     cLayer = L.tileLayer(maps[value], {
     cLayer = L.tileLayer(maps[value], {
         attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
         attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -1000,7 +957,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
 
     getGeoCodeInProgress = true;
     getGeoCodeInProgress = true;
     var url = findURL + "&text=" + address + ((magicKey) ? ("&magicKey=" + magicKey) : ', Basse-Normandie, France');
     var url = findURL + "&text=" + address + ((magicKey) ? ("&magicKey=" + magicKey) : ', Basse-Normandie, France');
-    //console.log('url', url);
     $.get(
     $.get(
     url,
     url,
     function(data, status) {
     function(data, status) {
@@ -1016,15 +972,14 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
            data.locations[0].extent.xmin > searchExtent.xmax) {
            data.locations[0].extent.xmin > searchExtent.xmax) {
 
 
           getGeoCodeInProgress = false;
           getGeoCodeInProgress = false;
-          //console.debug('getGeoCode', address, magicKey, '=>', data);
+
           return callback(null, data);
           return callback(null, data);
         }
         }
         getGeoCodeInProgress = false;
         getGeoCodeInProgress = false;
-        //console.debug('getGeoCode', address, magicKey, '=>', 'No result');
+
         callback('No result for ' + address);
         callback('No result for ' + address);
       } else {
       } else {
         getGeoCodeInProgress = false;
         getGeoCodeInProgress = false;
-        //console.debug('getGeoCode', address, magicKey, '=>', 'No result');
 
 
         callback(status !== 'success' ? status : 'No result for ' + address);
         callback(status !== 'success' ? status : 'No result for ' + address);
       }
       }
@@ -1033,8 +988,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
 
   $scope.getHtmlContent = function(identifier, record) {
   $scope.getHtmlContent = function(identifier, record) {
 
 
-    //var title = record._properties.name.string ? record._properties.name.string : record[record._properties.name.key];
-
     // Tooltip content
     // Tooltip content
     var tooltip = '';
     var tooltip = '';
 
 
@@ -1084,23 +1037,12 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
   };
   };
 
 
   $scope.initPopup = function() {
   $scope.initPopup = function() {
-    //console.log('initPopup', $scope.geoCode);
     $scope.postForm = null;
     $scope.postForm = null;
 
 
     getFullAddress(function(err, address) {
     getFullAddress(function(err, address) {
       if(err) {console.error(err);}
       if(err) {console.error(err);}
 
 
-      //console.log('add', address);
-      $scope.result = {eligibilite: {}, autres: {}};
-
-      // Debug
-      // $scope.result.eligibilite.prenom                  = 'Francois';
-      // $scope.result.eligibilite.nom                     = 'Beaufils';
-      // $scope.result.eligibilite.email                   = 'francoisbeaufils@zeno-labs.com';
-      // $scope.result.eligibilite.vous_etes               = 'locataire';
-      // $scope.result.eligibilite.ce_logement_est         = 'residence_principale';
-      // $scope.result.eligibilite.info_et_libertes        = true;
-      // $scope.result.eligibilite.accord                  = 'avec_souscription';
+      $scope.result                                 = {eligibilite: {}, autres: {}};
 
 
       $scope.result.eligibilite.geo_code            = JSON.stringify($scope.geoCode);
       $scope.result.eligibilite.geo_code            = JSON.stringify($scope.geoCode);
       $scope.result.eligibilite.code_postal         = address.Postal;
       $scope.result.eligibilite.code_postal         = address.Postal;
@@ -1143,11 +1085,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
 
   $scope.onSubmitAddress = function($item, $model, $label) {
   $scope.onSubmitAddress = function($item, $model, $label) {
 
 
-    // console.log('onSubmitAddress address', $scope.address);
-    // console.log('onSubmitAddress $item', $item);
-    // console.log('onSubmitAddress $model', $model);
-    // console.log('onSubmitAddress $label', $label);
-
     // Get magic key
     // Get magic key
     var item = _.find($scope.suggestions, {text: $item});
     var item = _.find($scope.suggestions, {text: $item});
 
 
@@ -1155,8 +1092,8 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       item           = $scope.suggestions[0];
       item           = $scope.suggestions[0];
       $scope.address = item.text;
       $scope.address = item.text;
     }
     }
-    $scope.magicKey = item.magicKey;
-    //console.log('onSubmitAddress -_-item', item, '=>', $scope.magicKey);
+    $scope.magicKey  = item.magicKey;
+
     $scope.getGeoCode($scope.address, $scope.magicKey, function(err, data) {
     $scope.getGeoCode($scope.address, $scope.magicKey, function(err, data) {
 
 
       $scope.geoCode = data && data.locations && data.locations[0] && data.locations[0].feature.geometry;
       $scope.geoCode = data && data.locations && data.locations[0] && data.locations[0].feature.geometry;
@@ -1168,17 +1105,11 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
             position: 'bottom right'
             position: 'bottom right'
       };
       };
 
 
-          // $mdToast.simple()
-          //   .template(')
-          //   .position('bottom right')
-          //   .hideDelay(3000);
-
       if(err || !$scope.geoCode) {
       if(err || !$scope.geoCode) {
         $scope.hideResultPane();
         $scope.hideResultPane();
 
 
         $mdToast.show(toast);
         $mdToast.show(toast);
       }
       }
-      //console.log('Addresses found for', $scope.address, '=>', data, '=> Geocode:', $scope.geoCode);
 
 
       if($scope.geoCode) {
       if($scope.geoCode) {
         addCurrentMarker();
         addCurrentMarker();
@@ -1199,8 +1130,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       $scope.result.eligibilite[key] = value;
       $scope.result.eligibilite[key] = value;
     });
     });
 
 
-    //console.log('postForm', $scope.result.eligibilite);
-
     $scope.$evalAsync();
     $scope.$evalAsync();
 
 
     var keys   = '';
     var keys   = '';
@@ -1240,7 +1169,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
           if(!isNaN(msg)) {
           if(!isNaN(msg)) {
             $scope.postForm = {ok: true};
             $scope.postForm = {ok: true};
 
 
-            //var template = $templateCache.get('nameOfTemplate.html');
 
 
             var numDemande =  moment().format('YYYYMMDD') + msg;
             var numDemande =  moment().format('YYYYMMDD') + msg;
 
 
@@ -1300,8 +1228,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
             body += '<td>' + res2 + '</td>';
             body += '<td>' + res2 + '</td>';
             body += '</tr>';
             body += '</tr>';
 
 
-            //console.log('$scope.result', $scope.result);
-
             body += '</table><br><br>';
             body += '</table><br><br>';
 
 
             body += 'Conformément à la loi "informatique et libertés" du 6 janvier 1978 modifiée, vous bénéficiez d’un droit d’accès, de rectification aux informations qui vous concernent, d’opposition au traitement de vos données personnelles. Si vous souhaitez exercer ce droit et obtenir la communication des informations vous concernant, merci de nous contacter :' + '<br>' +
             body += 'Conformément à la loi "informatique et libertés" du 6 janvier 1978 modifiée, vous bénéficiez d’un droit d’accès, de rectification aux informations qui vous concernent, d’opposition au traitement de vos données personnelles. Si vous souhaitez exercer ce droit et obtenir la communication des informations vous concernant, merci de nous contacter :' + '<br>' +