-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
197 lines (178 loc) · 7.75 KB
/
Copy pathscript.js
File metadata and controls
197 lines (178 loc) · 7.75 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
var keyused=false;
function changed(){
keyused=false;
}
function encodet(){
keyused=true;
var encoding=(document.getElementById("encoding").value);
var input = document.getElementById("inptext").value;
if(encoding==""){
document.getElementById("suggest").innerHTML="please enter a 5 digit key of your choice";
} else if (input=="") {
document.getElementById("suggest").innerHTML="enter text to encrypt";
} else {
var output ="";
var code1="";
var final="";
document.getElementById("button").innerHTML="You can double click to copy";
document.getElementById("suggest").innerHTML="suggestion:don't forget your encryption key";
var ifu=parseInt(encoding.charAt(0));
if(ifu=1) {
console.log("abcd");
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(3)));
var encoding2 = parseInt(encoding.charAt(2))*10+(parseInt(encoding.charAt(1)));
} else if(ifu=2) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(3)));
var encoding2 = parseInt(encoding.charAt(1))*10+(parseInt(encoding.charAt(2)));
}else if(ifu=3) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(2)));
var encoding2 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(1)));
}else if(ifu=4) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(2)));
var encoding2 = parseInt(encoding.charAt(1))*10+(parseInt(encoding.charAt(3)));
}else if(ifu=5) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(1)));
var encoding2 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(2)));
}else if(ifu=6) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(1)));
var encoding2 = parseInt(encoding.charAt(2))*10+(parseInt(encoding.charAt(3)));
}else if(ifu=7) {
var encoding1 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(4)));
var encoding2 = parseInt(encoding.charAt(2))*10+(parseInt(encoding.charAt(1)));
}else if(ifu=8) {
var encoding1 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(4)));
var encoding2 = parseInt(encoding.charAt(1))*10+(parseInt(encoding.charAt(2)));
}else if(ifu=9) {
var encoding1 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(2)));
var encoding2 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(1)));
}else if(ifu=0) {
var encoding1 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(2)));
var encoding2 = parseInt(encoding.charAt(1))*10+(parseInt(encoding.charAt(4)));
}
for (var i = 0; i < input.length; i++){
code1=input[i].charCodeAt(0).toString(10);
if (i % 2 == 0) {
output =parseInt(code1)+encoding1;
} else {
output =parseInt(code1)+encoding2;
}
final+=String.fromCodePoint(output);
}
setTimeout(function(){
document.getElementById("out").value=final;
}, 200);
setTimeout(function(){
document.getElementById("button").innerHTML="encode";
document.getElementById("suggest").innerHTML="";
},4000);}
}
function decodet(){
var encoding=document.getElementById("encoding").value;
var input = document.getElementById("inptext2").value;
if(encoding==""){
document.getElementById("suggest").innerHTML="please enter a 5 digit encryption key";
document.getElementById("suggest").scrollIntoView();
} else if (input=="") {
document.getElementById("suggest").innerHTML="enter text to decrypt";
}else{
if (keyused=true){
document.getElementById("suggest").innerHTML="do you want to use that key you can change it";
}
var output ="";
var code1="";
var final="";
var ifu=parseInt(encoding.charAt(0));
document.getElementById("button2").innerHTML="You can double click to copy";
if(ifu=1) {
console.log("abcd");
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(3)));
var encoding2 = parseInt(encoding.charAt(2))*10+(parseInt(encoding.charAt(1)));
} else if(ifu=2) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(3)));
var encoding2 = parseInt(encoding.charAt(1))*10+(parseInt(encoding.charAt(2)));
}else if(ifu=3) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(2)));
var encoding2 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(1)));
}else if(ifu=4) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(2)));
var encoding2 = parseInt(encoding.charAt(1))*10+(parseInt(encoding.charAt(3)));
}else if(ifu=5) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(1)));
var encoding2 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(2)));
}else if(ifu=6) {
var encoding1 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(1)));
var encoding2 = parseInt(encoding.charAt(2))*10+(parseInt(encoding.charAt(3)));
}else if(ifu=7) {
var encoding1 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(4)));
var encoding2 = parseInt(encoding.charAt(2))*10+(parseInt(encoding.charAt(1)));
}else if(ifu=8) {
var encoding1 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(4)));
var encoding2 = parseInt(encoding.charAt(1))*10+(parseInt(encoding.charAt(2)));
}else if(ifu=9) {
var encoding1 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(2)));
var encoding2 = parseInt(encoding.charAt(4))*10+(parseInt(encoding.charAt(1)));
}else if(ifu=0) {
var encoding1 = parseInt(encoding.charAt(3))*10+(parseInt(encoding.charAt(2)));
var encoding2 = parseInt(encoding.charAt(1))*10+(parseInt(encoding.charAt(4)));
}
for (var i = 0; i < input.length; i++){
code1=input[i].charCodeAt(0).toString(10);
if (i % 2 == 0) {
output =parseInt(code1)-encoding1;
} else {
output =parseInt(code1)-encoding2;
}
final+=String.fromCodePoint(output);
}
setTimeout(function(){
document.getElementById("out2").value=final;
}, 200);
setTimeout(function(){
document.getElementById("button2").innerHTML="decode";
document.getElementById("suggest").innerHTML="";
},4000);
}}
function copyen(){
var copyText = document.getElementById("out");
copyText.select();
document.getElementById("button").innerHTML="encode";
document.execCommand("copy");
}
function copyde(){
var copyText = document.getElementById("out2");
copyText.select();
document.getElementById("button2").innerHTML="decode";
document.execCommand("copy");
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('sw.js')
.then(() => { console.log('Service Worker Registered'); });
}
// Code to handle install prompt on desktop
let deferredPrompt;
const addBtn = document.querySelector('.add-button');
addBtn.style.display = 'none';
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Update UI to notify the user they can add to home screen
addBtn.style.display = 'block';
addBtn.addEventListener('click', () => {
// hide our user interface that shows our A2HS button
addBtn.style.display = 'none';
// Show the prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the prompt');
} else {
console.log('User dismissed the prompt');
}
deferredPrompt = null;
});
});
});