-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
101 lines (99 loc) · 3.85 KB
/
main.js
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
97
98
99
100
101
let capital_letters = "ABCDEFGHYJKLMNÑOPQRSTUVWXYZ";
let letters_accents = "áéíóúý";
let capital = 0;
function encrypter(){
let text = document.getElementById("input-text").value;
capital = 0;
if (text == "" || text == " " ){
Swal.fire({
position: 'center',
icon: 'error',
title: 'Debe ingresar texto para encriptar.',
showConfirmButton: false,
timer: 1600
})
} else{
for(i=0;i<text.length; i++){
if (capital_letters.indexOf(text.charAt(i),0)!=-1 || letters_accents.indexOf(text.charAt(i),0)!=-1){
capital++;
}
}
if (capital > 0){
Swal.fire({
position: 'center',
icon: 'error',
title: 'No se permite mayúsculas o acentos.',
showConfirmButton: false,
timer: 1600
})
} else{
let txtEncrypted = text.replace(/e/igm,"enter");
txtEncrypted = txtEncrypted.replace(/o/igm,"ober");
txtEncrypted = txtEncrypted.replace(/i/igm,"imes");
txtEncrypted = txtEncrypted.replace(/a/igm,"ai");
txtEncrypted = txtEncrypted.replace(/u/igm,"ufat");
document.getElementById("search-image").style.display = "none";
document.getElementById("first-part").style.display = "none";
document.getElementById("text-info").style.display = "none";
document.getElementById("show-text").innerHTML = txtEncrypted;
document.getElementById("show-text").style.display = "flex";
document.getElementById("show-text").style.display = "inherit";
document.getElementById("second-part").style.display = "show";
document.getElementById("second-part").style.display = "inherit";
document.getElementById("input-text").value = "";
}
}
}
function desencrypter(){
let text = document.getElementById("input-text").value;
capital = 0;
if (text == "" || text == " "){
Swal.fire({
position: 'center',
icon: 'error',
title: 'Debe ingresar texto para desencriptar.',
showConfirmButton: false,
timer: 1600
})
} else{
for(i=0;i<text.length; i++ ){
if (capital_letters.indexOf(text.charAt(i),0)!=-1 || letters_accents.indexOf(text.charAt(i),0)!=-1){
capital++;
}
}
if (capital > 0){
Swal.fire({
position: 'center',
icon: 'error',
title: 'No se permite mayúsculas o acentos.',
showConfirmButton: false,
timer: 1600
})
} else{
let txtEncrypted = text.replace(/enter/igm,"e");
txtEncrypted = txtEncrypted.replace(/ober/igm,"o");
txtEncrypted = txtEncrypted.replace(/imes/igm,"i");
txtEncrypted = txtEncrypted.replace(/ai/igm,"a");
txtEncrypted = txtEncrypted.replace(/ufat/igm,"u");
document.getElementById("search-image").style.display = "none";
document.getElementById("first-part").style.display = "none";
document.getElementById("show-text").innerHTML = txtEncrypted;
document.getElementById("second-part").style.display = "flex";
document.getElementById("second-part").style.display = "inherit";
document.getElementById("input-text").value = "";
}
}
}
function copy(){
let container = document.getElementById("show-text");
container.select();
document.execCommand("copy");
document.getElementById("input-text").focus();
Swal.fire({
position: 'center',
icon: 'success',
title: 'Texto copiado correctamente.',
showConfirmButton: false,
timer: 1500
})
}