Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.305 and 1.308

version 1.305, 2012/03/26 02:47:46 version 1.308, 2012/04/05 15:56:13
Line 1309  sub htmlareaselectactive { Line 1309  sub htmlareaselectactive {
                 $.fn.jPicker.defaults.images.clientPath="/adm/jpicker/images/";                  $.fn.jPicker.defaults.images.clientPath="/adm/jpicker/images/";
                 $(".colorchooser").jPicker();                  $(".colorchooser").jPicker();
   
                 // Only define the countdown if a dueDate variable is defined:  
   
                if (typeof(dueDate) != "undefined") {  
                   $("#duedatecountdown").countdown({until: dueDate, compact: true,   
                                                   layout: "<b>'.&mt("Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn}").'</b>",  
                                                   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 = '<b>' .  &mt('Due in: {dn} {dl} {hnn}{sep}{mnn}{sep}{snn} - Submit early!') . '</b>';
       $output .= <<JAVASCRIPT;
   
       var documentReadyTime;
   
   \$(document).ready(function() {
      if (typeof(dueDate) != "undefined") {
          documentReadyTime = (new Date()).getTime();
         \$("#duedatecountdown").countdown({until: dueDate, compact: true, 
            layout: "$dueDateLayout",
            onTick: function (periods) {
       var latencyEstimate = (documentReadyTime - clientTime) * 2;
               if(\$.countdown.periodsToSeconds(periods) < (60 + latencyEstimate)) {
                  \$(this).css("color", "red");   //Highlight last minute.
               }
            }
         });
      }
   });
   JAVASCRIPT
     if ($dragmath_prefix ne '') {      if ($dragmath_prefix ne '') {
         $output .= '          $output .= '
   
Line 1430  var dueDate       = new Date(serverDueDa Line 1464  var dueDate       = new Date(serverDueDa
 </script>  </script>
 ";  ";
   
       return $js;
   }
   ##
   # Sets the time at which the problem finished computing.
   # This just updates the serverTime and clientTime variables above.
   # Calling this in e.g. end_problem provides a better estimate of the
   # difference beetween the server and client time setting as 
   # the difference contains less of the latency/problem compute time.
   #
   sub set_compute_end_time {
   
       my $now = time()*1000; # Javascript times are in ms.
       my $js = "
   <script type='text/javascript'>
   //<![CDATA[
   serverTime = $now;
   clientTime = (new Date()).getTime();
   //]]>
   </script>
   
   ";
       return $js;
       
 }  }
   
 ############################################################  ############################################################
Line 2798  sub generate_menu { Line 2855  sub generate_menu {
                                 $$link{alttext} : $$link{linktext})                                  $$link{alttext} : $$link{linktext})
                             }), {                              }), {
                             href  => $$link{url},                              href  => $$link{url},
                             title => mt($$link{linktitle})                              title => mt($$link{linktitle}),
                               class => 'LC_menubuttons_link'
                             }).                              }).
                         $a->(mt($$link{linktext}), {                          $a->(mt($$link{linktext}), {
                             href  => $$link{url},                              href  => $$link{url},

Removed from v.1.305  
changed lines
  Added in v.1.308


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>