boutils 10 anni fa
parent
commit
1b508d9668
2 ha cambiato i file con 12 aggiunte e 98 eliminazioni
  1. 0 12
      index.html
  2. 12 86
      js/app.js

+ 0 - 12
index.html

@@ -134,18 +134,6 @@
 
           Aucun résultat trouvé!
         </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>
 
       <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']);
 
 app.directive('skrollr', function() {
@@ -11,38 +10,10 @@ app.directive('skrollr', function() {
   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) {
   $scope.title = "Manche Numerique";
   $scope.$sce  = $sce;
 
-//DATE_DEB_ETUDES_PREV
-
   var getGeoCodeInProgress = false,
       nbJoursFTTH          = 244,
       nbJoursInscription   = 60,
@@ -449,7 +420,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       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();
 
@@ -463,7 +434,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
     currentMarker.on('dragend', function(event) {
       var p = currentMarker.getLatLng();
-      //console.log('dragend', p);
 
       $scope.magicKey = null;
 
@@ -608,7 +578,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
     .error(function(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
       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();
     };
 
@@ -653,7 +621,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
     map.on('dblclick', function(e) {
       var p = e.latlng;
-      //console.log('click', e.latlng); // e is an event object (MouseEvent in this case)
+
       $scope.geoCode = {
         x: p.lng,
         y: p.lat
@@ -729,7 +697,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
       var i = 0, j = 0;
       $scope.suggestLocation = function(val) {
-        //console.log('__suggestLocation', val);
+
         $scope.suggestionsReady = false;
         i++;
         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) {
       var style = {
         color    : $scope.colors.ftth,
@@ -765,15 +732,13 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       };
 
       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) {
         $scope.loaded = true;
       }
       $scope.$evalAsync();
     });
 
-    //console.time('ADSL data');
     $http({method: 'POST', url: 'data/TEL_FT_ADSL.json'}).success(function(data) {
       var style = {
         color    : $scope.colors.adsl,
@@ -787,15 +752,13 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       };
 
       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) {
        $scope.loaded = true;
       }
       $scope.$evalAsync();
     });
 
-    //console.time('MiMo data');
     $http({method: 'POST', url: 'data/Couverture_mimo.json'}).success(function(data) {
       var style = {
         color    : $scope.colors.mimo,
@@ -809,8 +772,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       };
 
       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) {
        $scope.loaded = true;
       }
@@ -829,8 +791,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
   };
 
   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],
         x = point.y ? point.y : point[1];
@@ -872,8 +832,7 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
         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);
       $scope.$evalAsync();
     });
   };
 
   $scope.changeMap = function(value) {
-    //console.log('Goto', value);
     map.removeLayer(cLayer);
     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>',
@@ -1000,7 +957,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
     getGeoCodeInProgress = true;
     var url = findURL + "&text=" + address + ((magicKey) ? ("&magicKey=" + magicKey) : ', Basse-Normandie, France');
-    //console.log('url', url);
     $.get(
     url,
     function(data, status) {
@@ -1016,15 +972,14 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
            data.locations[0].extent.xmin > searchExtent.xmax) {
 
           getGeoCodeInProgress = false;
-          //console.debug('getGeoCode', address, magicKey, '=>', data);
+
           return callback(null, data);
         }
         getGeoCodeInProgress = false;
-        //console.debug('getGeoCode', address, magicKey, '=>', 'No result');
+
         callback('No result for ' + address);
       } else {
         getGeoCodeInProgress = false;
-        //console.debug('getGeoCode', address, magicKey, '=>', 'No result');
 
         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) {
 
-    //var title = record._properties.name.string ? record._properties.name.string : record[record._properties.name.key];
-
     // Tooltip content
     var tooltip = '';
 
@@ -1084,23 +1037,12 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
   };
 
   $scope.initPopup = function() {
-    //console.log('initPopup', $scope.geoCode);
     $scope.postForm = null;
 
     getFullAddress(function(err, address) {
       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.code_postal         = address.Postal;
@@ -1143,11 +1085,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
 
   $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
     var item = _.find($scope.suggestions, {text: $item});
 
@@ -1155,8 +1092,8 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       item           = $scope.suggestions[0];
       $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.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'
       };
 
-          // $mdToast.simple()
-          //   .template(')
-          //   .position('bottom right')
-          //   .hideDelay(3000);
-
       if(err || !$scope.geoCode) {
         $scope.hideResultPane();
 
         $mdToast.show(toast);
       }
-      //console.log('Addresses found for', $scope.address, '=>', data, '=> Geocode:', $scope.geoCode);
 
       if($scope.geoCode) {
         addCurrentMarker();
@@ -1199,8 +1130,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
       $scope.result.eligibilite[key] = value;
     });
 
-    //console.log('postForm', $scope.result.eligibilite);
-
     $scope.$evalAsync();
 
     var keys   = '';
@@ -1240,7 +1169,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
           if(!isNaN(msg)) {
             $scope.postForm = {ok: true};
 
-            //var template = $templateCache.get('nameOfTemplate.html');
 
             var numDemande =  moment().format('YYYYMMDD') + msg;
 
@@ -1300,8 +1228,6 @@ app.controller('mainController', function($scope, $detection, $http, $mdSidenav,
             body += '<td>' + res2 + '</td>';
             body += '</tr>';
 
-            //console.log('$scope.result', $scope.result);
-
             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>' +