fix merge conflict
authorchapel <jacob.chapel@gmail.com>
Mon, 14 Nov 2011 23:44:11 +0000 (15:44 -0800)
committerchapel <jacob.chapel@gmail.com>
Mon, 14 Nov 2011 23:44:11 +0000 (15:44 -0800)
app.js
public/index.html
public/javascripts/main.js
public/javascripts/protodiv.js
public/stylesheets/fc2.css

diff --git a/app.js b/app.js
index bda679382400c0d60f4a1b1f0cd70a8f5ac849f3..c94efaed7bd56c8ec0324494f44fec7f8b692282 100644 (file)
--- a/app.js
+++ b/app.js
@@ -1633,6 +1633,7 @@ app.get( '/archive/course/:id', checkAjax, loadUser, loadOldCourse, function( re
 })
 
 app.get( '/archive/note/:id', checkAjax, loadUser, function( req, res ) {
+  console.log( "id="+req.params.id)
   ArchivedNote.findById(req.params.id, function(err, note) {
     if ( err || !note ) {
       sendJson(res,  {status: 'error', message: 'This is not a valid id for a note'} );
index 374cfbfa67252670c7a2584999af8e9e599abb55..17d90287d19926647d70aca78d43d49918c0837c 100644 (file)
@@ -1,11 +1,19 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html>
+       <!-- 
+                Currently tested with:
+                                               Mac             Windows
+                                        ______________________
+                       Chrome  |       15              -
+                       Safari  |       5               -
+                       FF              |       8               8
+                       IE              |       N/A             9
+       -->
 
        <head>
                <title>FinalsClub.org</title>
 
                <!-- XXX Some SEO here would be nice -->
-
                <link rel='stylesheet' href='/stylesheets/fc2.css'>
 
                <script type='text/javascript' src='/javascripts/jquery.min.js'></script>
@@ -19,9 +27,7 @@
                <meta name="icon" href="">
 
        </head>
-
        <body>
-
                <div class="masthead">
                        <div class="logbar">
                                <div class="loginstatus">&nbsp;</div>
 
                <div id="topofcontent"></div>
 
-
-
                <div class="content">
                        <style>
                                /* The is here is because it's related less to "styling" and more to UI "behavior" */
                                .page { display: none; }
                        </style>
-
-
-
-
                        <div class=page id=pg_home>
                                <div class="contenthome">
                                        <div class="tagline">
                                                <iframe src="http://player.vimeo.com/video/30647271?title=0&amp;byline=0&amp;portrait=0" width="350" height="250" frameborder="0" webkitallowfullscreen="webkitAllowFullScreen" allowfullscreen="allowFullScreen"></iframe>
                                        </div>
                                </div>
-                               
                        </div>
 
-
-
                        <div class=page id=pg_schools>
                                <h1>Universities</h1>
                                <div class="proto school" id=PROTO_school onclick="goPage('/school/___id__')">
@@ -94,8 +91,6 @@
                                </div>
                        </div>
 
-
-
                        <div class=page id=pg_courses>
                                <h1>Courses for <span id=school_name></span></h1>
                                <div class="proto course" id=PROTO_course>
                                </div>
                        </div>
 
-
-
                        <div class=page id=pg_lectures>
                                <div class="proto lectures_head" id=PROTO_lectures_head>
                                        <h1>Lectures for Course __number__ : __name__</h1>
                                </div>
                        </div>
 
-
-
                        <div class=page id=pg_notes>
                                <h1>Notepads </h1>
                                <div class="proto note" id=PROTO_note>
                                </div>
                        </div>
 
-
-
                        <div class=page id=pg_archive_subjects>
                                <h1>Archived Subjects</h1>
                                <p>
                                                <a href="javascript:goPage('/archive/subject/__id__')">__name__</a>
                                        </li>
                                </ul>
-
                        </div>
 
-
-
                        <div class=page id=pg_archive_courses>
                                <h1>Archived Courses</h1>
                                <ul>
                                                <a href="javascript:goPage('/archive/course/__id__')">__name__</a>
                                        </li>
                                </ul>
-
                        </div>
 
-
-
                        <div class=page id=pg_archive_notes>
                                <h1>Archived Notes</h1>
                                <ul>
                                </ul>
                        </div>
 
-
-
                        <div class=page id=pg_archive_note_display>
                                <div id=PROTO_archive_note_display>
                                        <h1>__topic__</h1>
                                        <div>__text__</div>
+<pre>__err__</pre>
                                </div>
                        </div>
 
-
-
                        <div class=page id=pg_register>
                                <h1>Create an Account</h1>
                                <form id="credentials" action="/register" method="POST">
                                </form>
                        </div>
 
-
-
                        <div class=page id=pg_login>
                                <h1>Login</h1>
                                <form id="credentials" action="/login" method="POST">
                                </form>
                        </div>
 
-
                        <div class=page id=pg_conduct>
                                <div class="conduct">
                                        <h1>Code of Conduct</h1>
                                </div>
                        </div>
 
-
-
-
                        <div class=page id=pg_press>
                                <h1>FinalsClub in the Press</h1>
                                <div class="press">
                                        </p>
                                </div>
                        </div>
-
-
-
-
                        <div class=page id=pg_notfound>
                                <h1>Page Not Found</h1>
                                Sorry, there is no content for this page.
                        </div>
-
-
-
-
                </div>
 
-
-
-
                <div class="footer">
                        <table>
                                <tr>
                        </p>
                </div>
 
-
-
-
        </body>
 </html>
index d06a72d8024549de962e7ba500940de6df27d21a..e81bff20d8a59a45daa1248a5abfeededcecdebb 100644 (file)
-
 /*
-
 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 = []
+               var schools = [];
                if(typeof response == 'object') {
-                       schools = response.schools
+                       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]
-
+       var schoolId = matches[1];
        ProtoDiv.reset("PROTO_course");
-
        $.get("/school/"+schoolId, { cache: false }, function(response) {
-
-               var courses = []
+               var courses = [];
                if(typeof response == 'object') {
-                       var school = response.school
+                       var school = response.school;
                        $("#school_name").html(school.name);
-                       courses = school.courses
+                       courses = school.courses;
                }
-
                ProtoDiv.replicate("PROTO_course", courses);
-
-               cb("courses")
-
+               cb("courses");
        });
 }
 
-
-
-
 // go to the page that lists the lectures for a specific course
 function showLectures(matches, cb) {
-
-       var courseId = matches[1]
-
+       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")
-
+               ProtoDiv.reset("PROTO_lectures_head");
+               ProtoDiv.reset("PROTO_lectures_instructor");
+               ProtoDiv.reset("PROTO_lecture");
                if(typeof response == 'object') {
-
-                       var course = response.course
+                       var course = response.course;
                        if(course)
-                               ProtoDiv.replicate("PROTO_lectures_head", [course])
-
-                       var instructor = response.instructor
+                               ProtoDiv.replicate("PROTO_lectures_head", [course]);
+                       var instructor = response.instructor;
                        if(instructor)
-                               ProtoDiv.replicate("PROTO_lectures_instructor", [instructor])
-
-                       var lectures = response.lectures
+                               ProtoDiv.replicate("PROTO_lectures_instructor", [instructor]);
+                       var lectures = response.lectures;
                        if(lectures)
                                ProtoDiv.replicate("PROTO_lecture", lectures);
-
                }
-
-               cb("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]
-
+       var lectureId = matches[1];
        ProtoDiv.reset("PROTO_note");
-       
        $.get("/lecture/"+lectureId, { cache: false }, function(response) {
-
                if(typeof response == 'object') {
-
-                       var course = response.course
+                       var course = response.course;
                        //if(course)
                        //      ProtoDiv.replicate("PROTO_lectures_head", [course])
-
-                       var instructor = response.instructor
+                       var instructor = response.instructor;
                        //if(instructor)
                        //      ProtoDiv.replicate("PROTO_lectures_instructor", [instructor])
-
-                       var lecture = response.lecture
+                       var lecture = response.lecture;
                        //if(lecture)
                        //      ProtoDiv.replicate("PROTO_lecture", lectures);
-
-                       var notes = response.notes
+                       var notes = response.notes;
                        if(notes)
                                ProtoDiv.replicate("PROTO_note", notes);
-
                }
-
-               cb("notes")
+               cb("notes");
        });
 }
 
-
-
-
-
 // go to the page that lists the archived subject names
 function showArchiveSubjects(matches, cb) {
-
-       ProtoDiv.reset("PROTO_archive_subject")
-
+       ProtoDiv.reset("PROTO_archive_subject");
        $.get("/archive", { cache: false }, function(response) {
-
-               var subjects = response.subjects
-
-               ProtoDiv.replicate("PROTO_archive_subject", subjects)
-
+               var subjects = response.subjects;
+               ProtoDiv.replicate("PROTO_archive_subject", subjects);
        })
-
-       cb("archive_subjects")
+       cb("archive_subjects");
 }
 
-
-
 function showArchiveCourses(matches, cb) {
-
-       var subjectId = parseInt(matches[1])
-
-       ProtoDiv.reset("PROTO_archive_course")
-
+       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)
-
+               var courses = response.courses;
+               ProtoDiv.replicate("PROTO_archive_course", courses);
        })
-
-       cb("archive_courses")
+       cb("archive_courses");
 }
 
-
-
 function showArchiveNotes(matches, cb) {
-
-       var courseId = parseInt(matches[1])
-
-       ProtoDiv.reset("PROTO_archive_note")
-
+       var courseId = parseInt(matches[1]);
+       ProtoDiv.reset("PROTO_archive_note");
        $.get("/archive/course/"+courseId, { cache: false }, function(response) {
-
-               var notes = response.notes
+               var notes = response.notes;
                $.each(notes, function(i, note) {
                        if(!note.topic)
-                               note.topic = note.text.substr(0, 15)+" ..."
+                               note.topic = note.text.substr(0, 15)+" ...";
                })
-
-               ProtoDiv.replicate("PROTO_archive_note", notes)
-
+               ProtoDiv.replicate("PROTO_archive_note", notes);
        })
-
-       cb("archive_notes")
+       cb("archive_notes");
 }
 
 
 
 function showArchiveNote(matches, cb) {
-
-       var noteId = parseInt(matches[1])
-
-       ProtoDiv.reset("PROTO_archive_note_display")
-
+       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 <i>Mom!</i>", topic: "21st Century Greetings" }
+               var note = response.note;
+//note = { text: "Hi <i>Mom!</i>", topic: "21st Century Greetings" }
+//             note.text = note.text || ""
                if(!note.topic)
-                       note.topic = note.text.substr(0, 15)+" ..."
-
-               ProtoDiv.replicate("PROTO_archive_note_display", note)
-
+                       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")
+       cb("archive_note_display");
 }
 
-
-
 // go to the account registration page
 function showRegister(matches, cb) {
        // xxx clear fields?
@@ -231,28 +151,20 @@ function showRegister(matches, cb) {
        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 },
@@ -262,83 +174,73 @@ var pageVectors = [
        { 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: /^\/archive\/note\/([a-f0-9]{24})/, func: showArchiveNote },
        { regex: /^\/login/, func: showLogin },
        { regex: /^\/register/, func: showRegister },
        { regex: /^\/press/, func: showPress },
-       { regex: /^\/conduct/, func: showConduct },
+       { regex: /^\/conduct/, func: showConduct }
 ];
 
-
 /* Do and show the appropriate thing, based on the pages current URL */
 function showPage(y) {
-
-       var path = document.location.pathname
-
+       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)
+               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)
-
+                               window.scroll(0, y);
                        })
-                       break
+                       break;
                }
        }
-
        if(i == pageVectors.length) {
                $("#pg_notfound").fadeIn(100);
-               window.scroll(0, 0)
+               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]
+var topQueue = [0];
 function goPage(path) {
-       var y = 0 + window.pageYOffset
-       topQueue.push(y)
-       history.pushState({}, path, path);
-       showPage(0);
+       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) {
-       var y = topQueue.pop()
-       showPage( y );
+       popped = true;
+       showPage( topQueue.pop() );
 }
 
-
 $(document).ready(function() {
-
        // This code executes after the page has been fully loaded
-
-       window.onpopstate = goBack
-
+       $(".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
-
 })
 
-
-
-
-
index e74f143e939cbfa175883ef473e8354805ce5665..bf07460a5e2c417ce5fa9fa51cf1f5e1672ecf27 100644 (file)
@@ -112,6 +112,8 @@ ProtoDiv.replicate = function(id, arr, keep) {
                delete e.id
                mom.insertBefore(e, sib)
                ProtoDiv.inject(e, obj, i)
+               if(ProtoDiv.each)
+                       ProtoDiv.each(e, i, obj, mom)
        }
 
        if(!keep)
index 2b7ab0c6eed5081df562f56b50445f554d1433ed..d6a1e22c5c4069043e1c49cc69b380c1fd25a9e9 100644 (file)
@@ -240,7 +240,7 @@ div#wrapper div#header div.buttons {
 }
 
 div#wrapper div#header {
-       background: #444;
+       background: #333;
 }
 
 div#wrapper div#header .rcol {
@@ -883,8 +883,4 @@ div.conduct p.vague {
        -webkit-border-radius: 0.20em;
 }
 
-.proto {
-       /*display: none;*/
-}
-