Fix searh for terms and results including HTML chars
This commit is contained in:
parent
cfeafc11d9
commit
ae47583e2d
@ -256,7 +256,7 @@ function polyline_get_middle_coords(coords) {
|
||||
var highlighted_line;
|
||||
var default_street_color = "#3388ff";
|
||||
function search(e) {
|
||||
var query = htmlEntities(document.getElementById("search_query").value);
|
||||
var query = document.getElementById("search_query").value;
|
||||
document.getElementById('search_results').innerHTML = "";
|
||||
if (query.length > 0 || e.key == "Enter") {
|
||||
results = document.createElement("ul");
|
||||
@ -271,7 +271,7 @@ function search(e) {
|
||||
regex = new RegExp(query, 'i');
|
||||
if (item.feature.properties.name.match(regex)) {
|
||||
el = document.createElement("li");
|
||||
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="layers._layers[' + i + '].layer._layers[' + item._leaflet_id + '].fire(\'click\'); return false;">' + item.feature.properties.name + "</a>";
|
||||
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="layers._layers[' + i + '].layer._layers[' + item._leaflet_id + '].fire(\'click\'); return false;">' + htmlEntities(item.feature.properties.name) + "</a>";
|
||||
results.appendChild(el);
|
||||
}
|
||||
break;
|
||||
@ -283,12 +283,11 @@ function search(e) {
|
||||
regex = new RegExp(query, 'i');
|
||||
|
||||
if (item.feature.properties.name.match(regex)) {
|
||||
console.log(item.options.color);
|
||||
item.options.color = "#FF0000";
|
||||
item.redraw();
|
||||
el = document.createElement("li");
|
||||
zpos = polyline_get_middle_coords(item.feature.geometry.coordinates);
|
||||
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="latLng2 = L.latLng(' + zpos[1] + ',' + zpos[0] + '); jump_to(latLng2); return false;">' + item.feature.properties.name + "</a>";
|
||||
el.innerHTML = "[" + layers._layers[i].name + "] " + '<a href="#" onclick="latLng2 = L.latLng(' + zpos[1] + ',' + zpos[0] + '); jump_to(latLng2); return false;">' + htmlEntities(item.feature.properties.name) + "</a>";
|
||||
results.appendChild(el);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user