From 084d8aa67d01fdef824dc761df1e57073956637e Mon Sep 17 00:00:00 2001 From: ec2-user Date: Sun, 13 Nov 2011 22:25:11 +0000 Subject: [PATCH] archive pages working with 1page, 1st pass --- public/index.html | 30 +++++++++++++++-- public/javascripts/main.js | 68 +++++++++++++++++++++++++++++++------- 2 files changed, 83 insertions(+), 15 deletions(-) diff --git a/public/index.html b/public/index.html index d2690b0..82b0b9a 100644 --- a/public/index.html +++ b/public/index.html @@ -138,15 +138,39 @@ -
+

Archived Subjects

Please browse our archive of past courses covered at Harvard from 2008 through 2010.

+ +
+ + + +
+

Archived Courses

+ + +
+ + + +
+

Archived Notes

+ diff --git a/public/javascripts/main.js b/public/javascripts/main.js index aa8e351..f9b69ff 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -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 }, ]; -- 2.25.1