-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagina2.html
96 lines (84 loc) · 3.55 KB
/
pagina2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="./reset.css">
<link rel="stylesheet" href="./pagina2.css">
<title>Encriptador juan</title>
</head>
<body>
<header>
<img src= "imagenes/Vector.png" class="logo" >
</header>
<main>
<form>
<div class="text-box1">
<label for="input-text"></label>
<textarea name="input-text" id="input-text" cols="30" rows="10" class="form-control" style="resize: none" spellcheck="false"></textarea>
</div>
<div class="botones">
<p class="solo">Solo letras minúsculas y sin acentos</p>
<input type="button" value="Encriptar" id="boton-encriptar" class="btn btn-primary btn-sm">
<input type="button" value="Desencriptar" id="boton-desencriptar" class="btn btn-primary btn-sm">
</div>
</form>
<form>
<div class="text-box2">
<label for="input-text"></label>
<textarea name="encrypted-text" id="encrypted-text" cols="30" rows="10" class="form-control" style="resize: none" spellcheck="false"></textarea>
<br>
<input type="button" value="Copiar texto" id="boton-copiar" class="btn btn-primary btn-sm">
</div>
</form>
</main>
<script>
function encriptar() {
var texto = document.getElementById("input-text").value;
texto = texto
.replace(/e/gi, "enter")
.replace(/i/gi, "imes")
.replace(/a/gi, "ai")
.replace(/o/gi, "ober")
.replace(/u/gi, "ufat");
document.getElementById("encrypted-text").value = texto;
}
var boton = document.getElementById("boton-encriptar");
boton.onclick = function () {
if(document.getElementById("input-text").value.match(/^[a-z ]*$/)) {
encriptar();
} else {
alert("Solo se permiten letras minusculas, sin caracteres especiales.")
}
};
// La letra "e" es convertida para "enter"
// La letra "i" es convertida para "imes"
// La letra "a" es convertida para "ai"
// La letra "o" es convertida para "ober"
// La letra "u" es convertida para "ufat"
function desencriptar() {
var texto = document.querySelector("#input-text").value;
texto = texto
.replace(/enter/gi, "e")
.replace(/imes/gi, "i")
.replace(/ai/gi, "a")
.replace(/ober/gi, "o")
.replace(/ufat/gi, "u");
document.getElementById("encrypted-text").value = texto;
}
var boton = document.getElementById("boton-desencriptar");
boton.onclick = function () {
if(document.getElementById("input-text").value.match(/^[a-z ]*$/)) {
desencriptar();
} else {
alert("Solo se permiten letras minusculas, sin caracteres especiales.")
}
};
function copiar() {
navigator.clipboard.writeText(
document.getElementById("encrypted-text").value
);
}
document.querySelector("#boton-copiar").addEventListener("click", copiar);
</script>
</body>
</html>