-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script that loads participants dynamically. Needs code review.
- Loading branch information
1 parent
2b14951
commit 658ee4a
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(", ") + "."; | ||
} | ||
} | ||
}()); | ||
|