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

raeburn raeburn at source.lon-capa.org
Mon Aug 15 01:16:31 EDT 2011


raeburn		Mon Aug 15 05:16:31 2011 EDT

  Modified files:              
    /loncom/interface	loncommon.pm domainprefs.pm 
  Log:
  - javascript prototype for indexOf() for arrays, which is available in FF
    but not IE.
  - Fix class for <tr> tag in DC's interface to configure Load Balancer server.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1016 loncom/interface/loncommon.pm:1.1017
--- loncom/interface/loncommon.pm:1.1016	Wed Aug  3 18:25:11 2011
+++ loncom/interface/loncommon.pm	Mon Aug 15 05:16:30 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1016 2011/08/03 18:25:11 raeburn Exp $
+# $Id: loncommon.pm,v 1.1017 2011/08/15 05:16:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -632,6 +632,51 @@
 
 }
 
+sub javascript_array_indexof {
+    return <<ENDJS; 
+<script type="text/javascript" language="JavaScript">
+// <![CDATA[
+
+if (!Array.prototype.indexOf) {
+    Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
+        "use strict";
+        if (this === void 0 || this === null) {
+            throw new TypeError();
+        }
+        var t = Object(this);
+        var len = t.length >>> 0;
+        if (len === 0) {
+            return -1;
+        }
+        var n = 0;
+        if (arguments.length > 0) {
+            n = Number(arguments[1]);
+            if (n !== n) { // shortcut for verifying if it's NaN
+                n = 0;
+            } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
+                n = (n > 0 || -1) * Math.floor(Math.abs(n));
+            }
+        }
+        if (n >= len) {
+            return -1;
+        }
+        var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
+        for (; k < len; k++) {
+            if (k in t && t[k] === searchElement) {
+                return k;
+            }
+        }
+        return -1;
+    }
+}
+
+// ]]>
+</script>
+
+ENDJS
+
+}
+
 sub userbrowser_javascript {
     my $id_functions = &javascript_index_functions();
     return <<"ENDUSERBRW";
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.152 loncom/interface/domainprefs.pm:1.153
--- loncom/interface/domainprefs.pm:1.152	Wed Aug 10 14:54:42 2011
+++ loncom/interface/domainprefs.pm	Mon Aug 15 05:16:30 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.152 2011/08/10 14:54:42 raeburn Exp $
+# $Id: domainprefs.pm,v 1.153 2011/08/15 05:16:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -399,7 +399,8 @@
                 &Apache::loncommon::sorted_inst_types($dom);
             $js = &lonbalance_targets_js($dom,$types,\%servers).
                   &new_spares_js().
-                  &common_domprefs_js();
+                  &common_domprefs_js().
+                  &Apache::loncommon::javascript_array_indexof();
         }
         &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
     } else {
@@ -2762,7 +2763,7 @@
     if (ref($types) eq 'ARRAY') {
         $rownum += scalar(@{$types});
     }
-    my $css_class = 'class="LC_odd_row"';
+    my $css_class = ' class="LC_odd_row"';
     my $targets_div_style = 'display: none';
     my $disabled_div_style = 'display: block';
     my $homedom_div_style = 'display: none';
@@ -2835,14 +2836,14 @@
     $datatable .= '</div></td></tr>'.
                   &loadbalancing_rules($dom,$intdom,$currrules,$othertitle,
                                        $usertypes,$types,\%servers,$currbalancer,
-                                       $targets_div_style,$homedom_div_style);
+                                       $targets_div_style,$homedom_div_style,$css_class);
     $$rowtotal += $rownum;
     return $datatable;
 }
 
 sub loadbalancing_rules {
     my ($dom,$intdom,$currrules,$othertitle,$usertypes,$types,$servers,
-        $currbalancer,$targets_div_style,$homedom_div_style) = @_;
+        $currbalancer,$targets_div_style,$homedom_div_style,$css_class) = @_;
     my $output;
     my ($alltypes,$othertypes,$titles) = 
         &loadbalancing_titles($dom,$intdom,$usertypes,$types);
@@ -2859,7 +2860,7 @@
             }
             $output .= &loadbalance_rule_row($type,$titles->{$type},$current,
                                              $servers,$currbalancer,$dom,
-                                             $targets_div_style,$homedom_div_style);
+                                             $targets_div_style,$homedom_div_style,$css_class);
         }
     }
     return $output;
@@ -2897,7 +2898,7 @@
 
 sub loadbalance_rule_row {
     my ($type,$title,$current,$servers,$currbalancer,$dom,$targets_div_style,
-        $homedom_div_style) = @_;
+        $homedom_div_style,$css_class) = @_;
     my @rulenames = ('default','homeserver');
     my %ruletitles = &offloadtype_text();
     if ($type eq '_LC_external') {
@@ -2910,7 +2911,7 @@
         $style = $homedom_div_style;
     }
     my $output = 
-        '<tr><td valign="top"><div id="balanceruletitle_'.$type.'" style="'.$style.'">'.$title.'</div></td>'."\n".
+        '<tr'.$css_class.'><td valign="top"><div id="balanceruletitle_'.$type.'" style="'.$style.'">'.$title.'</div></td>'."\n".
         '<td><div id="balancerule_'.$type.'" style="'.$style.'">'."\n";
     for (my $i=0; $i<@rulenames; $i++) {
         my $rule = $rulenames[$i];




More information about the LON-CAPA-cvs mailing list