summaryrefslogtreecommitdiffstats
path: root/static/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/app.js')
-rw-r--r--static/app.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/static/app.js b/static/app.js
new file mode 100644
index 0000000..1168281
--- /dev/null
+++ b/static/app.js
@@ -0,0 +1,30 @@
+document.getElementById('file').addEventListener('change', function() {
+ const name = this.files.length ? this.files[0].name : '';
+ document.getElementById('filename').textContent = name;
+});
+
+(function() {
+ var toggleBtn = document.getElementById('theme-toggle');
+
+ function isLight() {
+ return document.documentElement.getAttribute('data-theme') === 'light';
+ }
+
+ function updateIcon() {
+ // Shows the icon for the theme you'd switch TO.
+ toggleBtn.textContent = isLight() ? '\u{1F319}' : '☀️';
+ }
+
+ toggleBtn.addEventListener('click', function() {
+ if (isLight()) {
+ document.documentElement.removeAttribute('data-theme');
+ localStorage.setItem('nymdrop-theme', 'dark');
+ } else {
+ document.documentElement.setAttribute('data-theme', 'light');
+ localStorage.setItem('nymdrop-theme', 'light');
+ }
+ updateIcon();
+ });
+
+ updateIcon();
+})();