From 1a2383911a7c4f5ed47e01e37e4794c31f062750 Mon Sep 17 00:00:00 2001 From: Eric Duminil <eric.duminil@gmail.com> Date: Fri, 14 Oct 2022 13:58:42 +0200 Subject: [PATCH] Could be cleaner. Some day. --- .../website/script/simstadt_openlayers.js | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js b/src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js index ad50814..37fd6ee 100644 --- a/src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js +++ b/src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js @@ -153,7 +153,26 @@ const regionChooser = (function(){ var sketch_percentage = Math.round(intersectionArea / polygonArea * 100); var id = feature.getId(); intersections.addFeature(intersection); - var link = '<li onmouseover="regionChooser.highlightPolygon(' + id + ')" onmouseout="regionChooser.resetHighlight(' + id +')">'; + + //TODO: Clean this mess. No jquery + + li = document.createElement('li'); + li.feature = feature; + + li.onmouseover = function(){ regionChooser.highlightPolygon(this.feature) }; + li.onmouseout = function(){ regionChooser.resetHighlight(this.feature) }; +/* li.setAttribute('onmouseover', 'regionChooser.highlightPolygon(' + id + ')"'); + li.setAttribute('onmouseout', 'regionChooser.resetHighlight(' + id + ')"'); +*/ let checkbox = li.appendChild(document.createElement('input')); + checkbox.type = 'checkbox' + checkbox.id = "citygml_" + feature.getId(); + let label = li.appendChild(document.createElement('label')); + label.setAttribute('for', "citygml_" + feature.getId()); + label.textContent = feature.name; + checkbox.setAttribute('onclick', "regionChooser.isDownloadPossible()"); + + +/* var link = '<li onmouseover="regionChooser.highlightPolygon(' + id + ')" onmouseout="regionChooser.resetHighlight(' + id +')">'; link += '<input type="checkbox" id="citygml_' + feature.getId() + '" class="select_citygml" onclick="regionChooser.isDownloadPossible();">' + '<label for="citygml_' + feature.getId() + '">' + feature['name'] + '</label>'; @@ -161,16 +180,14 @@ const regionChooser = (function(){ if (sketch_percentage == 100) { link += ", all inside"; } - dataPanel.append(link + ")\n"); +*/ dataPanel[0].appendChild(li); } - publicScope.highlightPolygon = function(i) { - var feature = kml_source.getFeatureById(i); + publicScope.highlightPolygon = function(feature) { feature.setStyle(styles.highlighted); } - publicScope.resetHighlight = function(i) { - var feature = kml_source.getFeatureById(i); + publicScope.resetHighlight = function(feature) { refreshStyle(feature); } -- GitLab