Browse Source

remove empty lines

ec2-user 12 years ago
parent
commit
f20708bcfd
3 changed files with 14 additions and 180 deletions
  1. 2 1
      app.js
  2. 1 54
      public/index.html
  3. 11 125
      public/javascripts/main.js

+ 2 - 1
app.js

@@ -1632,9 +1632,10 @@ 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 ) {
-      sendJson(res,  {status: 'error', message: 'This is not a valid id for a note'} );
+      sendJson(res,  {status: 'error', message: 'This is not a valid id for a note', err:err } );
     } else {
       ArchivedCourse.findOne({id: note.course_id}, function(err, course) {
         if ( err ) {

+ 1 - 54
public/index.html

@@ -1,23 +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>
@@ -31,9 +27,7 @@
 		<meta name="icon" href="">
 
 	</head>
-
 	<body>
-
 		<div class="masthead">
 			<div class="logbar">
 				<div class="loginstatus">&nbsp;</div>
@@ -60,18 +54,11 @@
 
 		<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">
@@ -94,11 +81,8 @@
 						<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__')">
@@ -107,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>
@@ -119,8 +101,6 @@
 				</div>
 			</div>
 
-
-
 			<div class=page id=pg_lectures>
 				<div class="proto lectures_head" id=PROTO_lectures_head>
 					<h1>Lectures for Course __number__ : __name__</h1>
@@ -138,8 +118,6 @@
 				</div>
 			</div>
 
-
-
 			<div class=page id=pg_notes>
 				<h1>Notepads </h1>
 				<div class="proto note" id=PROTO_note>
@@ -149,8 +127,6 @@
 				</div>
 			</div>
 
-
-
 			<div class=page id=pg_archive_subjects>
 				<h1>Archived Subjects</h1>
 				<p>
@@ -162,11 +138,8 @@
 						<a href="javascript:goPage('/archive/subject/__id__')">__name__</a>
 					</li>
 				</ul>
-
 			</div>
 
-
-
 			<div class=page id=pg_archive_courses>
 				<h1>Archived Courses</h1>
 				<ul>
@@ -174,11 +147,8 @@
 						<a href="javascript:goPage('/archive/course/__id__')">__name__</a>
 					</li>
 				</ul>
-
 			</div>
 
-
-
 			<div class=page id=pg_archive_notes>
 				<h1>Archived Notes</h1>
 				<ul>
@@ -188,17 +158,14 @@
 				</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">
@@ -272,8 +239,6 @@
 				</form>
 			</div>
 
-
-
 			<div class=page id=pg_login>
 				<h1>Login</h1>
 				<form id="credentials" action="/login" method="POST">
@@ -317,7 +282,6 @@
 				</form>
 			</div>
 
-
 			<div class=page id=pg_conduct>
 				<div class="conduct">
 					<h1>Code of Conduct</h1>
@@ -334,9 +298,6 @@
 				</div>
 			</div>
 
-
-
-
 			<div class=page id=pg_press>
 				<h1>FinalsClub in the Press</h1>
 				<div class="press">
@@ -368,23 +329,12 @@
 					</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>
@@ -417,8 +367,5 @@
 			</p>
 		</div>
 
-
-
-
 	</body>
 </html>

+ 11 - 125
public/javascripts/main.js

@@ -1,229 +1,149 @@
-
 /*
-
 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 = parseInt(matches[1])
-
+	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" }
+//note = { text: "Hi <i>Mom!</i>", 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?
@@ -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,36 +174,28 @@ 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 },
 ];
 
-
 /* 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)
@@ -300,12 +204,8 @@ function showPage(y) {
 	/*$('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.
@@ -323,7 +223,6 @@ function goPage(path) {
 	}
 }
 
-
 /* Simulates a "back" browser navigation.  */
 var popped = false;
 function goBack(event) {
@@ -331,30 +230,17 @@ function goBack(event) {
 	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() {
+	/*setTimeout(function() {
 		if(!popped)
 			showPage(0)
-	}, 2000);
-
+	}, 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
-
 })
 
-
-
-
-