Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"es2015"
]
}
29 changes: 29 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"keyword-spacing": 1,
"space-before-function-paren": [1, "never"],
"eqeqeq": 1,
"space-infix-ops": 1,
"comma-spacing": 1,
"brace-style": 1,
"no-multiple-empty-lines": 1,
"camelcase": 1,
"func-call-spacing": 1,
"key-spacing": 1,
"semi": 1,
"no-floating-decimal": 1,
"no-multi-spaces": 1,
"object-property-newline": 1,
"padded-blocks": [1, "never"],
"space-before-blocks": 1,
"space-in-parens": 1,
"spaced-comment": 1,
"quotes": [1, "single"],
"id-length": [1, { "exceptions": ["i", "j", "x"] }],
"indent": [1, 2],
"no-array-constructor": 1
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
Binary file added assets/icons/favicon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/favicon-96x961.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/favicon.ico
Binary file not shown.
Binary file added assets/icons/favicon1.ico
Binary file not shown.
Binary file added assets/icons/logo.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/logo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/ms.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added css/main.css
Empty file.
5 changes: 5 additions & 0 deletions dist/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

var test = 'hello';
var col = 'hi';
var yol = 'hiy';
50 changes: 50 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Card Library</title>
<link rel="icon" type="image/png" sizes="96x96" href="assets/icons/favicon-96x96.png">
<link rel="stylesheet" href="vendors/bootstrap-4/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<form class="needs-validation" novalidate>
<div class="form-row">
<div class="col-md-4 mb-3">
<label for="validationTooltip01">Name completed</label>
<input type="text" class="form-control" id="name"placeholder="Name completed" required>
<div class="invalid-tooltip">
campo obligatorio.
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationTooltip03">numero de tarjeta</label>
<input type="number" class="form-control" id="cn" placeholder="numero de tarjeta" min="1000000000000" max="999999999999999" required>
<div class="invalid-tooltip">
campo obligatorio.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationTooltip04">fecha de vencimiento</label>
<input type="date" class="form-control" id="exp" placeholder="fecha de vencimiento" required>
<div class="invalid-tooltip">
Please provide a valid state.
</div>
</div>
</div>
<button id="next" class="btn btn-primary" type="submit">Submit form</button>
</form>

