Skip to content
Snippets Groups Projects
Commit 680ca2b8 authored by Connor Brock's avatar Connor Brock
Browse files

Added JS script for a trail redirect, ultised by Spring MVC

parent da39e39e
No related branches found
No related tags found
1 merge request!18Resolve "As a child, I want an interesting and exciting story based trail with obvious landmarks, so I can follow the trail with ease."
...@@ -7,6 +7,7 @@ import org.springframework.validation.BindingResult; ...@@ -7,6 +7,7 @@ import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
//import jakarta.validation.Valid; //import jakarta.validation.Valid;
...@@ -21,8 +22,6 @@ public class LandmarksController { ...@@ -21,8 +22,6 @@ public class LandmarksController {
return modelAndView1; return modelAndView1;
} }
@PostMapping("/landmarkSub") @PostMapping("/landmarkSub")
public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model ) { public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model ) {
...@@ -41,13 +40,15 @@ public class LandmarksController { ...@@ -41,13 +40,15 @@ public class LandmarksController {
} }
}
}
} }
package Team5.SmartTowns.trailcontrollers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class DragonsTale {
@GetMapping("/dragonstale")
public ModelAndView getDragonsTale(){
ModelAndView modelAndView = new ModelAndView("src/main/resources/templates/towns/trails/dragonstale/index.html");
return modelAndView;
}
}
...@@ -36,4 +36,8 @@ public class Trail { ...@@ -36,4 +36,8 @@ public class Trail {
File imgFile = new File("src/main/resources/static/" + imgPath); File imgFile = new File("src/main/resources/static/" + imgPath);
return imgFile.exists() ? imgPath : notFoundPath; return imgFile.exists() ? imgPath : notFoundPath;
} }
public static List<Trail> getTrails() {
return trails;
}
} }
...@@ -35,4 +35,19 @@ public class TrailsController { ...@@ -35,4 +35,19 @@ public class TrailsController {
return mv; return mv;
} }
//Leave this, I'll create a thymeleaf redirect for multiple different trails, rather then just have one for each trail.
@GetMapping("/dragonstale")
public ModelAndView getDragonsTale(){
ModelAndView modelAndView = new ModelAndView("towns/trails/dragonstale/index");
return modelAndView;
}
//Same for this
@GetMapping("/dragonstale/landmarkone")
public ModelAndView getLandmark(){
ModelAndView modelAndView = new ModelAndView("towns/trails/dragonstale/trailcheckpoints/one/one");
return modelAndView;
}
} }
<!-- TODO Develop each individual landmark for DragonsTrail -->
<!-- Each trail should have a preestablished set of landmarks -->
<div th:fragment="landmarkInfoFrag" class="centre" id="landmarkList">
<ul>
<li th:replace=""> Landmark 1 </li>
<li> Landmark 2 </li>
<li> Larkmark 3 </li>
<li> Larkmark 4 </li>
<li> Larkmark 5 </li>
<li> Larkmark 6 </li>
</ul>
</div>
\ No newline at end of file
...@@ -15,15 +15,26 @@ ...@@ -15,15 +15,26 @@
<div class="centre"> <div class="centre">
<p> <p>
Adventurers... embark through these mystical historical landmarks and scenery, to ultimately discover the lair of the dragon. Adventurers... embark through mystical historical landmarks to ultimately discover the lair of the dragon.
Legend has it that within this ominous lair, mighty dragons, guardians of ancient wisdom and treasures untold lay.... Legend has it that within this ominous lair, mighty dragons, guardians of ancient wisdom and treasures untold lay....
</p> </p>
</div> </div>
<div class="centre">
<!-- TO DO, -->
</div>
<div class="centre"> <div class="centre">
<h3>Begin your hunt!</h3> <h3>Begin your hunt!</h3>
<button type="button" id="begin">Click here!</button> <button type="button" id="begin">Click here!</button>
</div> </div>
<script>
document.getElementById("begin").addEventListener("click", function (){
window.location.href = ("/dragonstale/landmarkone");
})
</script>
</body> </body>
</html> </html>
\ No newline at end of file
function onClick(){
var beginButton = document.getElementById("begin");
if (beginButton === true){
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment