]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/directions/osrm.js
Fix warnings from rubocop update
[rails.git] / app / assets / javascripts / index / directions / osrm.js
index 00ef24d6fb3f8d8ea6c2b5db6e73529e79a7efdf..2156bf309252c4e1fa50c3f0e657e0fe8e71bcf1 100644 (file)
@@ -31,7 +31,7 @@ function OSRMEngine() {
         I18n.t('javascripts.directions.instructions.end_oneway')        // 17
       ];
 
-      var url = "http://router.project-osrm.org/viaroute?z=14&output=json&instructions=true";
+      var url = document.location.protocol + "//router.project-osrm.org/viaroute?z=14&output=json&instructions=true";
 
       for (var i = 0; i < points.length; i++) {
         url += "&loc=" + points[i].lat + ',' + points[i].lng;
@@ -44,11 +44,11 @@ function OSRMEngine() {
         url += "&checksum=" + hintData.checksum;
       }
 
-      $.ajax({
+      return $.ajax({
         url: url,
         dataType: 'json',
         success: function (data) {
-          if (data.status == 207)
+          if (data.status === 207)
             return callback(true);
 
           previousPoints = points;
@@ -66,9 +66,10 @@ function OSRMEngine() {
             var instText = "<b>" + (i + 1) + ".</b> ";
             instText += TURN_INSTRUCTIONS[instCodes[0]];
             if (instCodes[1]) {
-              instText += "exit " + instCodes[1] + " ";
+              instText += I18n.t('javascripts.directions.instructions.exit', { exit: instCodes[1] } );
             }
-            if (instCodes[0] != 15) {
+            if (instCodes[0] !== 15) {
+              instText += " ";
               instText += s[1] ? "<b>" + s[1] + "</b>" : I18n.t('javascripts.directions.instructions.unnamed');
             }
             if ((i + 1) < data.route_instructions.length) {
@@ -91,4 +92,4 @@ function OSRMEngine() {
   };
 }
 
-OSM.Directions.addEngine(OSRMEngine(), false);
+OSM.Directions.addEngine(new OSRMEngine(), true);