Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
teddi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
wildfirecode13
teddi
Commits
8610a80e
Commit
8610a80e
authored
Nov 12, 2020
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
d0e514e0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
38 deletions
+33
-38
Countdown.d.ts
dist/Countdown.d.ts
+12
-13
Countdown.js
dist/Countdown.js
+4
-8
package.json
package.json
+1
-1
Countdown.ts
src/Countdown.ts
+16
-16
No files found.
dist/Countdown.d.ts
View file @
8610a80e
import
EventEmitter
from
"./EventEmitter"
;
import
EventEmitter
from
"./EventEmitter"
;
export
default
class
Countdown
extends
EventEmitter
<
any
>
{
export
default
class
Countdown
extends
EventEmitter
<
any
>
{
_timer
:
any
;
private
_timer
;
_text
:
any
;
private
_text
;
_seconds
:
any
;
private
_seconds
;
_format
:
any
;
private
_format
;
_counter
:
any
;
private
_counter
;
_delay
:
an
y
;
private
_dela
y
;
_running
:
boolean
;
private
_running
;
constructor
(
text
:
any
,
seconds
:
any
,
format
:
any
,
delay
:
any
);
constructor
(
text
:
any
,
seconds
:
any
,
format
:
any
,
delay
:
any
);
getCountdown
():
string
|
undefined
;
private
getCountdown
;
getHHMMSS
():
string
;
private
getHHMMSS
;
getMMSS
():
string
;
private
getMMSS
;
getText
():
any
;
private
getText
;
start
():
void
;
start
():
void
;
stop
():
void
;
private
stop
;
reset
(
$seconds
:
number
):
void
;
reset
(
$seconds
:
number
):
void
;
set
seconds
(
val
:
number
);
get
running
():
boolean
;
get
running
():
boolean
;
}
}
dist/Countdown.js
View file @
8610a80e
...
@@ -70,16 +70,12 @@ var Countdown = /** @class */ (function (_super) {
...
@@ -70,16 +70,12 @@ var Countdown = /** @class */ (function (_super) {
this
.
emit
(
"complete"
);
this
.
emit
(
"complete"
);
};
};
Countdown
.
prototype
.
reset
=
function
(
$seconds
)
{
Countdown
.
prototype
.
reset
=
function
(
$seconds
)
{
this
.
seconds
=
$seconds
;
this
.
_
seconds
=
$seconds
;
};
};
Object
.
defineProperty
(
Countdown
.
prototype
,
"seconds"
,
{
set
:
function
(
val
)
{
this
.
_seconds
=
val
;
},
enumerable
:
false
,
configurable
:
true
});
Object
.
defineProperty
(
Countdown
.
prototype
,
"running"
,
{
Object
.
defineProperty
(
Countdown
.
prototype
,
"running"
,
{
// set seconds(val: number) {
// this._seconds = val;
// }
get
:
function
()
{
get
:
function
()
{
return
this
.
_running
;
return
this
.
_running
;
},
},
...
...
package.json
View file @
8610a80e
{
{
"name"
:
"teddi"
,
"name"
:
"teddi"
,
"version"
:
"1.0.
4
"
,
"version"
:
"1.0.
5
"
,
"description"
:
""
,
"description"
:
""
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"types"
:
"dist/index.d.ts"
,
"types"
:
"dist/index.d.ts"
,
...
...
src/Countdown.ts
View file @
8610a80e
...
@@ -5,13 +5,13 @@ function getNum(n: any) {
...
@@ -5,13 +5,13 @@ function getNum(n: any) {
}
}
export
default
class
Countdown
extends
EventEmitter
<
any
>
{
export
default
class
Countdown
extends
EventEmitter
<
any
>
{
_timer
:
any
;
private
_timer
:
any
;
_text
:
any
;
private
_text
:
any
;
_seconds
:
any
;
private
_seconds
:
any
;
_format
:
any
;
private
_format
:
any
;
_counter
:
any
;
private
_counter
:
any
;
_delay
:
any
;
private
_delay
:
any
;
_running
=
false
;
private
_running
=
false
;
constructor
(
text
:
any
,
seconds
:
any
,
format
:
any
,
delay
:
any
)
{
constructor
(
text
:
any
,
seconds
:
any
,
format
:
any
,
delay
:
any
)
{
super
();
super
();
console
.
log
(
this
);
console
.
log
(
this
);
...
@@ -22,12 +22,12 @@ export default class Countdown extends EventEmitter<any> {
...
@@ -22,12 +22,12 @@ export default class Countdown extends EventEmitter<any> {
this
.
_delay
=
delay
||
1000
;
this
.
_delay
=
delay
||
1000
;
}
}
getCountdown
()
{
private
getCountdown
()
{
if
(
this
.
_format
==
"hhmmss"
)
return
this
.
getHHMMSS
();
if
(
this
.
_format
==
"hhmmss"
)
return
this
.
getHHMMSS
();
if
(
this
.
_format
==
"mmss"
)
return
this
.
getMMSS
();
if
(
this
.
_format
==
"mmss"
)
return
this
.
getMMSS
();
}
}
getHHMMSS
()
{
private
getHHMMSS
()
{
const
left
=
this
.
_seconds
-
this
.
_counter
;
const
left
=
this
.
_seconds
-
this
.
_counter
;
const
hours
=
Math
.
floor
(
left
/
3600
);
const
hours
=
Math
.
floor
(
left
/
3600
);
const
minutes
=
Math
.
floor
((
left
%
3600
)
/
60
);
const
minutes
=
Math
.
floor
((
left
%
3600
)
/
60
);
...
@@ -35,14 +35,14 @@ export default class Countdown extends EventEmitter<any> {
...
@@ -35,14 +35,14 @@ export default class Countdown extends EventEmitter<any> {
return
`
${
getNum
(
hours
)}
:
${
getNum
(
minutes
)}
:
${
getNum
(
seconds
)}
`
;
return
`
${
getNum
(
hours
)}
:
${
getNum
(
minutes
)}
:
${
getNum
(
seconds
)}
`
;
}
}
getMMSS
()
{
private
getMMSS
()
{
const
left
=
this
.
_seconds
-
this
.
_counter
;
const
left
=
this
.
_seconds
-
this
.
_counter
;
const
minutes
=
Math
.
floor
(
left
/
60
);
const
minutes
=
Math
.
floor
(
left
/
60
);
const
seconds
=
left
%
60
;
const
seconds
=
left
%
60
;
return
`
${
getNum
(
minutes
)}
:
${
getNum
(
seconds
)}
`
;
return
`
${
getNum
(
minutes
)}
:
${
getNum
(
seconds
)}
`
;
}
}
getText
()
{
private
getText
()
{
return
this
.
_text
.
replace
(
"{0}"
,
this
.
getCountdown
());
return
this
.
_text
.
replace
(
"{0}"
,
this
.
getCountdown
());
}
}
...
@@ -58,19 +58,19 @@ export default class Countdown extends EventEmitter<any> {
...
@@ -58,19 +58,19 @@ export default class Countdown extends EventEmitter<any> {
},
this
.
_delay
);
},
this
.
_delay
);
}
}
stop
()
{
private
stop
()
{
this
.
_running
=
false
;
this
.
_running
=
false
;
clearInterval
(
this
.
_timer
);
clearInterval
(
this
.
_timer
);
this
.
emit
(
"complete"
);
this
.
emit
(
"complete"
);
}
}
reset
(
$seconds
:
number
)
{
reset
(
$seconds
:
number
)
{
this
.
seconds
=
$seconds
;
this
.
_
seconds
=
$seconds
;
}
}
set
seconds
(
val
:
number
)
{
//
set seconds(val: number) {
this
.
_seconds
=
val
;
//
this._seconds = val;
}
//
}
get
running
()
{
get
running
()
{
return
this
.
_running
;
return
this
.
_running
;
...
...
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