From: ec2-user Date: Tue, 15 Nov 2011 00:39:53 +0000 (+0000) Subject: - X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3095988b826ce162dc7196b501a9d14b92763463;p=oweals%2Ffinalsclub.git - --- diff --git a/public/index-jacob.html b/public/index-jacob.html new file mode 100644 index 0000000..1a5f79a --- /dev/null +++ b/public/index-jacob.html @@ -0,0 +1,411 @@ + + + + + FinalsClub.org + + + + + + + + + + + + + + + + + + + +
+
+
 
+
+ +
 
+
+ +
+ + + +
+ + + + + +
+
+
+

+ Welcome to FinalsClub.org, a 501(c)(3) non-profit + open education project dedicated to helping college + students collaborate, learn, and share their + knowledge freely online. +

+

+ Please create an account with your school email address + to try our tools or browse our course archive to learn + something new. + Thank you for helping us improve access to education, + one lecture at a time. +

+

+
Learn something >>
+

+ +
+
+ +
+ + + +
+

Universities

+
+
__name__
+
__description__
+
+
+ + + +
+

Courses for

+
+
__department__
+ +
+
+ + + +
+
+

Lectures for Course __number__ : __name__

+ Subject: __subject__
+ Department: __department__
+
+
+ Instructor: __name__ (__email__)
+
+
+
+ __name__
+ Created: __date__
+
+
+
+ + + +
+

Notepads

+
+
+ __name__ +
+
+
+ + + +
+

Archived Subjects

+

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

+ + +
+ + + +
+

Archived Courses

+ + +
+ + + +
+

Archived Notes

+ +
+ + + +
+
+

__topic__

+
__text__
+
+
+ + + +
+

Create an Account

+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+   +
+
+ +
+
+
+
+
+ + + +
+

Login

+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
  +
+
+ + + Forgot password? + +
+
+
+
  +
+ +
+
+
+
+ + +
+
+

Code of Conduct

+

+ Keep it academic. +

+

+ This directive is deliberately vague to + accommodate creative humor, insight, and exploration.
+ Disruptive or irrelevant material, however, + will be subject to removal.
+ Just keep it academic, and we'll all be better off.
+

+
+
+ + + + +
+

FinalsClub in the Press

+
+ +

December 13, 2009

+

Plenty of Harvard graduates have traded on the fame and prestige of their alma mater, but few have done so the way Andrew Magliozzi has. The year he graduated, 2005, he started a tutoring company located steps from Harvard Yard, with a name, Veritas, that is the motto of his storied alma mater.

+

Then, two years ago, Magliozzi started up a side project called Finalsclub.org.

+

+ Read more ... +

+
+
+
+ +

Wednesday, February 18, 2009

+

A rapidly growing course preparatory Web site, FinalsClub.org, is moving forward with a plan to expand its site in spite of controversy over the legality of the venture.

+

The Web site, which allows students to share notes, create study groups, and blog about lectures and sections, recently hired 10 Harvard College students to serve as BETA testers for the site.

+

+ Read more ... +

+
+
+
+ +

September 27th, 2009

+

Computer Science professor and former Dean of Harvard, Harry Lewis, embraces FinalsClub's work and its guiding principle of open education. Even as Harvard University has not been wholly sympathetic to the FinalsClub mission, invoking the Copyright Act of 1976, assuming a similar position to other major institutions such as University of Texas, Lewis supports working towards the proverbial "temple of the free exchange of ideas." A course he taught in the Harvard Extension School was also shared freely online.

+

+ Read more ... +

+
+
+ + + + +
+

Page Not Found

+ Sorry, there is no content for this page. +
+ + + + +
+ + + + + +
+

+ This work is licensed under a + Creative Commons Attribution-ShareAlike 3.0 + United States License +

+

+ Creative Commons License + Real Time Web Analytics +

+
+ + + + + + diff --git a/public/index-joe.html b/public/index-joe.html new file mode 100644 index 0000000..17d9028 --- /dev/null +++ b/public/index-joe.html @@ -0,0 +1,371 @@ + + + + + + FinalsClub.org + + + + + + + + + + + + + + + + +
+
+
 
+
+ +
 
+
+ +
+ +
+ +
+
+
+

+ Welcome to FinalsClub.org, a 501(c)(3) non-profit + open education project dedicated to helping college + students collaborate, learn, and share their + knowledge freely online. +

+

+ Please create an account with your school email address + to try our tools or browse our course archive to learn + something new. + Thank you for helping us improve access to education, + one lecture at a time. +

+

+
Learn something >>
+

+ +
+
+
+ +
+

Universities

+
+
__name__
+
__description__
+
+
+ +
+

Courses for

+
+
__department__
+ +
+
+ +
+
+

Lectures for Course __number__ : __name__

+ Subject: __subject__
+ Department: __department__
+
+
+ Instructor: __name__ (__email__)
+
+
+
+ __name__
+ Created: __date__
+
+
+
+ +
+

Notepads

+
+
+ __name__ +
+
+
+ +
+

Archived Subjects

+

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

+ +
+ +
+

Archived Courses

+ +
+ +
+

Archived Notes

+ +
+ +
+
+

__topic__

+
__text__
+
__err__
+
+
+ +
+

Create an Account

+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+   +
+
+ +
+
+
+
+
+ +
+

Login

+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
  +
+
+ + + Forgot password? + +
+
+
+
  +
+ +
+
+
+
+ +
+
+

