--- loncom/interface/loncommon.pm 2011/08/03 18:25:11 1.1016 +++ loncom/interface/loncommon.pm 2011/08/15 05:16:30 1.1017 @@ -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 # @@ -630,6 +630,51 @@ function getDomainFromSelectbox(formname 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 {