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:
@ -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
|
||||
|
||||
|
5
lib/frontend/constants.js
Normal file
5
lib/frontend/constants.js
Normal file
@ -0,0 +1,5 @@
|
||||
export const STORAGE_KEYS = {
|
||||
CONFIG: 'fb-to-ical-config',
|
||||
EVENTS: 'fb-to-ical-events',
|
||||
}
|
||||
|
@ -24,4 +24,4 @@ const boot = () => {
|
||||
}
|
||||
}
|
||||
|
||||
export default boot
|
||||
boot()
|
||||
|
@ -1,4 +1,4 @@
|
||||
import logger from '../static/app/logger'
|
||||
import logger from './services/logger'
|
||||
import { configStore } from './stores'
|
||||
|
||||
export default () => {
|
||||
|
41
lib/frontend/services/logger.js
Normal file
41
lib/frontend/services/logger.js
Normal 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()
|
@ -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()
|
||||
|
@ -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) || '{}')
|
||||
|
@ -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 = () => {
|
||||
|
Reference in New Issue
Block a user