[LON-CAPA-cvs] cvs: loncom /interface coursecatalog.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 18 Oct 2006 13:52:17 -0000


raeburn		Wed Oct 18 09:52:17 2006 EDT

  Modified files:              
    /loncom/interface	coursecatalog.pm 
  Log:
  Don't display 'No courses' unless a specific department has been selected, and there are no courses for the selected year and/or semester.
  
  
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.8 loncom/interface/coursecatalog.pm:1.9
--- loncom/interface/coursecatalog.pm:1.8	Tue Oct 17 14:11:46 2006
+++ loncom/interface/coursecatalog.pm	Wed Oct 18 09:52:17 2006
@@ -758,39 +758,44 @@
             }
         }
         else {
-            for (var k=0; k<idyears.length; k++) {
-                if (idyears[k] == valyr) {
-                    idyr = k;
+            if (selDepartment > -1) {
+                for (var k=0; k<idyears.length; k++) {
+                    if (idyears[k] == valyr) {
+                        idyr = k;
+                    }
                 }
-            }
-            if (idyr != -1) {
-                for (var k=0; k<idsems[idyr].length; k++) {
-                    if (idsems[idyr][k] == valsem) {
-                        idsem = k;
+                if (idyr != -1) {
+                    for (var k=0; k<idsems[idyr].length; k++) {
+                        if (idsems[idyr][k] == valsem) {
+                            idsem = k;
+                        }
                     }
                 }
-            }
-            if (idsem != -1) {
-                for (var k=0; k<idcodes[idyr][idsem].length; k++) {
-                    if (idcodes[idyr][idsem][k] == valdept) {
-                        iddept = k;
+                if (idsem != -1) {
+                    for (var k=0; k<idcodes[idyr][idsem].length; k++) {
+                        if (idcodes[idyr][idsem][k] == valdept) {
+                            iddept = k;
+                        }
                     }
                 }
-            }
-            if (iddept != -1) {
-                document.$formname.Number.options[0] =  new Option('All','0',false,false);
-                for (var i=0; i<idcourses[idyr][idsem][iddept].length; i++) {
-                    var display = idcourses[idyr][idsem][iddept][i];
-                    if (longtitles[3] == 1) {
-                        if (idcourseslongs[idyr][idsem][iddept][i] != "") {
-                            display = idcourseslongs[idyr][idsem][iddept][i]
+                if (iddept != -1) {
+                    document.$formname.Number.options[0] =  new Option('All','0',false,false);
+                    for (var i=0; i<idcourses[idyr][idsem][iddept].length; i++) {
+                        var display = idcourses[idyr][idsem][iddept][i];
+                        if (longtitles[3] == 1) {
+                            if (idcourseslongs[idyr][idsem][iddept][i] != "") {
+                                display = idcourseslongs[idyr][idsem][iddept][i]
+                            }
                         }
+                        document.$formname.Number.options[i+1] = new Option(display,idcourses[idyr][idsem][iddept][i],false,false)
                     }
-                    document.$formname.Number.options[i+1] = new Option(display,idcourses[idyr][idsem][iddept][i],false,false)
+                } 
+                else {
+                    document.$formname.Number.options[0] =  new Option('No courses','0',true,true);
                 }
-            }
+            } 
             else {
-                document.$formname.Number.options[0] =  new Option('No courses','0',true,true);
+                document.$formname.Number.options[0] =  new Option('All','0',true,true);
             }
         }
         document.$formname.Number.selectedIndex = 0