Handle error in a cheap way
This commit is contained in:
parent
53108383eb
commit
76b250f8fd
1 changed files with 6 additions and 2 deletions
|
@ -67,6 +67,10 @@ $(function () {
|
||||||
$('#downloadprogress').text(Math.floor(percent) + '%')
|
$('#downloadprogress').text(Math.floor(percent) + '%')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function failed() {
|
||||||
|
window.location = '#'
|
||||||
|
}
|
||||||
|
|
||||||
function downloadfromident(ident) {
|
function downloadfromident(ident) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,11 +80,11 @@ $(function () {
|
||||||
deletebtn.show().prop('href', (g.config.server ? g.config.server : '') + 'del?delkey=' + stored + '&ident=' + ident.ident)
|
deletebtn.show().prop('href', (g.config.server ? g.config.server : '') + 'del?delkey=' + stored + '&ident=' + ident.ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest()
|
||||||
xhr.onload = downloaded
|
xhr.onload = downloaded
|
||||||
xhr.open('GET', (g.config.server ? g.config.server : '') + 'i/' + ident.ident)
|
xhr.open('GET', (g.config.server ? g.config.server : '') + 'i/' + ident.ident)
|
||||||
xhr.responseType = 'blob'
|
xhr.responseType = 'blob'
|
||||||
|
xhr.onerror = failed
|
||||||
xhr.addEventListener('progress', downloadprogress, false)
|
xhr.addEventListener('progress', downloadprogress, false)
|
||||||
xhr.send()
|
xhr.send()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue