-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUIdependencies.js
More file actions
182 lines (139 loc) · 4.46 KB
/
Copy pathUIdependencies.js
File metadata and controls
182 lines (139 loc) · 4.46 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
//NAME: ZANIF SANDY (ZAYSLASH)
var textbox = document.getElementById("text-box");
var submit = document.getElementById("submit");
var result = document.getElementById("results");
var Title = document.getElementById("title");
var DOM_shift = document.getElementById("shift");
var DOM_shift_two = document.getElementById("shift-two");
var method = document.getElementById("operation");
var right_button = document.getElementById("right");
var left_button = document.getElementById("left");
var upClick = document.getElementById("upimg");
var incase = document.getElementById("incase");
var keyWord = document.getElementById("key-word");
var method_specification = "Encode";
var menuStack = new Stack();
var backwardStack = new Stack();
menuStack.push("Affine Cipher");
menuStack.push("Auto Key Cipher");
menuStack.push("Atbash Cipher");
menuStack.push("ROT13");
menuStack.push("Vigenere Cipher");
menuStack.push("Caesar Cipher");
var display = function(){
if (menuStack.peek() === "Caesar Cipher"){
DOM_shift.type = "number";
DOM_shift.style.display = "inline-block";
keyWord.style.display = "inline-block";
Title.innerHTML = menuStack.peek();
}
else if (menuStack.peek() === "Vigenere Cipher") {
DOM_shift.type = "textbox";
DOM_shift.style.display = "inline-block";
DOM_shift_two.style.display = "none";
keyWord.style.display = "inline-block";
Title.innerHTML = menuStack.peek();
}
else if (menuStack.peek() === "ROT13") {
DOM_shift.style.display = "none";
DOM_shift_two.style.display = "none";
keyWord.style.display = "none";
Title.innerHTML = menuStack.peek();
}
else if (menuStack.peek() === "Atbash Cipher") {
DOM_shift.style.display = "none";
DOM_shift_two.style.display = "none";
keyWord.style.display = "none";
Title.innerHTML = menuStack.peek();
}
else if (menuStack.peek() === "Auto Key Cipher") {
DOM_shift.type = "textbox";
DOM_shift.style.display = "inline-block";
keyWord.style.display = "inline-block";
DOM_shift_two.style.display = "none";
Title.innerHTML = menuStack.peek();
}
else if (menuStack.peek() === "Affine Cipher") {
DOM_shift.type = "number";
DOM_shift_two.style.display = "inline-block";
keyWord.style.display = "inline-block";
Title.innerHTML = menuStack.peek();
}
}
method.onclick = function(){
if (method.innerHTML === "Encode"){
method.innerHTML = "Decode";
method_specification = "Encode";
submit.value = "Encode";
}else {
method.innerHTML = "Encode";
submit.value = "Decode";
method_specification = "Decode";
}
}
function ascii (a) { return a.charCodeAt(0); }
function codeToAscii(number){
return String.fromCharCode(number);
}
var function_loader = function(textdata){
if (menuStack.peek() === "Caesar Cipher"){
return caesarCipher(textdata,parseInt(DOM_shift.value), method_specification);
}
else if (menuStack.peek() === "Vigenere Cipher") {
return VigenereCipher(textdata,DOM_shift.value, method_specification)
}
else if (menuStack.peek() === "ROT13") {
return ROT13(textdata);
}
else if (menuStack.peek() === "Atbash Cipher") {
return AtbashCipher(textdata, method_specification);
}
else if (menuStack.peek() === "Auto Key Cipher") {
return AutoKeyCipher(textdata, DOM_shift.value, method_specification);
}
else if (menuStack.peek() === "Affine Cipher") {
return affineCipher(textdata, parseInt(DOM_shift.value) , parseInt(DOM_shift_two.value), method_specification);
}
}
submit.onclick = function(){
let textdata = textbox.value;
result.innerHTML = function_loader(textdata);
download_file(function_loader(textdata),`z${FileName}`,'text/plain')
}
upClick.onclick = function(){
textbox.value = result.innerText;
//console.log("cli")
}
var clicks = 0; // keeps count of backward left clicks
right_button.onclick = function(){
if (clicks > 0){
var temp = menuStack;
menuStack = backwardStack;
backwardStack = temp;
clicks = 0;
}else{
backwardStack.push(menuStack.peek())
menuStack.pop()
}
display();
}
left_button.onclick = function(){
if (clicks == 0){
var temp = menuStack;
menuStack = backwardStack;
backwardStack = temp;
clicks++
}
else{
backwardStack.push(menuStack.peek())
menuStack.pop()
clicks++;
}
display();
}
function loaders(){
display();
// Title.innerHTML = menuPosition[position];
// VigenereCipher("omstvboqz","hi","Decode")
}
loaders();