JSFiddle - React, Tailwind, and code Playground
by Gert Vaartjes
HTML
<div id="respondents"></div>
JavaScript
$(function () {
var url = 'https://docs.google.com/spreadsheet/pub?key=0AgkKO44ious-dGlES3ROcVFqTElicWtvLWIxWTBLM1E&single=true&gid=2&output=txt';
$.ajax({
type: 'GET',
url: url,
success: function (txt) {
var lines = txt.split('\n'),
cats = {};
$.each(lines, function (idx) {
var line = lines[idx];
var info = line.split("\t");
var cat = info[3];
if (!cats.hasOwnProperty(cat)) {
cats[cat] = [];
}
cats[cat].push(info[0] + ' ' + info[1] + ', ' + info[2]);
});
$list = $('<dl></dl>');
function add(idx2) {
$list.append('<dd>' + persons[idx2] + '</dd>');
}
for (var c in cats) {
if (cats.hasOwnProperty(c)) {
var persons = cats[c];
$list.append('<dt>' + c + '</dt>');
$.each(persons, add);
}
}
$list.appendTo('#respondents');
}
});
});