Take over search query to routing form

pull/54/merge
Candid Dauth 2016-10-12 17:13:03 +03:00
rodzic dff3e3d0b5
commit 98b9deed7f
3 zmienionych plików z 37 dodań i 0 usunięć

Wyświetl plik

@ -263,6 +263,20 @@
hide: function() {
clearRoutes();
el.hide();
},
route: function(queries, calcRoute) {
if(queries) {
for(var i=0; i<queries.length; i++) {
if(scope.destinations.length <= i)
scope.addDestination();
scope.destinations[i].query = queries[i];
}
}
if(calcRoute)
scope.route();
}
};
routeUi.hide();

Wyświetl plik

@ -15,6 +15,11 @@
clearRenders();
if(scope.searchString.trim() != "") {
if(scope.searchString.match(/ to /)) {
scope.showRoutingForm(true);
return routeUi.route(null, true);
}
map.loadStart();
map.socket.emit("find", { query: scope.searchString }, function(err, results) {
map.loadEnd();
@ -57,6 +62,7 @@
scope.showRoutingForm = function() {
searchUi.hide();
routeUi.show();
routeUi.route(fpUtils.splitRouteQuery(scope.searchString), false);
};
scope.$watch("showAll", function() {

Wyświetl plik

@ -291,6 +291,23 @@
};
};
fpUtils.splitRouteQuery = function(query) {
var queries = [ ];
var spl = query.split(/\s+to\s+/);
spl.forEach(function(it, i1) {
var spl2 = it.split(/\s+via\s+/);
spl2.forEach(function(it2, i2) {
if(i1 == spl.length-1 && i2 != 0)
queries.splice(-1, 0, it2); // vias after the last to should be inserted before the last to (Berlin to Hamburg via Munich should become Berlin, Munich, Hamburg)
else
queries.push(it2);
})
});
return queries;
};
return fpUtils;
});