1
- FutureOnlyTimeago = function ( ) {
1
+ FutureOnlyTimeago = function ( ) {
2
- var nextExecutionServerUrl = '' ;
2
+ var nextExecutionServerUrl = '' ;
3
- var timeouts = [ ] ;
3
+ var timeouts = [ ] ;
4
-
5
- jQuery . timeago . settings . allowFuture = true ;
6
-
7
- function futureHandler ( cronExpression , elem , parentElem ) {
8
- delete FutureOnlyTimeago . timeouts [ elem ] ;
9
- jQuery . ajax ( {
10
- type : 'POST' ,
11
- url : FutureOnlyTimeago . nextExecutionServerUrl ,
12
- data : { value : cronExpression , noprepend : true } ,
13
- success : function ( newNextExecutionHtml ) {
14
- // replace past date with new template
15
- $ ( parentElem ) . html ( newNextExecutionHtml ) ;
16
- var newElem = $ ( 'abbr.timeago' , parentElem ) ;
17
- makeFutureOnlyTimeago ( newElem ) ;
18
- }
19
- } ) ;
20
- } ;
21
4
22
- function makeFutureOnlyTimeago ( elem ) {
5
+ jQuery . timeago . settings . allowFuture = true ;
23
- var fromNowInMs = $ ( elem ) . attr ( 'data-date-diff-ms' ) ;
6
+
24
- var cronExpression = $ ( elem ) . attr ( 'data-cronstring' ) ;
7
+ function futureHandler ( cronExpression , elem , parentElem ) {
25
- var parentElem = $ ( elem ) . parent ( ) ;
8
+ delete FutureOnlyTimeago . timeouts [ elem ] ;
26
-
9
+ jQuery . ajax ( {
27
- if ( cronExpression && fromNowInMs < 1000 * 60 * 60 * 24 * 7 ) {
10
+ type : 'POST' ,
28
- var updateTimeout = setTimeout ( futureHandler . bind ( this , cronExpression , elem , parentElem ) , fromNowInMs ) ;
11
+ url : FutureOnlyTimeago . nextExecutionServerUrl ,
29
- FutureOnlyTimeago . timeouts [ elem ] = updateTimeout ;
12
+ data : { value : cronExpression , noprepend : true } ,
30
-
13
+ success : function ( newNextExecutionHtml ) {
31
- // cut off second as PrettyCron can only handle Cron expressions where minutes are the smallest unit
14
+ // replace past date with new template
32
- //var prettyCronString = prettyCron.toString(cronExpression.substr(cronExpression.indexOf(' ') + 1));
15
+ var active = $ ( 'input.job_active' , parentElem ) ;
33
- //$(parentElem).append('(<abbr class="cronExpression">' + prettyCronString + '</abbr>)');
16
+ $ ( parentElem ) . html ( newNextExecutionHtml ) ;
34
- }
17
+ $ ( parentElem ) . append ( active ) ;
35
- $ ( elem ) . timeago ( ) ;
18
+ var newElem = $ ( 'abbr.timeago' , parentElem ) ;
36
- }
19
+ makeFutureOnlyTimeago ( newElem ) ;
37
-
20
+ }
38
- // ${createLink(action: 'nextExecution')}
21
+ } ) ;
39
- function initializeTimeagos ( timeagos , nextExecutionServerUrl ) {
22
+ } ;
40
- this . nextExecutionServerUrl = nextExecutionServerUrl ;
23
+
41
- this . timeouts = [ ] ;
24
+ function makeFutureOnlyTimeago ( elem ) {
42
- $ . each ( timeagos , function ( index , elem ) {
25
+ var fromNowInMs = $ ( elem ) . attr ( 'data-date-diff-ms' ) ;
43
- makeFutureOnlyTimeago ( elem ) ;
26
+ var cronExpression = $ ( elem ) . attr ( 'data-cronstring' ) ;
44
- } ) ;
27
+ var parentElem = $ ( elem ) . parent ( ) ;
45
- }
28
+
46
-
29
+ if ( cronExpression && fromNowInMs < 1000 * 60 * 60 * 24 * 7 ) {
47
- return {
30
+ var updateTimeout = setTimeout ( futureHandler . bind ( this , cronExpression , elem , parentElem ) , fromNowInMs ) ;
48
- init : initializeTimeagos
31
+ FutureOnlyTimeago . timeouts [ elem ] = updateTimeout ;
49
- }
32
+
33
+ // cut off second as PrettyCron can only handle Cron expressions where minutes are the smallest unit
34
+ //var prettyCronString = prettyCron.toString(cronExpression.substr(cronExpression.indexOf(' ') + 1));
35
+ //$(parentElem).append('(<abbr class="cronExpression">' + prettyCronString + '</abbr>)');
36
+ }
37
+ $ ( elem ) . timeago ( ) ;
38
+ }
39
+
40
+ // ${createLink(action: 'nextExecution')}
41
+ function initializeTimeagos ( timeagos , nextExecutionServerUrl ) {
42
+ this . nextExecutionServerUrl = nextExecutionServerUrl ;
43
+ this . timeouts = [ ] ;
44
+ $ . each ( timeagos , function ( index , elem ) {
45
+ makeFutureOnlyTimeago ( elem ) ;
46
+ } ) ;
47
+ }
48
+
49
+ return {
50
+ init : initializeTimeagos
51
+ }
50
} ( ) ;
52
} ( ) ;
0 commit comments