Advertisement
agregen

IntCyoaCreator download progress indicator

Jan 14th, 2022 (edited)
1,636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.81 KB | None | 0 0
  1. <!-- Insert the following in the beginning of <body> (on the line above <div id="app">) -->
  2. <div id="indicator"><script>{let _XHR = XMLHttpRequest;  XMLHttpRequest = class XHR extends _XHR {constructor () {
  3.   super();
  4.   this.addEventListener('progress', e => {indicator.innerText = " Loading data: " + (!e.total ? `${e.loaded} bytes` : `${(100 * e.loaded / e.total).toFixed(2)}%`)});
  5.   this.addEventListener('loadend', () => {indicator.innerText = ""});
  6. }}}</script></div>
  7. <!-- Modifier: replace `${e.loaded} bytes` with `${(e.loaded/1024**2).toFixed(1)} MB` to display size in MB -->
  8. <!-- Modifier: replace the part after " Loading data: " with `${(100 * e.loaded / (e.total||SIZE)).toFixed(2)}%` to
  9.               always show percentage (SIZE is project.json size in bytes; remember to replace it on every update) -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement