diff --git a/public/css/style.scss b/public/css/style.scss
index a3f3b6a9f..456ee6c87 100644
--- a/public/css/style.scss
+++ b/public/css/style.scss
@@ -778,11 +778,17 @@ key {
}
}
-#restartTestButton, #showWordHistoryButton, #copyResultToClipboardButton {
- position: relative;
+.pageTest #resultExtraButtons{
opacity: 0;
+ display: grid;
+ grid-auto-flow: column;
+ gap: 1rem;
+}
+
+#restartTestButton, #showWordHistoryButton, #copyResultToClipboardButton, #restartTestButtonWithSameWordset {
+ position: relative;
border-radius: var(--roundness);
- padding: 1rem 5rem;
+ padding: 1rem 2rem;
width: min-content;
width: -moz-min-content;
color: var(--sub-color);
diff --git a/public/index.html b/public/index.html
index d74f824ef..b9bcca077 100644
--- a/public/index.html
+++ b/public/index.html
@@ -213,9 +213,12 @@
123
diff --git a/public/js/script.js b/public/js/script.js
index 94e1ee931..834b0b164 100644
--- a/public/js/script.js
+++ b/public/js/script.js
@@ -20,6 +20,7 @@ let resultVisible = false;
let activeWordTopBeforeJump = 0;
let activeWordTop = 0;
let activeWordJumped = false;
+let sameWordset = false;
let accuracyStats = {
correct: 0,
@@ -570,8 +571,7 @@ function showResult(difficultyFailed = false) {
$("#result .stats .time .bottom").text(testtime+'s');
setTimeout(function() {
- $("#showWordHistoryButton").removeClass('hidden').css('opacity',1);
- $("#copyResultToClipboardButton").removeClass('hidden').css('opacity',1);
+ $("#resultExtraButtons").removeClass('hidden').css('opacity',1);
}, 125);
@@ -589,9 +589,11 @@ function showResult(difficultyFailed = false) {
let pbVal = 0;
if(difficultyFailed){
- showNotification("Test failed",3000);
+ showNotification("Test failed",2000);
}else if(afkDetected){
- showNotification("Test invalid - AFK detected",3000);
+ showNotification("Test invalid - AFK detected",2000);
+ }else if(sameWordset){
+ showNotification("Test invalid - repeated",2000);
}else{
let completedEvent = {
wpm: stats.wpm,
@@ -693,6 +695,9 @@ function showResult(difficultyFailed = false) {
if(testInvalid){
otherText += "
invalid"
}
+ if(sameWordset){
+ otherText += "
repeated"
+ }
if(otherText == ""){
$("#result .stats .info").addClass('hidden');
@@ -784,7 +789,7 @@ function showResult(difficultyFailed = false) {
});
}
-function restartTest() {
+function restartTest(withSameWordset = false) {
clearIntervals();
time = 0;
afkDetected = false;
@@ -817,15 +822,10 @@ function restartTest() {
}, 125, ()=>{
$("#wordsTitle").slideUp(0);
});
- $("#showWordHistoryButton").stop(true,true).animate({
+ $("#resultExtraButtons").stop(true,true).animate({
opacity: 0
}, 125, ()=>{
- $("#showWordHistoryButton").addClass('hidden');
- });
- $("#copyResultToClipboardButton").stop(true,true).animate({
- opacity: 0
- }, 125, ()=>{
- $("#copyResultToClipboardButton").addClass('hidden');
+ $("#resultExtraButtons").addClass('hidden');
});
}
resultVisible = false;
@@ -833,7 +833,21 @@ function restartTest() {
el.stop(true, true).animate({
opacity: 0
}, 125, () => {
- initWords();
+ if(!withSameWordset){
+ sameWordset = false;
+ initWords();
+ }else{
+ sameWordset = true;
+ testActive = false;
+ currentWordIndex = 0;
+ accuracyStats = {
+ correct: 0,
+ incorrect: 0
+ }
+ inputHistory = [];
+ currentInput = "";
+ showWords();
+ }
$("#result").addClass('hidden');
$("#words").css('opacity', 0).removeClass('hidden').stop(true, true).animate({
opacity: 1
@@ -1232,6 +1246,20 @@ $(document.body).on("click", "#showWordHistoryButton", (event) => {
toggleResultWordsDisplay();
});
+
+
+$(document.body).on("click", "#restartTestButtonWithSameWordset", (event) => {
+ restartTest(true);
+});
+
+$(document).on("keypress", "#restartTestButtonWithSameWordset", (event) => {
+ if (event.keyCode == 32 || event.keyCode == 13) {
+ restartTest(true);
+ }
+});
+
+
+
$(document.body).on("click", "#copyResultToClipboardButton", (event) => {
copyResultToClipboard();
});