-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.js
57 lines (47 loc) · 1.51 KB
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Receives the details from the popup and handles common steps e.g. show backdrop and message.
* Emits message "timeSheetFill" to be handled by the timesheet automation scripts.
*/
(function () {
'use strict';
fmtApi.utils.setMessageProxy({
[fmtApi.events.timeSheetFormSubmit]: onTimeSheetFormSubmit,
[fmtApi.events.timeSheetFillAck]: hideModalMessage
});
async function onTimeSheetFormSubmit(payload) {
showModalMessage('Operation in progress');
// dispatch event for page timesheet automation script
fmtApi.utils.sendMessage({type: fmtApi.events.timeSheetFill, payload});
}
let uiModalElt;
function showModalMessage(messageStr) {
if (!uiModalElt) {
const
messageElt = document.createElement('div'),
modalStyles = `
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
background-color: rgba(0, 0, 0, .75);
z-index: 9999;
color: white;
`;
messageElt.textContent = messageStr;
messageElt.setAttribute('style', 'font-size: 36px;');
uiModalElt = document.createElement('div');
uiModalElt.setAttribute('style', modalStyles);
uiModalElt.appendChild(messageElt);
}
document.body.appendChild(uiModalElt);
}
function hideModalMessage() {
if (document.body.contains(uiModalElt)) {
uiModalElt = document.body.removeChild(uiModalElt);
}
}
})();