/*
 * Clock plugin using Moment.js (http://momentjs.com/) to
 * format the time and date.
 *
 * The only exposed property, 'format', determines the
 * format (see Moment.js documentation) to display time and date.
 *
 * Requires 'jquery' and 'moment' to be available through RequireJS.
 */
define(['jquery', 'moment'], function ($, moment) {
  "use strict";
  var config = {
    format: 'llll'
  };

  function updateClock() {
    var dt = moment();
    var clockText = dt.format(config.format);
    $('.widget-time').text(clockText);
  }

  $(document).ready(function () {
    var lang = navigator.language;
    if (moment.langData(lang)) {
      moment.lang(lang);
    } else {
      moment.lang(navigator.language.replace(/-.+/, ''));
    }
    updateClock();
    setInterval(updateClock, 1000);
  });

  return config;
});

@@ -527,16 +527,201 @@
 ckText);
+%0A%0A    var interval = 59 - dt.second();%0A    if (interval %3C 1) %7B%0A      interval = 1;%0A    %7D else if (interval %3E 5) %7B%0A      interval = 5;%0A    %7D%0A    setTimeout(updateClock, interval * 1000);
 %0A  %7D%0A%0A  
@@ -945,44 +945,8 @@
 ();%0A
-    setInterval(updateClock, 1000);%0A
   %7D)

Optimize clock