From 780c6bf054b72c914929b842a6b8c5e1e4237152 Mon Sep 17 00:00:00 2001 From: chapel Date: Sat, 19 Nov 2011 13:10:34 -0800 Subject: [PATCH] Fix instructor email showing when it shouldn't, Add more info for notes, fix date for lectures, add in joes fixes for FF and IE from 1pageb; --- public/index.html | 13 ++++++-- public/javascripts/main.js | 61 +++++++++++++++++++++++++++++++------- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/public/index.html b/public/index.html index 5e29cd5..5b5d069 100644 --- a/public/index.html +++ b/public/index.html @@ -167,7 +167,7 @@ Department: __department__
- Instructor: __name__ (__email__)
+ Instructor: __name__ (__email__)
@@ -201,10 +201,17 @@
-

Notepads

+
+

Note pads for Course __number__ : __name__

+ Subject: __subject__
+ Department: __department__
+
+
+ Instructor: __name__ (__email__)
+
- __name__ + __name__ Visits: __visits__
diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 424b61e..62809a7 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -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) }) -- 2.25.1