-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Agrego validaciones de js, completo curl y ejemplo de resp basica de …
…mockup
- Loading branch information
1 parent
34b9ce4
commit 63e4dcf
Showing
5 changed files
with
1,098 additions
and
26 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,72 @@ | ||
(function () { | ||
$(document).ready(function () { | ||
$("#formulario").submit(function (evt) { | ||
evt.preventDefault(); | ||
var data = { | ||
hash: $("#txtHash").val().trim(), | ||
algoritmo: $("#slcAlgoritmos").val().trim(), | ||
}; | ||
$.ajax({ | ||
url: "src/cracker.php", | ||
type: "post", | ||
data: {} | ||
}).done(function (respuesta) { | ||
console.log(respuesta); | ||
}); | ||
|
||
var validator = ValidatorJS.createValidator({ | ||
form: $("#formulario"), | ||
triggers: [ValidatorJS.VALIDATE_ON_FORM_SUBMIT, ValidatorJS.VALIDATE_ON_FIELD_BLUR], | ||
validField: function (args) { | ||
var $campo = args.field; | ||
var idCampo = $campo.get(0).id; | ||
$campo.closest(".form-group").removeClass("has-error"); | ||
$campo.attr('data-original-title', ""); | ||
}, | ||
invalidField: function (args) { | ||
var $campo = args.field; | ||
$campo.closest(".form-group").addClass("has-error"); | ||
$campo.tooltip( | ||
{ | ||
title: "", | ||
trigger: "focus", | ||
html: true | ||
}); | ||
$campo.data("mensajesTooltip", args.messages); | ||
var textoTooltip = ""; | ||
for (var i = 0; i < $campo.data("mensajesTooltip").length; i++) { | ||
textoTooltip += $campo.data("mensajesTooltip")[i].texto + "<br/>"; | ||
} | ||
$campo.attr('data-original-title', textoTooltip); | ||
}, | ||
invalidForm: function (args) { | ||
}, | ||
validForm: function (args) { | ||
args.event.preventDefault(); | ||
var data = { | ||
hash: $("#txtHash").val().trim(), | ||
algoritmo: $("#slcAlgoritmos").val().trim(), | ||
}; | ||
$.ajax({ | ||
url: getURL() + "src/cracker.php", | ||
type: "post", | ||
data: data | ||
}).done(function (respuesta) { | ||
console.log(respuesta); | ||
}); | ||
}, | ||
validValidation: function (args) { | ||
var $campo = args.field; | ||
var idCampo = args.field.attr("id"); | ||
var idTipoValidacion = args.validation.validationType; | ||
var mensajesTooltip = $campo.data("mensajesTooltip"); | ||
if (mensajesTooltip === undefined) { | ||
mensajesTooltip = []; | ||
} | ||
for (var i = 0; i < mensajesTooltip.length; i++) { | ||
if (mensajesTooltip[i].idTipoValidacion === idTipoValidacion) { | ||
mensajesTooltip.splice(i, 1); | ||
break; | ||
} | ||
} | ||
$campo.data("mensajesTooltip", mensajesTooltip); | ||
} | ||
|
||
}); | ||
validator.addValidation($("#txtHash"), ValidatorJS.VALIDATION_TYPE_LENGTH, {max: 512, message: {idTipoValidacion: ValidatorJS.VALIDATION_TYPE_LENGTH, texto: "El hash no puede tener más de 512 caracteres."}}); | ||
validator.addValidation($("#txtHash"), ValidatorJS.VALIDATION_TYPE_REQUIRED, {message: {idTipoValidacion: ValidatorJS.VALIDATION_TYPE_REQUIRED, texto: "El hash no puede estar vacío."}}); | ||
validator.addValidation($("#slcAlgoritmos"), ValidatorJS.VALIDATION_TYPE_REQUIRED, {message: {idTipoValidacion: ValidatorJS.VALIDATION_TYPE_REQUIRED, texto: "El algoritmo no puede estar sin seleccionar."}}); | ||
}); | ||
|
||
function getURL(){ | ||
return location.origin + "/labsis_hash_cracker_web/"; | ||
} | ||
|
||
})(); |
Oops, something went wrong.