Skip to content

Commit

Permalink
Update activities.md
Browse files Browse the repository at this point in the history
Took 28 minutes
  • Loading branch information
dport96 committed May 19, 2024
1 parent 265a023 commit a2d38ee
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions nrts/activities.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ labels:
- Activities
- Learning
---
<script src="https://cdnjs.cloudflare.com/ajax/libs/json5/2.2.3/index.min.js" integrity="sha512-44jdhc+R2TFfzBflS3/dGNEABiNUxBkkrqwO7GWTvGsj3HkQNr3GESvI9PUvAxmqxSnTosR0Ij9y3+o+6J1hig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<div id="table-container" class="container"></div>

<script type="text/javascript">
/*
const query = 'SELECT * WHERE C = "{{ site.data.bio.basics.email }}"';
fetch(`https://docs.google.com/spreadsheets/d/1cYoC5aqpM6r2DceIvGN8y0H5AK1b-n1CC-yX-NmWUtI/gviz/tq?tq=${query}`)
fetch(`https://docs.google.com/spreadsheets/d/1cYoC5aqpM6r2DceIvGN8y0H5AK1b-n1CC-yX-NmWUtI/gviz/tq?sheet=Activities&tq=${query}`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
Expand All @@ -24,7 +24,7 @@ labels:
.then(responseText => {
console.log(responseText);
let jsonString = responseText.match(/\{.*\}/)[0];
let jsonData = JSON5.parse(jsonString);
let jsonData = JSON.parse(jsonString);
let data = jsonData.table.rows.map(row => row.c.map(cell => cell.f))[0];
let headers = jsonData.table.cols.map(col => col.label);
tableHtml = '<table class="table table-bordered"><tbody><thead><tr><th>Activity</th><th>Completed Date</th></tr></thead>';
Expand All @@ -40,5 +40,42 @@ console.log(responseText);
.catch(error => {
console.error('There was a problem fetching the data:', error);
});
*/
</script>

</script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawTable);

function drawTable() {
var queryString = encodeURIComponent(`SELECT * WHERE C = "{{ site.data.bio.basics.email }}"`);
var query = new google.visualization.Query(
`https://docs.google.com/spreadsheets/d/1cYoC5aqpM6r2DceIvGN8y0H5AK1b-n1CC-yX-NmWUtI/gviz/tq?sheet=Activities&tq=${queryString}`
);

query.send(handleQueryResponse);
}

function handleQueryResponse(response) {
if (response.isError()) {
console.log('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}

var data = response.getDataTable();
var jsonData = JSON.parse(data.toJSON());

let tabledata = jsonData.rows.map(row => row.c.map(cell => cell.f))[0];
let headers = jsonData.cols.map(col => col.label);
tableHtml = '<table class="table table-bordered"><tbody><thead><tr><th>Activity</th><th>Completed Date</th></tr></thead>';
for(let i = 3; i < headers.length; i++) {
if(tabledata[i] === undefined) {
continue;
}
tableHtml += `<tr><td>${headers[i]}</td><td>${tabledata[i]}</td></tr>`;
}
tableHtml += '<tbody></table>';
document.getElementById('table-container').innerHTML = tableHtml;
}
</script>

0 comments on commit a2d38ee

Please sign in to comment.