archive pages working with 1page, 1st pass
authorec2-user <ec2-user@fcdev4.finalsclub.org>
Sun, 13 Nov 2011 22:25:11 +0000 (22:25 +0000)
committerec2-user <ec2-user@fcdev4.finalsclub.org>
Sun, 13 Nov 2011 22:25:11 +0000 (22:25 +0000)
public/index.html
public/javascripts/main.js

index d2690b0e0dabbab91800fc9b2913b088004dab6d..82b0b9a3028eec35beefcddd8fc00d737c0b68c2 100644 (file)
 
 
 
-                       <div class=page id=pg_archive>
+                       <div class=page id=pg_archive_subjects>
                                <h1>Archived Subjects</h1>
                                <p>
                                Please browse our archive of past courses
                                covered at Harvard from 2008 through 2010.
                                </p>
                                <ul>
-                                       <li id=PROTO_archived_subjects>
-                                               <a href="/archive/subject/__id__">__title__</a>
+                                       <li id=PROTO_archive_subject>
+                                               <a href="javascript:goPage('/archive/subject/__id__')">__name__</a>
+                                       </li>
+                               </ul>
+
+                       </div>
+
+
+
+                       <div class=page id=pg_archive_courses>
+                               <h1>Archived Courses</h1>
+                               <ul>
+                                       <li id=PROTO_archive_course>
+                                               <a href="javascript:goPage('/archive/course/__id__')">__name__</a>
+                                       </li>
+                               </ul>
+
+                       </div>
+
+
+
+                       <div class=page id=pg_archive_notes>
+                               <h1>Archived Notes</h1>
+                               <ul>
+                                       <li id=PROTO_archive_note>
+                                               <a href="/archive/note/___id__">__topic__</a>
                                        </li>
                                </ul>
 
index aa8e35142261718b1eb09755033df87519133604..f9b69ffefc1e0cbd12a6a03c9619a0f6692d11c1 100644 (file)
@@ -141,25 +141,67 @@ function showNotes(matches, cb) {
 
 
 
-var archivedSubjects = []
 
 // go to the page that lists the archived subject names
-function showArchive(matches, cb) {
+function showArchiveSubjects(matches, cb) {
 
-       // xxx fake data
-       archivedSubjects = [
-               { id: 83, title: "Anthropology" },
-               { id: 44, title: "CORE-Foreign Cultures" },
-               { id: 80, title: "CORE-Historical Study" }
-       ]
+       ProtoDiv.reset("PROTO_archive_subject")
 
-       ProtoDiv.reset("PROTO_archived_subjects")
-       ProtoDiv.replicate("PROTO_archived_subjects", archivedSubjects)
+       $.get("/archive", { }, function(response) {
 
-       cb("archive")
+               var subjects = response.subjects
+
+               ProtoDiv.replicate("PROTO_archive_subject", subjects)
+
+       })
+
+       cb("archive_subjects")
+}
+
+
+
+function showArchiveCourses(matches, cb) {
+
+       var subjectId = parseInt(matches[1])
+
+       ProtoDiv.reset("PROTO_archive_course")
+
+       $.get("/archive/subject/"+subjectId, { }, function(response) {
+
+               var courses = response.courses
+
+               ProtoDiv.replicate("PROTO_archive_course", courses)
+
+       })
+
+       cb("archive_courses")
 }
 
 
+
+function showArchiveNotes(matches, cb) {
+
+       var courseId = parseInt(matches[1])
+
+       ProtoDiv.reset("PROTO_archive_note")
+
+       $.get("/archive/course/"+courseId, { }, function(response) {
+
+               var notes = response.notes
+               $.each(notes, function(i, note) {
+                       if(!note.topic)
+                               note.topic = note.text.substr(0, 15)+" ..."
+               })
+
+               ProtoDiv.replicate("PROTO_archive_note", notes)
+
+       })
+
+       cb("archive_notes")
+}
+
+
+
 // go to the account registration page
 function showRegister(matches, cb) {
        // xxx clear fields?
@@ -202,10 +244,12 @@ var pageVectors = [
        { regex: /^\/school\/([a-f0-9]{24})/, func: showCourses },
        { regex: /^\/course\/([a-f0-9]{24})/, func: showLectures },
        { regex: /^\/lecture\/([a-f0-9]{24})/, func: showNotes },
+       { regex: /^\/archive\/?$/, func: showArchiveSubjects },
+       { regex: /^\/archive\/subject\/([0-9]+)/, func: showArchiveCourses },
+       { regex: /^\/archive\/course\/([0-9]+)/, func: showArchiveNotes },
        { regex: /^\/login/, func: showLogin },
        { regex: /^\/register/, func: showRegister },
        { regex: /^\/press/, func: showPress },
-       { regex: /^\/archive/, func: showArchive },
        { regex: /^\/conduct/, func: showConduct },
 ];