Skip to content

Commit

Permalink
Added script that loads participants dynamically. Needs code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres-remote committed Oct 27, 2012
1 parent 2b14951 commit 658ee4a
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions scripts/load_cg_participants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//This script dynamically loads the participants of the CG and shows them in the spec.
(function requestParticipants(){
var xhr = new XMLHttpRequest(),
output = document.querySelector("#participants"),
participantsURL = output.querySelector("a").getAttribute("href"),
tempElem = document.createElement("temp"),
participants;
if(!participantsURL){
return;
}
xhr.open("GET", participantsURL,true);
xhr.onreadystatechange= processParticipants;
xhr.send(null);

function processParticipants(){
if (xhr.readyState==4) {
//participants are in a table on the other website
tempElem.innerHTML = xhr.responseText;
participants = tempElem.querySelectorAll("td > h3");
if(participants.length > 0){
showParticipants(participants)
}
}
}

function showParticipants(){
var names = [],
prefix = "Participants of the Responsive Images Community Group are: ";
if(participants.length){
for(var i = 0; i < participants.length; i++){
names.push(participants.item(i).textContent);
}
output.innerHTML = prefix + names.join(", ") + ".";
}
}
}());

0 comments on commit 658ee4a

Please sign in to comment.