imamnurby commited on
Commit
4ef3e67
·
1 Parent(s): bcbe2c0

Update static/frontend.js

Browse files
Files changed (1) hide show
  1. static/frontend.js +225 -186
static/frontend.js CHANGED
@@ -57,33 +57,66 @@
57
  function onOut(string){
58
  document.getElementById(string).style.display ='none';
59
  }
60
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  async function getResponse(url, user_query){
62
- try {
63
  let final_url = url + '?user_query=' + user_query
64
  console.log(final_url)
65
 
66
- let predictions = await fetch(final_url);
67
- console.log(predictions)
68
-
69
- if (predictions.status == 200){
70
- return predictions.json()
71
- }
72
- else{
73
- document.getElementById("spinner").style.display = 'none';
74
- let error_msg = "Error, return code: " + predictions.status
75
- alert(error_msg);
76
- }
77
-
78
- } catch (error) {
79
- document.getElementById("spinner").style.display = 'none';
80
- console.log("error")
81
- console.log(error)
82
- let error_msg = "Error, return code: " + predictions.status
83
- alert(error_msg);
84
- }
85
  }
86
-
87
  //when retrieve is clicked
88
  async function onSubmit(){
89
  document.getElementById("spinner").style.display = 'none';
@@ -102,180 +135,186 @@
102
  document.getElementById("spinner").style.display = 'none';
103
  // document.getElementById("grey-container").className = 'album py-5 bg-light';
104
 
105
- let response = predictions['predictions']
106
- //loop through number of results
107
- html = ''
108
- var w = 0
109
- for(let i=0; i < response.length; i++){
110
-
111
- html += '<div class="row g-4 m-2" id="predictions">';
112
- html += '<div class="col-6">';
113
- html += '<div class="card border-primary mb-3">';
114
- // library name and description
115
- html += '<div class="card-body">';
116
- html += '<h5 class="card-title text-primary">'+ response[i]["library_name"] +'</h5>';
117
- html += '<p class="card-text">'+ response[i]["Description"] +'</p>';
118
- html += '</div>';
119
- // end library name and description
120
- // group button bottom (View GitHub and See Usage Patterns and Configs)
121
- html += '<div class="card-footer">';
122
- html += '<div class=" d-flex justify-content-between align-items-center">';
123
- html += '<div class="btn-group">'
124
- html += '<a type="button" class="btn btn-sm btn-outline-secondary" href='+ response[i]["Github URL"] +'>View Github</a>';
125
- html += '</div>'
126
- html += '<a href="javascript:void(0)" id="myTooltip" data-bs-toggle="tooltip" data-bs-placement="right" onclick="onClickMore('+ response[i]["id"] +')">See Usage Patterns and Interface Configs</a>';
127
- html += '</div>';
128
- html += '</div>';
129
- html += '</div>';
130
- html += '</div>';
131
- // end card group button
132
- html += '<div class="col-6"><div id="'+ response[i]["id"] +'" style="display: none;" class="card border-primary mb-3">';
133
- html += '<div class="card-body">';
134
- //begin accordion outer
135
- html += '<div class="accordion" id="accordionOuter'+ i + '">';
136
- // first item
137
- html += '<div class="accordion-item">';
138
- html += '<h2 class="accordion-header" id="headingOneOuter"'+ i + '>';
139
- html += '<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne'+ i +'" aria-expanded="true" aria-controls="collapseOne'+ i +'">'
140
- html += 'Interface Configuration';
141
- html += '</button>';
142
- html += '</h2>';
143
- html += '<div id="collapseOne'+ i +'" class="accordion-collapse collapse show" aria-labelledby="headingOneOuter"'+ i +'data-bs-parent="#accordionOuter'+ i + '">'
144
- html += '<div class="accordion-body">'
145
- // html += 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven\'t heard of them accusamus labore sustainable VHS.'
146
-
147
- // interface configuration begin
148
- html += '<h6>Protocol: '+ response[i]["hw_config"]["protocol"]+ '</h6>';
149
- html += '<table class="table table-hover"><thead><tr><th>Arduino Type</th><th>I/O hardware --> Arduino</th></tr></thead><tbody>'
150
- //loop through hardware config
151
- for (const property in response[i]["hw_config"]["pin_connection_from_hw_to_arduino"]){
152
- let firstLetter = property.charAt(0).toUpperCase();
153
- let remLetter = property.substring(1).split("_");
154
- html += '<tr><td>' + firstLetter + remLetter[0] + '_' + remLetter[1].charAt(0).toUpperCase() + remLetter[1].substring(1) + '</td><td>';
155
- //loop through the arduino type
156
- for (let y=0; y < response[i]["hw_config"]["pin_connection_from_hw_to_arduino"][property].length; y++){
157
- // html += '(' + (response[i]["hw_config"]["pin_connection_from_hw_to_arduino"][property][y][0] + ',' + response[i]["hw_config"]["pin_connection_from_hw_to_arduino"][property][y][1]) + ') ';
158
- html += '(' + response[i]["hw_config"]["pin_connection_from_hw_to_arduino"][property][y] +') ';
159
- }
160
- html += ' </td></tr>';
161
- }
162
- html += '</tbody></table> ';
163
- // end interface configuration
164
-
165
- html += '</div>'
166
- html += '</div>'
167
- html += '</div>'
168
- // end first item
169
-
170
- //second item
171
- html += '<div class="accordion-item">';
172
- html += '<h2 class="accordion-header" id="headingTwoOuter'+ i +'">';
173
- html += '<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo'+ i +'" aria-expanded="false" aria-controls="collapseTwo'+ i +'">'
174
- html += 'Usage Patterns';
175
- html += '</button>';
176
- html += '</h2>';
177
- html += '<div id="collapseTwo'+ i +'" class="accordion-collapse collapse" aria-labelledby="headingTwoOuter'+ i +'" data-bs-parent="#accordionOuter'+ i + '">'
178
- html += '<div class="accordion-body">'
179
- // html += 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven\'t heard of them accusamus labore sustainable VHS.'
180
- // begin usage pattern
181
- let w = 0
182
- Object.keys(response[i]["usage_patterns"]).forEach(function(key) {
183
- let usages_arr = response[i]["usage_patterns"][key]
184
- // begin accordion inner
185
- html += '<div class="accordion" id="accordionInner">'
186
- // begin item
187
- html += ' <div class="accordion-item">'
188
- html += ' <h2 class="accordion-header" id="headingOneInner'+ key + i +'">'
189
- if (w == 0){
190
- html += ' <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOneInner'+ key + i +'" aria-expanded="true" aria-controls="collapseOneInner'+ key + i +'">'
191
- }
192
- else {
193
- html += ' <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOneInner'+ key + i +'" aria-expanded="false" aria-controls="collapseOneInner'+ key + i +'">'
194
- }
195
- html += ' Sensor Object: '+ key
196
- html += ' </button>'
197
- html += ' </h2>'
198
- if (w == 0){
199
- html += ' <div id="collapseOneInner'+ key + i +'" class="accordion-collapse collapse show" aria-labelledby="headingOneInner'+ key + i +'">'
200
- }
201
- else {
202
- html += ' <div id="collapseOneInner'+ key + i +'" class="accordion-collapse collapse" aria-labelledby="headingOneInner'+ key + i +'">'
203
  }
204
- html += ' <div class="accordion-body">'
 
205
 
206
- // being accordion inner
207
- html += '<div style="margin-bottom: 15px" class="accordion" id="accordionPanelsStayOpenExample"' + response[i]["id"] + key + '>'; //1
 
 
208
 
209
- for (let x=0; x < usages_arr.length; x++){
210
- let pattern = usages_arr[x].split("[API-SEP]")
211
- html += '<div data-bs-toggle="collapse" data-bs-target="#patternCollapse' + response[i]["id"] + key + x + '">'; //2
212
- html += '<div class="accordion-item">'; //3
213
- html += '<h2 class="accordion-header" id="panelsStayOpen-heading' + response[i]["id"] + key +'">';
214
-
215
- if (x == 0){
216
- html += '<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapse' + response[i]["id"] + key + x + '" aria-expanded="true" aria-controls="panelsStayOpen-collapse' + response[i]["id"] + key + x + '">';
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
218
  else {
219
- html += '<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapse' + response[i]["id"] + key + x + '" aria-expanded="false" aria-controls="panelsStayOpen-collapse' + response[i]["id"] + key + x + '">';
220
  }
221
-
222
- html += 'Pattern ' + (x+1);
223
- html += '</button>';
224
- html += '</h2>';
225
-
226
- //4
227
- if (x== 0){
228
- html += '<div id="panelsStayOpen-collapse' + response[i]["id"] + key + x + '" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-heading' + response[i]["id"] + key + x + '">';
229
- } else {
230
- html += '<div id="panelsStayOpen-collapse' + response[i]["id"] + key + x + '" class="accordion-collapse collapse" aria-labelledby="panelsStayOpen-heading' + response[i]["id"] + key + x + '">';
231
  }
232
- html += '<div class="accordion-body">' //5
233
- html += '<ul>';
234
- for (let y=0; y<pattern.length; y++){
235
- html += '<li>' + pattern[y] + '</li>';
236
  }
237
- html += '</ul>';
238
- html += '</div>' //5
239
- html += '</div>'; //4
240
- html += '</div>'; //3
241
- html += '</div>'; //2
242
- }
243
- html += '</div>' //1
244
-
245
- html += ' </div>'
246
- html += ' </div>'
247
- html += ' </div>'
248
- //end item
249
- html += '</div>'
250
- // end accordion inner
251
- w += 1
252
- });
253
- // end usage pattern
254
-
255
- html += '</div>'
256
- html += '</div>'
257
- html += '</div>'
258
- //end second item
259
-
260
- html += '</div>';
261
- // end accordion outer
262
-
263
- //button close
264
- html += '<div class="position-absolute top-0 end-0">'
265
- html += '<button type="button" class="btn-close" aria-label="Close" onclick="onOut('+ response[i]["id"] +')"></button>';
266
- html += '</div>';
267
- // end button close
268
-
269
- html += '</div></div>';
270
- html += '</div></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  }
 
 
272
 
273
- //append the html to the container
274
- document.getElementById("main-parent").innerHTML = (html);
275
-
276
- html2 = '<div class="container"><p class="float-right"><a href="#">Back to top</a></p>';
277
- //append footer to allow going back to the top
278
- document.getElementById("footer").innerHTML = (html2);
279
  }
280
  else {
281
  document.getElementById("spinner").style.display = 'none';
 
57
  function onOut(string){
58
  document.getElementById(string).style.display ='none';
59
  }
60
+
61
+ // async function getResponse(url, user_query){
62
+ // try {
63
+ // let predictions = await fetch(url,{
64
+ // method: 'POST',
65
+ // body: JSON.stringify({'user_query': user_query}),
66
+ // headers: {
67
+ // 'Content-type': 'application/json; charset=UTF-8',
68
+ // 'Access-Control-Allow-Origin': '*',
69
+ // 'Access-Control-Allow-Methods': 'POST, GET',
70
+ // }
71
+ // });
72
+ // return predictions.json()
73
+ // } catch (error) {
74
+ // console.log(error)
75
+ // }
76
+ // }
77
+
78
+ // async function getResponse(url, user_query){
79
+ // try {
80
+ // let final_url = url + '?user_query=' + user_query
81
+ // console.log(final_url)
82
+
83
+ // let predictions = await fetch(final_url);
84
+ // console.log(predictions)
85
+
86
+ // if (predictions.status == 200){
87
+ // return predictions.json()
88
+ // }
89
+ // else{
90
+ // document.getElementById("spinner").style.display = 'none';
91
+ // let error_msg = "Error, return code: " + predictions.status
92
+ // alert(error_msg);
93
+ // }
94
+
95
+ // } catch (error) {
96
+ // document.getElementById("spinner").style.display = 'none';
97
+ // console.log("error")
98
+ // console.log(error)
99
+ // let error_msg = "Error, return code: " + predictions.status
100
+ // alert(error_msg);
101
+ // }
102
+ // }
103
+
104
  async function getResponse(url, user_query){
 
105
  let final_url = url + '?user_query=' + user_query
106
  console.log(final_url)
107
 
108
+ let predictions = await fetch(final_url)
109
+ .then(res => {
110
+ if (res.ok){
111
+ return res.json()
112
+ } else {
113
+ throw new Error(res.text())
114
+ }
115
+ })
116
+ .catch(error => alert(error))
117
+ return predictions
 
 
 
 
 
 
 
 
 
118
  }
119
+
120
  //when retrieve is clicked
121
  async function onSubmit(){
122
  document.getElementById("spinner").style.display = 'none';
 
135
  document.getElementById("spinner").style.display = 'none';
136
  // document.getElementById("grey-container").className = 'album py-5 bg-light';
137
 
138
+
139
+
140
+ if (typeof predictions['predictions'] == "string"){
141
+ alert("Library not found in the database. Please try another query!")
142
+ document.getElementById("footer").innerHTML = '';
143
+ } else {
144
+ let response = predictions['predictions']
145
+ //loop through number of results
146
+ html = ''
147
+ var w = 0
148
+ for(let i=0; i < response.length; i++){
149
+
150
+ html += '<div class="row g-4 m-2" id="predictions">';
151
+ html += '<div class="col-6">';
152
+ html += '<div class="card border-primary mb-3">';
153
+ // library name and description
154
+ html += '<div class="card-body">';
155
+ html += '<h5 class="card-title text-primary">'+ response[i]["library_name"] +'</h5>';
156
+ html += '<p class="card-text">'+ response[i]["Description"] +'</p>';
157
+ html += '</div>';
158
+ // end library name and description
159
+ // group button bottom (View GitHub and See Usage Patterns and Configs)
160
+ html += '<div class="card-footer">';
161
+ html += '<div class=" d-flex justify-content-between align-items-center">';
162
+ html += '<div class="btn-group">'
163
+ html += '<a type="button" class="btn btn-sm btn-outline-secondary" href='+ response[i]["Github URL"] +'>View Github</a>';
164
+ html += '</div>'
165
+ html += '<a href="javascript:void(0)" id="myTooltip" data-bs-toggle="tooltip" data-bs-placement="right" onclick="onClickMore('+ response[i]["id"] +')">See Usage Patterns and Interface Configs</a>';
166
+ html += '</div>';
167
+ html += '</div>';
168
+ html += '</div>';
169
+ html += '</div>';
170
+ // end card group button
171
+ html += '<div class="col-6"><div id="'+ response[i]["id"] +'" style="display: none;" class="card border-primary mb-3">';
172
+ html += '<div class="card-body">';
173
+ //begin accordion outer
174
+ html += '<div class="accordion" id="accordionOuter'+ i + '">';
175
+ // first item
176
+ html += '<div class="accordion-item">';
177
+ html += '<h2 class="accordion-header" id="headingOneOuter"'+ i + '>';
178
+ html += '<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne'+ i +'" aria-expanded="true" aria-controls="collapseOne'+ i +'">'
179
+ html += 'Interface Configuration';
180
+ html += '</button>';
181
+ html += '</h2>';
182
+ html += '<div id="collapseOne'+ i +'" class="accordion-collapse collapse show" aria-labelledby="headingOneOuter"'+ i +'data-bs-parent="#accordionOuter'+ i + '">'
183
+ html += '<div class="accordion-body">'
184
+ // html += 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven\'t heard of them accusamus labore sustainable VHS.'
185
+
186
+ // interface configuration begin
187
+ html += '<h6>Protocol: '+ response[i]["hw_config"]["protocol"]+ '</h6>';
188
+ html += '<table class="table table-hover"><thead><tr><th>Arduino Type</th><th>I/O hardware --> Arduino</th></tr></thead><tbody>'
189
+ //loop through hardware config
190
+ for (const property in response[i]["hw_config"]["pin_connection_from_hw_to_arduino"]){
191
+ let firstLetter = property.charAt(0).toUpperCase();
192
+ let remLetter = property.substring(1).split("_");
193
+ html += '<tr><td>' + firstLetter + remLetter[0] + '_' + remLetter[1].charAt(0).toUpperCase() + remLetter[1].substring(1) + '</td><td>';
194
+ //loop through the arduino type
195
+ for (let y=0; y < response[i]["hw_config"]["pin_connection_from_hw_to_arduino"][property].length; y++){
196
+ // html += '(' + (response[i]["hw_config"]["pin_connection_from_hw_to_arduino"][property][y][0] + ',' + response[i]["hw_config"]["pin_connection_from_hw_to_arduino"][property][y][1]) + ') ';
197
+ html += '(' + response[i]["hw_config"]["pin_connection_from_hw_to_arduino"][property][y] +') ';
198
+ }
199
+ html += ' </td></tr>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
201
+ html += '</tbody></table> ';
202
+ // end interface configuration
203
 
204
+ html += '</div>'
205
+ html += '</div>'
206
+ html += '</div>'
207
+ // end first item
208
 
209
+ //second item
210
+ html += '<div class="accordion-item">';
211
+ html += '<h2 class="accordion-header" id="headingTwoOuter'+ i +'">';
212
+ html += '<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo'+ i +'" aria-expanded="false" aria-controls="collapseTwo'+ i +'">'
213
+ html += 'Usage Patterns';
214
+ html += '</button>';
215
+ html += '</h2>';
216
+ html += '<div id="collapseTwo'+ i +'" class="accordion-collapse collapse" aria-labelledby="headingTwoOuter'+ i +'" data-bs-parent="#accordionOuter'+ i + '">'
217
+ html += '<div class="accordion-body">'
218
+ // html += 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven\'t heard of them accusamus labore sustainable VHS.'
219
+ // begin usage pattern
220
+ let w = 0
221
+ Object.keys(response[i]["usage_patterns"]).forEach(function(key) {
222
+ let usages_arr = response[i]["usage_patterns"][key]
223
+ // begin accordion inner
224
+ html += '<div class="accordion" id="accordionInner">'
225
+ // begin item
226
+ html += ' <div class="accordion-item">'
227
+ html += ' <h2 class="accordion-header" id="headingOneInner'+ key + i +'">'
228
+ if (w == 0){
229
+ html += ' <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOneInner'+ key + i +'" aria-expanded="true" aria-controls="collapseOneInner'+ key + i +'">'
230
  }
231
  else {
232
+ html += ' <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOneInner'+ key + i +'" aria-expanded="false" aria-controls="collapseOneInner'+ key + i +'">'
233
  }
234
+ html += ' Sensor Object: '+ key
235
+ html += ' </button>'
236
+ html += ' </h2>'
237
+ if (w == 0){
238
+ html += ' <div id="collapseOneInner'+ key + i +'" class="accordion-collapse collapse show" aria-labelledby="headingOneInner'+ key + i +'">'
 
 
 
 
 
239
  }
240
+ else {
241
+ html += ' <div id="collapseOneInner'+ key + i +'" class="accordion-collapse collapse" aria-labelledby="headingOneInner'+ key + i +'">'
 
 
242
  }
243
+ html += ' <div class="accordion-body">'
244
+
245
+ // being accordion inner
246
+ html += '<div style="margin-bottom: 15px" class="accordion" id="accordionPanelsStayOpenExample"' + response[i]["id"] + key + '>'; //1
247
+
248
+ for (let x=0; x < usages_arr.length; x++){
249
+ let pattern = usages_arr[x].split("[API-SEP]")
250
+ html += '<div data-bs-toggle="collapse" data-bs-target="#patternCollapse' + response[i]["id"] + key + x + '">'; //2
251
+ html += '<div class="accordion-item">'; //3
252
+ html += '<h2 class="accordion-header" id="panelsStayOpen-heading' + response[i]["id"] + key +'">';
253
+
254
+ if (x == 0){
255
+ html += '<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapse' + response[i]["id"] + key + x + '" aria-expanded="true" aria-controls="panelsStayOpen-collapse' + response[i]["id"] + key + x + '">';
256
+ }
257
+ else {
258
+ html += '<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapse' + response[i]["id"] + key + x + '" aria-expanded="false" aria-controls="panelsStayOpen-collapse' + response[i]["id"] + key + x + '">';
259
+ }
260
+
261
+ html += 'Pattern ' + (x+1);
262
+ html += '</button>';
263
+ html += '</h2>';
264
+
265
+ //4
266
+ if (x== 0){
267
+ html += '<div id="panelsStayOpen-collapse' + response[i]["id"] + key + x + '" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-heading' + response[i]["id"] + key + x + '">';
268
+ } else {
269
+ html += '<div id="panelsStayOpen-collapse' + response[i]["id"] + key + x + '" class="accordion-collapse collapse" aria-labelledby="panelsStayOpen-heading' + response[i]["id"] + key + x + '">';
270
+ }
271
+ html += '<div class="accordion-body">' //5
272
+ html += '<ul>';
273
+ for (let y=0; y<pattern.length; y++){
274
+ html += '<li>' + pattern[y] + '</li>';
275
+ }
276
+ html += '</ul>';
277
+ html += '</div>' //5
278
+ html += '</div>'; //4
279
+ html += '</div>'; //3
280
+ html += '</div>'; //2
281
+ }
282
+ html += '</div>' //1
283
+
284
+ html += ' </div>'
285
+ html += ' </div>'
286
+ html += ' </div>'
287
+ //end item
288
+ html += '</div>'
289
+ // end accordion inner
290
+ w += 1
291
+ });
292
+ // end usage pattern
293
+
294
+ html += '</div>'
295
+ html += '</div>'
296
+ html += '</div>'
297
+ //end second item
298
+
299
+ html += '</div>';
300
+ // end accordion outer
301
+
302
+ //button close
303
+ html += '<div class="position-absolute top-0 end-0">'
304
+ html += '<button type="button" class="btn-close" aria-label="Close" onclick="onOut('+ response[i]["id"] +')"></button>';
305
+ html += '</div>';
306
+ // end button close
307
+
308
+ html += '</div></div>';
309
+ html += '</div></div>';
310
  }
311
+ //append the html to the container
312
+ document.getElementById("main-parent").innerHTML = (html);
313
 
314
+ html2 = '<div class="container"><p class="float-right"><a href="#">Back to top</a></p>';
315
+ //append footer to allow going back to the top
316
+ document.getElementById("footer").innerHTML = (html2);
317
+ }
 
 
318
  }
319
  else {
320
  document.getElementById("spinner").style.display = 'none';