diff --git a/MazdaRoutesEditor/src/main/resources/static/js/main.js b/MazdaRoutesEditor/src/main/resources/static/js/main.js index df26d04..81b7b07 100644 --- a/MazdaRoutesEditor/src/main/resources/static/js/main.js +++ b/MazdaRoutesEditor/src/main/resources/static/js/main.js @@ -80,6 +80,11 @@ $('#cleanNewRoute').on('click', cleanNewRoute); $('#addNewRoute').on('click', addNewRoute); $('#saveToFile').on('click', saveToFile); + $('#setAPIKey').on('click', setAPIKey); + $('#createSettings').click(function(e) { + createSettings(); + e.preventDefault(); + }); }); function createMap() { @@ -479,22 +484,22 @@ }); } } - - $('#createSettings').click(function(e) { - createSettings(); - e.preventDefault(); - }); + + function setAPIKey(){ + GraphHopper.getInstance().apiKey = window.prompt( + "Enter GraphHopper API key or obtain one at https://graphhopper.com/", GraphHopper.getInstance().apiKey || ""); + if (GraphHopper.getInstance().apiKey != null) { + $('#graphhopperAPILabel').html("GraphHopper API key set"); + $('#graphhopperAPILabel').removeClass("alert-danger"); + $('#graphhopperAPILabel').addClass("alert-success"); + } + } function createSettings() { if (GraphHopper.getInstance().apiKey == null) { - GraphHopper.getInstance().apiKey = window.prompt( - "Enter GraphHopper API key or obtain one at https://graphhopper.com/", ""); + setAPIKey(); if (GraphHopper.getInstance().apiKey == null) { return; - } else { - $('#graphhopperAPILabel').html("GraphHopper API key set"); - $('#graphhopperAPILabel').removeClass("alert-danger"); - $('#graphhopperAPILabel').addClass("alert-success"); } } diff --git a/MazdaRoutesEditor/src/main/resources/templates/index.html b/MazdaRoutesEditor/src/main/resources/templates/index.html index 5e9fbdd..56ec1b8 100644 --- a/MazdaRoutesEditor/src/main/resources/templates/index.html +++ b/MazdaRoutesEditor/src/main/resources/templates/index.html @@ -49,7 +49,7 @@