diff --git a/index.html b/index.html index 81fc938..e559ccb 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ body { background-color: #1e1e1e; color: #f0f0f0; + font-family: 'Courier New', monospace; } table { @@ -19,7 +20,7 @@ th, td { padding: 12px; - text-align: center; + text-align: left; border-bottom: 1px solid #ddd; } @@ -37,8 +38,7 @@ Name Added At - Completed tests - Started tests + Compl./started Time Typing Best 15s Best 30s @@ -69,7 +69,15 @@ for (url of urls) { fetch(url) - .then(response => response.json()) + .then(response => { + if(response.status == 429) { + throw new Error('Rate limiting triggered, please wait a few minutes'); + } + else if(!response.ok) { + throw new Error('Code ' + response.status); + } + return response.json(); + }) .then(data => { const { name, addedAt, typingStats, personalBests } = data.data; const { completedTests, startedTests, timeTyping } = typingStats; @@ -83,7 +91,11 @@ max_acc = acc; } } - return max_wpm + ' | ' + max_acc + '%'; + + max_wpm = Math.round(max_wpm); + // set max_wpm to fixed-length of 3 + max_wpm = ' '.repeat(3 - max_wpm.toString().length) + max_wpm; + return '' + max_wpm + ' ' + max_acc.toFixed(1) + '%'; } const best15s = getMaxWpmAcc(time['15']); @@ -99,8 +111,7 @@ ${name} ${new Date(addedAt).toLocaleDateString()} - ${completedTests} - ${startedTests} + ${completedTests}/${startedTests} ${new Date(timeTyping * 1000).toISOString().substr(11, 8)} ${best15s} ${best30s} @@ -115,7 +126,7 @@ table.insertAdjacentHTML('beforeend', row); }) - .catch(error => { alert(error); console.error(error); }); + .catch(error => { document.body.insertAdjacentHTML('beforeend', '

' + error + '

') }); }