Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
ee0d5707
Commit
ee0d5707
authored
Oct 10, 2016
by
LE GAC Renaud
Browse files
Move the JavaScript function reprDuration as a global function in app.js.
parent
72ae3edc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
47 deletions
+44
-47
static/app.js
static/app.js
+44
-0
static/track_events/src/reprDuration.js
static/track_events/src/reprDuration.js
+0
-47
No files found.
static/app.js
View file @
ee0d5707
...
...
@@ -28,6 +28,50 @@ Ext.require('TrackEvents.form.field.UserData');
Ext
.
require
(
'
TrackEvents.form.field.UserDataMultiDefault
'
);
Ext
.
require
(
'
TrackEvents.form.plugin.UserDataConsistency
'
);
/**
* Global function vonverting a duration in nanosecond into a string.
*
* @param {Number} value
* The duration in seconds
*
* @return {String}
* The duration express as the number of year + the number of months
* e.g. "3y + 09m"
*
*/
reprDuration
=
function
(
value
)
{
"
use strict
"
;
var
duration
=
value
,
month
,
nd
,
nm
,
ny
,
rep
,
year
;
// duration of year and month in seconds
year
=
365
*
24
*
3600
;
month
=
year
/
12
;
// number of years and months
ny
=
Math
.
floor
(
duration
/
year
);
nm
=
Math
.
floor
((
duration
-
ny
*
year
)
/
month
);
// format the number of month
nm
=
Ext
.
String
.
leftPad
(
nm
.
toString
(),
2
,
'
0
'
);
// format the response
if
(
ny
>
0
)
{
rep
=
Ext
.
String
.
format
(
"
{0}y + {1}m
"
,
ny
,
nm
);
}
else
if
(
nm
>
0
)
{
rep
=
Ext
.
String
.
format
(
"
{0}m
"
,
nm
);
}
else
{
nd
=
duration
/
(
24
*
3600
);
rep
=
Ext
.
String
.
leftPad
(
nd
.
toString
(),
2
,
'
0
'
);
}
return
rep
;
};
Ext
.
onReady
(
function
(){
"
use strict
"
;
...
...
static/track_events/src/reprDuration.js
deleted
100644 → 0
View file @
72ae3edc
/**
* Convert a duration in nanosecond into a string.
*
* @param {Number} value
* The duration in seconds
*
* @return {String}
* The duration express as the number of year + the number of months e.g. "3y + 09m"
*
*/
function
reprDuration
(
value
)
{
"
use strict
"
;
var
duration
=
value
,
month
,
nd
,
nm
,
ny
,
rep
,
year
;
// duration of year and month in seconds
year
=
365
*
24
*
3600
;
month
=
year
/
12
;
// number of years and months
ny
=
Math
.
floor
(
duration
/
year
);
nm
=
Math
.
floor
((
duration
-
ny
*
year
)
/
month
);
// format the number of month
nm
=
Ext
.
String
.
leftPad
(
nm
.
toString
(),
2
,
'
0
'
);
// format the response
if
(
ny
>
0
)
{
rep
=
Ext
.
String
.
format
(
"
{0}y + {1}m
"
,
ny
,
nm
);
}
else
if
(
nm
>
0
)
{
rep
=
Ext
.
String
.
format
(
"
{0}m
"
,
nm
);
}
else
{
nd
=
duration
/
(
24
*
3600
);
rep
=
Ext
.
String
.
leftPad
(
nd
.
toString
(),
2
,
'
0
'
);
}
return
rep
;
}
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