Code of Conduct

+

+ Keep it academic. +

+

+ This directive is deliberately vague to + accommodate creative humor, insight, and exploration.
+ Disruptive or irrelevant material, however, + will be subject to removal.
+ Just keep it academic, and we'll all be better off.
+

+
+
+ +
+

FinalsClub in the Press

+
+ +

December 13, 2009

+

Plenty of Harvard graduates have traded on the fame and prestige of their alma mater, but few have done so the way Andrew Magliozzi has. The year he graduated, 2005, he started a tutoring company located steps from Harvard Yard, with a name, Veritas, that is the motto of his storied alma mater.

+

Then, two years ago, Magliozzi started up a side project called Finalsclub.org.

+

+ Read more ... +

+
+
+
+ +

Wednesday, February 18, 2009

+

A rapidly growing course preparatory Web site, FinalsClub.org, is moving forward with a plan to expand its site in spite of controversy over the legality of the venture.

+

The Web site, which allows students to share notes, create study groups, and blog about lectures and sections, recently hired 10 Harvard College students to serve as BETA testers for the site.

+

+ Read more ... +

+
+
+
+ +

September 27th, 2009

+

Computer Science professor and former Dean of Harvard, Harry Lewis, embraces FinalsClub's work and its guiding principle of open education. Even as Harvard University has not been wholly sympathetic to the FinalsClub mission, invoking the Copyright Act of 1976, assuming a similar position to other major institutions such as University of Texas, Lewis supports working towards the proverbial "temple of the free exchange of ideas." A course he taught in the Harvard Extension School was also shared freely online.

+

+ Read more ... +

+
+
+
+

Page Not Found

+ Sorry, there is no content for this page. +
+
+ + +
+

+ This work is licensed under a + Creative Commons Attribution-ShareAlike 3.0 + United States License +

+

+ Creative Commons License + Real Time Web Analytics +

+
+ + + diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 17d9028..0000000 --- a/public/index.html +++ /dev/null @@ -1,371 +0,0 @@ - - - - - - FinalsClub.org - - - - - - - - - - - - - - - - -
-
-
 
-
- -
 
-
- -
- -
- -
-
-
-

- Welcome to FinalsClub.org, a 501(c)(3) non-profit - open education project dedicated to helping college - students collaborate, learn, and share their - knowledge freely online. -

-

- Please create an account with your school email address - to try our tools or browse our course archive to learn - something new. - Thank you for helping us improve access to education, - one lecture at a time. -

-

-
Learn something >>
-

- -
-
-
- -
-

Universities

-
-
__name__
-
__description__
-
-
- -
-

Courses for

-
-
__department__
- -
-
- -
-
-

Lectures for Course __number__ : __name__

- Subject: __subject__
- Department: __department__
-
-
- Instructor: __name__ (__email__)
-
-
-
- __name__
- Created: __date__
-
-
-
- -
-

Notepads

-
-
- __name__ -
-
-
- -
-

Archived Subjects

-

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

- -
- -
-

Archived Courses

- -
- -
-

Archived Notes

- -
- -
-
-

__topic__

-
__text__
-
__err__
-
-
- -
-

Create an Account

-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
-   -
-
- -
-
-
-
-
- -
-

Login

-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
  -
-
- - - Forgot password? - -
-
-
-
  -
- -
-
-
-
- -
-
-

Code of Conduct

-

- Keep it academic. -

-

- This directive is deliberately vague to - accommodate creative humor, insight, and exploration.
- Disruptive or irrelevant material, however, - will be subject to removal.
- Just keep it academic, and we'll all be better off.
-

-
-
- -
-

FinalsClub in the Press

-
- -

December 13, 2009

-

Plenty of Harvard graduates have traded on the fame and prestige of their alma mater, but few have done so the way Andrew Magliozzi has. The year he graduated, 2005, he started a tutoring company located steps from Harvard Yard, with a name, Veritas, that is the motto of his storied alma mater.

-

Then, two years ago, Magliozzi started up a side project called Finalsclub.org.

-

- Read more ... -

-
-
-
- -

Wednesday, February 18, 2009

-

A rapidly growing course preparatory Web site, FinalsClub.org, is moving forward with a plan to expand its site in spite of controversy over the legality of the venture.

-

The Web site, which allows students to share notes, create study groups, and blog about lectures and sections, recently hired 10 Harvard College students to serve as BETA testers for the site.

-

- Read more ... -

-
-
-
- -

September 27th, 2009

-

Computer Science professor and former Dean of Harvard, Harry Lewis, embraces FinalsClub's work and its guiding principle of open education. Even as Harvard University has not been wholly sympathetic to the FinalsClub mission, invoking the Copyright Act of 1976, assuming a similar position to other major institutions such as University of Texas, Lewis supports working towards the proverbial "temple of the free exchange of ideas." A course he taught in the Harvard Extension School was also shared freely online.

-

- Read more ... -

-
-
-
-

Page Not Found

- Sorry, there is no content for this page. -
-
- - -
-

- This work is licensed under a - Creative Commons Attribution-ShareAlike 3.0 - United States License -

-

- Creative Commons License - Real Time Web Analytics -

-
- - - diff --git a/public/index2.html b/public/index2.html deleted file mode 100644 index 1a5f79a..0000000 --- a/public/index2.html +++ /dev/null @@ -1,411 +0,0 @@ - - - - - FinalsClub.org - - - - - - - - - - - - - - - - - - - -
-
-
 
