This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ClickEvent = (input) => { | |
input.addEventListener('click', () => { | |
input.select() | |
}) | |
} | |
export default ClickEvent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setHiddenInput (wrapper, options) { | |
var inputValue = '' | |
const hiddenInput = wrapper.querySelector(`input[name=${options['inputName']}]`) | |
const inputs = [] | |
const inputIds = [...Array(options['inputCount']).keys()]; | |
inputIds.forEach($input => { | |
const foundInput = wrapper.querySelector(`#honeycrisp-single-input-${$input}`) | |
inputs.push(foundInput) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @function handleForward | |
* @param {HTMLElement} nextEl | |
* Handle the right arrow action | |
*/ | |
function handleForward(nextEl) { | |
if (!(nextEl instanceof HTMLInputElement)) { return } | |
nextEl.focus() | |
nextEl.select() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const BeforeInputEvent = (input) => { | |
input.addEventListener('beforeinput', (event) => { | |
const isNumeric = n => !isNaN(n); | |
if (!isNumeric(event.data)) { | |
event.preventDefault() | |
return | |
} | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PasteEvent = (input, wrapper) => { | |
input.addEventListener('paste', (event) => { | |
const pasteData = event.clipboardData.getData('text/plain') | |
const isNumeric = n => !isNaN(n); | |
if (!isNumeric(pasteData)) { | |
return | |
} | |
const originalInput = input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Input Generation. Build the necessary inputs | |
* based on the options defined by the user | |
*/ | |
import InputGeneration from './input-generation' | |
/** | |
* @class Honeycrisp | |
* @param {HTMLElement} el | |
* @param {Object} [options] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Event Listeners. These events will provide | |
* the behavior necessary to ensure the inputs | |
* are smooth and responsive. | |
*/ | |
import PasteEvent from './events/paste' | |
import BeforeInputEvent from './events/before-input' | |
import KeydownEvent from './events/keydown' | |
import InputEvent from './events/input' | |
import ClickEvent from './events/click' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @function defaultOptions | |
* Set options that can be overridden | |
* when creating the Honeycrisp instance. | |
*/ | |
function defaultOptions () { | |
return { | |
inputClass: 'default-input-class', | |
wrapperClass: 'default-wrapper-class', | |
inputCount: 6, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const User = require("../models/user") | |
exports.register = function (req, res) { | |
User.register( | |
new User({ | |
email: req.body.email, | |
username: req.body.username | |
}), req.body.password, function (err, msg) { | |
if (err) { | |
res.send(err); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const passportLocalMongoose = require('passport-local-mongoose'); | |
const Schema = mongoose.Schema; | |
const UserSchema = new Schema({ | |
username: { | |
type: String, | |
required: true, | |
unique: true | |
}, |
NewerOlder