Skip to content

Commit df09207

Browse files
author
sulfuroussquares
committed
display basic information in results area
1 parent 62f2f30 commit df09207

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

browser-extension/tabs.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ function pasteQuery() {
88

99
document.addEventListener('DOMContentLoaded', pasteQuery);
1010

11+
// this function accepts an {object} and returns the contents displayed to the page
12+
function displayResults(jsonData) {
13+
// results is an array of n items
14+
let results = jsonData['results'];
15+
16+
results.forEach((element) => {
17+
let item = JSON.stringify(element);
18+
// you can now access element.body, element.lecture, element.timestamp, element.week
19+
document.getElementById('results-area').innerText = element.body;
20+
21+
// create a new div area for each element
22+
// insert into that div, elements for each body/lecture/timestamp/week
23+
});
24+
}
25+
1126
console.log('made it to tabs');
1227
// test hitting our local server
1328
fetch('http://localhost:5000/test')
@@ -16,6 +31,13 @@ fetch('http://localhost:5000/test')
1631
})
1732
.then(function (jsonResponse) {
1833
console.log(jsonResponse);
34+
// document.getElementById('results-area').innerText = JSON.stringify(
35+
// jsonResponse['results'][0]
36+
// );
37+
38+
// document.getElementById('results-area').innerText =
39+
// JSON.stringify(jsonResponse);
40+
displayResults(jsonResponse);
1941
})
2042
.catch(function (error) {
2143
console.log('Error: ' + error);

0 commit comments

Comments
 (0)