-
- -
 
-
- -
- - - -
- - - - - -
-
-
-

- Welcome to FinalsClub.org, a 501(c)(3) non-profit - open education project dedicated to helping college - students collaborate, learn, and share their - knowledge freely online. -

-

- Please create an account with your school email address - to try our tools or browse our course archive to learn - something new. - Thank you for helping us improve access to education, - one lecture at a time. -

-

-
Learn something >>
-

- -
-
- -
- - - -
-

Universities

-
-
__name__
-
__description__
-
-
- - - -
-

Courses for

-
-
__department__
- -
-
- - - -
-
-

Lectures for Course __number__ : __name__

- Subject: __subject__
- Department: __department__
-
-
- Instructor: __name__ (__email__)
-
-
-
- __name__
- Created: __date__
-
-
-
- - - -
-

Notepads

-
-
- __name__ -
-
-
- - - -
-

Archived Subjects

-

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

- - -
- - - -
-

Archived Courses

- - -
- - - -
-

Archived Notes

- -
- - - -
-
-

__topic__

-
__text__
-
-
- - - -
-

Create an Account

-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
-   -
-
- -
-
-
-
-
- - - -
-

Login

-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
  -
-
- - - Forgot password? - -
-
-
-
  -
- -
-
-
-
- - -
-
-

Code of Conduct

-

- Keep it academic. -

-

- This directive is deliberately vague to - accommodate creative humor, insight, and exploration.
- Disruptive or irrelevant material, however, - will be subject to removal.
- Just keep it academic, and we'll all be better off.
-

-
-
- - - - -
-

FinalsClub in the Press

-
- -

December 13, 2009

-

Plenty of Harvard graduates have traded on the fame and prestige of their alma mater, but few have done so the way Andrew Magliozzi has. The year he graduated, 2005, he started a tutoring company located steps from Harvard Yard, with a name, Veritas, that is the motto of his storied alma mater.

-

Then, two years ago, Magliozzi started up a side project called Finalsclub.org.

-

- Read more ... -

-
-
-
- -

Wednesday, February 18, 2009

-

A rapidly growing course preparatory Web site, FinalsClub.org, is moving forward with a plan to expand its site in spite of controversy over the legality of the venture.

-

The Web site, which allows students to share notes, create study groups, and blog about lectures and sections, recently hired 10 Harvard College students to serve as BETA testers for the site.

-

- Read more ... -

-
-
-
- -

September 27th, 2009

-

Computer Science professor and former Dean of Harvard, Harry Lewis, embraces FinalsClub's work and its guiding principle of open education. Even as Harvard University has not been wholly sympathetic to the FinalsClub mission, invoking the Copyright Act of 1976, assuming a similar position to other major institutions such as University of Texas, Lewis supports working towards the proverbial "temple of the free exchange of ideas." A course he taught in the Harvard Extension School was also shared freely online.

-

- Read more ... -

-
-
- - - - -
-

Page Not Found

- Sorry, there is no content for this page. -
- - - - -
- - - - - -
-

- This work is licensed under a - Creative Commons Attribution-ShareAlike 3.0 - United States License -

-

- Creative Commons License - Real Time Web Analytics -

