-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.js
35 lines (33 loc) · 1.03 KB
/
help.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
const q = (x, y = false) => {
return (y == null || !y || isNaN(y)) ?
document.querySelector(x) : document.querySelectorAll(x)
},
on = (el, type, listener, all = false) => {
if (el) {
(all) ? el.forEach(e => e.addEventListener(type, listener)) :
el.addEventListener(type, listener);
return
}
},
replaceIn = i => {
return i.replaceAll('-', ' – ')
.replaceAll('*', ' × ')
.replaceAll('/', ' ∻ ')
.replaceAll(' ', '')
},
replaceOut = o => {
return o.replaceAll('–', '-')
.replaceAll('×', '*')
.replaceAll('∻', '/')
.replaceAll('^', '**')
.replaceAll('%', '/100')
.replaceAll(' ', '')
},
cls = (el, value, type) => {
if (el) {
(type === 'a') ? el.classList.add(value) :
(type === 'r') ? el.classList.remove(value) :
el.classList.toggle(value);
return
}
}