From a176146843afff058dfe783ed5aa4d9d7a91eeb1 Mon Sep 17 00:00:00 2001 From: Kognise Date: Sat, 6 Apr 2019 16:50:52 -0400 Subject: [PATCH] Fix script --- dev.js | 14 +++++++++++++- index.html | 2 +- script.js | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dev.js b/dev.js index 9f65da5..f3c5ac1 100644 --- a/dev.js +++ b/dev.js @@ -18,6 +18,13 @@ app.get('/', async (req, res) => { res.send(injected) }) +app.get('/script.js', async (req, res) => { + console.log('> Serving script') + const script = await fs.readFile('script.js') + res.contentType('javascript') + res.send(script) +}) + app.use('/dist', (req, res, next) => { console.log('> Serving a stylesheet') next() @@ -33,7 +40,12 @@ chokidar.watch('index.html', { ignoreInitial: true }).on('all', () => { reload() }) -chokidar.watch('src/*.scss', { ignoreInitial: true }).on('all', async (event, file) => { +chokidar.watch('script.js', { ignoreInitial: true }).on('all', () => { + console.log('> Script changed') + reload() +}) + +chokidar.watch('src/*.scss', { ignoreInitial: true }).on('all', (event, file) => { console.log('> Stylesheet changed') sass.render({ file, outputStyle: 'compressed' }, async (errors, { css }) => { if (errors) { diff --git a/index.html b/index.html index 9e1c690..3f133aa 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ Water.css - + diff --git a/script.js b/script.js index 71b4935..f4d239d 100644 --- a/script.js +++ b/script.js @@ -1,8 +1,11 @@ document.getElementById('switch').addEventListener('click', () => { const stylesheet = document.getElementById('stylesheet') + const ph = document.getElementById('ph') if (stylesheet.getAttribute('href') === 'dist/dark.css') { stylesheet.setAttribute('href', 'dist/light.css') + ph.src = ph.src.replace('theme=dark', 'theme=light') } else { stylesheet.setAttribute('href', 'dist/dark.css') + ph.src = ph.src.replace('theme=light', 'theme=dark') } }) \ No newline at end of file