-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraft.js
201 lines (136 loc) · 4.82 KB
/
draft.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// const startBtn = document.querySelector('#btn-start');
// const timer1 = startBtn.addEventListener('click', () => {
// let actualSeconds = 1*60-1;
// let myTimer = setInterval(pomodoro, 1000);
// function pomodoro() {
// document.getElementById("timer-into-seconds").innerHTML = "( " + actualSeconds + " seconds )";
// actualSeconds -= 1;
// }
// if(actualSeconds <= 0){
// clearInterval(myTimer);
// document.getElementById("timer-into-seconds").innerHTML = "Break time!";
// }})
// const startBtn = document.querySelector('#btn-start');
// // let display = document.querySelector('#timer');
// const timer1 = startBtn.addEventListener('click', (e) => {
// e.stopPropagation()
// let actualSeconds = 1*60-1;
// const myTimer = setInterval(function pomodoro(){
// document.getElementById("timer-into-seconds").innerHTML = "( " + actualSeconds + " seconds )";
// actualSeconds -= 1;
// }, 1000);
// if(actualSeconds <= 0){
// clearInterval(myTimer);
// document.getElementById("timer-into-seconds").innerHTML = "Break time!";
// }});
// minutes /////////////////
// setTimeout(() => { document.getElementById("minutes").innerHTML = "24 : 00"; }, 1000);
// let minutes = 1;
// let seconds = 59;
// setInterval(function pomodoroo(){
// document.getElementById("minutes").innerHTML = minutes + " : " + seconds;
// minutes -= 1;
// if(actualSeconds <= 0){
// clearInterval(pomodoroo);
// document.getElementById("minutes").innerHTML = "00 : 00"
// }
// }, 60*1000);
// }
// );
////////connect these
// function timer2() {
// let actualSecondss = 5*60-1;
// setInterval(function pomodorooo(){
// document.getElementById("timer-into-seconds").innerHTML = "( " + actualSecondss + " seconds )";
// actualSecondss -= 1;
// if(actualSecondss <= 0){
// clearInterval(pomodorooo);
// document.getElementById("timer-into-seconds").innerHTML = "Restart your timer?"
// }
// }, 1000);
// // minutes /////////////////
// setTimeout(() => { document.getElementById("minutes").innerHTML = "4 : 00"; }, 1000);
// let minutess = 3;
// let secondss = 59;
// setInterval(function pomodoroooo(){
// document.getElementById("minutes").innerHTML = minutess +
// " : " + secondss;
// minutess -= 1;
// if(actualSecondss <= 0){
// clearInterval(pomodoroooo);
// document.getElementById("minutes").innerHTML = "00 : 00"
// }
// }, 60*1000);
// };
// function doHomework(subject, callback) {
// alert(`Starting my ${subject} homework.`);
// callback();
// }
// function alertFinished(){
// alert('Finished my homework');
// }
// doHomework('math', alertFinished);
// const promise1 = new Promise((resolve, reject) => {
// resolve('Success!');
// });
// promise1.then((value) => {
// console.log(value);
// // Expected output: "Success!"
// });
// doSomething(function (result) {
// doSomethingElse(result, function (newResult) {
// doThirdThing(newResult, function (finalResult) {
// console.log(`Got the final result: ${finalResult}`);
// }, failureCallback);
// }, failureCallback);
// }, failureCallback);
// function failureCallback(error) {
// console.error(`Error generating audio file: ${error}`);
// }
const currentTime = {
mins: 25,
secs: 0,
incriment: function (current = this) {
if (current.secs == 59) {
currentTime.mins += 1
currentTime.secs = 0
} else {
currentTime.secs += 1
}
return {
...currentTime
}
},
decriment: function (current = this) {
if (current.secs == 0 && current.mins > 0) {
currentTime.mins -= 1
currentTime.secs = 59
} else {
currentTime.secs -= 1
}
return {
...currentTime
}
}
}
const datetimeHelper = ({ mins, secs }) => {
return `M${mins}S{secs}`
}
const startBtn = document.querySelector('#btn-start');
const timer1 = startBtn.addEventListener('click', () => {
let actualSeconds = 1 * 60 - 1;
function pomodoro() {
currentTime.decriment(currentTime)
document.querySelector("span#seconds").innerHTML = currentTime.secs < 10 ? `0${currentTime.secs}` : currentTime.secs;
document.querySelector("span#minutes").innerHTML = currentTime.mins < 10 ? `0${currentTime.mins}` : currentTime.mins;
actualSeconds = 1;
}
let tick = setInterval(() => {
pomodoro()
console.log(currentTime)
}, 1000);
while (actualSeconds <= 0) {
clearInterval(tick);
document.getElementById("timer-into-seconds").innerHTML = "Break time!";
}
})