Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Murukesh Mohanan
web
Commits
c09a79ea
Commit
c09a79ea
authored
Oct 06, 2020
by
Murukesh Mohanan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix long standing bugs in countup
parent
23271711
Pipeline
#1368
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
countdown.html
countdown.html
+1
-0
js/countdown.js
js/countdown.js
+8
-2
No files found.
countdown.html
View file @
c09a79ea
...
...
@@ -6,6 +6,7 @@
<div
class=
"minutes"
id=
"minutes"
></div>
</div>
<svg
id=
"arcs"
>
<circle
class=
"years"
id=
"yeararc"
r=
"22vw"
cx=
"50%"
cy=
"50%"
></circle>
<circle
class=
"days"
id=
"dayarc"
r=
"24vw"
cx=
"50%"
cy=
"50%"
></circle>
<circle
class=
"hours"
id=
"hourarc"
r=
"25vw"
cx=
"50%"
cy=
"50%"
></circle>
<circle
class=
"minutes"
id=
"minarc"
r=
"25.65vw"
cx=
"50%"
cy=
"50%"
></circle>
...
...
js/countdown.js
View file @
c09a79ea
function
getTimeSince
(
startTime
)
{
var
t
=
Date
.
parse
(
new
Date
())
-
Date
.
parse
(
startTime
)
;
var
t
=
new
Date
()
-
startTime
;
var
seconds
=
Math
.
floor
((
t
/
1000
)
%
60
);
var
minutes
=
Math
.
floor
((
t
/
1000
/
60
)
%
60
);
var
hours
=
Math
.
floor
((
t
/
(
1000
*
60
*
60
))
%
24
);
...
...
@@ -38,6 +38,9 @@ function initializeClock(id, startTime) {
var
minutesElem
=
clock
.
querySelector
(
'
#minutes
'
);
function
plural
(
n
,
w
,
wp
)
{
if
(
n
==
0
)
{
return
''
;
}
if
(
n
==
1
)
{
return
n
+
'
'
+
w
;
}
...
...
@@ -47,6 +50,7 @@ function initializeClock(id, startTime) {
function
updateClock
()
{
var
t
=
getTimeSince
(
startTime
);
yearsElem
.
innerHTML
=
plural
(
t
.
years
,
'
year
'
,
'
years
'
);
daysElem
.
innerHTML
=
plural
(
t
.
days
,
'
day
'
,
'
days
'
);
hoursElem
.
innerHTML
=
plural
(
t
.
hours
,
'
hour
'
,
'
hours
'
);
minutesElem
.
innerHTML
=
(
'
0
'
+
t
.
minutes
).
slice
(
-
2
)
+
'
:
'
+
(
'
0
'
+
t
.
seconds
).
slice
(
-
2
);
...
...
@@ -54,7 +58,9 @@ function initializeClock(id, startTime) {
minLength
=
t
.
minutes
+
t
.
seconds
/
60
;
hrLength
=
t
.
hours
+
minLength
/
60
;
dayLength
=
t
.
days
+
hrLength
/
24
;
yearLength
=
t
.
years
+
t
.
days
/
365
;
updateArc
(
"
yeararc
"
,
dayLength
,
365
);
updateArc
(
"
dayarc
"
,
dayLength
,
365
);
updateArc
(
"
hourarc
"
,
hrLength
,
24
);
updateArc
(
"
minarc
"
,
minLength
,
60
);
...
...
@@ -68,7 +74,7 @@ function initializeClock(id, startTime) {
var
timeinterval
=
setInterval
(
updateClock
,
1000
);
}
var
deadline
=
new
Date
(
'
2019-12-22
08:40 +5:
30
'
);
var
deadline
=
new
Date
(
'
2019-12-22
T08:40+05
30
'
);
document
.
addEventListener
(
"
DOMContentLoaded
"
,
function
(
event
)
{
initializeClock
(
'
countdown
'
,
deadline
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment