Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. let currentArray = [];
  2.  
  3. let getFlow=()=>{
  4. $.get('data.json', function(data){
  5. if(currentArray.length == 0){
  6. console.log(data);
  7. data.map(function(dat){
  8. $('.questions').html('');
  9. $('.flow-buttons').html('');
  10.  
  11. let keys = Object.keys(dat);
  12. let values = Object.values(dat);
  13.  
  14. $('.question').html(keys+'?');
  15. currentArray.push(keys[0]);
  16.  
  17. values.map(function(val){
  18. let valueKeys = Object.keys(val);
  19.  
  20. valueKeys.map(function(valKey){
  21. $('.flow-buttons').append(`<button id='`+valKey+`' onclick='pushButton(this.id)'>`+valKey+`</button>`);
  22. });
  23. });
  24. });
  25. console.log(currentArray);
  26. }else{
  27. let chain = currentArray.join('.');
  28. let dataChain = 'data.'+chain;
  29. console.log(chain);
  30. console.log(dataChain);
  31. console.log(data.How_many_dependent_variables_do_you_have.One);
  32. dataChain.map(function(x){
  33. console.log(x);
  34. });
  35. }
  36. });
  37. }
  38.  
  39. let pushButton=(id)=>{
  40. currentArray.push(id);
  41. console.log(currentArray);
  42. getFlow();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement