Advertisement
Guest User

Untitled

a guest
May 4th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <!-- Function to load in info from different docs -->
  2. function loadDoc(UrlString) {
  3. var xhttp = new XMLHttpRequest();
  4. xhttp.onreadystatechange = function() {
  5. if (xhttp.readyState == 4 && xhttp.status == 200) {
  6. document.getElementById("storybox").innerHTML = xhttp.responseText;
  7. }
  8. };
  9. console.log("URL = " + UrlString);
  10. xhttp.open("GET", UrlString, true);
  11. xhttp.send();
  12. }
  13.  
  14. function buttonClicked(buttonid) {
  15. console.log("entered case statement");
  16. var UrlString = "templates/story/pt1/Start.html";
  17. switch(buttonid) {
  18. case "YesStart":
  19. UrlString = "templates/story/pt1/YesStart.html";
  20. console.log("test");
  21. loadDoc(UrlString);
  22. break;
  23. case "Sleep":
  24. UrlString = "templates/story/pt1/Sleep.html";
  25. loadDoc(UrlString);
  26. break;
  27. case "Swindon":
  28. UrlString = "templates/story/pt1/Swindon.html";
  29. loadDoc(UrlString);
  30. break;
  31. default:
  32. document.getElementById("storybox").innerHTML = "<p>That part of the story hasn't been written yet. Click to</p><button type='button' class='btn btn-danger' id='nobtn' onclick='buttonClicked('YesStart')'>Restart</button>";
  33. <!-- Output error info -->
  34. console.log(buttonid);
  35. };
  36. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement