epiclock.minute.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // Green
  26. //if (dist > 180000) { // 5min
  27. // Special changes to 20' and 5' for MINEDU
  28. if (dist > 1200000) { //>20min
  29. if (!(div_clock.hasClass('time_warning_three'))) {
  30. div_clock.addClass('time_warning_three');
  31. }
  32. }
  33. // Yellow
  34. // if (dist <= 180000) { //3min
  35. if (dist <= 1200000) { //20min
  36. div_clock.removeClass('time_warning_three');
  37. if (!(div_clock.hasClass('time_warning_two'))) {
  38. div_clock.addClass('time_warning_two');
  39. }
  40. }
  41. // Red
  42. // if (dist <= 60000) { //1min
  43. if (dist <= 300000) { //5min
  44. div_clock.removeClass('time_warning_two');
  45. if (!(div_clock.hasClass('time_warning_one'))) {
  46. div_clock.addClass('time_warning_one');
  47. }
  48. }
  49. },
  50. function ()
  51. {
  52. epClock = this;
  53. });
  54. }(jQuery));