From bcca20a486a0c224fd1b370b6e321553283b5651 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Mon, 7 Oct 2024 11:13:05 +0200 Subject: [PATCH] fix: latin name for black alder (alnus glutinosa) --- .../map_applications/phytophthora/js/map.js | 461 ++++++++---------- 1 file changed, 202 insertions(+), 259 deletions(-) diff --git a/src/main/webapp/map_applications/phytophthora/js/map.js b/src/main/webapp/map_applications/phytophthora/js/map.js index cbbf27c6..52e59a2e 100755 --- a/src/main/webapp/map_applications/phytophthora/js/map.js +++ b/src/main/webapp/map_applications/phytophthora/js/map.js @@ -36,8 +36,7 @@ var geolocation; * Initializes the map with all its layers * @returns {undefined} */ -async function initMap() -{ +async function initMap() { var features = new ol.Collection(); // Icon styling for the observations layer @@ -45,52 +44,52 @@ async function initMap() var styles = { // Bøk = rød 'fagus sylvatica': [new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({color: [255, 0, 0, 1]}), - stroke: new ol.style.Stroke({width: 1, color: [0, 0, 0, 1]}), - radius: iconRadius - }) - })], + image: new ol.style.Circle({ + fill: new ol.style.Fill({ color: [255, 0, 0, 1] }), + stroke: new ol.style.Stroke({ width: 1, color: [0, 0, 0, 1] }), + radius: iconRadius + }) + })], // Gråor = dyp oransje 'alnus incana': [new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({color: [239, 133, 19, 1]}), - stroke: new ol.style.Stroke({width: 1, color: [0, 0, 0, 1]}), - radius: iconRadius - }) - })], + image: new ol.style.Circle({ + fill: new ol.style.Fill({ color: [239, 133, 19, 1] }), + stroke: new ol.style.Stroke({ width: 1, color: [0, 0, 0, 1] }), + radius: iconRadius + }) + })], // Eik = gul 'quercus': [new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({color: [239, 236, 19, 1]}), - stroke: new ol.style.Stroke({width: 1, color: [0, 0, 0, 1]}), - radius: iconRadius - }) - })], + image: new ol.style.Circle({ + fill: new ol.style.Fill({ color: [239, 236, 19, 1] }), + stroke: new ol.style.Stroke({ width: 1, color: [0, 0, 0, 1] }), + radius: iconRadius + }) + })], // Lønn = grønn 'acer': [new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({color: [0, 255, 0, 1]}), - stroke: new ol.style.Stroke({width: 1, color: [0, 0, 0, 1]}), - radius: iconRadius - }) - })], + image: new ol.style.Circle({ + fill: new ol.style.Fill({ color: [0, 255, 0, 1] }), + stroke: new ol.style.Stroke({ width: 1, color: [0, 0, 0, 1] }), + radius: iconRadius + }) + })], // Svartor = grågrønn - 'svartor': [new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({color: [122, 175, 131, 1]}), - stroke: new ol.style.Stroke({width: 1, color: [0, 0, 0, 1]}), - radius: iconRadius - }) - })], + 'alnus glutinosa': [new ol.style.Style({ + image: new ol.style.Circle({ + fill: new ol.style.Fill({ color: [122, 175, 131, 1] }), + stroke: new ol.style.Stroke({ width: 1, color: [0, 0, 0, 1] }), + radius: iconRadius + }) + })], // Planteriket = blå 'plantae': [new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({color: [0, 0, 255, 1]}), - stroke: new ol.style.Stroke({width: 1, color: [0, 0, 0, 1]}), - radius: iconRadius - }) + image: new ol.style.Circle({ + fill: new ol.style.Fill({ color: [0, 0, 255, 1] }), + stroke: new ol.style.Stroke({ width: 1, color: [0, 0, 0, 1] }), + radius: iconRadius }) + }) ] }; @@ -102,24 +101,21 @@ async function initMap() style: function (feature, resolution) { // Site that has been cleared is all black var observationData = JSON.parse(feature.get("observationData")); - + var retVal = null; - if (feature.get("cropOrganism") != null && feature.get("cropOrganism")["latinName"] != null) - { + if (feature.get("cropOrganism") != null && feature.get("cropOrganism")["latinName"] != null) { retVal = styles[feature.get("cropOrganism")["latinName"].toLowerCase()]; - } else - { + } else { retVal = styles["plantae"]; } //console.info(retVal[0].getImage().getStroke().getWidth()); // If symptom has been registered, mark with inner black dot - if (observationData["symptom"] != "Ikke symptom" && observationData["symptom"] != "Irrelevant") - { + if (observationData["symptom"] != "Ikke symptom" && observationData["symptom"] != "Irrelevant") { retVal = [ new ol.style.Style({ image: new ol.style.Circle({ - fill: new ol.style.Fill({color: [0, 0, 0, 1]}), - stroke: new ol.style.Stroke({width: 8, color: retVal[0].getImage().getFill().getColor()}), + fill: new ol.style.Fill({ color: [0, 0, 0, 1] }), + stroke: new ol.style.Stroke({ width: 8, color: retVal[0].getImage().getFill().getColor() }), radius: iconRadius }) }) @@ -136,12 +132,12 @@ async function initMap() features: new ol.Collection() }), style: [new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({color: [255, 255, 255, 1]}), - stroke: new ol.style.Stroke({color: [0, 0, 0, 1], width: 3, lineDash: [2, 2]}), - radius: 10 - }) - })] + image: new ol.style.Circle({ + fill: new ol.style.Fill({ color: [255, 255, 255, 1] }), + stroke: new ol.style.Stroke({ color: [0, 0, 0, 1], width: 3, lineDash: [2, 2] }), + radius: 10 + }) + })] }); @@ -157,15 +153,15 @@ async function initMap() }); var topo = - new ol.layer.Tile({ - opacity: 1, - source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options)) - }); - - + new ol.layer.Tile({ + opacity: 1, + source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */(options)) + }); + + map = new ol.Map({ target: 'map', - controls: ol.control.defaults({attribution: false}), // Hide the attribution + controls: ol.control.defaults({ attribution: false }), // Hide the attribution layers: [ topo, featureOverlay, @@ -186,19 +182,19 @@ async function initMap() }); var positionFeature = new ol.Feature(); positionFeature.setStyle( - new ol.style.Style({ - image: new ol.style.Circle({ - radius: 6, - fill: new ol.style.Fill({ - color: '#3399CC', - }), - stroke: new ol.style.Stroke({ - color: '#fff', - width: 2, - }), + new ol.style.Style({ + image: new ol.style.Circle({ + radius: 6, + fill: new ol.style.Fill({ + color: '#3399CC', }), - }) - ); + stroke: new ol.style.Stroke({ + color: '#fff', + width: 2, + }), + }), + }) + ); geolocation.on('change:position', function () { var coordinates = geolocation.getPosition(); @@ -223,9 +219,9 @@ async function initMap() map.on('click', function (evt) { //features = [] var feature = map.forEachFeatureAtPixel( - evt.pixel, function (ft, l) { - return ft; - } + evt.pixel, function (ft, l) { + return ft; + } ); var vectorSource = newFeatureOverlay.getSource(); @@ -237,8 +233,7 @@ async function initMap() var fakeFeature = createFeature(feature.getGeometry().getCoordinates()); vectorSource.addFeature(fakeFeature); displayFeature(feature); - } else if (registration) - { + } else if (registration) { var newFeature = createFeature(map.getCoordinateFromPixel(evt.pixel)); vectorSource.addFeature(newFeature); editFeature(newFeature.getId()); @@ -251,10 +246,8 @@ async function initMap() let openLayersDefaultStyle = undefined; -function getOpenLayersDefaultStyle() -{ - if (openLayersDefaultStyle == undefined) - { +function getOpenLayersDefaultStyle() { + if (openLayersDefaultStyle == undefined) { var fill = new ol.style.Fill({ color: 'rgba(255,255,255,0.4)' }); @@ -284,8 +277,7 @@ function getOpenLayersDefaultStyle() * @param {type} fromSeason * @returns {undefined} */ -function getAndRenderObservations(fromSeason) -{ +function getAndRenderObservations(fromSeason) { //console.info("getAndRenderObservations(" + season + ")"); $.getJSON("/rest/observation/filter/1/geoJSON?from=" + fromSeason + "-01-01&pestId=" + phytophthora.organismId, function (geoData) { //console.info(geoData) @@ -308,66 +300,58 @@ function getAndRenderObservations(fromSeason) * @param {type} countyNo * @returns {undefined} */ -function getAndRenderObservationsForReport(fromSeason, countyNo = "-1") -{ +function getAndRenderObservationsForReport(fromSeason, countyNo = "-1") { //console.info("getAndRenderObservations(" + season + ")"); $.getJSON("/rest/observation/filter/1/geoJSON?from=" + fromSeason + "-01-01&pestId=" + phytophthora.organismId, function (geoData) { //console.info(geoData) // Filter by county $.getJSON("/corsproxy/https://ws.geonorge.no/kommuneinfo/v1/fylker/" + countyNo + "/omrade") - .always(function (serviceResponse) { - //console.info(geoData); - //console.info(serviceResponse); - - if (parseInt(countyNo) > 0) - { - var filteredFeatures = []; - for (var i = 0; i < geoData.features.length; i++) - { - var featureToBeFiltered = geoData.features[i]; - coordinate = proj4("EPSG:4326", "EPSG:4258", [featureToBeFiltered.geometry.coordinates[0], featureToBeFiltered.geometry.coordinates[1]]); - // For some weird reason, d3 returns NOT contains in our case - if (!d3.geoContains(serviceResponse.omrade, coordinate)) - { - //console.info(featureToBeFiltered); - filteredFeatures.push(featureToBeFiltered); - } + .always(function (serviceResponse) { + //console.info(geoData); + //console.info(serviceResponse); + + if (parseInt(countyNo) > 0) { + var filteredFeatures = []; + for (var i = 0; i < geoData.features.length; i++) { + var featureToBeFiltered = geoData.features[i]; + coordinate = proj4("EPSG:4326", "EPSG:4258", [featureToBeFiltered.geometry.coordinates[0], featureToBeFiltered.geometry.coordinates[1]]); + // For some weird reason, d3 returns NOT contains in our case + if (!d3.geoContains(serviceResponse.omrade, coordinate)) { //console.info(featureToBeFiltered); + filteredFeatures.push(featureToBeFiltered); } - //console.info(filteredFeatures); - geoData.features = filteredFeatures; + //console.info(featureToBeFiltered); } + //console.info(filteredFeatures); + geoData.features = filteredFeatures; + } - var format = new ol.format.GeoJSON(); + var format = new ol.format.GeoJSON(); - var drawnfeatures = format.readFeatures(geoData, { - //dataProjection: "EPSG:32633", - dataProjection: "EPSG:4326", - featureProjection: map.getView().getProjection().getCode() - }); - featureOverlay.getSource().clear(); - featureOverlay.getSource().addFeatures(drawnfeatures); - } - ); + var drawnfeatures = format.readFeatures(geoData, { + //dataProjection: "EPSG:32633", + dataProjection: "EPSG:4326", + featureProjection: map.getView().getProjection().getCode() + }); + featureOverlay.getSource().clear(); + featureOverlay.getSource().addFeatures(drawnfeatures); + } + ); }); } -function toggleRegistration(theButton) -{ - if (registration) - { +function toggleRegistration(theButton) { + if (registration) { theButton.title = "Registrering er AV"; theButton.style.color = "white"; - } else - { + } else { theButton.title = "Registrering er PÅ"; theButton.style.color = "red"; } registration = !registration; } -function toggleTracking(theButton) -{ +function toggleTracking(theButton) { geolocation.setTracking(!geolocation.getTracking()); theButton.style.backgroundColor = geolocation.getTracking() ? "green" : "rgba(0,60,136,.5)"; theButton.title = geolocation.getTracking() ? "Vis min posisjon er PÅ" : "Vis min posisjon er AV"; @@ -378,10 +362,8 @@ function toggleTracking(theButton) * @param {type} coordinate * @returns {createFeature.newFeature|ol.Feature} */ -var createFeature = function (coordinate) -{ - if (coordinate.length == 2) - { +var createFeature = function (coordinate) { + if (coordinate.length == 2) { coordinate = [coordinate[0], coordinate[1], 0]; } var point = new ol.geom.Point(coordinate); @@ -401,8 +383,7 @@ var createFeature = function (coordinate) return newFeature; } -var displayFeature = function (feature) -{ +var displayFeature = function (feature) { var featureForm = document.getElementById("featureForm"); var observationData = JSON.parse(feature.get("observationData")); @@ -440,8 +421,7 @@ var forekomsttypeLatinskeNavn = [ var forekomsttyper = []; var phytophthora = {}; -function initForekomsttyper() -{ +function initForekomsttyper() { $.getJSON("/rest/organism/search/latinnames?keywords=" + forekomsttypeLatinskeNavn.join(","), function (data) { forekomsttyper = data; }); @@ -449,70 +429,65 @@ function initForekomsttyper() function initPhytophthora() { $.getJSON("/rest/organism/search/latinnames?keywords=Phytophthora sp", function (data) { - if (data.length == 1) - { + if (data.length == 1) { phytophthora = data[0]; initMap(); } }); } -var getCropOrganism = function (organismId) -{ - for (var i = 0; i < forekomsttyper.length; i++) - { - if (forekomsttyper[i].organismId == organismId) - { +var getCropOrganism = function (organismId) { + for (var i = 0; i < forekomsttyper.length; i++) { + if (forekomsttyper[i].organismId == organismId) { return forekomsttyper[i]; } } } -var symptoms = ["Flekker", "Glisne kroner","Oppsprekking","Død","Andre symptom","Andre skader","Ikke symptom","Irrelevant"]; +var symptoms = ["Flekker", "Glisne kroner", "Oppsprekking", "Død", "Andre symptom", "Andre skader", "Ikke symptom", "Irrelevant"]; var funns = ["[Ukjent]", "Phytophthora gonapodyides", "Phytophthora lacustris", "Phytophthora plurivora", "Phytophthora cambivora", "Phytophthora cactorum", "Phytophthora sp"] -var provetypes = ["[Ikke prøve]","Jord","Vev","Vann","Blad","Bait"]; +var provetypes = ["[Ikke prøve]", "Jord", "Vev", "Vann", "Blad", "Bait"]; -var editFeature = function (featureId) -{ +var editFeature = function (featureId) { var feature = featureId > 0 ? featureOverlay.getSource().getFeatureById(featureId) - : newFeatureOverlay.getSource().getFeatureById(featureId); + : newFeatureOverlay.getSource().getFeatureById(featureId); var observationData = JSON.parse(feature.get("observationData")); var timeOfObservation = new moment(feature.get("timeOfObservation")); var featureForm = document.getElementById("featureForm"); var html = - '<button type="button" onclick="unFocusForm()" title="Avbryt">X</button>' + - (featureId > 0 ? '<button type="button" onclick="deleteFeature(' + featureId + ')">Delete</button>' : '') + - '<h3>' + (featureId > 0 ? "R" : "Ny r") + 'egistrering</h3>' + - '<table>' + - '<tr><td>Plante</td><td>' + - generateCropSelect("forekomsttype", forekomsttyper, feature.get("cropOrganism")["organismId"]) + - '</td></tr>' + - '<tr><td>Plante spes.</td><td>' + - '<input type="text" id="plantespes" name="plantespes" size="15" value="' + (observationData["plantespes"] != null ? observationData["plantespes"] : "") + '"/></td></tr>' + - '<tr><td>Symptom</td><td>' + - generateSelect("symptom", symptoms, observationData["symptom"]) + - '</td></tr>' + - '<tr><td>Sym spes.</td><td>' + - '<input type="text" id="symspes" name="symspes" size="15" value="' + (observationData["symspes"] != null ? observationData["symspes"] : "") + '"/></td></tr>' + - - '<tr><td>Prøvetype</td><td>' + - generateSelect("provetype", provetypes, observationData["provetype"]) + - '</td></tr>' + - '<tr><td>Prøvenummer</td><td>' + - '<input type="text" id="provenummer" name="provenummer" size="15" value="' + (observationData["provenummer"] != null ? observationData["provenummer"] : "") + '"/></td></tr>' + - '<tr><td>Funn</td><td>' + - generateSelect("funn", funns, observationData["funn"]) + - '</td></tr>' + - '<tr><td>Mer info</td><td>' + - '<textarea id="beskrivelse" name="beskrivelse">' + (feature.get("observationText") != null ? feature.get("observationText") : "") + '</textarea>' + - '</td></tr>' + - '<tr><td>Dato</td><td>' + - '<input type="text" id="dato" name="dato" size="10" value="' + timeOfObservation.format("DD.MM.YYYY") + '"/></td></tr>' + - '<tr><td></td><td>' + - '<input type="submit" value="Lagre" onclick="storeFeature(' + feature.getId() + ');"/></td></tr>' + - '</table>'; + '<button type="button" onclick="unFocusForm()" title="Avbryt">X</button>' + + (featureId > 0 ? '<button type="button" onclick="deleteFeature(' + featureId + ')">Delete</button>' : '') + + '<h3>' + (featureId > 0 ? "R" : "Ny r") + 'egistrering</h3>' + + '<table>' + + '<tr><td>Plante</td><td>' + + generateCropSelect("forekomsttype", forekomsttyper, feature.get("cropOrganism")["organismId"]) + + '</td></tr>' + + '<tr><td>Plante spes.</td><td>' + + '<input type="text" id="plantespes" name="plantespes" size="15" value="' + (observationData["plantespes"] != null ? observationData["plantespes"] : "") + '"/></td></tr>' + + '<tr><td>Symptom</td><td>' + + generateSelect("symptom", symptoms, observationData["symptom"]) + + '</td></tr>' + + '<tr><td>Sym spes.</td><td>' + + '<input type="text" id="symspes" name="symspes" size="15" value="' + (observationData["symspes"] != null ? observationData["symspes"] : "") + '"/></td></tr>' + + + '<tr><td>Prøvetype</td><td>' + + generateSelect("provetype", provetypes, observationData["provetype"]) + + '</td></tr>' + + '<tr><td>Prøvenummer</td><td>' + + '<input type="text" id="provenummer" name="provenummer" size="15" value="' + (observationData["provenummer"] != null ? observationData["provenummer"] : "") + '"/></td></tr>' + + '<tr><td>Funn</td><td>' + + generateSelect("funn", funns, observationData["funn"]) + + '</td></tr>' + + '<tr><td>Mer info</td><td>' + + '<textarea id="beskrivelse" name="beskrivelse">' + (feature.get("observationText") != null ? feature.get("observationText") : "") + '</textarea>' + + '</td></tr>' + + '<tr><td>Dato</td><td>' + + '<input type="text" id="dato" name="dato" size="10" value="' + timeOfObservation.format("DD.MM.YYYY") + '"/></td></tr>' + + '<tr><td></td><td>' + + '<input type="submit" value="Lagre" onclick="storeFeature(' + feature.getId() + ');"/></td></tr>' + + '</table>'; featureForm.innerHTML = html; @@ -520,10 +495,9 @@ var editFeature = function (featureId) //console.info(feature); }; -var storeFeature = function (featureId) -{ +var storeFeature = function (featureId) { var feature = featureId > 0 ? featureOverlay.getSource().getFeatureById(featureId) - : newFeatureOverlay.getSource().getFeatureById(featureId); + : newFeatureOverlay.getSource().getFeatureById(featureId); // Store, clear newFeature layer // Need to add feature as payload @@ -541,8 +515,7 @@ var storeFeature = function (featureId) var observationText = document.getElementById("beskrivelse").value; var observationHeading = "Registrering av phytophthora"; var timeOfObservation = moment(document.getElementById("dato").value + "+0200", "DD.MM.YYYYZ"); - if (timeOfObservation.year() < 2000) - { + if (timeOfObservation.year() < 2000) { alert("Feil dato (før år 2000). Datoformat er DD.MM.ÅÅÅÅ"); return; } @@ -585,22 +558,18 @@ var storeFeature = function (featureId) // If storing an existing feature, remove the one // that was there before storing, since the returned // one has a new gisId (featureId) - if (featureId > 0) - { + if (featureId > 0) { featureOverlay.getSource().removeFeature(feature); } featureOverlay.getSource().addFeatures(drawnfeatures); unFocusForm(); }, error: function (jqXHR, textStatus, errorThrown) { - if (jqXHR.status == 401) - { - if (confirm("Kan ikke lagre fordi du er logget ut av applikasjonen. Klikk OK for å logge inn.")) - { + if (jqXHR.status == 401) { + if (confirm("Kan ikke lagre fordi du er logget ut av applikasjonen. Klikk OK for å logge inn.")) { window.location.reload(); } - } else - { + } else { alert("Beklager, en feil oppsto. Status = " + jqXHR.status + ", eventuell feilmelding: " + textStatus); } } @@ -614,10 +583,8 @@ var storeFeature = function (featureId) * @param {type} featureId * @returns {undefined} */ -var deleteFeature = function (featureId) -{ - if (!confirm("Er du sikker på at du vil slette?")) - { +var deleteFeature = function (featureId) { + if (!confirm("Er du sikker på at du vil slette?")) { return; } @@ -631,51 +598,41 @@ var deleteFeature = function (featureId) // If storing an existing feature, remove the one // that was there before storing, since the returned // one has a new gisId (featureId) - if (featureId > 0) - { + if (featureId > 0) { featureOverlay.getSource().removeFeature(feature); } unFocusForm(); }, error: function (jqXHR, textStatus, errorThrown) { - if (jqXHR.status == 401) - { - if (confirm("Kan ikke slette fordi du er logget ut av applikasjonen. Klikk OK for å logge inn.")) - { + if (jqXHR.status == 401) { + if (confirm("Kan ikke slette fordi du er logget ut av applikasjonen. Klikk OK for å logge inn.")) { window.location.reload(); } - } else - { + } else { alert("Beklager, en feil oppsto. Status = " + jqXHR.status + ", eventuell feilmelding: " + textStatus); } } }); } -var generateSelect = function (selectName, options, preselect) -{ +var generateSelect = function (selectName, options, preselect) { var retVal = '<select id="' + selectName + '" name="' + selectName + '">'; - for (var i = 0; i < options.length; i++) - { + for (var i = 0; i < options.length; i++) { retVal += '<option value="' + options[i] + '"' + (options[i] == preselect ? " selected=\"selected\"" : "") + '">' + options[i] + '</option>'; } retVal += '</select>'; return retVal; } -var generateCropSelect = function (selectName, cropOrganisms, preselect) -{ +var generateCropSelect = function (selectName, cropOrganisms, preselect) { var retVal = '<select id="' + selectName + '" name="' + selectName + '">'; - for (var c = 0; c < forekomsttypeLatinskeNavn.length; c++) - { + for (var c = 0; c < forekomsttypeLatinskeNavn.length; c++) { currentLatinName = forekomsttypeLatinskeNavn[c]; - for (var i = 0; i < cropOrganisms.length; i++) - { - if (cropOrganisms[i].latinName == currentLatinName) - { + for (var i = 0; i < cropOrganisms.length; i++) { + if (cropOrganisms[i].latinName == currentLatinName) { retVal += '<option value="' + cropOrganisms[i].organismId + '"' + (cropOrganisms[i].organismId == preselect ? " selected=\"selected\"" : "") + '">' + - (currentLatinName == "Plantae" ? "Annet" : getLocalizedOrganismName(cropOrganisms[i], hardcodedLanguage)) - + '</option>'; + (currentLatinName == "Plantae" ? "Annet" : getLocalizedOrganismName(cropOrganisms[i], hardcodedLanguage)) + + '</option>'; } } } @@ -683,22 +640,19 @@ var generateCropSelect = function (selectName, cropOrganisms, preselect) return retVal; } -var focusForm = function () -{ +var focusForm = function () { var featureForm = document.getElementById("featureForm"); featureForm.style.display = "block"; } -var unFocusForm = function () -{ +var unFocusForm = function () { var featureForm = document.getElementById("featureForm"); featureForm.style.display = "none"; // Also remove feature (if one) on the New feature overlay newFeatureOverlay.getSource().clear(); } -var navigateTo = function (center) -{ +var navigateTo = function (center) { var centerPosition = ol.proj.transform(center, 'EPSG:4326', 'EPSG:3857'); view = new ol.View({ center: centerPosition, @@ -717,16 +671,13 @@ var navigateTo = function (center) */ function showLocation() { if (navigator.geolocation) { - if (window.location.protocol === "http:") - { + if (window.location.protocol === "http:") { navigator.geolocation.getCurrentPosition(function (geopositionObj) { // TODO: position and display location icon } ); - } else - { - if (confirm("Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.")) - { + } else { + if (confirm("Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.")) { window.location = "https:" + window.location.href.substring(window.location.protocol.length); } } @@ -737,16 +688,13 @@ function showLocation() { function navToLocation() { if (navigator.geolocation) { - if (window.location.protocol === "https:") - { + if (window.location.protocol === "https:") { navigator.geolocation.getCurrentPosition(function (geopositionObj) { navigateTo([geopositionObj.coords.longitude, geopositionObj.coords.latitude]); } ); - } else - { - if (confirm("Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.")) - { + } else { + if (confirm("Lokalisering fungerer bare over https (sikker tilkobling mellom nettleser og tjener). Klikk OK for å gå til sikker tilkobling.")) { window.location = "https:" + window.location.href.substring(window.location.protocol.length); } } @@ -760,41 +708,36 @@ function navToLocation() { * @param {type} selectedSeason * @returns {undefined} */ -function initSeasonSelectList(selectedSeason) -{ +function initSeasonSelectList(selectedSeason) { // What's the current year? var thisYear = new Date().getFullYear(); // How many years do we go back? $.ajax({ url: "/rest/observation/first/" + phytophthora.organismId }) - .done(function (data) { - var time = moment(data); - var firstYear = time.toDate().getFullYear(); - // Loop gjennom år, lag valgliste :-) - var startSeasonList = document.getElementById("startSeason"); - for (var i = firstYear; i <= thisYear; i++) - { - var yearOpt = new Option("", i); - yearOpt.innerHTML = i + " →" - if (i == selectedSeason) - { - yearOpt.selected = true; - } - startSeasonList.options[startSeasonList.options.length] = yearOpt; - } - }) - .fail(function (jqXHR, textStatus, errorThrown) { - if(jqXHR.status==404) - { - alert("Could not find any observations of organism with id=" + phytophthora.organismId); - document.getElementById("startSeason").options[0] = new Option("" + thisYear, thisYear); - } - else - { - alert(textStatus + ": " + errorThrown); + .done(function (data) { + var time = moment(data); + var firstYear = time.toDate().getFullYear(); + // Loop gjennom år, lag valgliste :-) + var startSeasonList = document.getElementById("startSeason"); + for (var i = firstYear; i <= thisYear; i++) { + var yearOpt = new Option("", i); + yearOpt.innerHTML = i + " →" + if (i == selectedSeason) { + yearOpt.selected = true; } - }); + startSeasonList.options[startSeasonList.options.length] = yearOpt; + } + }) + .fail(function (jqXHR, textStatus, errorThrown) { + if (jqXHR.status == 404) { + alert("Could not find any observations of organism with id=" + phytophthora.organismId); + document.getElementById("startSeason").options[0] = new Option("" + thisYear, thisYear); + } + else { + alert(textStatus + ": " + errorThrown); + } + }); } -- GitLab