1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-06-05 22:09:25 +02:00

refactor: completely remove existing javascript and use Svelte app

exclusively for rendering
This commit is contained in:
Ondřej Synáček
2020-12-20 15:24:25 +01:00
parent 377a4bcd80
commit 8900474af7
15 changed files with 17 additions and 141 deletions

View File

@ -8,11 +8,16 @@
#form input {
margin: 5px;
}
input#url {
flex: 1;
font-size: 1rem;
}
</style>
<script>
import { createEvent } from '../actions'
import logger from '../../static/app/logger'
import logger from '../services/logger'
let value

View File

@ -0,0 +1,5 @@
export const STORAGE_KEYS = {
CONFIG: 'fb-to-ical-config',
EVENTS: 'fb-to-ical-events',
}

View File

@ -24,4 +24,4 @@ const boot = () => {
}
}
export default boot
boot()

View File

@ -1,4 +1,4 @@
import logger from '../static/app/logger'
import logger from './services/logger'
import { configStore } from './stores'
export default () => {

View File

@ -0,0 +1,41 @@
class Logger {
constructor() {
this._remote = false
}
log({ message, level, service }) {
console.info(
`%c${level}\n%c${service}\n%c${message}`,
'color: white; background-color: blue; font-weight: 800',
'color: grey',
'color: black'
)
if (!this._remote) {
return
}
this._log({ message, level, service })
}
setRemoteLogging(value) {
this._remote = value
}
_log({ message, level, service }) {
return new Promise((resolve, reject) => {
fetch('/track', {
method: 'POST',
headers: {
'Accept': 'text/html, application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({ message, level, service, env: 'browser' })
})
.then(resolve)
.catch(reject)
})
}
}
export default new Logger()

View File

@ -1,10 +1,6 @@
import { STORAGE_KEYS } from '../constants'
import { configStore, eventStore } from '../stores'
export const STORAGE_KEYS = {
CONFIG: 'fb-to-ical-config',
EVENTS: 'fb-to-ical-events',
}
class StorageListener {
constructor() {
this._storeSubscribers = new Set()

View File

@ -1,6 +1,6 @@
import { writable } from 'svelte/store'
import { STORAGE_KEYS } from '../services/storageListener'
import { STORAGE_KEYS } from '../constants'
const createConfigStore = () => {
const state = JSON.parse(localStorage.getItem(STORAGE_KEYS.CONFIG) || '{}')

View File

@ -1,6 +1,6 @@
import { writable } from 'svelte/store'
import { STORAGE_KEYS } from '../services/storageListener'
import { STORAGE_KEYS } from '../constants'
import { migrateRecord, sortRecord } from '../utils'
const createEventStore = () => {