more work on 1page
authorfcdev@sleepless.com <ec2-user@ip-10-168-42-13.us-west-1.compute.internal>
Sun, 13 Nov 2011 02:31:35 +0000 (02:31 +0000)
committerfcdev@sleepless.com <ec2-user@ip-10-168-42-13.us-west-1.compute.internal>
Sun, 13 Nov 2011 02:31:35 +0000 (02:31 +0000)
public/index.html
public/javascripts/main.js
public/javascripts/protodiv.js
public/stylesheets/fc2.css

index e2c1b61baeef21806bbc504317291432d05f06d4..a7a0aac2dd9d3e44deab3e0b975ed9c55613ae3c 100644 (file)
                        <div class=page id=pg_schools>
                                <h1>Universities</h1>
                                <div class="school" id=PROTO_school>
-                                       <div class=name>
-                                               <a href="javascript:goCourses('__name__')">__name__</a>
-                                               (__numCourses__ courses)
+                                       <div class=name>__name__</div>
+                                       <div class=desc>__description__</div>
+                                       <div class=tocourses>
+                                               <a href="javascript:goCourses('__name__', '___id__', __i__)">
+                                               Click for courses ...
+                                               </a>
                                        </div>
                                </div>
                        </div>
 
                        <div class=page id=pg_courses>
                                <h1>Courses for <span id=school_name></span></h1>
+                               <div class=course id=PROTO_course>
+                                       <div class=dept>__department__</div>
+                                       <div class=name>
+                                               <a href="javascript:goLectures('___id__')">__number__: __name__</a>
+                                       </div>
+                               </div>
+                       </div>
 
-                               <ul>
-                                       <li id=PROTO_course><a href="course/__id__">__name__</a></li>
-                               </ul>
+
+
+                       <div class=page id=pg_lectures>
+                               <h1>Lectures for <span id=course_name></span></h1>
+                               <div class=course id=PROTO_lecture>
+                                       <div class=name>
+                                               <a href="goPads('___id__')">__name__</a>
+                                       </div>
+                               </div>
                        </div>
 
 
index f33d6019a48687357f9a3df04e4c7dccbc6ba3fc..7273f79f61c72ded404169369d739ba96280f6a7 100644 (file)
@@ -25,15 +25,16 @@ function showPage(id) {
 
 
 
-var schools = []
 
 // go to the page that lists the schools
+var schools = []
 function goSchools() {
+       ProtoDiv.reset("PROTO_school");
        hideAllPages();
        $.get("/schools", {}, function(response) {
-               if(typeof response == 'object')
+               if(typeof response == 'object') {
                        schools = response.schools
-               ProtoDiv.reset("PROTO_school");
+               }
                ProtoDiv.replicate("PROTO_school", schools);
                showPage("schools")
        });
@@ -41,23 +42,51 @@ function goSchools() {
 
 
 
-var courses = []
-
 // go to the page that lists the courses for a specific school
-function goCourses(name) {
+var courses = []
+function goCourses(schoolName, schoolId, a) {
+       ProtoDiv.reset("PROTO_course");
        hideAllPages();
-       $("#school_name").html(name);
-//             $.get("/courses", {}, function(response) {
-//                     if(typeof response == 'object')
-//                             courses = response.courses
-var courses = [
-{ id: "4e6d1e9b42bbef522c000a8f", name: "History 12: Introduction to the Middle East" },
-{ id: "4e8aa3f62e4b97e67b001f47", name: "ANTH160AC/ISF 160: The Forms of Folklorek" }
-]
-               ProtoDiv.reset("PROTO_course");
+       $.get("/school/"+schoolId, {}, function(response) {
+               courses = []
+               if(typeof response == 'object') {
+                       var school = response.school
+                       $("#school_name").html(school.name);
+                       courses = school.courses
+               }
                ProtoDiv.replicate("PROTO_course", courses);
                showPage("courses")
-//             });
+       });
+}
+
+
+
+
+// go to the page that lists the lectures for a specific course
+var lectures = []
+function goLectures(courseId) {
+       ProtoDiv.reset("PROTO_lecture");
+       hideAllPages();
+       $.get("/course/"+courseId, {}, function(response) {
+
+response = {
+       course: {
+               name: "FooCourse",
+               lectures: [
+                       { _id: 1, name: "lecture 1" },
+                       { _id: 2, name: "lecture 2" },
+               ]
+       }
+}
+               lectures = []
+               if(typeof response == 'object') {
+                       var course = response.course
+                       $("#course_name").html(course.name);
+                       lectures = course.lectures
+               }
+               ProtoDiv.replicate("PROTO_lecture", lectures);
+               showPage("lectures")
+       });
 }
 
 
index fa741d61e1b74bb2c5a6cfc28778faea6473421e..e74f143e939cbfa175883ef473e8354805ce5665 100644 (file)
@@ -46,7 +46,9 @@ ProtoDiv.map = function(node, list, cb) {
        }
 }
 
-ProtoDiv.substitute = function(s, obj) {
+ProtoDiv.substitute = function(s, obj, i) {
+       if(i !== undefined)
+               s = s.replace(/__i__/g, i);
        for(var key in obj) {
                re = new RegExp("__"+key+"__", "g")
                s = s.replace(re, obj[key])
@@ -54,14 +56,14 @@ ProtoDiv.substitute = function(s, obj) {
        return s
 }
 
-ProtoDiv.inject = function(id, obj) {
+ProtoDiv.inject = function(id, obj, n) {
        var proto = ProtoDiv.elem(id)
 
-       proto.innerHTML = ProtoDiv.substitute(proto.innerHTML, obj)
+       proto.innerHTML = ProtoDiv.substitute(proto.innerHTML, obj, n)
 
        for(var i = 0; i < proto.attributes.length; i++) {
                var a = proto.attributes[i]
-               a.textContent = ProtoDiv.substitute(a.textContent, obj)
+               a.textContent = ProtoDiv.substitute(a.textContent, obj, n)
        }
 
        for(var key in obj) {
@@ -109,7 +111,7 @@ ProtoDiv.replicate = function(id, arr, keep) {
                var e = proto.cloneNode(true)
                delete e.id
                mom.insertBefore(e, sib)
-               ProtoDiv.inject(e, obj)
+               ProtoDiv.inject(e, obj, i)
        }
 
        if(!keep)
index 77cc7f0d1251eb3e0851712bde35edbbdaa581dd..9c4a2369e575192ca9bf19b0f51e1526d6effe5c 100644 (file)
@@ -616,9 +616,6 @@ div.school {
 
 }
 
-.school h2 {
-}
-
 /*
 .content .container1 h1 {
        background: #778899;
@@ -654,11 +651,23 @@ div.menubar {
        text-align: right;
 }
 
-div.school h2 {
+div.school div.name {
+       font-weight: bold;
        font-size: 120%;
        margin: 0 0;
 }
 
+div.school div.desc {
+       font-size: 90%;
+       color: #888;
+       font-style: italic;
+       margin: 0 0;
+}
+
+div.course {
+       margin: 1em 0;
+}
+
 #messages {
        margin: 0em 5%;
 }