|
47 | 47 | let weekCH = document.getElementById('weekCH')
|
48 | 48 | let countdownDays = document.getElementById('countdownDays')
|
49 | 49 | let miniCountdown = document.getElementById('miniCountdown')
|
| 50 | + let root = document.querySelector(':root'); |
50 | 51 | let isClassCountdown = true
|
51 | 52 | let isClassHidden = true
|
52 | 53 | let lastScheduleData = {
|
|
57 | 58 | countdown: null,
|
58 | 59 | countdownText: null
|
59 | 60 | },
|
60 |
| - scheduleArray: [null, null, null] |
| 61 | + scheduleArray: [null, null, null], |
| 62 | + timetable: null, |
| 63 | + divider: [null, null] |
61 | 64 | }
|
62 | 65 |
|
63 | 66 | function setScheduleClass() {
|
|
75 | 78 | else
|
76 | 79 | classHtml += `<div class="class">${scheduleData.scheduleArray[i]}</div>`
|
77 | 80 | }
|
| 81 | + if (scheduleData.divider.indexOf(i) != -1) |
| 82 | + classHtml += '<div class="divider"></div>' |
78 | 83 | }
|
79 | 84 | classContainer.innerHTML = classHtml
|
80 | 85 | }
|
81 | 86 |
|
82 |
| - function setBackgroundDisplay(){ |
| 87 | + function setBackgroundDisplay() { |
83 | 88 | let elements = document.getElementsByClassName('background')
|
84 |
| - for (element of elements){ |
| 89 | + for (element of elements) { |
85 | 90 | element.style.visibility = (scheduleData.currentHighlight.type === 'current' && isClassHidden) ? 'hidden' : 'visible'
|
86 | 91 | }
|
87 | 92 | }
|
|
120 | 125 | y: classContainer.offsetHeight
|
121 | 126 | }
|
122 | 127 | } else if (scheduleData.currentHighlight.type === 'upcoming') {
|
123 |
| - offset = { |
124 |
| - x: highlightElement.offsetLeft - countdownContainer.offsetWidth / 2 - Number(getComputedStyle(highlightElement).marginLeft.replace('px', '')), |
125 |
| - y: classContainer.offsetHeight |
| 128 | + if (scheduleData.currentHighlight.index != 0 && scheduleData.divider.indexOf((scheduleData.currentHighlight.index - 1)) != -1) { |
| 129 | + offset = { |
| 130 | + x: highlightElement.offsetLeft - countdownContainer.offsetWidth / 2 - Number(getComputedStyle(highlightElement).marginLeft.replace('px', '')) - getComputedStyle(root).getPropertyValue('--divider-width').replace('px', '') / 2 - getComputedStyle(root).getPropertyValue('--divider-margin').replace('px', ''), |
| 131 | + y: classContainer.offsetHeight |
| 132 | + } |
| 133 | + } else { |
| 134 | + offset = { |
| 135 | + x: highlightElement.offsetLeft - countdownContainer.offsetWidth / 2 - Number(getComputedStyle(highlightElement).marginLeft.replace('px', '')), |
| 136 | + y: classContainer.offsetHeight |
| 137 | + } |
126 | 138 | }
|
127 | 139 | }
|
128 | 140 | if (scheduleData.currentHighlight.isEnd) {
|
|
162 | 174 |
|
163 | 175 | let lastTickTime = new Date().getTime()
|
164 | 176 | setInterval(() => {
|
165 |
| - if (new Date().getTime() - lastTickTime >= 1000){ |
| 177 | + if (new Date().getTime() - lastTickTime >= 1000) { |
166 | 178 | lastTickTime = new Date().getTime()
|
167 | 179 | tick()
|
168 | 180 | }
|
169 | 181 | }, 20);
|
170 | 182 |
|
171 |
| - const root = document.querySelector(':root'); |
172 | 183 | for (key in scheduleConfig.css_style) {
|
173 | 184 | root.style.setProperty(key, scheduleConfig.css_style[key])
|
174 | 185 | }
|
|
181 | 192 | timer = setTimeout(() => {
|
182 | 193 | root.style.opacity = '1'
|
183 | 194 | }, 5000);
|
184 |
| - }else{ |
| 195 | + } else { |
185 | 196 | clearTimeout(timer)
|
186 | 197 | root.style.opacity = '1'
|
187 |
| - } |
| 198 | + } |
188 | 199 | if (event.target.className.indexOf('notIgnoreClick') == -1) {
|
189 | 200 | ipcRenderer.send('setIgnore', true)
|
190 | 201 | } else {
|
191 | 202 | ipcRenderer.send('setIgnore', false)
|
192 | 203 | }
|
193 |
| - |
| 204 | + |
194 | 205 | });
|
195 | 206 | ipcRenderer.send('setIgnore', true)
|
196 | 207 |
|
|
0 commit comments