-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
170 lines (147 loc) · 6.02 KB
/
script.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
let icon = document.getElementById("icon")
icon.addEventListener('click', function (event) {
icon.classList.toggle('icons-dark')
let body = document.querySelector("body")
body.classList.toggle('body-dark')
})
let shift_keys = document.querySelectorAll('.shift')
for (let shift_key of shift_keys) {
shift_key.addEventListener('click', function (event) {
let capslock_keys = document.querySelectorAll('.capsLock')
let shift_caps = null
for (let capslock of capslock_keys) {
if (capslock.parentElement.classList.contains('shift')) {
capslock.classList.toggle('capsLock-on')
shift_caps = capslock
}
}
if (shift_caps !== null) {
if (shift_caps.classList.contains('capsLock-on')) {
let xs_keys = document.querySelectorAll('.key-xs')
for (let xs_key of xs_keys) {
if (!xs_key.classList.contains('key-fn')) {
if (xs_key.classList.contains('none-letter'))
xs_key.innerText = xs_key.getAttribute('shift-on')
if (!xs_key.classList.contains('none-letter'))
xs_key.innerText = xs_key.innerText.toUpperCase()
}
}
}
if (!shift_caps.classList.contains('capsLock-on')) {
let xs_keys = document.querySelectorAll('.key-xs')
for (let xs_key of xs_keys) {
if (!xs_key.classList.contains('key-fn')) {
if (xs_key.classList.contains('none-letter'))
xs_key.innerText = xs_key.getAttribute('shift-off')
if (!xs_key.classList.contains('none-letter'))
xs_key.innerText = xs_key.innerText.toLowerCase()
}
}
}
}
})
}
let capslock_key = document.querySelector('.caps-lock')
capslock_key.addEventListener('click', function (event) {
let capslock = this.querySelector('.capsLock')
capslock.classList.toggle('capsLock-on')
if (capslock.classList.contains('capsLock-on')) {
let xs_keys = document.querySelectorAll('.key-xs')
for (let xs_key of xs_keys) {
if (!xs_key.classList.contains('key-fn')) {
if (!xs_key.classList.contains('none-letter'))
xs_key.innerText = xs_key.innerText.toUpperCase()
}
}
}
if (!capslock.classList.contains('capsLock-on')) {
let xs_keys = document.getElementsByClassName('key-xs')
for (let xs_key of xs_keys) {
if (!xs_key.classList.contains('key-fn')) {
if (!xs_key.classList.contains('none-letter'))
xs_key.innerText = xs_key.innerText.toLowerCase()
}
}
}
})
let keys = document.querySelectorAll('.key')
for (let key of keys) {
if (!key.classList.contains('key-fn')) {
key.addEventListener('click', function (even) {
let detail = document.getElementById('detail')
if (key.innerText === 'Tab') {
detail.value += '\u00A0'
detail.value += '\u00A0'
detail.value += '\u00A0'
detail.value += '\u00A0'
} else if (key.innerText === ' ')
detail.value += '\u00A0'
else
detail.value += key.innerText
})
}
}
let delete_key = document.querySelector('.delete')
delete_key.addEventListener('click', function (event) {
let detail = document.getElementById('detail')
let isTab = detail.value.slice(detail.value.length - 4)
if (isTab === '\u00A0\u00A0\u00A0\u00A0')
detail.value = detail.value.slice(0, -4)
else
detail.value = detail.value.slice(0, -1)
})
let enter_key = document.querySelector('.enter')
enter_key.addEventListener('click', function () {
let detail = document.getElementById('detail')
detail.value += '\n'
})
let isHolded = false
let deleteInterval = null
delete_key.onmouseup = function (event) {
isHolded = false
clearInterval(deleteInterval)
}
delete_key.onmousedown = function (event) {
isHolded = true
deleteInterval = setInterval(function () {
if (isHolded) {
let detail = document.getElementById('detail')
let isTab = detail.value.slice(detail.value.length - 4)
if (isTab === '\u00A0\u00A0\u00A0\u00A0')
detail.value = detail.value.slice(0, -4)
else
detail.value = detail.value.slice(0, -1)
}
}, 100)
}
const changeKeyboardMobile = document.getElementById('change-keyboard-mobile')
changeKeyboardMobile.addEventListener('click', function (event) {
if (document.body.clientWidth <= 996) {
let keyBoardMobile = document.getElementsByClassName('keyboard-mobile')[0]
let keyBoardEmoji = document.getElementsByClassName('keyboard-emoji')[0]
if (keyBoardMobile.style.display === "none") {
keyBoardMobile.style.display = "flex";
keyBoardEmoji.style.display = 'none'
} else {
keyBoardMobile.style.display = "none";
keyBoardEmoji.style.display = 'flex'
keyBoardEmoji.style.flexDirection = 'column'
}
}
})
const changeKeyboardEmoji = document.getElementById('change-keyboard-emoji')
changeKeyboardEmoji.addEventListener('click', function (event) {
if (document.body.clientWidth <= 996) {
let keyBoardMobile = document.getElementsByClassName('keyboard-mobile')[0]
let keyBoardEmoji = document.getElementsByClassName('keyboard-emoji')[0]
if (keyBoardMobile.style.display === "none") {
keyBoardMobile.style.display = "flex";
keyBoardEmoji.style.display = 'none'
keyBoardMobile.style.flexDirection = 'column'
} else {
keyBoardMobile.style.display = "none";
keyBoardEmoji.style.display = 'flex'
keyBoardEmoji.style.flexDirection = 'column'
}
}
})