app.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. var app = new Vue({
  2. el: '#app',
  3. data: {
  4. config: {
  5. released_episode: 80,
  6. last_diorama: 50,
  7. available_dioramas: 0,
  8. first_diorama: 6,
  9. github_levels: [],
  10. github_episodes: [],
  11. github_success: false,
  12. github_access_token: "ac4311edd3cc5acf4ccc321525a96a",
  13. },
  14. },
  15. mounted: function () {
  16. },
  17. watch: {
  18. },
  19. computed: {
  20. test: function () {
  21. },
  22. }
  23. })
  24. function getData() {
  25. var xhr = new XMLHttpRequest();
  26. var url = "http://localhost:8000";
  27. console.log("url", url);
  28. xhr.onreadystatechange = function () {
  29. if (this.readyState == 4 && this.status == 200) {
  30. var response = JSON.parse(this.responseText);
  31. app.config.github_episodes = response;
  32. app.config.github_success = true;
  33. console.log(xhr.responseText);
  34. }
  35. };
  36. xhr.open("GET", url, true);
  37. xhr.send();
  38. }
  39. function setData() {
  40. var newName = 'John Smith',
  41. xhr = new XMLHttpRequest();
  42. xhr.open('POST', 'http://localhost:8000/set');
  43. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  44. xhr.onload = function() {
  45. console.log(xhr.responseText);
  46. };
  47. xhr.send(encodeURI('name=' + newName));
  48. }