forked from iamsushank/mutual-cart-3380
-
Notifications
You must be signed in to change notification settings - Fork 0
/
track.js
126 lines (110 loc) · 3.12 KB
/
track.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
function datechecker() {
// event.preventDefault();
// console.log(typeof parseInt(jsdate.value));
// console.log(parseInt(jsdate.value));
// document.getElementById("1").innerHTML = jsdate.value;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let todaydate = String(date.getDate()).padStart(2, "0");
let datepattern = todaydate + "," + month + "," + year;
output.innerText = datepattern;
}
function myFunction() {
document.getElementById("jsdate").stepUp(1);
datechecker();
}
function myFunction2() {
document.getElementById("jsdate").stepDown(1);
datechecker();
}
function today() {
var date = new Date();
var n = date.getDate();
document.getElementById("1").innerHTML = n;
}
let btnshow = document.getElementById("button-day");
let output = document.getElementById("1");
btnshow.addEventListener("click", () => {
let today = new Date();
let day = today.getDay();
var days = new Array(7);
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";
var r = days[today.getDay()];
let date = today.getDate();
let current_date = `${r},${date}`;
output.innerText = current_date;
});
// StopWatch
const lapBtn = document.getElementById("lapBtn");
const timerSec = document.getElementById("timerSec");
const timerMins = document.getElementById("timerMins");
const timerHrs = document.getElementById("timerHrs");
const startBtn = document.getElementById("button-start");
const resetBtn = document.getElementById("resetBtn");
const lapRecord = document.getElementById("lapRecord");
let hours = 0;
let minutes = 0;
let seconds = 0;
let displaySec = seconds;
let displayMins = minutes;
let displayHours = hours;
let interval = null;
let status = "stopped";
let lapNow = null;
function start() {
seconds++;
if (seconds < 10) displaySec = "0" + seconds.toString();
else displaySec = seconds;
if (minutes < 10) displayMins = "0" + minutes.toString();
else displayMins = minutes;
if (hours < 10) displayHours = "0" + hours.toString();
else displayHours = hours;
if (seconds / 60 === 1) {
minutes++;
seconds = 0;
if (minutes / 60 === 1) {
hours++;
minutes = 0;
}
}
timerSec.innerHTML = displaySec;
timerMins.innerHTML = displayMins;
timerHrs.innerHTML = displayHours;
}
function startStop() {
if (status === "stopped") {
interval = setInterval(start, 10);
startBtn.innerHTML = "Stop";
status = "started";
} else {
clearInterval(interval);
startBtn.innerHTML = "Start";
status = "stopped";
}
}
function reset() {
clearInterval(interval);
seconds = 0;
minutes = 0;
hours = 0;
timerSec.innerHTML = "00";
timerMins.innerHTML = "00";
timerHrs.innerHTML = "00";
startBtn.innerHTML = "Start";
lapRecord.innerHTML = "";
status = "stopped";
}
function lap() {
lapNow = `<div class="lap">Total: ${hours} : ${minutes} : ${seconds}</div>`;
lapRecord.innerHTML += lapNow; //+=
}
lapBtn.addEventListener("click", lap);
startBtn.addEventListener("click", startStop);
resetBtn.addEventListener("click", reset);