| 243 | |
| 244 | const $log = $('<div>'); |
| 245 | const appendToLog = (msg) => { |
| 246 | if (typeof msg === 'string') msg = document.createTextNode(msg); |
| 247 | // Add some margin to cover rounding error and to make it easier to engage the auto-scroll. |
| 248 | const scrolledToBottom = $log[0].scrollHeight <= $log[0].scrollTop + $log[0].clientHeight + 5; |
| 249 | const $msg = $('<div>').css('white-space', 'nowrap').append(msg).appendTo($log); |
| 250 | if (scrolledToBottom) $log[0].scrollTop = $log[0].scrollHeight; |
| 251 | return $msg; |
| 252 | }; |
| 253 | const $bar = $('<progress>'); |
| 254 | let barLastUpdate = Date.now(); |
| 255 | const incrementBar = async (amount = 1) => { |