Merge branch '1page' of github.com:/finalsclubdev/FinalsClub
authorec2-user <ec2-user@fcdev4.finalsclub.org>
Sat, 19 Nov 2011 21:11:47 +0000 (21:11 +0000)
committerec2-user <ec2-user@fcdev4.finalsclub.org>
Sat, 19 Nov 2011 21:11:47 +0000 (21:11 +0000)
public/index.html
public/javascripts/main.js

index ee11f231330a2952fd02cc5733d717f8e52e38d7..4a6e3828b29c6fc4ca448900884593167e53f642 100644 (file)
@@ -24,7 +24,7 @@
 
                <div class="masthead">
                        <div class="logbar">
-        <div class="loginstatus"><div id="login_status" class="page"><div id="PROTO_login_info">Currently logged in as <span class="username">__name__</span></div></div></div>
+        <div class="loginstatus"><div id="login_status"><div id="PROTO_login_info">Currently logged in as <span class="username">__name__</span></div></div></div>
                        </div>
                        <div class="navbar">
                                <table>
                                        Department: __department__<br>
                                </div>
                                <div class="proto lectures_instructor" id=PROTO_lectures_instructor>
-                                       Instructor: __name__ (__email__)<br>
+          Instructor: __name__ <span class="instructor_email">(__email__)</span><br>
                                </div>
                                <div class="proto lecture" id=PROTO_lecture>
                                        <div class=name>
 
 
                        <div class=page id=pg_notes>
-                               <h1>Notepads </h1>
+                               <div class="proto notes_head" id=PROTO_notes_head>
+                                       <h1>Note pads for Course __number__ : __name__</h1>
+                                       Subject: __subject__<br>
+                                       Department: __department__<br>
+                               </div>
+                               <div class="proto notes_instructor" id=PROTO_notes_instructor>
+          Instructor: __name__ <span class="instructor_email">(__email__)</span><br>
+                               </div>
                                <div class="proto note" id=PROTO_note>
                                        <div class=name>
-                                               <a href="/note/___id__">__name__</a>
+                                               <a href="/note/___id__">__name__</a> Visits: __visits__
                                        </div>
                                </div>
         <div>
index 424b61e2edaa0f2a0c6a7589ebdcb9aadf904745..62809a7be3b4045a2207d753f4d096abaebb1abb 100644 (file)
@@ -193,9 +193,20 @@ router.add('course', function(data, cb) {
   if (data.lectures) {
     response.push({
       id: 'lecture',
-      data: data.lectures
+      data: data.lectures.map(function(lecture) {
+        var date = new Date(lecture.date);
+        lecture.date = date.toDateString();
+        return lecture;
+      })
     })
   }
+  cb('lectures', response);
+
+  if (!data.instructor.email) {
+    $('.instructor_email').hide();
+  } else {
+    $('.instructor_email').show();
+  }
 
   if (data.course.authorized) {
     $('#new_lecture').show();
@@ -222,7 +233,6 @@ router.add('course', function(data, cb) {
     });
   }
 
-  cb('lectures', response);
 });
 
 
@@ -234,6 +244,20 @@ router.add('lecture', function(data, cb) {
 
   var response = [];
 
+  if (data.course) {
+    response.push({
+      id: 'notes_head',
+      data: data.course
+    })
+  }
+
+  if (data.instructor) {
+    response.push({
+      id: 'notes_instructor',
+      data: data.instructor
+    })
+  }
+
   if (data.notes) {
     response.push({
       id: 'note',
@@ -241,6 +265,14 @@ router.add('lecture', function(data, cb) {
     })
   }
   
+  cb("notes", response);
+
+  if (!data.instructor.email) {
+    $('.instructor_email').hide();
+  } else {
+    $('.instructor_email').show();
+  }
+  
   if (data.lecture.authorized) {
     $('#new_note').show();
     $('#new_note').click(function(e) {
@@ -265,7 +297,6 @@ router.add('lecture', function(data, cb) {
       })
     });
   }
-  cb("notes", response);
 });
 
 
@@ -484,21 +515,25 @@ function showPage(y) {
 */
 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() );
 }
 
 
-       window.onpopstate = goBack
+window.onpopstate = goBack
 
 $(document).ready(function() {
 
@@ -518,7 +553,11 @@ $(document).ready(function() {
   })
 
        // 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
+  setTimeout(function() {
+    if (!popped) {
+      showPage( 0 );           // needed for some older browsers, redundant for chrome
+    }
+  }, 200)
 
 })