-
- - - - - - diff --git a/public/javascripts/main-jacob.js b/public/javascripts/main-jacob.js new file mode 100644 index 0000000..41b9f0f --- /dev/null +++ b/public/javascripts/main-jacob.js @@ -0,0 +1,376 @@ + +/* + +This is the core logic for the main page. +It implements most page transitions by showing and hiding DIV elements +in the page with javascript+jquery + +*/ + + +/* Convert a JSON string to an object, or null if unparseable */ +function j2o(json) { try { return JSON.parse(json); } catch(e) { return null; } } + +/* Convert an object to a JSON string (just easier to type than "JSON.stringify" */ +function o2j(obj) { return JSON.stringify(obj); } + + + +function showHome(cb) { + cb("home"); +} + + + +// go to the page that lists the schools +function showSchools(response, cb) { + + var path = window.location.pathname; + + ProtoDiv.reset("PROTO_school"); + + + var schools = [] + if(typeof response == 'object') { + schools = response.schools + } + + ProtoDiv.replicate("PROTO_school", schools); + + cb("schools"); + +} + + + +// go to the page that lists the courses for a specific school +function showCourses(response, cb) { + + var path = window.location.pathname; + + + ProtoDiv.reset("PROTO_course"); + + var courses = [] + if(typeof response == 'object') { + var school = response.school + $("#school_name").html(school.name); + courses = school.courses + } + + ProtoDiv.replicate("PROTO_course", courses); + + cb("courses") +} + + + + +// go to the page that lists the lectures for a specific course +function showLectures(response, cb) { + + var path = window.location.pathname; + + + ProtoDiv.reset("PROTO_lecture"); + + ProtoDiv.reset("PROTO_lectures_head") + ProtoDiv.reset("PROTO_lectures_instructor") + ProtoDiv.reset("PROTO_lecture") + + if(typeof response == 'object') { + + var course = response.course + if(course) + ProtoDiv.replicate("PROTO_lectures_head", [course]) + + var instructor = response.instructor + if(instructor) + ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]) + + var lectures = response.lectures + if(lectures) + ProtoDiv.replicate("PROTO_lecture", lectures); + + } + + cb("lectures") +} + + + +// go to the page that lists the note taking sessions for a specific lecture +function showNotes(response, cb) { + + var path = window.location.pathname; + + + ProtoDiv.reset("PROTO_note"); + + if(typeof response == 'object') { + + var course = response.course + //if(course) + // ProtoDiv.replicate("PROTO_lectures_head", [course]) + + var instructor = response.instructor + //if(instructor) + // ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]) + + var lecture = response.lecture + //if(lecture) + // ProtoDiv.replicate("PROTO_lecture", lectures); + + var notes = response.notes + if(notes) + ProtoDiv.replicate("PROTO_note", notes); + + } + + cb("notes") +} + + +// go to the page that lists the archived subject names +function showArchiveSubjects(response, cb) { + + var path = window.location.pathname; + + ProtoDiv.reset("PROTO_archive_subject") + + var subjects = response.subjects + + ProtoDiv.replicate("PROTO_archive_subject", subjects) + + cb("archive_subjects") +} + + + +function showArchiveCourses(response, cb) { + + var path = window.location.pathname; + + + ProtoDiv.reset("PROTO_archive_course") + + var courses = response.courses + + ProtoDiv.replicate("PROTO_archive_course", courses) + + cb("archive_courses") +} + + + +function showArchiveNotes(response, cb) { + + var path = window.location.pathname; + + + ProtoDiv.reset("PROTO_archive_note") + + var notes = response.notes + $.each(notes, function(i, note) { + if(!note.topic) + note.topic = note._id//note.text.substr(0, 15)+" ..." + }) + + ProtoDiv.replicate("PROTO_archive_note", notes) + + cb("archive_notes") +} + + + +function showArchiveNote(response, cb) { + + var path = window.location.pathname; + + + ProtoDiv.reset("PROTO_archive_note_display") + + var note = response.note +note = { text: "Hi Mom!", topic: "21st Century Greetings" } + if(!note.topic) + note.topic = note.text.substr(0, 15)+" ..." + + ProtoDiv.replicate("PROTO_archive_note_display", note) + + cb("archive_note_display") +} + + + +// go to the account registration page +function showRegister(response, cb) { + // xxx clear fields? + // xxx change FORM to use AJAX + cb("register"); +} + + +function showLogin(response, cb) { + cb("login"); +} + + + + +// go to the press articles page +function showPress(response, cb) { + cb("press"); +} + + +// go to the "code of conduct" page +function showConduct(response, cb) { + cb("conduct"); +} + + + + +var pageVectors = [ + { regex: /^\/(index.html)?$/, func: showHome }, + { regex: /^\/schools/, func: showSchools }, + { 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: /^\/archive\/note\/([0-9]+)/, func: showArchiveNote }, + { regex: /^\/login/, func: showLogin }, + { regex: /^\/register/, func: showRegister }, + { regex: /^\/press/, func: showPress }, + { regex: /^\/conduct/, func: showConduct }, +]; + +var testVectors = { + schools: showSchools, + school: showCourses, + course: showLectures, + lecture: showNotes, + archive: showArchiveSubjects, + archivesubject: showArchiveCourses, + archivecourse: showArchiveNotes, + archivenote: showArchiveNote, + login: showLogin, + press: showPress, + conduct: showConduct +} + +/* Do and show the appropriate thing, based on the pages current URL */ +function showPage(y) { + + var path = document.location.pathname + + var mainSlug = path.match(/((?:[a-z][a-z]+))/) ? path.match(/((?:[a-z][a-z]+))/)[1].toLowerCase() : ''; + if (mainSlug === 'archive') { + var archiveSlugs = path.match(/((?:[a-z][a-z]+))\/((?:[a-z][a-z0-9_]*))/); + if (archiveSlugs) { + mainSlug = mainSlug + archiveSlugs[2]; + } + } + + $(".page").hide(); //(100); // hide all pseudo pages + + if (testVectors[mainSlug]) { + return $.get(path, { cache: false }, function(response) { + if (response.status === 'error') { + console.log(response.message) + $("#pg_notfound").fadeIn(100); + window.scroll(0, 0) + return; + } + testVectors[mainSlug](response, function(pageId) { + $("#pg_"+pageId).fadeIn(100); + window.scroll(0, y) + }) + }); + } else if (path === '/') { + return showHome(function(pageId) { + $("#pg_"+pageId).fadeIn(100); + window.scroll(0, y) + }) + } + + $("#pg_notfound").fadeIn(100); + window.scroll(0, 0) + /* + for(var i = 0; i < pageVectors.length; i++) { + var vector = pageVectors[i] + var matches = path.match(vector.regex) + if(matches) { + vector.func(function(pageId) { + + $("#pg_"+pageId).fadeIn(100); + + window.scroll(0, y) + + }) + break + } + } + + + if(i == pageVectors.length) { + } + // scroll to top of page (as if we'd done a real page fetch) + /*$('html, body').animate({ + scrollTop: $("#topofcontent").offset().top + }, 100);*/ + +} + + + + +/* Simulates a page load. + 'path' is something like "/schools", etc. + A page fetch doesn't really happen. + Based on what path looks like, an appropriate DIV is shown, and action taken +*/ +var topQueue = [0] +function goPage(path) { + var y = 0 + window.pageYOffset + topQueue.push(y) + history.pushState({}, path, path); + showPage(0); +} + + +/* Simulates a "back" browser navigation. */ +function goBack(event) { + var y = topQueue.pop() + showPage( y ); +} + + + window.onpopstate = goBack + + $('a[href^=/]').live('click', function(e) { + var path = e.target.pathname || '/'; + var checkNote = path.match(/((?:[a-z][a-z]+))/); + if (checkNote && checkNote[1] == 'note') { + return true; + } else { + goPage(path) + return false; + } + }) +$(document).ready(function() { + + // This code executes after the page has been fully loaded + + + // xxx older FF browsers don't fire a page load/reload - deal with it somehow. + // showPage( 0 ); // needed for some older browsers, redundant for chrome + +}) + + + + + diff --git a/public/javascripts/main-joe.js b/public/javascripts/main-joe.js new file mode 100644 index 0000000..e81bff2 --- /dev/null +++ b/public/javascripts/main-joe.js @@ -0,0 +1,246 @@ +/* +This is the core logic for the main page. +It implements most page transitions by showing and hiding DIV elements +in the page with javascript+jquery +*/ + +/* Convert a JSON string to an object, or null if unparseable */ +function j2o(json) { try { return JSON.parse(json); } catch(e) { return null; } } + +/* Convert an object to a JSON string (just easier to type than "JSON.stringify" */ +function o2j(obj) { return JSON.stringify(obj); } + +function showHome(matches, cb) { + cb("home"); +} + +// go to the page that lists the schools +function showSchools(matches, cb) { + ProtoDiv.reset("PROTO_school"); + $.get("/schools", { cache: false }, function(response) { + var schools = []; + if(typeof response == 'object') { + schools = response.schools; + } + ProtoDiv.replicate("PROTO_school", schools); + cb("schools"); + }); +} + +// go to the page that lists the courses for a specific school +function showCourses(matches, cb) { + var schoolId = matches[1]; + ProtoDiv.reset("PROTO_course"); + $.get("/school/"+schoolId, { cache: false }, function(response) { + var courses = []; + if(typeof response == 'object') { + var school = response.school; + $("#school_name").html(school.name); + courses = school.courses; + } + ProtoDiv.replicate("PROTO_course", courses); + cb("courses"); + }); +} + +// go to the page that lists the lectures for a specific course +function showLectures(matches, cb) { + var courseId = matches[1]; + ProtoDiv.reset("PROTO_lecture"); + $.get("/course/"+courseId, { cache: false }, function(response) { + ProtoDiv.reset("PROTO_lectures_head"); + ProtoDiv.reset("PROTO_lectures_instructor"); + ProtoDiv.reset("PROTO_lecture"); + if(typeof response == 'object') { + var course = response.course; + if(course) + ProtoDiv.replicate("PROTO_lectures_head", [course]); + var instructor = response.instructor; + if(instructor) + ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]); + var lectures = response.lectures; + if(lectures) + ProtoDiv.replicate("PROTO_lecture", lectures); + } + cb("lectures"); + }); +} + +// go to the page that lists the note taking sessions for a specific lecture +function showNotes(matches, cb) { + var lectureId = matches[1]; + ProtoDiv.reset("PROTO_note"); + $.get("/lecture/"+lectureId, { cache: false }, function(response) { + if(typeof response == 'object') { + var course = response.course; + //if(course) + // ProtoDiv.replicate("PROTO_lectures_head", [course]) + var instructor = response.instructor; + //if(instructor) + // ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]) + var lecture = response.lecture; + //if(lecture) + // ProtoDiv.replicate("PROTO_lecture", lectures); + var notes = response.notes; + if(notes) + ProtoDiv.replicate("PROTO_note", notes); + } + cb("notes"); + }); +} + +// go to the page that lists the archived subject names +function showArchiveSubjects(matches, cb) { + ProtoDiv.reset("PROTO_archive_subject"); + $.get("/archive", { cache: false }, function(response) { + 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, { cache: false }, 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, { cache: false }, 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"); +} + + + +function showArchiveNote(matches, cb) { + var noteId = matches[1]; + ProtoDiv.reset("PROTO_archive_note_display"); + $.get("/archive/note/"+noteId, { cache: false }, function(response) { + var note = response.note; +//note = { text: "Hi Mom!", topic: "21st Century Greetings" } +// note.text = note.text || "" + if(!note.topic) + note.topic = note.text.substr(0, 15)+" ..."; +// if(note.err) { +// note.topic = note.message +// note.err = note.err.stack +// } +// + ProtoDiv.replicate("PROTO_archive_note_display", note); + }) + cb("archive_note_display"); +} + +// go to the account registration page +function showRegister(matches, cb) { + // xxx clear fields? + // xxx change FORM to use AJAX + cb("register"); +} + +function showLogin(matches, cb) { + cb("login"); +} + +// go to the press articles page +function showPress(matches, cb) { + cb("press"); +} + +// go to the "code of conduct" page +function showConduct(matches, cb) { + cb("conduct"); +} + +var pageVectors = [ + { regex: /^\/(index.html)?$/, func: showHome }, + { regex: /^\/schools/, func: showSchools }, + { 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: /^\/archive\/note\/([a-f0-9]{24})/, func: showArchiveNote }, + { regex: /^\/login/, func: showLogin }, + { regex: /^\/register/, func: showRegister }, + { regex: /^\/press/, func: showPress }, + { regex: /^\/conduct/, func: showConduct } +]; + +/* Do and show the appropriate thing, based on the pages current URL */ +function showPage(y) { + var path = document.location.pathname; + $(".page").hide(); //(100); // hide all pseudo pages + for(var i = 0; i < pageVectors.length; i++) { + var vector = pageVectors[i]; + var matches = path.match(vector.regex); + if(matches) { + vector.func(matches, function(pageId) { + $("#pg_"+pageId).fadeIn(100); + window.scroll(0, y); + }) + break; + } + } + if(i == pageVectors.length) { + $("#pg_notfound").fadeIn(100); + window.scroll(0, 0); + } + // scroll to top of page (as if we'd done a real page fetch) + /*$('html, body').animate({ + scrollTop: $("#topofcontent").offset().top + }, 100);*/ +} + +/* Simulates a page load. + 'path' is something like "/schools", etc. + A page fetch doesn't really happen. + Based on what path looks like, an appropriate DIV is shown, and action taken +*/ +var topQueue = [0]; +function goPage(path) { + if(history.pushState !== undefined) { + topQueue.push(window.pageYOffset); + history.pushState({}, path, path); + showPage(0); + } + else { + document.location = path; + } +} + +/* Simulates a "back" browser navigation. */ +var popped = false; +function goBack(event) { + popped = true; + showPage( topQueue.pop() ); +} + +$(document).ready(function() { + // This code executes after the page has been fully loaded + $(".proto").css("display", "none"); // make all the prototypes invisible + //$("body").get(0).onunload = function() { } // fires when leaving the page proper + ProtoDiv.each = function(e) { $(e).show() }; + window.onpopstate = goBack; + /*setTimeout(function() { + if(!popped) + showPage(0) + }, 2000);*/ + // xxx older FF browsers don't fire a page load/reload - deal with it somehow. + // showPage( 0 ); // needed for some older browsers, redundant for chrome +}) + diff --git a/public/javascripts/main.js b/public/javascripts/main.js deleted file mode 100644 index e81bff2..0000000 --- a/public/javascripts/main.js +++ /dev/null @@ -1,246 +0,0 @@ -/* -This is the core logic for the main page. -It implements most page transitions by showing and hiding DIV elements -in the page with javascript+jquery -*/ - -/* Convert a JSON string to an object, or null if unparseable */ -function j2o(json) { try { return JSON.parse(json); } catch(e) { return null; } } - -/* Convert an object to a JSON string (just easier to type than "JSON.stringify" */ -function o2j(obj) { return JSON.stringify(obj); } - -function showHome(matches, cb) { - cb("home"); -} - -// go to the page that lists the schools -function showSchools(matches, cb) { - ProtoDiv.reset("PROTO_school"); - $.get("/schools", { cache: false }, function(response) { - var schools = []; - if(typeof response == 'object') { - schools = response.schools; - } - ProtoDiv.replicate("PROTO_school", schools); - cb("schools"); - }); -} - -// go to the page that lists the courses for a specific school -function showCourses(matches, cb) { - var schoolId = matches[1]; - ProtoDiv.reset("PROTO_course"); - $.get("/school/"+schoolId, { cache: false }, function(response) { - var courses = []; - if(typeof response == 'object') { - var school = response.school; - $("#school_name").html(school.name); - courses = school.courses; - } - ProtoDiv.replicate("PROTO_course", courses); - cb("courses"); - }); -} - -// go to the page that lists the lectures for a specific course -function showLectures(matches, cb) { - var courseId = matches[1]; - ProtoDiv.reset("PROTO_lecture"); - $.get("/course/"+courseId, { cache: false }, function(response) { - ProtoDiv.reset("PROTO_lectures_head"); - ProtoDiv.reset("PROTO_lectures_instructor"); - ProtoDiv.reset("PROTO_lecture"); - if(typeof response == 'object') { - var course = response.course; - if(course) - ProtoDiv.replicate("PROTO_lectures_head", [course]); - var instructor = response.instructor; - if(instructor) - ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]); - var lectures = response.lectures; - if(lectures) - ProtoDiv.replicate("PROTO_lecture", lectures); - } - cb("lectures"); - }); -} - -// go to the page that lists the note taking sessions for a specific lecture -function showNotes(matches, cb) { - var lectureId = matches[1]; - ProtoDiv.reset("PROTO_note"); - $.get("/lecture/"+lectureId, { cache: false }, function(response) { - if(typeof response == 'object') { - var course = response.course; - //if(course) - // ProtoDiv.replicate("PROTO_lectures_head", [course]) - var instructor = response.instructor; - //if(instructor) - // ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]) - var lecture = response.lecture; - //if(lecture) - // ProtoDiv.replicate("PROTO_lecture", lectures); - var notes = response.notes; - if(notes) - ProtoDiv.replicate("PROTO_note", notes); - } - cb("notes"); - }); -} - -// go to the page that lists the archived subject names -function showArchiveSubjects(matches, cb) { - ProtoDiv.reset("PROTO_archive_subject"); - $.get("/archive", { cache: false }, function(response) { - 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, { cache: false }, 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, { cache: false }, 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"); -} - - - -function showArchiveNote(matches, cb) { - var noteId = matches[1]; - ProtoDiv.reset("PROTO_archive_note_display"); - $.get("/archive/note/"+noteId, { cache: false }, function(response) { - var note = response.note; -//note = { text: "Hi Mom!", topic: "21st Century Greetings" } -// note.text = note.text || "" - if(!note.topic) - note.topic = note.text.substr(0, 15)+" ..."; -// if(note.err) { -// note.topic = note.message -// note.err = note.err.stack -// } -// - ProtoDiv.replicate("PROTO_archive_note_display", note); - }) - cb("archive_note_display"); -} - -// go to the account registration page -function showRegister(matches, cb) { - // xxx clear fields? - // xxx change FORM to use AJAX - cb("register"); -} - -function showLogin(matches, cb) { - cb("login"); -} - -// go to the press articles page -function showPress(matches, cb) { - cb("press"); -} - -// go to the "code of conduct" page -function showConduct(matches, cb) { - cb("conduct"); -} - -var pageVectors = [ - { regex: /^\/(index.html)?$/, func: showHome }, - { regex: /^\/schools/, func: showSchools }, - { 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: /^\/archive\/note\/([a-f0-9]{24})/, func: showArchiveNote }, - { regex: /^\/login/, func: showLogin }, - { regex: /^\/register/, func: showRegister }, - { regex: /^\/press/, func: showPress }, - { regex: /^\/conduct/, func: showConduct } -]; - -/* Do and show the appropriate thing, based on the pages current URL */ -function showPage(y) { - var path = document.location.pathname; - $(".page").hide(); //(100); // hide all pseudo pages - for(var i = 0; i < pageVectors.length; i++) { - var vector = pageVectors[i]; - var matches = path.match(vector.regex); - if(matches) { - vector.func(matches, function(pageId) { - $("#pg_"+pageId).fadeIn(100); - window.scroll(0, y); - }) - break; - } - } - if(i == pageVectors.length) { - $("#pg_notfound").fadeIn(100); - window.scroll(0, 0); - } - // scroll to top of page (as if we'd done a real page fetch) - /*$('html, body').animate({ - scrollTop: $("#topofcontent").offset().top - }, 100);*/ -} - -/* Simulates a page load. - 'path' is something like "/schools", etc. - A page fetch doesn't really happen. - Based on what path looks like, an appropriate DIV is shown, and action taken -*/ -var topQueue = [0]; -function goPage(path) { - if(history.pushState !== undefined) { - topQueue.push(window.pageYOffset); - history.pushState({}, path, path); - showPage(0); - } - else { - document.location = path; - } -} - -/* Simulates a "back" browser navigation. */ -var popped = false; -function goBack(event) { - popped = true; - showPage( topQueue.pop() ); -} - -$(document).ready(function() { - // This code executes after the page has been fully loaded - $(".proto").css("display", "none"); // make all the prototypes invisible - //$("body").get(0).onunload = function() { } // fires when leaving the page proper - ProtoDiv.each = function(e) { $(e).show() }; - window.onpopstate = goBack; - /*setTimeout(function() { - if(!popped) - showPage(0) - }, 2000);*/ - // xxx older FF browsers don't fire a page load/reload - deal with it somehow. - // showPage( 0 ); // needed for some older browsers, redundant for chrome -}) - diff --git a/public/javascripts/main2.js b/public/javascripts/main2.js deleted file mode 100644 index 41b9f0f..0000000 --- a/public/javascripts/main2.js +++ /dev/null @@ -1,376 +0,0 @@ - -/* - -This is the core logic for the main page. -It implements most page transitions by showing and hiding DIV elements -in the page with javascript+jquery - -*/ - - -/* Convert a JSON string to an object, or null if unparseable */ -function j2o(json) { try { return JSON.parse(json); } catch(e) { return null; } } - -/* Convert an object to a JSON string (just easier to type than "JSON.stringify" */ -function o2j(obj) { return JSON.stringify(obj); } - - - -function showHome(cb) { - cb("home"); -} - - - -// go to the page that lists the schools -function showSchools(response, cb) { - - var path = window.location.pathname; - - ProtoDiv.reset("PROTO_school"); - - - var schools = [] - if(typeof response == 'object') { - schools = response.schools - } - - ProtoDiv.replicate("PROTO_school", schools); - - cb("schools"); - -} - - - -// go to the page that lists the courses for a specific school -function showCourses(response, cb) { - - var path = window.location.pathname; - - - ProtoDiv.reset("PROTO_course"); - - var courses = [] - if(typeof response == 'object') { - var school = response.school - $("#school_name").html(school.name); - courses = school.courses - } - - ProtoDiv.replicate("PROTO_course", courses); - - cb("courses") -} - - - - -// go to the page that lists the lectures for a specific course -function showLectures(response, cb) { - - var path = window.location.pathname; - - - ProtoDiv.reset("PROTO_lecture"); - - ProtoDiv.reset("PROTO_lectures_head") - ProtoDiv.reset("PROTO_lectures_instructor") - ProtoDiv.reset("PROTO_lecture") - - if(typeof response == 'object') { - - var course = response.course - if(course) - ProtoDiv.replicate("PROTO_lectures_head", [course]) - - var instructor = response.instructor - if(instructor) - ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]) - - var lectures = response.lectures - if(lectures) - ProtoDiv.replicate("PROTO_lecture", lectures); - - } - - cb("lectures") -} - - - -// go to the page that lists the note taking sessions for a specific lecture -function showNotes(response, cb) { - - var path = window.location.pathname; - - - ProtoDiv.reset("PROTO_note"); - - if(typeof response == 'object') { - - var course = response.course - //if(course) - // ProtoDiv.replicate("PROTO_lectures_head", [course]) - - var instructor = response.instructor - //if(instructor) - // ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]) - - var lecture = response.lecture - //if(lecture) - // ProtoDiv.replicate("PROTO_lecture", lectures); - - var notes = response.notes - if(notes) - ProtoDiv.replicate("PROTO_note", notes); - - } - - cb("notes") -} - - -// go to the page that lists the archived subject names -function showArchiveSubjects(response, cb) { - - var path = window.location.pathname; - - ProtoDiv.reset("PROTO_archive_subject") - - var subjects = response.subjects - - ProtoDiv.replicate("PROTO_archive_subject", subjects) - - cb("archive_subjects") -} - - - -function showArchiveCourses(response, cb) { - - var path = window.location.pathname; - - - ProtoDiv.reset("PROTO_archive_course") - - var courses = response.courses - - ProtoDiv.replicate("PROTO_archive_course", courses) - - cb("archive_courses") -} - - - -function showArchiveNotes(response, cb) { - - var path = window.location.pathname; - - - ProtoDiv.reset("PROTO_archive_note") - - var notes = response.notes - $.each(notes, function(i, note) { - if(!note.topic) - note.topic = note._id//note.text.substr(0, 15)+" ..." - }) - - ProtoDiv.replicate("PROTO_archive_note", notes) - - cb("archive_notes") -} - - - -function showArchiveNote(response, cb) { - - var path = window.location.pathname; - - - ProtoDiv.reset("PROTO_archive_note_display") - - var note = response.note -note = { text: "Hi Mom!", topic: "21st Century Greetings" } - if(!note.topic) - note.topic = note.text.substr(0, 15)+" ..." - - ProtoDiv.replicate("PROTO_archive_note_display", note) - - cb("archive_note_display") -} - - - -// go to the account registration page -function showRegister(response, cb) { - // xxx clear fields? - // xxx change FORM to use AJAX - cb("register"); -} - - -function showLogin(response, cb) { - cb("login"); -} - - - - -// go to the press articles page -function showPress(response, cb) { - cb("press"); -} - - -// go to the "code of conduct" page -function showConduct(response, cb) { - cb("conduct"); -} - - - - -var pageVectors = [ - { regex: /^\/(index.html)?$/, func: showHome }, - { regex: /^\/schools/, func: showSchools }, - { 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: /^\/archive\/note\/([0-9]+)/, func: showArchiveNote }, - { regex: /^\/login/, func: showLogin }, - { regex: /^\/register/, func: showRegister }, - { regex: /^\/press/, func: showPress }, - { regex: /^\/conduct/, func: showConduct }, -]; - -var testVectors = { - schools: showSchools, - school: showCourses, - course: showLectures, - lecture: showNotes, - archive: showArchiveSubjects, - archivesubject: showArchiveCourses, - archivecourse: showArchiveNotes, - archivenote: showArchiveNote, - login: showLogin, - press: showPress, - conduct: showConduct -} - -/* Do and show the appropriate thing, based on the pages current URL */ -function showPage(y) { - - var path = document.location.pathname - - var mainSlug = path.match(/((?:[a-z][a-z]+))/) ? path.match(/((?:[a-z][a-z]+))/)[1].toLowerCase() : ''; - if (mainSlug === 'archive') { - var archiveSlugs = path.match(/((?:[a-z][a-z]+))\/((?:[a-z][a-z0-9_]*))/); - if (archiveSlugs) { - mainSlug = mainSlug + archiveSlugs[2]; - } - } - - $(".page").hide(); //(100); // hide all pseudo pages - - if (testVectors[mainSlug]) { - return $.get(path, { cache: false }, function(response) { - if (response.status === 'error') { - console.log(response.message) - $("#pg_notfound").fadeIn(100); - window.scroll(0, 0) - return; - } - testVectors[mainSlug](response, function(pageId) { - $("#pg_"+pageId).fadeIn(100); - window.scroll(0, y) - }) - }); - } else if (path === '/') { - return showHome(function(pageId) { - $("#pg_"+pageId).fadeIn(100); - window.scroll(0, y) - }) - } - - $("#pg_notfound").fadeIn(100); - window.scroll(0, 0) - /* - for(var i = 0; i < pageVectors.length; i++) { - var vector = pageVectors[i] - var matches = path.match(vector.regex) - if(matches) { - vector.func(function(pageId) { - - $("#pg_"+pageId).fadeIn(100); - - window.scroll(0, y) - - }) - break - } - } - - - if(i == pageVectors.length) { - } - // scroll to top of page (as if we'd done a real page fetch) - /*$('html, body').animate({ - scrollTop: $("#topofcontent").offset().top - }, 100);*/ - -} - - - - -/* Simulates a page load. - 'path' is something like "/schools", etc. - A page fetch doesn't really happen. - Based on what path looks like, an appropriate DIV is shown, and action taken -*/ -var topQueue = [0] -function goPage(path) { - var y = 0 + window.pageYOffset - topQueue.push(y) - history.pushState({}, path, path); - showPage(0); -} - - -/* Simulates a "back" browser navigation. */ -function goBack(event) { - var y = topQueue.pop() - showPage( y ); -} - - - window.onpopstate = goBack - - $('a[href^=/]').live('click', function(e) { - var path = e.target.pathname || '/'; - var checkNote = path.match(/((?:[a-z][a-z]+))/); - if (checkNote && checkNote[1] == 'note') { - return true; - } else { - goPage(path) - return false; - } - }) -$(document).ready(function() { - - // This code executes after the page has been fully loaded - - - // xxx older FF browsers don't fire a page load/reload - deal with it somehow. - // showPage( 0 ); // needed for some older browsers, redundant for chrome - -}) - - - - -