feat(individual parts): multiple download types
This commit is contained in:
parent
d124065af2
commit
32989a1254
1 changed files with 15 additions and 13 deletions
28
src/main.ts
28
src/main.ts
|
@ -85,25 +85,27 @@ const main = (): void => {
|
|||
fieldset.append(e, label, br)
|
||||
}
|
||||
|
||||
// submit button
|
||||
const submitBtn = w.document.createElement('input')
|
||||
submitBtn.type = 'submit'
|
||||
submitBtn.value = 'Download PDF'
|
||||
fieldset.append(submitBtn)
|
||||
// submit buttons
|
||||
for (const btn of btns) {
|
||||
const submitBtn = w.document.createElement('input')
|
||||
submitBtn.type = 'submit'
|
||||
submitBtn.value = btn.name
|
||||
fieldset.append(submitBtn)
|
||||
|
||||
const onSubmit = async (): Promise<void> => {
|
||||
// lock the button when processing
|
||||
submitBtn.onclick = null
|
||||
const onSubmit = async (): Promise<void> => {
|
||||
// lock the button when processing
|
||||
submitBtn.onclick = null
|
||||
|
||||
const checked = fieldset.querySelector('input:checked') as HTMLInputElement
|
||||
const partName = checked.alt
|
||||
const checked = fieldset.querySelector('input:checked') as HTMLInputElement
|
||||
const partName = checked.alt
|
||||
|
||||
const data = new Blob([await score.savePdf()])
|
||||
saveAs(data, `${filename} - ${partName}.pdf`)
|
||||
const data = new Blob([await btn.action(score)])
|
||||
saveAs(data, `${filename} - ${partName}.${btn.fileExt}`)
|
||||
|
||||
submitBtn.onclick = onSubmit
|
||||
}
|
||||
submitBtn.onclick = onSubmit
|
||||
}
|
||||
submitBtn.onclick = onSubmit
|
||||
}),
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue