mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-02-04 14:39:02 +08:00
changed evens on test complete
added login tip added required password confirmation when registering
This commit is contained in:
parent
16219f12ca
commit
1f48191e10
13 changed files with 3261 additions and 9 deletions
|
|
@ -10,11 +10,18 @@
|
|||
"**/node_modules/**"
|
||||
],
|
||||
"redirects": [],
|
||||
"rewrites": [{
|
||||
"source": "**",
|
||||
"destination": "/soon.html"
|
||||
}],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "**",
|
||||
"destination": "/soon.html"
|
||||
}
|
||||
],
|
||||
"cleanUrls": true,
|
||||
"trailingSlash": false
|
||||
},
|
||||
"functions": {
|
||||
"predeploy": [
|
||||
"npm --prefix \"$RESOURCE_DIR\" run lint"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
123
functions/.eslintrc.json
Normal file
123
functions/.eslintrc.json
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
{
|
||||
"parserOptions": {
|
||||
// Required for certain syntax usages
|
||||
"ecmaVersion": 2017
|
||||
},
|
||||
"plugins": [
|
||||
"promise"
|
||||
],
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
// Removed rule "disallow the use of console" from recommended eslint rules
|
||||
"no-console": "off",
|
||||
|
||||
// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules
|
||||
"no-regex-spaces": "off",
|
||||
|
||||
// Removed rule "disallow the use of debugger" from recommended eslint rules
|
||||
"no-debugger": "off",
|
||||
|
||||
// Removed rule "disallow unused variables" from recommended eslint rules
|
||||
"no-unused-vars": "off",
|
||||
|
||||
// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules
|
||||
"no-mixed-spaces-and-tabs": "off",
|
||||
|
||||
// Removed rule "disallow the use of undeclared variables unless mentioned in /*global */ comments" from recommended eslint rules
|
||||
"no-undef": "off",
|
||||
|
||||
// Warn against template literal placeholder syntax in regular strings
|
||||
"no-template-curly-in-string": 1,
|
||||
|
||||
// Warn if return statements do not either always or never specify values
|
||||
"consistent-return": 1,
|
||||
|
||||
// Warn if no return statements in callbacks of array methods
|
||||
"array-callback-return": 1,
|
||||
|
||||
// Require the use of === and !==
|
||||
"eqeqeq": 2,
|
||||
|
||||
// Disallow the use of alert, confirm, and prompt
|
||||
"no-alert": 2,
|
||||
|
||||
// Disallow the use of arguments.caller or arguments.callee
|
||||
"no-caller": 2,
|
||||
|
||||
// Disallow null comparisons without type-checking operators
|
||||
"no-eq-null": 2,
|
||||
|
||||
// Disallow the use of eval()
|
||||
"no-eval": 2,
|
||||
|
||||
// Warn against extending native types
|
||||
"no-extend-native": 1,
|
||||
|
||||
// Warn against unnecessary calls to .bind()
|
||||
"no-extra-bind": 1,
|
||||
|
||||
// Warn against unnecessary labels
|
||||
"no-extra-label": 1,
|
||||
|
||||
// Disallow leading or trailing decimal points in numeric literals
|
||||
"no-floating-decimal": 2,
|
||||
|
||||
// Warn against shorthand type conversions
|
||||
"no-implicit-coercion": 1,
|
||||
|
||||
// Warn against function declarations and expressions inside loop statements
|
||||
"no-loop-func": 1,
|
||||
|
||||
// Disallow new operators with the Function object
|
||||
"no-new-func": 2,
|
||||
|
||||
// Warn against new operators with the String, Number, and Boolean objects
|
||||
"no-new-wrappers": 1,
|
||||
|
||||
// Disallow throwing literals as exceptions
|
||||
"no-throw-literal": 2,
|
||||
|
||||
// Require using Error objects as Promise rejection reasons
|
||||
"prefer-promise-reject-errors": 2,
|
||||
|
||||
// Enforce “for” loop update clause moving the counter in the right direction
|
||||
"for-direction": 2,
|
||||
|
||||
// Enforce return statements in getters
|
||||
"getter-return": 2,
|
||||
|
||||
// Disallow await inside of loops
|
||||
"no-await-in-loop": 2,
|
||||
|
||||
// Disallow comparing against -0
|
||||
"no-compare-neg-zero": 2,
|
||||
|
||||
// Warn against catch clause parameters from shadowing variables in the outer scope
|
||||
"no-catch-shadow": 1,
|
||||
|
||||
// Disallow identifiers from shadowing restricted names
|
||||
"no-shadow-restricted-names": 2,
|
||||
|
||||
// Enforce return statements in callbacks of array methods
|
||||
"callback-return": 2,
|
||||
|
||||
// Require error handling in callbacks
|
||||
"handle-callback-err": 2,
|
||||
|
||||
// Warn against string concatenation with __dirname and __filename
|
||||
"no-path-concat": 1,
|
||||
|
||||
// Prefer using arrow functions for callbacks
|
||||
"prefer-arrow-callback": 1,
|
||||
|
||||
// Return inside each then() to create readable and reusable Promise chains.
|
||||
// Forces developers to return console logs and http calls in promises.
|
||||
"promise/always-return": 2,
|
||||
|
||||
//Enforces the use of catch() on un-returned promises
|
||||
"promise/catch-or-return": 2,
|
||||
|
||||
// Warn against nested then() or catch() statements
|
||||
"promise/no-nesting": 1
|
||||
}
|
||||
}
|
||||
1
functions/.gitignore
vendored
Normal file
1
functions/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
node_modules/
|
||||
30
functions/index.js
Normal file
30
functions/index.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
const functions = require('firebase-functions');
|
||||
|
||||
const admin = require('firebase-admin');
|
||||
admin.initializeApp();
|
||||
|
||||
|
||||
// // Create and Deploy Your First Cloud Functions
|
||||
// // https://firebase.google.com/docs/functions/write-firebase-functions
|
||||
//
|
||||
// exports.helloWorld = functions.https.onRequest((request, response) => {
|
||||
// response.send("Hello from Firebase!");
|
||||
// });
|
||||
|
||||
|
||||
exports.sendEmailNotification = functions.https.onRequest(async (request, response) => {
|
||||
admin.firestore().collection('mail').add({
|
||||
to: "bartnikjack@gmail.com",
|
||||
message: {
|
||||
subject: request.query.subject,
|
||||
html: request.query.body,
|
||||
}
|
||||
}).then(() => {
|
||||
console.log('Email queued');
|
||||
return response.send('Email queued');
|
||||
}).catch((e) => {
|
||||
console.log('Error adding email to queue ' + e);
|
||||
return response.send('Error adding email to queue ' + e);
|
||||
|
||||
});
|
||||
});
|
||||
3008
functions/package-lock.json
generated
Normal file
3008
functions/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
25
functions/package.json
Normal file
25
functions/package.json
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "functions",
|
||||
"description": "Cloud Functions for Firebase",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"serve": "firebase emulators:start --only functions",
|
||||
"shell": "firebase functions:shell",
|
||||
"start": "npm run shell",
|
||||
"deploy": "firebase deploy --only functions",
|
||||
"logs": "firebase functions:log"
|
||||
},
|
||||
"engines": {
|
||||
"node": "8"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase-admin": "^8.10.0",
|
||||
"firebase-functions": "^3.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.12.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"firebase-functions-test": "^0.2.0"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
30
package-lock.json
generated
Normal file
30
package-lock.json
generated
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"cors": {
|
||||
"version": "2.8.5",
|
||||
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
||||
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
||||
"requires": {
|
||||
"object-assign": "^4",
|
||||
"vary": "^1"
|
||||
}
|
||||
},
|
||||
"nodemailer": {
|
||||
"version": "6.4.6",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.6.tgz",
|
||||
"integrity": "sha512-/kJ+FYVEm2HuUlw87hjSqTss+GU35D4giOpdSfGp7DO+5h6RlJj7R94YaYHOkoxu1CSaM0d3WRBtCzwXrY6MKA=="
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
|
||||
},
|
||||
"vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -155,6 +155,8 @@
|
|||
<div class="title">wpm over time</div>
|
||||
<canvas id="wpmChart"></canvas>
|
||||
</div>
|
||||
<div class="loginTip">Sign in to save your results</div>
|
||||
|
||||
</div>
|
||||
<div id="restartTestButton" class="" tabindex="0"><i class="fas fa-redo-alt"></i></div>
|
||||
<div id="liveWpm">123</div>
|
||||
|
|
@ -195,6 +197,7 @@
|
|||
<input type="text" placeholder="name">
|
||||
<input type="text" placeholder="email">
|
||||
<input type="password" placeholder="password">
|
||||
<input type="password" placeholder="verify password">
|
||||
</form>
|
||||
</div>
|
||||
<div class="login side">
|
||||
|
|
|
|||
|
|
@ -597,6 +597,15 @@ key {
|
|||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
#result .loginTip {
|
||||
-ms-grid-column: 1;
|
||||
-ms-grid-column-span: 2;
|
||||
grid-column: 1/3;
|
||||
text-align: center;
|
||||
margin-top: 3rem;
|
||||
color: var(--sub-color);
|
||||
}
|
||||
|
||||
#result .stats {
|
||||
display: -ms-grid;
|
||||
display: grid;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -492,6 +492,12 @@ key {
|
|||
}
|
||||
height: 100%;
|
||||
}
|
||||
.loginTip{
|
||||
grid-column: 1/3;
|
||||
text-align: center;
|
||||
margin-top: 3rem;
|
||||
color: var(--sub-color);
|
||||
}
|
||||
.stats{
|
||||
display: grid;
|
||||
gap: .5rem;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ $(".pageLogin .register input").keyup(e => {
|
|||
let name = $(".pageLogin .register input")[0].value;
|
||||
let email = $(".pageLogin .register input")[1].value;
|
||||
let password = $(".pageLogin .register input")[2].value;
|
||||
let passwordVerify = $(".pageLogin .register input")[3].value;
|
||||
|
||||
if (password != passwordVerify) {
|
||||
showNotification("Passwords do not match",3000);
|
||||
return;
|
||||
}
|
||||
|
||||
firebase.auth().createUserWithEmailAndPassword(email, password).then(user => {
|
||||
// Account has been created here.
|
||||
|
|
|
|||
|
|
@ -430,19 +430,23 @@ function showResult() {
|
|||
showCrown();
|
||||
}
|
||||
completedEvent.uid = firebase.auth().currentUser.uid;
|
||||
firebase.analytics().logEvent('testCompleted', completedEvent);
|
||||
db_testCompleted(completedEvent);
|
||||
dbSnapshot.unshift(completedEvent);
|
||||
});
|
||||
$("#result .loginTip").addClass('hidden');
|
||||
} else {
|
||||
showNotification("Sign in to save your result",3000);
|
||||
firebase.analytics().logEvent('testCompletedNoLogin', completedEvent);
|
||||
$("#result .loginTip").removeClass('hidden');
|
||||
|
||||
// showNotification("Sign in to save your result",3000);
|
||||
}
|
||||
completedEvent.valid = true;
|
||||
} else {
|
||||
showNotification("Test invalid", 3000);
|
||||
completedEvent.valid = false;
|
||||
firebase.analytics().logEvent('testCompletedInvalid', completedEvent);
|
||||
|
||||
}
|
||||
|
||||
firebase.analytics().logEvent('testCompleted', completedEvent);
|
||||
|
||||
let infoText = "";
|
||||
infoText = config.mode;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue