-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (52 loc) · 2.21 KB
/
index.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
71
import { doClassList } from './src/scripts/utils.js'
import { requestRates } from './src/scripts/rates/request.js'
import { loader } from './src/scripts/UI/loader.js'
import { setSizeForScrol, setHeight } from './src/scripts/general/setSize.js'
import { setDefaultCurrency, loadOpeationFromDataBase, loadDefaultRates, addOptionDefaultRates } from './src/scripts/general/memory.js'
import { loadAllRate } from './src/scripts/rates/addRate.js'
import { selectOperations } from './src/scripts/budget/selectHistory.js'
import { clearInput } from './src/scripts/general/clearInputs.js'
import { $iconBurger, showMenu } from './src/scripts/general/menuBurger.js'
import { $btnClearAll, deleteAllOperation } from './src/scripts/budget/clearAll.js'
import { $btnAddOperation, getDescriptionOperation } from './src/scripts/budget/form.js'
import { $userIcon, showForm } from './src/scripts/login/render.js' ////////////////
window.addEventListener('DOMContentLoaded', () => {
try {
requestRates()
loader()
window.addEventListener('load', start)
} catch (error) {
console.log(error)
}
})
const start = () => {
if (checkEndUrl('currentRates.html')) {
setSizeForScrol('.current-rate', '.current-rate__header', '.rate')
loadDefaultRates()
} else if (checkEndUrl('history.html')) {
setSizeForScrol('.history', '.history__header', '.operation')
loadOpeationFromDataBase()
selectOperations()
} else if (checkEndUrl('addCurrency.html')) {
loadAllRate()
} else if (checkEndUrl('news.html')) {
console.log('news')
} else {
setSizeForScrol('.current-rate', '.current-rate__header', '.rate')
setSizeForScrol('.history', '.history__header', '.operation')
setHeight('.wallet__body', 'min')
loadOpeationFromDataBase()
selectOperations()
setDefaultCurrency()
loadDefaultRates()
addOptionDefaultRates()
clearInput()
$btnClearAll.addEventListener('click', deleteAllOperation)
$btnAddOperation.addEventListener('click', getDescriptionOperation)
}
$userIcon.addEventListener('click', showForm)
$iconBurger.addEventListener('click', showMenu)
doClassList('.wrapper', 'add', '_show')
loader('stop')
}
const checkEndUrl = (url) => location.href.endsWith(url)