weekend project to make a simple web app using Typescript/Ionic/Angular.

app.js 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. var message = document.getElementById("message");
  2. var timer = document.getElementById("timer");
  3. var button = document.getElementById("button");
  4. var audio = document.getElementById("audiotag");
  5. var Timers = /** @class */ (function () {
  6. function Timers() {
  7. }
  8. Timers.prototype.countDown = function (minutes) {
  9. var orginalTime = minutes;
  10. var counter = minutes * 60;
  11. var interval = setInterval(function () {
  12. var minutes = Math.floor(counter / 60);
  13. var second = counter % 60;
  14. if (second < 10) {
  15. second = "0" + second;
  16. }
  17. timer.innerHTML = minutes + " : " + second;
  18. counter--;
  19. if (counter < 0) {
  20. audio.play();
  21. }
  22. if (counter < 0) {
  23. button.style.visibility = "visible";
  24. clearInterval(interval);
  25. console.log('it worked');
  26. }
  27. }, 1000);
  28. };
  29. return Timers;
  30. }());
  31. var timers = new Timers;
  32. button.addEventListener('click', function () { timers.countDown(5); button.style.visibility = "hidden"; });