Skip to content

Commit

Permalink
Merge branch 'master' into otakar
Browse files Browse the repository at this point in the history
  • Loading branch information
Otakar Andrysek authored Jan 26, 2017
2 parents 19cb217 + 04466a2 commit c762549
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Typing Test
![GIF of typing test](https://github.com/SST-CTF/typing-test/blob/master/Documentation/Nov-22-2016%16-12-36?raw=true)
[![Code Climate](https://codeclimate.com/github/SST-CTF/typing-test/badges/gpa.svg)](https://codeclimate.com/github/SST-CTF/typing-test)
[![Issue Count](https://codeclimate.com/github/SST-CTF/typing-test/badges/issue_count.svg)](https://codeclimate.com/github/SST-CTF/typing-test)
![GIF of typing test](https://github.com/SST-CTF/typing-test/blob/master/docs/Nov-22-2016%2016-12-36.gif?raw=true)
#### [Live demo ](https://sst-ctf.github.io/typing-test/)
## Description
The best way to test typing speed and accuracy for a user provided string. This JS + HTML combo can be run server or client side.
Expand Down
36 changes: 18 additions & 18 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function readTextFile(file, arrayData)
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
if(rawFile.status == 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;
strToTest = new Array(allText);
Expand Down Expand Up @@ -129,23 +129,23 @@ function deterCPProtect() {
for (var i = 0; i < fields.length; i++) {
var field = fields[i];

if (typeof field.onpaste != "function" && !!field.getAttribute("onpaste")) {
if (typeof field.onpaste !== "function" && !!field.getAttribute("onpaste")) {
field.onpaste = eval("(function () { " + field.getAttribute("onpaste") + " })");
}

if (typeof field.onpaste == "function") {
if (typeof field.onpaste === "function") {
var oninput = field.oninput;

field.oninput = function () {
if (typeof oninput == "function") {
if (typeof oninput === "function") {
oninput.apply(this, arguments);
}

if (typeof this.previousValue == "undefined") {
this.previousValue = this.value;
}

var pasted = (Math.abs(this.previousValue.length - this.value.length) > 1 && this.value != "");
var pasted = (Math.abs(this.previousValue.length - this.value.length) > 1 && this.value !== "");

if (pasted && !this.onpaste.apply(this, arguments)) {
this.value = this.previousValue;
Expand Down Expand Up @@ -232,7 +232,7 @@ function endTest() {
var typedWord = typedValues[i];

//Determine if the user typed the correct word or incorrect
if (typedWord != neededWord) {
if (typedWord !== neededWord) {
//They typed it incorrectly, so increment the bad words counter
badWords = badWords + 1;
errWords += typedWord + " = " + neededWord + "\n";
Expand Down Expand Up @@ -339,7 +339,7 @@ function calcStat() {
}

//Determine if the test is complete based on them having typed everything exactly as expected
if (thisTyped.value == document.JobOp.given.value) {
if (thisTyped.value === document.JobOp.given.value) {
endTest();
}

Expand All @@ -354,7 +354,7 @@ function calcStat() {
}

//Our handy error handling
} catch (e) {};
} catch (e) {}
}

// Takes name from prompt, ready to store into MYSQL
Expand All @@ -363,14 +363,14 @@ function myFunction()
var person = prompt("Please enter your name", "");
// Profanity Filter (if there is a better way to do this LMK)
if (
person.search("ota") == - 1 &&
person.search("Ota") == - 1 &&
person.search("fruhwirth") == - 1 &&
person.search("Fruhwirth") == - 1 &&
person.search("morales") == - 1 &&
person.search("Morales") == - 1 &&
person.search("cena") == - 1 &&
person.search("Cena") == - 1
person.search("ota") === - 1 &&
person.search("Ota") === - 1 &&
person.search("fruhwirth") === - 1 &&
person.search("Fruhwirth") === - 1 &&
person.search("morales") === - 1 &&
person.search("Morales") === - 1 &&
person.search("cena") === - 1 &&
person.search("Cena") === - 1
)
{
alert(person);
Expand All @@ -395,8 +395,8 @@ function myFunction()

// Simply does a check on focus to determine if the test has started
function doCheck() {
if (hasStarted == false) {
if (hasStarted === false) {
// The test has not started, but the user is typing already -- maybe we should start?
beginTest(); // Yes, we should -- consider it done!
}
}
}

0 comments on commit c762549

Please sign in to comment.