-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
78 lines (49 loc) · 1.87 KB
/
Copy pathscript.js
File metadata and controls
78 lines (49 loc) · 1.87 KB
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
const textArea = document.querySelector(".text-area");
const mensaje = document.querySelector(".mensaje");
const button = document.getElementById(".button");
//button.disabled=true;
function btnEncriptar(){
const textoEncriptado = encriptar(textArea.value);
mensaje.value = textoEncriptado;
textArea.value = "";
mensaje.style.backgroundImage = "none";
}
function encriptar(stringEncriptada){
let matrizCodigo = [["e", "enter"], ["i", "imes"], ["a", "ai"], ["o", "ober"],["u", "ufat"]];
stringEncriptada = stringEncriptada.toLowerCase();
for(let i = 0; i<matrizCodigo.length; i++){
if(stringEncriptada.includes(matrizCodigo[i][0])){
stringEncriptada=stringEncriptada.replaceAll(matrizCodigo[i][0],matrizCodigo[i][1]);
}
}
return stringEncriptada;
}
function toggleButton(msj) {
const button=document.getElementById("btncopy");
if (msj.value != '') {
document.getElementById('btncopy').disabled= true;
} else {
document.getElementById('btncopy').disabled=false;
}
}
function copiado (){
const copiarTexto = document.querySelector(".mensaje");
copiarTexto.select();
copiarTexto.setSelectionRange(0, 99999);
document.execCommand("copy");
}
function btnDesencriptar(){
const textoDesencriptado = desencriptar(textArea.value);
mensaje.value = textoDesencriptado;
textArea.value = "";
}
function desencriptar(stringDesencriptada){
let matrizCodigo = [["e", "enter"], ["i", "imes"], ["a", "ai"], ["o", "ober"],["u", "ufat"]];
stringDesencriptada = stringDesencriptada.toLowerCase();
for(let i = 0; i<matrizCodigo.length; i++){
if(stringDesencriptada.includes(matrizCodigo[i][1])){
stringDesencriptada=stringDesencriptada.replaceAll(matrizCodigo[i][1],matrizCodigo[i][0]);
}
}
return stringDesencriptada;
}