--- loncom/interface/lonhtmlcommon.pm 2012/03/25 14:36:01 1.304 +++ loncom/interface/lonhtmlcommon.pm 2012/04/04 10:47:29 1.307 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.304 2012/03/25 14:36:01 foxr Exp $ +# $Id: lonhtmlcommon.pm,v 1.307 2012/04/04 10:47:29 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1309,21 +1309,55 @@ sub htmlareaselectactive { $.fn.jPicker.defaults.images.clientPath="/adm/jpicker/images/"; $(".colorchooser").jPicker(); - // Only define the countdown if a dueDate variable is defined: - - if (typeof(dueDate) != "undefined") { - $("#duedatecountdown").countdown({until: dueDate, compact: true, - layout: "Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn}", - onTick: function (periods) { - if($.countdown.periodsToSeconds(periods) < 60) { - $(this).css("color", "red"); //Highlight last minute. - } - } - }); - } }); '; + # Code to put a due date countdown in 'duedatecountdown' span. + # This is currently located in the breadcrumb headers. + # note that the dueDateLayout is internatinoalized below. + # Here document is used to support the substitution into the javascript below. + # ..which unforunately necessitates escaping the $'s in the javascript. + # There are several times of importance + # + # serverDueDate - The absolute time at which the problem expires. + # serverTime - The server's time when the problem finished computing. + # clientTime - The client's time...as close to serverTime as possible. + # The clientTime will be slightly later due to + # 1. The latency between problem computation and + # the first network action. + # 2. The time required between the page load-start and the actual + # initial javascript execution that got clientTime. + # These are used as follows: + # The difference between clientTime and serverTime are used to + # correct for differences in clock settings between the browser's system and the + # server's. + # + # The difference between clientTime and the time at which the ready() method + # starts executing is used to estimate latencies for page load and submission. + # Since this is an estimate, it is doubled. The latency estimate + one minute + # is used to determine when the countdown timer turns red to warn the user + # to think about submitting. + + my $dueDateLayout = '' . &mt('Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn} - Submit early!') . ''; + $output .= < +// + + +"; + return $js; + } ############################################################