Add initialization view
This commit is contained in:
33
js/modules/views/initialization.js
Normal file
33
js/modules/views/initialization.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/* eslint-env browser */
|
||||
|
||||
/* global i18n: false */
|
||||
|
||||
|
||||
const OPTIMIZATION_MESSAGE_DISPLAY_THRESHOLD = 2000; // milliseconds
|
||||
|
||||
// type Canceler = () => Eff Unit
|
||||
//
|
||||
// setMessage :: Unit -> Eff (dom :: DOM) Canceler
|
||||
const setMessage = () => {
|
||||
const message = document.querySelector('.app-loading-screen .message');
|
||||
if (!message) {
|
||||
return () => {};
|
||||
}
|
||||
message.innerText = i18n('loading');
|
||||
|
||||
const optimizingMessageTimeoutId = setTimeout(() => {
|
||||
const innerMessage = document.querySelector('.app-loading-screen .message');
|
||||
if (!innerMessage) {
|
||||
return;
|
||||
}
|
||||
innerMessage.innerText = i18n('optimizingApplication');
|
||||
}, OPTIMIZATION_MESSAGE_DISPLAY_THRESHOLD);
|
||||
|
||||
return () => {
|
||||
clearTimeout(optimizingMessageTimeoutId);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
setMessage,
|
||||
};
|
Reference in New Issue
Block a user