Skip to content

Instantly share code, notes, and snippets.

@caglarorhan
Created January 5, 2022 23:52
Show Gist options
  • Save caglarorhan/cebf76622c5602010498d492ffe41f76 to your computer and use it in GitHub Desktop.
Save caglarorhan/cebf76622c5602010498d492ffe41f76 to your computer and use it in GitHub Desktop.
Cok canim cekti, keyfine. Aklimda cok deli is akisi modelleri var. Apple Stayla min UI max islevsellik.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>start_pause_stop_timer</title>
<style>
button{
width: 100px;
height: 50px;
font-size: 20px;
cursor: pointer;
}
</style>
</head>
<body>
<button id="startTimerButton">START</button>
<button id="timerDisplayAndPauseButton">0</button>
<button id="resetTimerButton">RESET</button>
<script>
let TMR = window.hasOwnProperty('TMR') ? TMR : {};
TMR.timerSwitchPaused = true;
TMR.timerDisplay = document.getElementById('timerDisplayAndPauseButton');
TMR.startTimerButton = document.getElementById('startTimerButton');
TMR.resetTimerButton = document.getElementById('resetTimerButton');
TMR.startTimerButton.addEventListener('click',()=>{
TMR.startTimer()
})
TMR.resetTimerButton.addEventListener('click',()=>{
TMR.resetTimer()
})
TMR.timerDisplay.addEventListener('click',()=>{
(TMR.timerSwitchPaused)?TMR.startTimer():TMR.pauseTimer();
})
TMR.startTimer = function(){
TMR.timerSwitchPaused = false;
TMR.timer = setInterval(function(){
TMR.timerDisplay.innerHTML = (TMR.timerDisplay.innerHTML * 1 + 1)+"";
}, 1000);
};
TMR.pauseTimer = function(){
clearInterval(TMR.timer);
TMR.timerSwitchPaused = true;
};
TMR.resetTimer = function(){
TMR.timerSwitchPaused = true;
TMR.timerDisplay.innerHTML = "0";
clearInterval(TMR.timer);
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment