return schools and courses to schools page
authorSeth Woodworth <seth@sethish.com>
Fri, 6 Jan 2012 04:28:06 +0000 (23:28 -0500)
committerSeth Woodworth <seth@sethish.com>
Fri, 6 Jan 2012 04:28:06 +0000 (23:28 -0500)
app.js
public/index.html
public/javascripts/main.js

diff --git a/app.js b/app.js
index 721d3978a5d54bf92c1c5b1df7c6c4227ca62854..80a05910fb58551b94f918af4c42e991facf5941 100644 (file)
--- a/app.js
+++ b/app.js
@@ -489,7 +489,11 @@ app.get( '/schools', checkAjax, loadUser, function( req, res ) {
       // If schools are found, loop through them gathering any courses that are
       // associated with them and then render the page with that information.
       sendJson(res, { 'user': user.sanitized, 'schools' : schools.map(function(school) {
-        return school.sanitized;
+        var s = school.sanitized;
+        s['courses'] = Course.find( { 'school' : s._id } ).sort( 'name', '1' ).run(function( err, courses) {
+            return courses.map( function(c) { return c.sanitized; } );
+        });
+        return s
       })})
     } else {
       // If no schools have been found, display none
index e9fbf41a9306142dd2a2f0fd7c7bb2727790799e..6d14b37088d6fcbc4f20d70d07899fa7e31d7e37 100644 (file)
                                <h1>Universities</h1>
                        </div>
             <script id="schoolTmpl" type="text/x-jquery-tmpl">
-                ${name}<br/>
+                <div class="school">
+                    <div class="name">${name}</div>
+                    <div class="desc">${description}</div>
+                    <ul class="courses">
+                    {{tmpl(courses) "#course"}}
+
+                    </ul>
+                </div> <!-- .school -->
             </script>
             <script id="course" type="text/x-jquery-tmpl">
-                               <div class="proto school" id="PROTO_school" onclick="goPage('/school/___id__')">
-                                       <div class=name>__name__</div>
-                                       <div class=desc>__description__</div>
-                               </div>
+                <li>${dept}: ${name} (${number})</li>
             </script>
       <!--================================================================= -->
                        <div class=page id=pg_courses>
index f81cd7b2dc4889121b3278f0a68288bf782dfd8f..73995c0a56b4d8c4aebc708f756bbabd72cd916a 100644 (file)
@@ -124,13 +124,11 @@ router.add('home', false, function(cb) {
 router.add('schools', function(data, cb) {
   console.log(data);
   $('#school_link').addClass('active');
-  response = {
+  var response = {
     id: 'school',
     data: data.schools
   }
-  console.log('blanking html');
-  $('#pg_schools').html('');
-  console.log(data.schools);
+  //$('#pg_schools').html('');
   $('#pg_schools').css('display', 'block');
   $('#schoolTmpl').tmpl( data.schools ).appendTo("#pg_schools");
 });