Fix instructor email showing when it shouldn't,
authorchapel <jacob.chapel@gmail.com>
Sat, 19 Nov 2011 21:10:34 +0000 (13:10 -0800)
committerchapel <jacob.chapel@gmail.com>
Sat, 19 Nov 2011 21:10:34 +0000 (13:10 -0800)
Add more info for notes, fix date for lectures,
add in joes fixes for FF and IE from 1pageb;

public/index.html
public/javascripts/main.js

index 5e29cd56ef12f69a7322deb1b40db5b081fe674f..5b5d069ecc8fc834dac195b23b0a4fdc0fe21b25 100644 (file)
                                        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)
 
 })