Difference between revisions of "Chapters"

From Kappapedia
Jump to: navigation, search
Line 3: Line 3:
 
<html>
 
<html>
 
<script>
 
<script>
var people = new Array();
+
var chapters = new Array();
function person(firstName, lastName, age) {
+
function chapter(chapterName, foundingDate, location, url) {
this.FirstName = firstName;
+
this.ChapterName = chapterName;
this.LastName = lastName;
+
this.FoundingDate = parseInt(parseFloat(foundingDate));
this.Age = parseInt(parseFloat(age));
+
this.Location = location;
 +
        this.URL = url;
 
}
 
}
 
function drawArray(form) {
 
function drawArray(form) {
var v = "";
+
var v = "<table style='width:100%;'>";
for (var i=0; i<people.length; i++) {
+
for (var i=0; i<chapters.length; i++) {
v += people[i].FirstName + " " + people[i].LastName + " (" + people[i].Age + ")<br>";
+
v += "<tr><td><a href='" + chapters[i].URL + "'>" + chapters[i].ChapterName + "</a></td><td>" + chapters[i].FoundingDate + "</td><td>" + chapters[i].Location + "<br>";
 
}
 
}
document.getElementById('list').innerHTML = v
+
document.getElementById('list').innerHTML = v + "</table>"
 
}
 
}
 
window.onload = function(){
 
window.onload = function(){
  
people[people.length++] = new person("Nick", "Wimsatt", 22);
+
chapters[chapters.length++] = new chapter("Alpha Deuteron", 1870, "Monmouth College, Monmouth, IL", "http://wiki.kappakappagamma.org/index.php/Alpha");
people[people.length++] = new person("Jean", "Davis", 50);
+
chapters[chapters.length++] = new chapter("Beta", 1871, "St. Mary's School, Knoxville, IL", "http://wiki.kappakappagamma.org/index.php/Beta");
people[people.length++] = new person("Shawn", "Long", 35);
+
chapters[chapters.length++] = new chapter("Gamma", 1872, "Smithson College, Logansport, IN", "http://wiki.kappakappagamma.org/index.php/Gamma");
 
drawArray();
 
drawArray();
  
 
}
 
}
function addToArray(form) {
+
 
if (form.FirstName.value == "") {
+
function sortByChapterName(a, b) {
alert("Please enter the first name!");
+
var x = a.ChapterName.toLowerCase();
form.FirstName.focus();
+
var y = b.ChapterName.toLowerCase();
return false;
 
}
 
if (form.LastName.value == "") {
 
alert("Please enter the last name!");
 
form.LastName.focus();
 
return false;
 
}
 
if (form.Age.value == "") {
 
alert("Please enter the age!");
 
form.Age.focus();
 
return false;
 
}
 
people[people.length++] = new person(form.FirstName.value, form.LastName.value, form.Age.value);
 
form.FirstName.value = "";
 
form.LastName.value = "";
 
form.Age.value = "";
 
drawArray(form);
 
}
 
function sortByFirstName(a, b) {
 
var x = a.FirstName.toLowerCase();
 
var y = b.FirstName.toLowerCase();
 
 
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
 
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
 
}
 
}
function sortByLastName(a, b) {
+
function sortByLocation(a, b) {
var x = a.LastName.toLowerCase();
+
var x = a.Location.toLowerCase();
var y = b.LastName.toLowerCase();
+
var y = b.Location.toLowerCase();
 
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
 
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
 
}
 
}
Line 61: Line 41:
 
return ((x < y) ? -1 : ((x > y) ? 1 : sortByFirstName(a, b)));
 
return ((x < y) ? -1 : ((x > y) ? 1 : sortByFirstName(a, b)));
 
}
 
}
function sortByAge(a, b) {
+
function sortByFoundingDate(a, b) {
var x = a.Age;
+
var x = a.FoundingDate;
var y = b.Age;
+
var y = b.FoundingDate;
 
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
 
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
 
}
 
}
 
