| const spinnerMotives: { [key: string]: NodeJS.Timeout } = {}; |
| let _body: any; |
|
|
| |
| |
| |
| |
| |
| function _getBody(): HTMLBodyElement { |
| if (_body === undefined) { |
| _body = document.getElementsByTagName("body")[0]; |
| } |
| return _body; |
| } |
|
|
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| export function stopWaitSpinner(id: string) { |
| if (spinnerMotives[id]) { |
| clearTimeout(spinnerMotives[id]); |
| delete spinnerMotives[id]; |
| } |
|
|
| if (Object.keys(spinnerMotives).length === 0) { |
| |
| const body = _getBody(); |
| body.classList.remove("waiting"); |
| } |
| } |
|
|
| |
| |
| |
| export function stopAllWaitSpinners() { |
| for (const id in spinnerMotives) { |
| stopWaitSpinner(id); |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| export function startWaitSpinner(timeOut = 30000): string { |
| |
|
|
| |
| const body = _getBody(); |
| body.classList.add("waiting"); |
|
|
| |
| const id = Math.random().toString(36).substring(2); |
| spinnerMotives[id] = setTimeout(() => { |
| |
| |
| stopWaitSpinner(id); |
| }, timeOut); |
|
|
| return id; |
| } |
|
|