From 1c08833792a1597594f4220cd244746c88dc0c20 Mon Sep 17 00:00:00 2001
From: Jonas Leder <jonas@jonasled.de>
Date: Sat, 9 Nov 2019 11:48:15 +0100
Subject: [PATCH] hide domain select and recaptcha if not in use

---
 templates/home.html | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/templates/home.html b/templates/home.html
index 850dd2f..b423cf6 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -3,12 +3,14 @@
    <head>
          <link href="{{ url_for('static', filename='style.css') }}" rel="stylesheet">
          <title>URL shorter</title>
-         <script src="https://www.google.com/recaptcha/api.js" async defer></script>
-         <script>
-            function onSubmit(token) {
-              document.getElementById("form").submit();
-            }
-          </script>
+         {% if recaptchaPrivateKey %}
+            <script src="https://www.google.com/recaptcha/api.js" async defer></script>
+            <script>
+               function onSubmit(token) {
+               document.getElementById("form").submit();
+               }
+            </script>
+         {% endif %}
       </head>
 
    <body>
@@ -17,12 +19,21 @@
             {% if not short_url %}
                <form method="post" id= "form" class="login-form" action="">
                   <input id="url" name="url" type="url" placeholder="long url" value="{{long_url_prefilled}}"/>
+                  {% if showDomainSelect %}
                   Domain: <select name="domain" id="domain">
                      {{domain | safe}}
                   </select>
                   <br><p> </p>
+                  {% else %}
+                  <input type="hidden" name="domain" id="domain" value={{domain}}>
+                  {% endif %}
                   <input id="short" name="short" type="text" placeholder="short name" value="{{short_url_prefilled}}"/>
+
+                  {% if recaptchaPrivateKey %}
                   <button class="g-recaptcha" data-sitekey="{{recaptchaPublicKey}}" data-callback='onSubmit'>short</button>
+                  {% else %}
+                  <button>short</button>
+                  {% endif %}
                </form>
             {% else %}
                <h3>Your shortened URL is: <a href="http://{{short_url}}"> {{short_url}}</a></h3>
-- 
GitLab