function sortArray(form, column) {
 
function sortArray(form, column) {
if (people.length == 0) {
+
if (chapters.length == 0) {
 
alert("Please add one or more people before sorting!");
 
alert("Please add one or more people before sorting!");
 
return false;
 
return false;
Line 73: Line 53:
 
switch (column) {
 
switch (column) {
 
case 1 :
 
case 1 :
people.sort(sortByFirstName);
+
chapters.sort(sortByChapterName);
 
break;
 
break;
 
case 2 :
 
case 2 :
people.sort(sortByLastName);
+
chapters.sort(sortByFoundingDate);
 
break;
 
break;
 
case 3 :
 
case 3 :
people.sort(sortByAge);
+
chapters.sort(sortByLocation);
 
break;
 
break;
 
case 4 :
 
case 4 :
people.sort(sortByLastNameThenFirst);
+
chapters.sort(sortByLastNameThenFirst);
 
break;
 
break;
 
}
 
}
Line 89: Line 69:
 
// -->
 
// -->
 
</script>
 
</script>
<div onclick="sortArray(document.forms['Demo'], 3)">Sort by Age</div></html>
+
<table style='width:100%'><tr>
 +
<td><div onclick="sortArray(document.forms['Demo'], 1)">Chapter Name</div></td>
 +
<td><div onclick="sortArray(document.forms['Demo'], 2)">Founding Date</div></td>
 +
<td><div onclick="sortArray(document.forms['Demo'], 3)">Location</div></td>
 +
</tr></table>
 +
</html>
 
----
 
----
  

Revision as of 16:48, 14 June 2011

List of Kappa Kappa Gamma chapters founded in 1870 to present date:

<html> <script> var chapters = new Array(); function chapter(chapterName, foundingDate, location, url) { this.ChapterName = chapterName; this.FoundingDate = parseInt(parseFloat(foundingDate)); this.Location = location;

       this.URL = url;

} function drawArray(form) {

var v = ""; for (var i=0; i<chapters.length; i++) { v += "
<a href='" + chapters[i].URL + "'>" + chapters[i].ChapterName + "</a>" + chapters[i].FoundingDate + "" + chapters[i].Location + "
";

}

document.getElementById('list').innerHTML = v + "
"

} window.onload = function(){

chapters[chapters.length++] = new chapter("Alpha Deuteron", 1870, "Monmouth College, Monmouth, IL", "http://wiki.kappakappagamma.org/index.php/Alpha"); chapters[chapters.length++] = new chapter("Beta", 1871, "St. Mary's School, Knoxville, IL", "http://wiki.kappakappagamma.org/index.php/Beta"); chapters[chapters.length++] = new chapter("Gamma", 1872, "Smithson College, Logansport, IN", "http://wiki.kappakappagamma.org/index.php/Gamma"); drawArray();

}

function sortByChapterName(a, b) { var x = a.ChapterName.toLowerCase(); var y = b.ChapterName.toLowerCase(); return ((x < y) ? -1 : ((x > y) ? 1 : 0)); } function sortByLocation(a, b) { var x = a.Location.toLowerCase(); var y = b.Location.toLowerCase(); return ((x < y) ? -1 : ((x > y) ? 1 : 0)); } function sortByLastNameThenFirst(a, b) { var x = a.LastName.toLowerCase(); var y = b.LastName.toLowerCase(); return ((x < y) ? -1 : ((x > y) ? 1 : sortByFirstName(a, b))); } function sortByFoundingDate(a, b) { var x = a.FoundingDate; var y = b.FoundingDate; return ((x < y) ? -1 : ((x > y) ? 1 : 0)); } function sortArray(form, column) { if (chapters.length == 0) { alert("Please add one or more people before sorting!"); return false; } switch (column) { case 1 : chapters.sort(sortByChapterName); break; case 2 : chapters.sort(sortByFoundingDate); break; case 3 : chapters.sort(sortByLocation); break; case 4 : chapters.sort(sortByLastNameThenFirst); break; } drawArray(form); } // --> </script>

Chapter Name
Founding Date
Location

</html>


test

Alpha Deuteron
Beta
Gamma
Delta
Epsilon
Zeta
Eta
Iota
Theta
Beta Gamma
Lambda
Mu
Nu
Omicron Deuteron
Chi
Pi Deuteron
Rho Deuteron
Tau
Kappa
Beta Beta Deuteron
Upsilon
Beta Zeta
Phi
Xi
Beta Tau
Psi Deuteron
Omega
Sigma
Beta Rho Deuteron
Gamma Rho
Beta Nu
Beta Alpha
Beta Delta
Beta Epsilon
Beta Eta Deuteron
Beta Iota
Beta Lambda
Beta Mu
Beta Xi