<script src="vendors/jquery/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="vendors/bootstrap-4/js/bootstrap.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/libreria.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<!-- <script type="text/javascript" src="js/apiTarjetas.js"></script> -->
</body>
</html>
34 changes: 34 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function(){
'use strict';
window.addEventListener('load', function(){
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form){
form.addEventListener('submit', function(event){
if (form.checkValidity() === false){
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}, false);
})();



var $buttonNext = $('#next');
var $inputCard = $('#cn');
$inputCard.on('input', function(event) {
event.preventDefault();
var nroinput = $inputCard.val();
localStorage.input = $inputCard.val();
objeto.isValidCreditCard($(this).val().trim(), $buttonNext);
$buttonNext.on('click', function(event) {
event.preventDefault();
$(location).attr('href', 'views/datosUsuario.html');
});
});
console.log(localStorage.input);
12 changes: 12 additions & 0 deletions js/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var data = {
'4544164785372342': ['vanessa mendoza inoñan', '23/09/19', '223456', true],
'45441647853723': ['juan llontop dominguez', '23/12/20', '223457', true],
'4544164785372375': ['valeria mendez retrina', '23/10/18', '223458', true],
'4544164785372345': ['betty gomez frida', '23/03/21', '223459', true],
'4544164785372326': ['gabriela socorro trinita', '23/06/23', '223460', true],
'4544164785372347': ['hugo gomez yuma', '23/03/24', '223461', true],
'4454416478537555': ['humberto trello huamani', '23/10/20', '223462', true],
'4544164785372349': ['dayci berrocal gonzales', '23/06/19', '223463', false],
'4544164785372334': ['regina frida willon', '23/08/19', '223464', false],
'4544164785372391': ['lorena carmona kullop', '23/09/19', '223465', false],
};
82 changes: 82 additions & 0 deletions js/lhun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
$("#ccnum").keyup(function(e){
var num = $(this).val().toString();
var charCount = num.length;

/* VALIDACION DE TIPO */
if(charCount == 1) {
if(num == "4"){
$("#type").html("VISA");
}
}
if(charCount == 2){
if(num == "34" || num == "37"){
$("#type").html("AMEX");
} else if( num == "51" || num == "55" || num == "53"){
$("#type").html("MASTER CARD");
} else if( num == "55" ){
$("#type").html("DISCOVER");
}
}
if(charCount == 3){
if(num == "644"){
$("#type").html("DISCOVER")
}
}
if(charCount == 4){
if(num == "6011"){
$("#type").html("DISCOVER");
}
}
/* !VALIDACION DE TIPO */

/* ALGORITMO */
if(charCount == 13 || charCount == 14 || charCount == 15 || charCount == 16){
var valid = isValid(num, charCount);
if(valid){
$("#type").html("valida");
$("input").attr("name", "checkout.cardNumber").attr("class", "valid-card");
} else {
$("#type").html("invalida");
$("input").attr("name", "checkout.cardNumber").attr("class", "invalid-card");
}
}
/* !ALGORITMO */
});

function isValid(ccNum, charCount){
var double = true;
var numArr = [];
var sumTotal = 0;
for(i=0; i<charCount; i++){
var digit = parseInt(ccNum.charAt(i));

if(double){
digit = digit * 2;
digit = toSingle(digit);
double = false;
} else {
double = true;
}
numArr.push(digit);
}


for(i=0; i<numArr.length; i++){
sumTotal += numArr[i];
}
var diff = eval(sumTotal % 10);
console.log(diff);
console.log(diff == "0");
return (diff == "0");
}

function toSingle(digit){
if(digit > 9){
var tmp = digit.toString();
var d1 = parseInt(tmp.charAt(0));
var d2 = parseInt(tmp.charAt(1));
return (d1 + d2);
} else {
return digit;
}
}
72 changes: 72 additions & 0 deletions js/libreria.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
(function() {
// Funciones que habilita el boton del formulario
function activeButton(btn) {
btn.attr('disabled', false);
}

// Funcion que desabilita el boton del formulario
function desactiveButton(btn) {
btn.attr('disabled', true);
}

// Funcion que valida la longitud del input ingresado por el usuario
function longitud(input) {
if (input.trim().length === 16) {
return input;
}
}

// Funcion que valida la longitud del input ingresado por el usuario
function soloNumeros(input) {
var regex = /^[0-9]+$/;
if (regex.test(input)) {
return input;
}
}
var x = 0;
var objeto = {
isValidCreditCard: function(numberCard, btn) {
var creditCardNumber = soloNumeros(longitud(numberCard));
if (creditCardNumber !== undefined) {
var arr = [];
var sumaTotal = 0;
for (var index = creditCardNumber.length - 1; index >= 0; index--) {
arr.push(creditCardNumber[index]);
}
for (var index = 1; index < arr.length; index = index + 2) {
arr[index] = arr[index] * 2;
if (arr[index] >= 10) {
arr[index] = arr[index] - 9;
}
}

for (var index = 0; index < arr.length; index++) {
sumaTotal = sumaTotal + parseInt(arr[index]);
}

if (sumaTotal % 10 === 0) {
console.log('Es una tarjeta valida');
activeButton(btn);
} else {
console.log('No es un numero valido');
desactiveButton(btn);
}
} else {
console.log('Verifique el numero de su tarjeta');
desactiveButton(btn);
}
},
getX: function() {
return x;
},
incrementar: function() {
x++;
return this;
}
};
if (typeof window.objeto === 'undefined') {
window.objeto = window._ = objeto;
} else {
console.log('Ya existe libreria');
}
})();
12 changes: 12 additions & 0 deletions logo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<img src="assets/icons/logo.jpg" alt="">
</body>
</html>
Loading