prettier --write

This commit is contained in:
RainLoop Team 2019-07-04 22:19:24 +03:00
parent 450528ff00
commit 8a0be3212d
164 changed files with 7053 additions and 9008 deletions

View file

@ -1,12 +1,10 @@
import window from 'window';
import {bMobileDevice, bSafari} from 'Common/Globals';
import { bMobileDevice, bSafari } from 'Common/Globals';
import * as Links from 'Common/Links';
import * as Events from 'Common/Events';
import {trim} from 'Common/Utils';
import { trim } from 'Common/Utils';
class Audio
{
class Audio {
notificator = null;
player = null;
@ -20,16 +18,14 @@ class Audio
this.player = this.createNewObject();
this.supported = !bMobileDevice && !bSafari && !!this.player && !!this.player.play;
if (this.supported && this.player && this.player.canPlayType)
{
if (this.supported && this.player && this.player.canPlayType) {
this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, '');
this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, '');
this.supportedOgg = '' !== this.player.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, '');
this.supportedNotification = this.supported && this.supportedMp3;
}
if (!this.player || (!this.supportedMp3 && !this.supportedOgg && !this.supportedWav))
{
if (!this.player || (!this.supportedMp3 && !this.supportedOgg && !this.supportedWav)) {
this.supported = false;
this.supportedMp3 = false;
this.supportedOgg = false;
@ -37,8 +33,7 @@ class Audio
this.supportedNotification = false;
}
if (this.supported && this.player)
{
if (this.supported && this.player) {
const stopFn = () => this.stop();
this.player.addEventListener('ended', stopFn);
@ -50,8 +45,7 @@ class Audio
createNewObject() {
const player = window.Audio ? new window.Audio() : null;
if (player && player.canPlayType && player.pause && player.play)
{
if (player && player.canPlayType && player.pause && player.play) {
player.preload = 'none';
player.loop = false;
player.autoplay = false;
@ -66,8 +60,7 @@ class Audio
}
stop() {
if (this.supported && this.player.pause)
{
if (this.supported && this.player.pause) {
this.player.pause();
}
@ -79,10 +72,8 @@ class Audio
}
clearName(name = '', ext = '') {
name = trim(name);
if (ext && '.' + ext === name.toLowerCase().substr((ext.length + 1) * -1))
{
if (ext && '.' + ext === name.toLowerCase().substr((ext.length + 1) * -1)) {
name = trim(name.substr(0, name.length - 4));
}
@ -90,8 +81,7 @@ class Audio
}
playMp3(url, name) {
if (this.supported && this.supportedMp3)
{
if (this.supported && this.supportedMp3) {
this.player.src = url;
this.player.play();
@ -100,8 +90,7 @@ class Audio
}
playOgg(url, name) {
if (this.supported && this.supportedOgg)
{
if (this.supported && this.supportedOgg) {
this.player.src = url;
this.player.play();
@ -113,8 +102,7 @@ class Audio
}
playWav(url, name) {
if (this.supported && this.supportedWav)
{
if (this.supported && this.supportedWav) {
this.player.src = url;
this.player.play();
@ -123,16 +111,13 @@ class Audio
}
playNotification() {
if (this.supported && this.supportedMp3)
{
if (!this.notificator)
{
if (this.supported && this.supportedMp3) {
if (!this.notificator) {
this.notificator = this.createNewObject();
this.notificator.src = Links.sound('new-mail.mp3');
}
if (this.notificator && this.notificator.play)
{
if (this.notificator && this.notificator.play) {
this.notificator.play();
}
}