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:
parent
f577fb6385
commit
cf41deedd9
|
@ -1,7 +1,3 @@
|
||||||
const noJS = () => {
|
|
||||||
return Boolean(document.querySelector("#nojs").checked)
|
|
||||||
}
|
|
||||||
|
|
||||||
const useStorage = () => Boolean(window.localStorage)
|
const useStorage = () => Boolean(window.localStorage)
|
||||||
|
|
||||||
// NOTE: Generate random IDs: https://stackoverflow.com/a/2117523/3056783
|
// NOTE: Generate random IDs: https://stackoverflow.com/a/2117523/3056783
|
||||||
|
@ -28,7 +24,6 @@ const parseStartTimeFromiCalString = (text = '') => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
noJS,
|
|
||||||
uuidv4,
|
uuidv4,
|
||||||
parseStartTimeFromiCalString,
|
parseStartTimeFromiCalString,
|
||||||
useStorage,
|
useStorage,
|
||||||
|
|
|
@ -35,6 +35,12 @@
|
||||||
<input id="submit" type='submit' value='Submit' />
|
<input id="submit" type='submit' value='Submit' />
|
||||||
</form>
|
</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 id="status">
|
||||||
<div class="status-item" id="network">
|
<div class="status-item" id="network">
|
||||||
Fetching file...
|
Fetching file...
|
||||||
|
@ -50,14 +56,6 @@
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<label for="nojs">
|
|
||||||
<input id="nojs" type="checkbox" />
|
|
||||||
No JavaScript
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<div class="list-wrapper">
|
<div class="list-wrapper">
|
||||||
<table id="list" class="hidden">
|
<table id="list" class="hidden">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { noJS, uuidv4, parseStartTimeFromiCalString, useStorage } from './app/utils'
|
import { uuidv4, parseStartTimeFromiCalString, useStorage } from './app/utils'
|
||||||
import {
|
import {
|
||||||
migrateRecord,
|
migrateRecord,
|
||||||
getStorage,
|
getStorage,
|
||||||
|
@ -199,19 +199,8 @@ import generateICS from '../../lib/services/ics-generator'
|
||||||
const link = document.querySelector("#current-download")
|
const link = document.querySelector("#current-download")
|
||||||
const table = document.querySelector('#list')
|
const table = document.querySelector('#list')
|
||||||
const tableBody = table.querySelector('tbody')
|
const tableBody = table.querySelector('tbody')
|
||||||
const noJScheckbox = document.querySelector('#nojs')
|
|
||||||
|
|
||||||
const loadNoJS = () => {
|
if (window.navigator && window.navigator.serviceWorker) {
|
||||||
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()) {
|
|
||||||
const serviceWorker = window.navigator.serviceWorker
|
const serviceWorker = window.navigator.serviceWorker
|
||||||
serviceWorker.register('sw.js', {
|
serviceWorker.register('sw.js', {
|
||||||
scope: './',
|
scope: './',
|
||||||
|
@ -245,18 +234,7 @@ import generateICS from '../../lib/services/ics-generator'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!noJS()) {
|
hydrateList()
|
||||||
hydrateList()
|
|
||||||
}
|
|
||||||
|
|
||||||
noJScheckbox.addEventListener('click', (event) => {
|
|
||||||
if (!useStorage()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
localStorage.setItem('fb-to-ical-nojs', event.target.checked)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const handleHTMLResponse = (html) => {
|
const handleHTMLResponse = (html) => {
|
||||||
try {
|
try {
|
||||||
|
@ -295,10 +273,6 @@ import generateICS from '../../lib/services/ics-generator'
|
||||||
}
|
}
|
||||||
|
|
||||||
submitButton.addEventListener('click', (event) => {
|
submitButton.addEventListener('click', (event) => {
|
||||||
if (noJS()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!form.reportValidity()) {
|
if (!form.reportValidity()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,3 +158,11 @@ td.actions a {
|
||||||
a.delete-record {
|
a.delete-record {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notice {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#nojs {
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue