This repository has been archived by the owner on Feb 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from datagovsg/lint-directives
Linter auto-fix everything
- Loading branch information
Showing
77 changed files
with
2,403 additions
and
2,438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
import assert from 'assert'; | ||
|
||
export class SafeInterval { | ||
constructor(fn, interval, retryTimeout) { | ||
this.isRunning = false; | ||
this.timeout = null; | ||
|
||
retryTimeout = retryTimeout || interval; | ||
|
||
//fn returns a Promise | ||
this.loop = function() { | ||
this.timeout = null; | ||
|
||
var promise = this.currentPromise = fn(); | ||
|
||
this.currentPromise | ||
.then(()=>{ | ||
if (promise == this.currentPromise && this.isRunning) { | ||
this.timeout = setTimeout(this.loop, interval); | ||
} | ||
}) | ||
.catch((err) => { | ||
console.log(err) | ||
if (promise == this.currentPromise && this.isRunning) { | ||
this.timeout = setTimeout(this.loop, retryTimeout); | ||
} | ||
}) | ||
}.bind(this); | ||
} | ||
|
||
stop() { | ||
this.isRunning = false; | ||
if (this.timeout !== null) { | ||
clearTimeout(this.timeout); | ||
} | ||
} | ||
|
||
start() { | ||
if (this.isRunning) return; | ||
this.isRunning = true; | ||
this.loop(); | ||
} | ||
} | ||
import assert from 'assert' | ||
|
||
export class SafeInterval { | ||
constructor (fn, interval, retryTimeout) { | ||
this.isRunning = false | ||
this.timeout = null | ||
|
||
retryTimeout = retryTimeout || interval | ||
|
||
// fn returns a Promise | ||
this.loop = function () { | ||
this.timeout = null | ||
|
||
let promise = this.currentPromise = fn() | ||
|
||
this.currentPromise | ||
.then(()=>{ | ||
if (promise == this.currentPromise && this.isRunning) { | ||
this.timeout = setTimeout(this.loop, interval) | ||
} | ||
}) | ||
.catch((err) => { | ||
console.log(err) | ||
if (promise == this.currentPromise && this.isRunning) { | ||
this.timeout = setTimeout(this.loop, retryTimeout) | ||
} | ||
}) | ||
}.bind(this) | ||
} | ||
|
||
stop () { | ||
this.isRunning = false | ||
if (this.timeout !== null) { | ||
clearTimeout(this.timeout) | ||
} | ||
} | ||
|
||
start () { | ||
if (this.isRunning) return | ||
this.isRunning = true | ||
this.loop() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import assert from 'assert'; | ||
|
||
export class SafeScheduler { | ||
constructor(fn, hours, minutes = 0, seconds = 0) { | ||
this.isRunning = false; | ||
this.timeout = null; | ||
|
||
//fn returns a Promise | ||
this.loop = function() { | ||
this.timeout = null; | ||
|
||
fn() | ||
.then(()=>{ | ||
if (this.isRunning) { | ||
this.timeout = setTimeout(this.loop, | ||
new Date().setHours(hours, minutes, seconds) - Date.now() | ||
); | ||
} | ||
}) | ||
.catch(() => { | ||
if (this.isRunning) { | ||
this.timeout = setTimeout(this.loop, 60000 /* retryTimeout */); | ||
} | ||
}) | ||
}.bind(this); | ||
} | ||
|
||
stop() { | ||
this.isRunning = false; | ||
if (this.timeout !== null) { | ||
clearTimeout(this.timeout); | ||
} | ||
} | ||
|
||
start() { | ||
assert (!this.isRunning); | ||
this.isRunning = true; | ||
this.loop(); | ||
} | ||
} | ||
import assert from 'assert' | ||
|
||
export class SafeScheduler { | ||
constructor (fn, hours, minutes = 0, seconds = 0) { | ||
this.isRunning = false | ||
this.timeout = null | ||
|
||
// fn returns a Promise | ||
this.loop = function () { | ||
this.timeout = null | ||
|
||
fn() | ||
.then(()=>{ | ||
if (this.isRunning) { | ||
this.timeout = setTimeout(this.loop, | ||
new Date().setHours(hours, minutes, seconds) - Date.now() | ||
) | ||
} | ||
}) | ||
.catch(() => { | ||
if (this.isRunning) { | ||
this.timeout = setTimeout(this.loop, 60000 /* retryTimeout */) | ||
} | ||
}) | ||
}.bind(this) | ||
} | ||
|
||
stop () { | ||
this.isRunning = false | ||
if (this.timeout !== null) { | ||
clearTimeout(this.timeout) | ||
} | ||
} | ||
|
||
start () { | ||
assert(!this.isRunning) | ||
this.isRunning = true | ||
this.loop() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
beeline/directives/bookingBreadcrumbs/bookingBreadcrumbs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
|
||
|
||
export default ['$rootScope', | ||
function breadcrumbs($rootScope) { | ||
function breadcrumbs ($rootScope) { | ||
return { | ||
template: | ||
`<div class="item"><img ng-src="{{breadcrumbs_dir}}{{imgNames[step]}}"></div>`, | ||
scope: { | ||
step: '@', | ||
}, | ||
link: function(scope, elem, attr) { | ||
link: function (scope, elem, attr) { | ||
scope.breadcrumbs_dir = 'img/'+$rootScope.o.APP.PREFIX + 'booking-breadcrumbs/' | ||
scope.imgNames = [ | ||
'ProgressBar01_ChooseStops.svg', | ||
'ProgressBar02_ChooseDates.svg', | ||
'ProgressBar03_ReviewBooking.svg', | ||
'ProgressBar04_MakePayment.svg', | ||
]; | ||
|
||
} | ||
}; | ||
] | ||
}, | ||
} | ||
}] |
Oops, something went wrong.