2021-01-18 16:24:57 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
2021-08-27 15:30:02 +01:00
|
|
|
export class BackgroundService {
|
2021-01-18 16:24:57 +01:00
|
|
|
|
2021-10-18 17:42:25 +01:00
|
|
|
callBacks: {
|
2021-10-19 09:41:06 +01:00
|
|
|
type: 'Offline' | 'Online' | 'Notification',
|
2021-10-18 17:42:25 +01:00
|
|
|
object?: string
|
|
|
|
|
funx: Function
|
|
|
|
|
}[] = []
|
|
|
|
|
|
2021-01-18 16:24:57 +01:00
|
|
|
constructor() { }
|
2021-08-27 15:35:29 +01:00
|
|
|
|
|
|
|
|
online() {
|
|
|
|
|
document.body.style.setProperty(`--color`, "#0782C9");
|
|
|
|
|
document.body.style.setProperty(`--color2`, "#45BAFF");
|
|
|
|
|
document.body.style.setProperty(`--color3`, "#0782C9");
|
|
|
|
|
document.body.style.setProperty(`--color4`, "#0782c9f0");
|
|
|
|
|
document.body.style.setProperty(`--color5`, "#45BAFF");
|
2021-10-18 17:42:25 +01:00
|
|
|
this.callBacks.forEach((e) => {
|
|
|
|
|
if (e.type == 'Online') {
|
|
|
|
|
e.funx()
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-08-27 15:35:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
offline() {
|
|
|
|
|
document.body.style.setProperty(`--color`, "#ffb703");
|
|
|
|
|
document.body.style.setProperty(`--color2`, "#ffb703");
|
|
|
|
|
document.body.style.setProperty(`--color3`, "#ffb703");
|
|
|
|
|
document.body.style.setProperty(`--color4`, "#ffb703");
|
|
|
|
|
document.body.style.setProperty(`--color5`, "#ffb703");
|
2021-10-18 17:42:25 +01:00
|
|
|
this.callBacks.forEach((e) => {
|
|
|
|
|
if (e.type == 'Offline') {
|
|
|
|
|
e.funx()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-19 09:41:06 +01:00
|
|
|
registerBackService(type: 'Offline' | 'Online' | 'Notification', funx: Function, object = '') {
|
2021-10-18 17:42:25 +01:00
|
|
|
this.callBacks.push({
|
|
|
|
|
type,
|
|
|
|
|
funx,
|
|
|
|
|
object
|
|
|
|
|
})
|
2021-08-27 15:35:29 +01:00
|
|
|
}
|
2021-01-18 16:24:57 +01:00
|
|
|
}
|