--- loncom/interface/loncommon.pm 2011/08/03 18:25:11 1.1016 +++ loncom/interface/loncommon.pm 2011/08/15 15:58:28 1.1018 @@ -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.1018 2011/08/15 15:58:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -632,6 +632,51 @@ ENDJS } +sub javascript_array_indexof { + return < +// >> 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; + } +} + +// ]]> + + +ENDJS + +} + sub userbrowser_javascript { my $id_functions = &javascript_index_functions(); return <<"ENDUSERBRW"; @@ -6895,11 +6940,15 @@ sub validate_page { sub start_scrollbox { - my ($outerwidth,$width,$height)=@_; + my ($outerwidth,$width,$height,$id)=@_; unless ($outerwidth) { $outerwidth='520px'; } unless ($width) { $width='500px'; } unless ($height) { $height='200px'; } - return "
"; + my $div_id; + if ($id ne '') { + $div_id = " id='$id'"; + } + return "
"; } sub end_scrollbox { @@ -6933,10 +6982,14 @@ sub simple_error_page { } sub start_data_table { - my ($add_class) = @_; + my ($add_class,$id) = @_; my $css_class = (join(' ','LC_data_table',$add_class)); + my $table_id; + if (defined($id)) { + $table_id = ' id="'.$id.'"'; + } &start_data_table_count(); - return ''."\n"; + return '
'."\n"; } sub end_data_table {