remove manual "no javascript" switch

This was a stupid checkbox made only as an experiment. The page can
still be loaded without JavaScript and works, no need to trigger it
manually.
This commit is contained in:
Ondřej Synáček 2020-07-17 22:33:57 +02:00
parent f577fb6385
commit cf41deedd9
4 changed files with 17 additions and 42 deletions

View File

@ -1,7 +1,3 @@
const noJS = () => {
return Boolean(document.querySelector("#nojs").checked)
}
const useStorage = () => Boolean(window.localStorage)
// NOTE: Generate random IDs: https://stackoverflow.com/a/2117523/3056783
@ -28,7 +24,6 @@ const parseStartTimeFromiCalString = (text = '') => {
}
export {
noJS,
uuidv4,
parseStartTimeFromiCalString,
useStorage,

View File

@ -35,6 +35,12 @@
<input id="submit" type='submit' value='Submit' />
</form>
<noscript>
<div id="nojs" class="notice">
🤚 JavaScript is <em>disabled</em>. Enable to get full experience and offline capabilities.
</div>
</noscript>
<div id="status">
<div class="status-item" id="network">
Fetching file...
@ -50,14 +56,6 @@
<br />
<label for="nojs">
<input id="nojs" type="checkbox" />
No JavaScript
</label>
<br />
<br />
<div class="list-wrapper">
<table id="list" class="hidden">
<thead>

View File

@ -1,4 +1,4 @@
import { noJS, uuidv4, parseStartTimeFromiCalString, useStorage } from './app/utils'
import { uuidv4, parseStartTimeFromiCalString, useStorage } from './app/utils'
import {
migrateRecord,
getStorage,
@ -199,19 +199,8 @@ import generateICS from '../../lib/services/ics-generator'
const link = document.querySelector("#current-download")
const table = document.querySelector('#list')
const tableBody = table.querySelector('tbody')
const noJScheckbox = document.querySelector('#nojs')
const loadNoJS = () => {
if (!useStorage()) {
return
}
const value = localStorage.getItem('fb-to-ical-nojs')
noJScheckbox.checked = value ? JSON.parse(value) : false
}
loadNoJS()
if (window.navigator && window.navigator.serviceWorker && !noJS()) {
if (window.navigator && window.navigator.serviceWorker) {
const serviceWorker = window.navigator.serviceWorker
serviceWorker.register('sw.js', {
scope: './',
@ -245,18 +234,7 @@ import generateICS from '../../lib/services/ics-generator'
})
}
if (!noJS()) {
hydrateList()
}
noJScheckbox.addEventListener('click', (event) => {
if (!useStorage()) {
return
}
localStorage.setItem('fb-to-ical-nojs', event.target.checked)
})
hydrateList()
const handleHTMLResponse = (html) => {
try {
@ -295,10 +273,6 @@ import generateICS from '../../lib/services/ics-generator'
}
submitButton.addEventListener('click', (event) => {
if (noJS()) {
return
}
if (!form.reportValidity()) {
return
}

View File

@ -158,3 +158,11 @@ td.actions a {
a.delete-record {
font-size: 1.2rem;
}
.notice {
font-size: 0.9rem;
}
#nojs {
margin: 5px 0;
}