-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs
29 lines (24 loc) · 1.03 KB
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import UrlHandler from '/src/UrlHandler.mjs'
import SVGRenderer from '/src/SVGRenderer.mjs'
import PNGRenderer from '/src/PNGRenderer.mjs'
//import PDFRenderer from '/src/PDFRenderer.mjs'
const box = document.querySelector('preview-box')
const form = document.querySelector('settings-form')
form.addEventListener('change', (e) => {
box.setAttribute('value', e.detail.url)
box.setAttribute('color', e.detail.color)
box.setAttribute('size', e.detail.size)
box.update()
})
box.setAttribute('value', form.url)
box.setAttribute('color', form.color)
box.setAttribute('size', form.size)
box.update()
document.querySelector('#download-svg').addEventListener('click', async () => {
const shortUrl = await UrlHandler.fetchShortenedUrlWithRetry(form.url)
SVGRenderer.downloadSVG(shortUrl, form.color, form.size)
})
document.querySelector('#download-png').addEventListener('click', async () => {
const shortUrl = await UrlHandler.fetchShortenedUrlWithRetry(form.url)
PNGRenderer.downloadPNG(shortUrl, form.color, form.size)
})