-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
87 lines (60 loc) · 3.23 KB
/
script.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
const startText = document.getElementById("jtextarea1");
const finalText = document.getElementById("jtextarea2");
const buttonEncode = document.getElementById("jbtnEncode");
const buttonDecode = document.getElementById("jbtnDecode");
const buttonCopy = document.getElementById("jbtnCopy");
const buttonRestart = document.getElementById("jbtnRestart");
function encode(){
let msj = startText.value.toLowerCase();
var textEncoded = msj.replace(/e/igm,"enter");
var textEncoded = textEncoded.replace(/o/igm,"ober");
var textEncoded = textEncoded.replace(/i/igm,"imes");
var textEncoded = textEncoded.replace(/a/igm,"ai");
var textEncoded = textEncoded.replace(/u/igm,"ufat");
finalText.value = textEncoded;
document.getElementById("jbtnEncode").style.visibility = "hidden";
document.getElementById("jbtnCopy").style.visibility = "visible";
document.getElementById("jexclamation2").style.visibility = "visible";
document.getElementById("jexclamation1").style.visibility = "hidden";
}
buttonEncode.onclick = encode;
function decode(){
let msj = startText.value.toLowerCase();
var textDecoded = msj.replace(/enter/igm,"e");
var textDecoded = textDecoded.replace(/ober/igm,"o");
var textDecoded = textDecoded.replace(/imes/igm,"i");
var textDecoded = textDecoded.replace(/ai/igm,"a");
var textDecoded = textDecoded.replace(/ufat/igm,"u");
finalText.value = textDecoded;
document.getElementById("jbtnEncode").style.display = "none";
document.getElementById("jbtnDecode").style.display = "none";
document.getElementById("jexclamation3").style.visibility = "hidden";
document.getElementById("jbtnRestart").style.display = "inline";
}
buttonDecode.onclick = decode;
function copy(){
const textCopied = document.getElementById("jtextarea2");
textCopied.select()
document.execCommand("copy");
startText.value = textCopied.value;
const info = "Cuando hagas clic en el botón Descifrar verás aquí el resultado.";
finalText.value = info;
document.getElementById("jbtnCopy").style.visibility = "hidden";
document.getElementById("jexclamation2").style.visibility = "hidden";
document.getElementById("jexclamation3").style.visibility = "visible";
document.getElementById("jbtnDecode").style.visibility = "visible";
document.getElementById("jbtnEncode").style.visibility = "hidden";
}
buttonCopy.onclick = copy;
function refresh() {
const restart = document.getElementById("jbtnRestart");
location.reload();
}
buttonRestart.onclick = refresh;
/*
Probando funcion para copiar usando el clipboard
function copy(){
var textEncoded = finalText.value;
navigator.clipboard.writeText(textDecoded);
}
*/