Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. /* When a user types into the search input you should
  2. * 1) Search for players using the backend
  3. * 2) Build html to display the list of users
  4. * 3) Append the html from step 2 to the results div
  5. */
  6.  
  7. var playerArray = ["Quinn Baker", "Mighy Moose", "Brian Bae", "Kenta Matusdaira", "Dimitrij Ovtcharov"];
  8. var ratingArray = ["1777", "1234", "2000", "2801", "2799"];
  9. for(var i = 0; i < playerArray.length; i++) {
  10. var node = document.createElement("li");
  11. var textnode = document.createTextNode(search);
  12. node.appendChild(textnode);
  13. document.getElementById("playerArray").appendChild(node);
  14. }
  15.  
  16. for(var i = 0; i < ratingArray.length; i++) {
  17. var node = document.createElement("li");
  18. var textnode = document.createTextNode(search);
  19. node.appendChild(textnode);
  20. document.getElementById("ratingArray").appendChild(node);
  21. }
  22.  
  23. var results = document.querySelector('#results');
  24. var search = document.querySelector('#search');
  25.  
  26. var user = {id: 1, firstName: "firstName", lastName: "lastName"};
  27. var userDiv = document.createElement('div');
  28. userDiv.innerHTML = user.firstName
  29.  
  30. // Append stuff to results list
  31. results.appendChild(userDiv);
  32.  
  33. // Get players from the server
  34.  
  35. // React to input changes
  36. mainSearch.addEventListener('keyup', function() {
  37. fetch('player-ratings.json').then(function(results){
  38. results.json().then(function(users) {
  39. fetch(JSON.stringify(users));
  40. });
  41. });
  42. });
  43.  
  44. citySearch.addEventListener('keyup', function() {
  45. fetch('player-ratings.json').then(function(results){
  46. results.json().then(function(users) {
  47. fetch(JSON.stringify(users));
  48. });
  49. });
  50. });
  51.  
  52. stateSearch.addEventListener('keyup', function() {
  53. fetch('player-ratings.json').then(function(results){
  54. results.json().then(function(users) {
  55. fetch(JSON.stringify(users));
  56. });
  57. });
  58. });
  59.  
  60. ratingSearch1.addEventListener('keyup', function() {
  61. fetch('player-ratings.json').then(function(results){
  62. results.json().then(function(users) {
  63. fetch(JSON.stringify(users));
  64. });
  65. });
  66. });
  67.  
  68. ratingSearch2.addEventListener('keyup', function() {
  69. fetch('player-ratings.json').then(function(results){
  70. results.json().then(function(users) {
  71. fetch(JSON.stringify(users));
  72. });
  73. });
  74. });
  75.  
  76. /*give player list and rating list ids
  77. get rid of names in the lis
  78. create an array which list of random players names
  79. loop through the list of names
  80. also loop through the ratings
  81. for each name, create an li element containing the name and append it to the name list
  82. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement