From 9457e3062f129992b90af2cc5f12403df6568972 Mon Sep 17 00:00:00 2001 From: quaso Date: Sun, 21 Feb 2016 11:20:16 +0100 Subject: [PATCH] entering GraphHopper API key improved --- .../src/main/resources/static/js/main.js | 27 +++++++++++-------- .../src/main/resources/templates/index.html | 17 +++++++++++- 2 files changed, 32 insertions(+), 12 deletions(-) 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 @@
  • Show all routes