Skip to content

Instantly share code, notes, and snippets.

@techieshark
Created December 8, 2011 02:28
Show Gist options
  • Save techieshark/1445839 to your computer and use it in GitHub Desktop.
Save techieshark/1445839 to your computer and use it in GitHub Desktop.
List of people who responded yes/maybe to Facebook event
<html>
<head>
<title>Facebook Evevt Attendees</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="yes.js"></script>
<script type="text/javascript" src="maybe.js"></script>
<script type="text/javascript">
// code modified from http://www.zachhunter.com/2011/06/json-to-csv/
// for performing case insensitive sort
function charOrdA(a, b){
a = a.toLowerCase(); b = b.toLowerCase();
if (a>b) return 1;
if (a <b) return -1;
return 0;
}
// returns an alphabetically ascending sorted string of names (1 per line)
// the input sould be the output of the FB Graph Explorer
// e.g. https://developers.facebook.com/tools/explorer/?method=GET&path=266042140109148%2Fattending
function getNames(fbDataArr) {
var names = [];
for (i in fbDataArr) {
names.push(fbDataArr[i].name);
}
return names.sort(charOrdA).join('\r\n');
}
$(document).ready(function () {
// yes and maybe variables come from included scripts
// which are output from FB Graph Explorer, in a format like:
// yes = { "data": [...], }
// Grab and print just the names from each set.
$('#yeses').text(getNames(yeses.data));
$('#maybes').text(getNames(maybes.data));
});
</script>
</head>
<body>
<h1>FB: Yeses</h1>
<pre id="yeses"></pre>
<h1>FB: Maybes</h1>
<pre id="maybes"></pre>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment