<div class=page id=pg_schools>
<h1>Universities</h1>
<div class="school" id=PROTO_school>
- <div class=name>
- <a href="javascript:goCourses('__name__')">__name__</a>
- (__numCourses__ courses)
+ <div class=name>__name__</div>
+ <div class=desc>__description__</div>
+ <div class=tocourses>
+ <a href="javascript:goCourses('__name__', '___id__', __i__)">
+ Click for courses ...
+ </a>
</div>
</div>
</div>
<div class=page id=pg_courses>
<h1>Courses for <span id=school_name></span></h1>
+ <div class=course id=PROTO_course>
+ <div class=dept>__department__</div>
+ <div class=name>
+ <a href="javascript:goLectures('___id__')">__number__: __name__</a>
+ </div>
+ </div>
+ </div>
- <ul>
- <li id=PROTO_course><a href="course/__id__">__name__</a></li>
- </ul>
+
+
+ <div class=page id=pg_lectures>
+ <h1>Lectures for <span id=course_name></span></h1>
+ <div class=course id=PROTO_lecture>
+ <div class=name>
+ <a href="goPads('___id__')">__name__</a>
+ </div>
+ </div>
</div>
-var schools = []
// go to the page that lists the schools
+var schools = []
function goSchools() {
+ ProtoDiv.reset("PROTO_school");
hideAllPages();
$.get("/schools", {}, function(response) {
- if(typeof response == 'object')
+ if(typeof response == 'object') {
schools = response.schools
- ProtoDiv.reset("PROTO_school");
+ }
ProtoDiv.replicate("PROTO_school", schools);
showPage("schools")
});
-var courses = []
-
// go to the page that lists the courses for a specific school
-function goCourses(name) {
+var courses = []
+function goCourses(schoolName, schoolId, a) {
+ ProtoDiv.reset("PROTO_course");
hideAllPages();
- $("#school_name").html(name);
-// $.get("/courses", {}, function(response) {
-// if(typeof response == 'object')
-// courses = response.courses
-var courses = [
-{ id: "4e6d1e9b42bbef522c000a8f", name: "History 12: Introduction to the Middle East" },
-{ id: "4e8aa3f62e4b97e67b001f47", name: "ANTH160AC/ISF 160: The Forms of Folklorek" }
-]
- ProtoDiv.reset("PROTO_course");
+ $.get("/school/"+schoolId, {}, function(response) {
+ courses = []
+ if(typeof response == 'object') {
+ var school = response.school
+ $("#school_name").html(school.name);
+ courses = school.courses
+ }
ProtoDiv.replicate("PROTO_course", courses);
showPage("courses")
-// });
+ });
+}
+
+
+
+
+// go to the page that lists the lectures for a specific course
+var lectures = []
+function goLectures(courseId) {
+ ProtoDiv.reset("PROTO_lecture");
+ hideAllPages();
+ $.get("/course/"+courseId, {}, function(response) {
+
+response = {
+ course: {
+ name: "FooCourse",
+ lectures: [
+ { _id: 1, name: "lecture 1" },
+ { _id: 2, name: "lecture 2" },
+ ]
+ }
+}
+ lectures = []
+ if(typeof response == 'object') {
+ var course = response.course
+ $("#course_name").html(course.name);
+ lectures = course.lectures
+ }
+ ProtoDiv.replicate("PROTO_lecture", lectures);
+ showPage("lectures")
+ });
}
}
}
-ProtoDiv.substitute = function(s, obj) {
+ProtoDiv.substitute = function(s, obj, i) {
+ if(i !== undefined)
+ s = s.replace(/__i__/g, i);
for(var key in obj) {
re = new RegExp("__"+key+"__", "g")
s = s.replace(re, obj[key])
return s
}
-ProtoDiv.inject = function(id, obj) {
+ProtoDiv.inject = function(id, obj, n) {
var proto = ProtoDiv.elem(id)
- proto.innerHTML = ProtoDiv.substitute(proto.innerHTML, obj)
+ proto.innerHTML = ProtoDiv.substitute(proto.innerHTML, obj, n)
for(var i = 0; i < proto.attributes.length; i++) {
var a = proto.attributes[i]
- a.textContent = ProtoDiv.substitute(a.textContent, obj)
+ a.textContent = ProtoDiv.substitute(a.textContent, obj, n)
}
for(var key in obj) {
var e = proto.cloneNode(true)
delete e.id
mom.insertBefore(e, sib)
- ProtoDiv.inject(e, obj)
+ ProtoDiv.inject(e, obj, i)
}
if(!keep)