epiclock.minute.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*!
  2. * minute countdown renderer for epiclock
  3. *
  4. * Copyright (c) Eric Garside
  5. * Copyright (c) Chamilo team
  6. * Dual licensed under:
  7. * MIT: http://www.opensource.org/licenses/mit-license.php
  8. * GPLv3: http://www.opensource.org/licenses/gpl-3.0.html
  9. */
  10. "use strict";
  11. /*global window, jQuery */
  12. /*jslint white: true, browser: true, onevar: true, undef: true, eqeqeq: true, bitwise: true, regexp: true, strict: true, newcap: true, immed: true, maxerr: 50, indent: 4 */
  13. (function ($) {
  14. //constants
  15. var epClock; // clock object
  16. // Setup
  17. $.epiclock.addRenderer('minute', function (element, value)
  18. {
  19. var currentTime = new Date().valueOf();
  20. var dist = epClock.time+epClock.__offset - currentTime;
  21. //Sets the value to the clock very important!
  22. element.text(value);
  23. var div_clock = $('#exercise_clock_warning');
  24. // 60000 = 60 seconds
  25. if (dist <= 180000) { //3min
  26. if (!(div_clock.hasClass('time_warning_two'))) {
  27. div_clock.addClass('time_warning_two');
  28. }
  29. }
  30. if (dist <= 60000) { //1min
  31. div_clock.removeClass('time_warning_two');
  32. if (!(div_clock.hasClass('time_warning_one'))) {
  33. div_clock.addClass('time_warning_one');
  34. }
  35. }
  36. },
  37. function ()
  38. {
  39. epClock = this;
  40. });
  41. }(jQuery));