-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.js
70 lines (56 loc) · 1.69 KB
/
util.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
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict'
class Area {
constructor(xs, ys, W, H) {
this.xs = xs
this.ys = ys
this.W = W
this.H = H
}
}
function dialogToTopRightPrepare() {
DIALOG_REF.style.right = DIALOG_REF.getBoundingClientRect().left + 'px'
DIALOG_REF.style.left = 'auto'
}
function showTemplateInMessage(templateRef) {
tempRefForMessageContent?.remove()
tempRefForMessageContent = MESSAGE_REF.appendChild(templateRef)
}
function showTemplateInDialog(templateRef) {
tempRefForDialogContent?.remove()
tempRefForDialogContent = DIALOG_REF.appendChild(templateRef)
}
function switchMessageVisibility(setTransparent) {
!messagePermanent && changeElementTransparency(MESSAGE_REF, !setTransparent)
}
function showMessage(refTemplate, setPermanent) {
showTemplateInMessage(refTemplate)
changeMessageVisibility(setPermanent)
}
function changeMessageVisibility(setPermanent) {
messagePermanent = setPermanent
changeElementTransparency(MESSAGE_REF, setPermanent)
}
function changeElementTransparency(ref, removeOrSet) {
removeOrSet ? ref.classList.remove('transparent') : ref.classList.add('transparent')
}
function errorToConsole(data) {
console.log(`błąd typu '${data.errEvType}' w zapytaniu: ${data.idx + 1}/${formData.photosCount}`)
}
function summaryToConsole(data) {
console.log(`zapytań: ${data.idx + 1}/${formData.photosCount}, w tym z błędem: ${data.errCnt}`)
}
function storeFormData(data) {
localStorage.setItem('formData', JSON.stringify(data))
}
function loadFormData() {
let data
if (data = JSON.parse(localStorage.getItem('formData'))) {
Object.keys(data).forEach(key => formData[key] = data[key])
}
}
try {
if (process) {
module.exports = {Area}
}
} catch {
}