From 9d93d25b0d87d481a2cfceac1c55ebc32fc5782e Mon Sep 17 00:00:00 2001
From: Rhys Evans <EvansRM17@cardiff.ac.uk>
Date: Sun, 3 Dec 2023 17:57:20 +0000
Subject: [PATCH] Added 4 basic locations associated with the Penarth and Risca
 trails listed in the landamrk submission form. Moved said forms javascript to
 a seperate file

---
 src/main/resources/data.sql                   |  7 ++++
 .../static/scripts/landmarkFormThScript.js    | 35 ++++++++++++++++
 .../templates/Landmarks/LandmarkFormTh.html   | 41 ++-----------------
 3 files changed, 45 insertions(+), 38 deletions(-)
 create mode 100644 src/main/resources/static/scripts/landmarkFormThScript.js

diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql
index c095af09..c7b960de 100644
--- a/src/main/resources/data.sql
+++ b/src/main/resources/data.sql
@@ -25,3 +25,10 @@ insert into locations (locationID, locationName , locationEmail,locationDescript
 insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (14, 'The Medieval Courthouse','','Location description here','Caerphilly',0103);
 insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (15 ,'Caerphilly Castle','','Location description here','Caerphilly',0103);
 insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (16, 'Ty Vaughan House','','Location description here','Caerphilly',0103);
+
+insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (17, 'Risca Colliery','','Location description here','Risca',0201);
+insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (18, 'Black Vein Colliery Disaster','','Location description here','Risca',0201);
+
+
+insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (19, 'The Esplanade','','Location description here','Penarth',0301);
+insert into locations (locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) value (20, 'The Old Swimming Baths','','Location description here','Penarth',0301);
diff --git a/src/main/resources/static/scripts/landmarkFormThScript.js b/src/main/resources/static/scripts/landmarkFormThScript.js
new file mode 100644
index 00000000..dc8ca6d9
--- /dev/null
+++ b/src/main/resources/static/scripts/landmarkFormThScript.js
@@ -0,0 +1,35 @@
+
+
+    // verification function of the above form
+    function landmarkFormValidation(){
+    var pass=true;
+    var trail = document.forms["landmarkSubmission"]["trailID"].value
+    var location = document.forms["landmarkSubmission"]["landmarkLocation"].value
+    var description = document.forms["landmarkSubmission"]["landmarkDescription"].value;
+    var descriptionWrdCount=description.split(" ").length
+    if (descriptionWrdCount>200){
+    alert('Please keep your description to a maximum of 200 words.');
+    pass = false;
+}
+
+    if (trail==0){ // values of 0 and "" used to ensure default drop down option isn't submittable
+    alert('Invalid trail selected. \nPlease select the trail you wish to join.');
+    pass = false;
+}
+
+    if (location==""){
+    alert('Invalid location selected. \nPlease select the location you wish to join.');
+
+    pass = false; // ensure correct trail is selected in accordance to the town it takes place in
+
+} if ( (location=="Caerphilly" & (parseInt(trail/100)!==1)) ||
+    (location=="Risca" & (parseInt(trail/100)!==2)) ||
+    (location=="Penarth" & (parseInt(trail/100)!==3)) ){
+    alert('Trail unavailable in your current location. \nPlease choose an available trail');
+    pass = false;
+}
+
+    return pass;
+}
+
+
diff --git a/src/main/resources/templates/Landmarks/LandmarkFormTh.html b/src/main/resources/templates/Landmarks/LandmarkFormTh.html
index a8f42293..b54a9143 100644
--- a/src/main/resources/templates/Landmarks/LandmarkFormTh.html
+++ b/src/main/resources/templates/Landmarks/LandmarkFormTh.html
@@ -5,6 +5,9 @@
     <title>Landmark Sign Up</title>
     <link rel="stylesheet" th:href="@{css/landmarkFormStyle.css}">
     <link rel="stylesheet" th:href="@{css/templatingstyle.css}">
+<!--    <link rel="script" th:href="@{scripts/landmarkFormThScript.js}">-->
+    <script src="scripts/landmarkFormThScript.js"></script>
+<!--    <style in="scripts/landmarkFormThScript.js"></style>-->
 
 
 </head>
@@ -58,45 +61,7 @@
     <hr style="height:40px; visibility:hidden;" />
 </main>
 
-<script>
 
-
-
-
-// verification function of the above form
-    function landmarkFormValidation(){
-        var pass=true;
-        var trail = document.forms["landmarkSubmission"]["trailID"].value
-        var location = document.forms["landmarkSubmission"]["landmarkLocation"].value
-        var description = document.forms["landmarkSubmission"]["landmarkDescription"].value;
-        var descriptionWrdCount=description.split(" ").length
-        if (descriptionWrdCount>200){
-            alert('Please keep your description to a maximum of 200 words.');
-            pass = false;
-        }
-
-        if (trail==0){ // values of 0 and "" used to ensure default drop down option isn't submittable
-            alert('Invalid trail selected. \nPlease select the trail you wish to join.');
-            pass = false;
-        }
-
-        if (location==""){
-            alert('Invalid location selected. \nPlease select the location you wish to join.');
-
-            pass = false; // ensure correct trail is selected in accordance to the town it takes place in
-
-        } if ( (location=="Caerphilly" & (parseInt(trail/100)!==1)) ||
-            (location=="Risca" & (parseInt(trail/100)!==2)) ||
-            (location=="Penarth" & (parseInt(trail/100)!==3)) ){
-            alert('Trail unavailable in your current location. \nPlease choose an available trail');
-            pass = false;
-        }
-
-        return pass;
-    }
-
-
-</script>
 <footer th:insert="~{/towns/Templating.html :: footer}"></footer>
 </body>
 </html>
\ No newline at end of file
-- 
GitLab