-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathapp.js
48 lines (36 loc) · 1.24 KB
/
app.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
import './bootstrap';
import Alpine from 'alpinejs';
window.Alpine = Alpine;
Alpine.start();
// Textarea identation support
import * as indentation from 'indent-textarea';
const textarea = document.querySelector('textarea');
if (textarea) {
indentation.watch(textarea);
}
// Highlight code blocks and line numbers
import 'highlightjs-line-numbers.js';
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll('pre code').forEach((el) => {
hljs.highlightElement(el);
hljs.lineNumbersBlock(el);
});
});
// Clipboard
import ClipboardJS from 'clipboard';
new ClipboardJS('.copy-btn');
// Dark mode
const darkModeToggles = document.getElementsByClassName('darkModeToggle');
for (let i = 0; i < darkModeToggles.length; i++) {
darkModeToggles[i].onclick = function () {
if (localStorage.theme === 'light') {
localStorage.theme = 'dark';
document.querySelector('html').classList.add('dark');
document.querySelector('html').classList.remove('light');
} else {
localStorage.theme = 'light';
document.querySelector('html').classList.remove('dark');
document.querySelector('html').classList.add('light');
}
};
}