<a href="/"><img src="/images/finals-club-wht.png" class="logo"/></a>
</td>
<td class="menu">
- <a href="javascript:goSchools()">Courses</a>
+ <a href="javascript:goSchools()">Start Here!</a>
<a href="http://blog.finalsclub.org">Blog</a>
<a href="javascript:goArchivedSubjects()">Archive</a>
<a href="javascript:goPress()">Press</a>
<div class="logbar"> </div>
</div>
+ <div id="topofcontent"></div>
+
<div class="content">
<div class=page id=pg_schools>
<h1>Universities</h1>
- <div class="school" id=PROTO_school>
+ <div class="school" id=PROTO_school onclick="goCourses('__name__', '___id__', __i__)">
<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_lectures>
<h1>Lectures for <span id=course_name></span></h1>
- <div class=course id=PROTO_lecture>
+ <div class=lecture id=PROTO_lecture>
+ <div class=name>
+ <a href="javascript:goPads('___id__')">__name__</a>
+ </div>
+ </div>
+ </div>
+
+
+
+ <div class=page id=pg_pads>
+ <h1>Notepads for <span id=lecture_name></span></h1>
+ <div class=pad id=PROTO_pad>
<div class=name>
- <a href="goPads('___id__')">__name__</a>
+ <a href="">__name__</a>
</div>
</div>
</div>
$(".page").fadeOut(100);
}
function showPage(id) {
+ //alert("showPage "+id);
$("#pg_"+id).fadeIn(100);
+
+ $('html, body').animate({ scrollTop: 0 }, 10);
+ /*$('html, body').animate({
+ scrollTop: $("#topofcontent").offset().top
+ }, 100);*/
+
+}
+
+function goPage(id) {
+
+ showPage(id)
+
+ //if(id == 'home')
+ // id = 'index.html'
+ //history.pushState({prev:document.location.pathname.substr(1)}, "Page "+id, "/"+id);
+ history.pushState({prev:id}, "Page "+id, "/"+id);
+
}
schools = response.schools
}
ProtoDiv.replicate("PROTO_school", schools);
- showPage("schools")
+ goPage("schools")
});
}
courses = school.courses
}
ProtoDiv.replicate("PROTO_course", courses);
- showPage("courses")
+ goPage("courses", "/courses/"+schoolId)
});
}
lectures = course.lectures
}
ProtoDiv.replicate("PROTO_lecture", lectures);
- showPage("lectures")
+ goPage("lectures")
+ });
+}
+
+
+
+
+// go to the page that lists the lectures for a specific course
+var pads = []
+function goPads(lectureId) {
+ ProtoDiv.reset("PROTO_pad");
+ hideAllPages();
+ $.get("/lecture/"+lectureId, {}, function(response) {
+
+response = {
+ lecture: {
+ name: "Foo Lecture",
+ pads: [
+ { _id: 1, name: "pad 1" },
+ { _id: 2, name: "pad 2" },
+ ]
+ }
+}
+ pads = []
+ if(typeof response == 'object') {
+ var lecture = response.lecture
+ $("#lecture_name").html(lecture.name);
+ pads = course.pads
+ }
+ ProtoDiv.replicate("PROTO_pad", lectures);
+ goPage("pads")
});
}
ProtoDiv.reset("PROTO_archived_subjects");
ProtoDiv.replicate("PROTO_archived_subjects", archivedSubjects);
- showPage("archive");
+ goPage("archive");
}
hideAllPages();
// xxx clear fields?
// xxx change FORM to use AJAX
- showPage("register");
+ goPage("register");
}
// go to the press articles page
function goPress() {
hideAllPages();
- showPage("press");
+ goPage("press");
}
// go to the "code of conduct" page
function goConduct() {
hideAllPages();
- showPage("conduct");
+ goPage("conduct");
}
$(document).ready(function() {
// This executes after the page has been fully loaded
- showPage("home");
+
+ window.onpopstate = function(event) {
+
+ var state = event.state
+ //alert("pop: "+o2j(state));
+
+ hideAllPages();
+
+ if(!state) {
+
+ history.replaceState(null, "", "/index.html");
+ showPage("home");
+
+ }
+ else {
+ //alert("location: " + document.location + ", state: " + JSON.stringify(event.state));
+ //history.replaceState(null, "", state.prev);
+ showPage(state.prev);
+ // showPage(state.prev);
+ //alert("location: " + document.location + ", state: " + JSON.stringify(event.state));
+ }
+ };
+
+ //showPage("home");
})