Guest User

Untitled

a guest
Jan 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.70 KB | None | 0 0
  1. // Retrieve JSON information
  2.  
  3. $('#search').keyup(function() {
  4. var searchField = $('#search').val();
  5. var regex = new RegExp(searchField, "i");
  6. var output = '<div class="row">';
  7.  
  8. $.getJSON('coretype.json', function(data) {
  9. $.each(data, function(key, val) {
  10. if (val.identifier.search(regex) !== -1) {
  11. console.log(val);
  12. var thisVal = JSON.stringify(val);
  13. output += "<h5 class='sclear' onclick='addToList(" + thisVal + ")'>" + val.identifier + "</h5>"
  14. }
  15. });
  16. output += '</div>';
  17. $('#searchResult').html(output);
  18. $('#search').focus(
  19. function() {
  20. $(this).val('');
  21. });
  22. });
  23. });
  24.  
  25.  
  26.  
  27. // this is the click of the keyword
  28. $('#result').on('click', 'li', function() {
  29. var click_text = $(this).text();
  30. console.log(click_text);
  31. var thisObj = []; // affects overall function
  32. // thisObj = findObject(click_text);
  33. console.log(thisObj);
  34. $(this).css('display', 'none');
  35. $(this).empty();
  36.  
  37. });
  38. // prog bar
  39. $('input').on('click', function() {
  40. var valeur = 0;
  41. $('input:checked').each(function() {
  42. if ($(this).attr('value') > valeur) {
  43. valeur = $(this).attr('value');
  44. }
  45. });
  46. $('.progress-bar').css('width', valeur + '%').attr('aria-valuenow', valeur);
  47. });
  48.  
  49. });
  50.  
  51. var searchObjs = [];
  52.  
  53. // this function below is the actual display of the multiselect
  54.  
  55. function addToList(obj) {
  56. //console.log(obj);
  57. searchObjs.push(item2);
  58.  
  59. $('#searchResult').html('');
  60. $('#result').append('<li class="list-group-item link-class">' + obj.identifier) + '</li>';
  61. var item2 = {}; // this creates items that we can then use to populate progress
  62. item2["identifier"] = obj.identifier;
  63. item2["progressbar1"] = obj.progressbar1;
  64. item2["progressbar2"] = obj.progressbar2;
  65. item2["progressbar3"] = obj.progressbar3;
  66. item2 = $.parseJSON(item2);
  67. document.getElementById("progdata").innerHTML = obj.progressbar1;
  68. }
  69.  
  70.  
  71. function findObject(identifier) {
  72. var found = 0;
  73. for (var i = 0, len = searchObjs.length; i < len; i++) {
  74. if (searchObjs[i].identifier === identifier) {
  75. return searchObjs[i]; // Return as soon as the object is found
  76. found = 1;
  77. }
  78. }
  79. if (found === 0) {
  80. return null; // The object was not found
  81. }
  82. }
  83.  
  84. <body id="bootstrap-overrides">
  85.  
  86.  
  87. <!-- Header and Search Bar -->
  88. <div class="container" style="width:900px; margin-bottom: 5em">
  89. <h2 align="center">EnneaTest</h2>
  90. <br />
  91. <br />
  92.  
  93. <div align="center">
  94. <input type="text" name="search" id="search" placeholder="trait type" class="form-control" />
  95. </div>
  96. <div id="searchResult"></div>
  97. <div id="rlist">
  98. <ul>
  99. <li class="list" id="result"></li>
  100. <li class="list" id="progdata"></li>
  101. </ul>
  102. </div>
  103. </div>
  104.  
  105.  
  106. <!-- Progress Bars Start -->
  107. <div class="container" style="width:900px;">
  108. <div class="progress progress-striped active">
  109. <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
  110. </div>
  111. </div>
  112. <div class="row tasks">
  113.  
  114.  
  115. <div class="col-md-2">
  116. <input type="checkbox" name="progress" class="progress" value="10">
  117. </div>
  118. <div class="col-md-2">
  119. <input type="checkbox" name="done" class="done" value="20">
  120. </div>
  121. </div>
  122. </div>
  123. </body>
  124.  
  125. [
  126. {
  127. "identifier":"Happy",
  128. "progressbar1": 100,
  129. "progressbar2": 60,
  130. "progressbar3": -40
  131. },
  132. {
  133. "identifier":"Fat",
  134. "progressbar1": -30,
  135. "progressbar2": -20,
  136. "progressbar3": 30
  137. }
  138. ]
Add Comment
Please, Sign In to add comment