Better progress messages

This commit is contained in:
Kovid Goyal 2016-05-02 20:39:24 +05:30
parent 00d689e6ac
commit c8891928cb
2 changed files with 11 additions and 4 deletions

View File

@ -28,8 +28,7 @@ def load_resources(db, book, root_name, previous_resources, proceed):
v'delete previous_resources[k]' v'delete previous_resources[k]'
if book.manifest.files[root_name].has_maths: if book.manifest.files[root_name].has_maths:
return load_mathjax(db, book, ans, proceed) return load_mathjax(db, book, ans, proceed)
proceed(ans) return proceed(ans)
return
name = pending_resources.shift() name = pending_resources.shift()
if ans[name]: if ans[name]:
return setTimeout(do_one, 0) return setTimeout(do_one, 0)

View File

@ -199,7 +199,11 @@ class ReadUI:
for name in progress_track: for name in progress_track:
x += progress_track[name] x += progress_track[name]
pbar.setAttribute('value', x + '') pbar.setAttribute('value', x + '')
progress.lastChild.textContent = _('Downloaded {0}, {1} left').format(human_readable(x), human_readable(total - x)) if x is total:
msg = _('Downloaded {}, saving to disk, this may take a few seconds...').format(human_readable(total))
else:
msg = _('Downloaded {0}, {1} left').format(human_readable(x), human_readable(total - x))
progress.lastChild.textContent = msg
def show_failure(): def show_failure():
det = ['<h4>{}</h4><div>{}</div><hr>'.format(fname, err_html) for fname, err_html in failed_files].join('') det = ['<h4>{}</h4><div>{}</div><hr>'.format(fname, err_html) for fname, err_html in failed_files].join('')
@ -312,7 +316,11 @@ class ReadUI:
for name in progress_track: for name in progress_track:
x += progress_track[name] x += progress_track[name]
pbar.setAttribute('value', x + '') pbar.setAttribute('value', x + '')
progress.lastChild.textContent = _('Downloaded {0}, {1} left').format(human_readable(x), human_readable(total - x)) if x is total:
msg = _('Downloaded {}, saving to disk, this may take a few seconds...').format(human_readable(total))
else:
msg = _('Downloaded {0}, {1} left').format(human_readable(x), human_readable(total - x))
progress.lastChild.textContent = msg
def on_progress(loaded, ftotal): def on_progress(loaded, ftotal):
progress_track[this] = loaded progress_track[this] = loaded