Skip to content

Commit

Permalink
Code updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
halfnibble committed Aug 14, 2019
1 parent f3c34b1 commit 7a6d46f
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 185 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ typings/

# Cloud 9
.c9

# JS build output
dist/main.js

# package lock file
package-lock.json
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ One of your teammates has already finished the NameValidator. Look at it for gui

## Instruction

1. Clone the [web-150-finale](https://ide.c9.io/halfnibble_1/web-150-finale) Cloud9 workspace. You need at least one clone per team.
1. Clone the [web-150-finale](https://github.com/SeattleCentral/web150_finale) git repo and change into the dir.

```
git clone https://github.com/SeattleCentral/web150_finale
cd web150_finale/
```
2. Run `npm install` to make sure you have all the required dependencies.
3. Start Gulp with `gulp`.
3. Start the dev server with `npm run dev`.
4. Assign a validator function constructor to each member of your team. There are 5 validators total you may assign, 1 per team member
- PhoneValidator
- EmailValidator
Expand Down
2 changes: 1 addition & 1 deletion index.html → dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,6 @@ <h6 class="my-0">Promo code</h6>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/build/app.js"></script>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
19 changes: 0 additions & 19 deletions gulpfile.js

This file was deleted.

127 changes: 0 additions & 127 deletions js/build/app.js

This file was deleted.

56 changes: 28 additions & 28 deletions js/validators/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@
* Date Submitted: 2018-08-15
*/

var NameValidator = function(fieldId) {
this.id = fieldId;
this.element = document.getElementById(fieldId);
console.log(this.element.parentElement);
this.errorElement = this.element.parentElement
.getElementsByClassName('invalid-feedback')[0];
console.log(this.errorElement);
this.setup();
}
class NameValidator {

NameValidator.prototype.setup = function() {
this.element.addEventListener('keyup', (event) => {
if (this.valid()) {
this.hideErrorMessage();
} else {
this.showErrorMessage();
}
}, false);
}
constructor(fieldId) {
this.id = fieldId;
this.element = document.getElementById(fieldId);
this.errorElement = this.element.parentElement
.getElementsByClassName('invalid-feedback')[0];
this.setup();
}

NameValidator.prototype.valid = function() {
let value = this.element.value;
return /^\D{2,}/.test(value);
}
setup() {
this.element.addEventListener('keyup', (event) => {
if (this.valid()) {
this.hideErrorMessage();
} else {
this.showErrorMessage();
}
}, false);
}

NameValidator.prototype.hideErrorMessage = function() {
this.errorElement.style.display = 'none';
}
valid() {
let value = this.element.value;
return /^\D{2,}/.test(value);
}

hideErrorMessage() {
this.errorElement.style.display = 'none';
}

NameValidator.prototype.showErrorMessage = function() {
this.errorElement.style.display = 'block';
console.log(this.errorElement);
showErrorMessage() {
this.errorElement.style.display = 'block';
}
}

export { NameValidator }
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "registration_form",
"version": "1.0.0",
"description": "Registration Form",
"scripts": {
"test": "webpack --mode development",
"build": "webpack --mode production",
"dev": "webpack-dev-server"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
"gulp": "^3.9.1",
"gulp-series": "^1.0.2",
"gulp-watch": "^5.0.1",
"rollup-plugin-babel": "^3.0.7",
"rollup-stream": "^1.24.1",
"vinyl-source-stream": "^2.0.0"
"webpack": "^4.37.0",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.7.2"
},
"dependencies": {
"express": "^4.16.3"
Expand Down
19 changes: 19 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const path = require("path")

module.exports = {
entry: './js/app.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist')
},
devServer: {
contentBase: path.resolve(__dirname, 'dist'),
port: 8080,
host: '0.0.0.0',
hot: true,
allowedHosts: [
'.amazonaws.com',
'localhost'
]
}
}

0 comments on commit 7a6d46f

Please sign in to comment.