fix: open url

This commit is contained in:
Xmader 2020-12-31 14:08:00 -05:00
parent bb39ebccc9
commit c01d797983
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
1 changed files with 5 additions and 3 deletions

View File

@ -192,17 +192,19 @@ export namespace BtnAction {
else return url
}
export const download = (url: UrlInput, fallback?: () => Promisable<void>, timeout?: number): BtnAction => {
export const download = (url: UrlInput, fallback?: () => Promisable<void>, timeout?: number, target?: '_blank'): BtnAction => {
return process(async (): Promise<void> => {
const _url = await normalizeUrlInput(url)
const a = document.createElement('a')
a.href = _url
a.target = '_blank'
if (target) a.target = target
a.dispatchEvent(new MouseEvent('click'))
}, fallback, timeout)
}
export const openUrl = download
export const openUrl = (url: UrlInput, fallback?: () => Promisable<void>, timeout?: number): BtnAction => {
return download(url, fallback, timeout, '_blank')
}
export const mscoreWindow = (scoreinfo: ScoreInfo, fn: (w: Window, score: WebMscore, processingTextEl: ChildNode) => any): BtnAction => {
return async (btnName, btn, setText) => {