2018-07-04 20:50:46 +00:00
|
|
|
import * as plugins from './sl.destlocal.plugins';
|
2018-07-05 21:40:33 +00:00
|
|
|
import { DestinationLocal } from './sl.destlocal.classes.destinationlocal';
|
2016-05-13 23:18:44 +00:00
|
|
|
|
|
|
|
export class Ora {
|
2018-07-05 21:40:33 +00:00
|
|
|
/**
|
|
|
|
* the destinationLocalInstance that ora talks to
|
|
|
|
*/
|
|
|
|
destinationLocalInstance: DestinationLocal;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the state of the current ora
|
|
|
|
*/
|
|
|
|
state: 'running' | 'stopped' | 'paused' = 'stopped';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the actual ora object
|
|
|
|
*/
|
2018-03-01 00:06:12 +00:00
|
|
|
private _oraObject;
|
2018-07-05 21:40:33 +00:00
|
|
|
|
|
|
|
constructor(destinationLocalInstanceArg: DestinationLocal = new DestinationLocal()) {
|
|
|
|
this.destinationLocalInstance = destinationLocalInstanceArg;
|
2017-03-11 11:30:18 +00:00
|
|
|
this._oraObject = plugins.ora({
|
|
|
|
spinner: 'dots',
|
2018-03-03 12:57:55 +00:00
|
|
|
text: '',
|
|
|
|
color: 'blue'
|
2018-03-01 00:06:12 +00:00
|
|
|
});
|
2017-03-11 11:30:18 +00:00
|
|
|
}
|
2018-07-05 21:40:33 +00:00
|
|
|
|
2017-03-11 11:30:18 +00:00
|
|
|
text(textArg) {
|
2018-03-01 00:06:12 +00:00
|
|
|
this._oraObject.text = textArg;
|
2017-03-11 11:30:18 +00:00
|
|
|
}
|
2016-10-16 00:26:43 +00:00
|
|
|
|
2017-03-11 11:30:18 +00:00
|
|
|
start(textArg?: string, colorArg?: string) {
|
2018-03-01 00:06:12 +00:00
|
|
|
if (textArg) {
|
|
|
|
this.text(textArg);
|
|
|
|
}
|
|
|
|
if (colorArg) {
|
|
|
|
this._oraObject.color = colorArg;
|
|
|
|
}
|
2018-07-05 21:40:33 +00:00
|
|
|
this.state = 'running';
|
2018-03-01 00:06:12 +00:00
|
|
|
this._oraObject.start();
|
2017-03-11 11:30:18 +00:00
|
|
|
}
|
2018-07-05 21:40:33 +00:00
|
|
|
|
2017-03-11 11:30:18 +00:00
|
|
|
end() {
|
2018-03-01 00:06:12 +00:00
|
|
|
this._oraObject.stop();
|
|
|
|
this._oraObject.clear();
|
2018-07-05 21:40:33 +00:00
|
|
|
this.state = 'stopped';
|
2017-03-11 11:30:18 +00:00
|
|
|
}
|
2018-11-04 12:22:45 +00:00
|
|
|
|
2017-03-11 11:30:18 +00:00
|
|
|
pause() {
|
2018-03-01 00:06:12 +00:00
|
|
|
this._oraObject.stop();
|
2018-07-05 21:40:33 +00:00
|
|
|
this.state = 'paused';
|
2017-03-11 11:30:18 +00:00
|
|
|
}
|
2018-07-05 21:40:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* stop is an alias for end
|
|
|
|
*/
|
2018-03-01 00:06:12 +00:00
|
|
|
stop() {
|
|
|
|
this.end();
|
2017-03-11 11:30:18 +00:00
|
|
|
}
|
2016-10-16 00:26:43 +00:00
|
|
|
}
|