-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
222 lines (185 loc) · 7.43 KB
/
app.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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
let buttonMoved = false;
let serverResponse = "";
let serverResponseStatusCode = 0;
let serverResponceStatusText = "";
let infoCentre = new InfoCentre();
let requestCentre = new RequestCentre();
let scoreCentre = new ScoreCentre();
$(document).ready(function () {
init();
});
$(function () {
$("#submitButton").on({
mouseover: function () {
if (buttonMoved === false) {
$(this).css({
left: 300 + "px"
});
buttonMoved = true;
} else {
$(this).css({
left: 0 + "px"
});
buttonMoved = false;
}
}
});
});
$(function () {
$("form").submit(function () {
console.log("i have been clicked")
//TODO add some complicated validation check here
});
});
function checkUserName() {
if (document.getElementById("exampleInputEmail1").value === "connectadmin@tesco.com" && checkPassword(document.getElementById("exampleInputPassword1").value) === true) {
scoreCentre.scoreForAnswer(document.getElementById("exampleInputEmail1").value);
infoCentre.achievementUnlock("Achievement Unlocked", "You logged in!",4000);
localStorage.setItem("loggedIn", "true");
window.location.replace("q1.html");
} else {
infoCentre.toast("error", "Error", "Incorrect Login Credentials", 2000)
}
buttonFixed();
}
function checkPassword(password = "empty") {
let data = {
username: "does not matter",
password: password
};
//TODO UPDATE SERVER CALL WITH REAL TEAM
if (requestCentre.jsonRequest("Post", "http://51.143.154.149:8080/code-group/"+ localStorage.getItem("team_id") +"/login", data) === 200) {
return true
}
}
function buttonFixed() {
if (localStorage.getItem("button") !== "fixed") {
localStorage.setItem("button", "fixed");
scoreCentre.scoreForRogueButton();
achievementUnlock("Achievement Unlocked!", "You fixed the rogue button", 4000);
}
}
String.prototype.capitalize = function () {
return this.replace(/(?:^|\s)\S/g, function (a) {
return a.toUpperCase();
});
};
function trollFace() {
console.log("░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄\n" +
"░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄\n" +
"░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█\n" +
"░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░█\n" +
"░▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░█\n" +
"█▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒█\n" +
"█▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█\n" +
"░█▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█\n" +
"░░█░░▀▄▀█▄▄░█▀▀▀▄▄▄▄▀▀█▀██░█\n" +
"░░░█░░██░░▀█▄▄▄█▄▄█▄████░█\n" +
"░░░░█░░░▀▀▄░█░░░█░███████░█\n" +
"░░░░░▀▄░░░▀▀▄▄▄█▄█▄█▄█▄▀░░█\n" +
"░░░░░░░▀▄▄░▒▒▒▒░░░░░░░░░░█\n" +
"░░░░░░░░░░▀▀▄▄░▒▒▒▒▒▒▒▒▒▒░█\n" +
"░░░░░░░░░░░░░░▀▄▄▄▄▄░░░░░█")
}
function clue1() {
console.log("HA you thought it be that easy " + localStorage.getItem("antiHackerName") + "!?, fix it yourself!\n\n-SuperHACKERZZZZZZ2K19");
trollFace();
}
function styleSwap(sheet) {
if (sheet === "hacked") {
document.getElementById("pageStyle").setAttribute("href", "public/styles/hacked.css");
document.getElementById("tesco_logo").style.display = "none";
document.getElementById("logo_text").style.display = "none";
document.getElementById("home_icon").style.display = "none";
document.getElementById("hacked_logo").style.display = "block";
}
}
function init() {
if (localStorage.getItem("pageStyle") === "hacked") {
styleSwap("hacked");
} else {
intro(); //TODO remove this before launch
}
console.log("It looks like you've been hacked, Dont worry, the Hacker has left a trail\n\ncall clue1(); to begin getting your site back!\n\n- Not the Hacker... promise!");
}
$(function () {
$(".glitch-img").mgGlitch({
destroy: false,
glitch: true,
scale: true,
blend: true,
blendModeType: 'hue',
glitch1TimeMin: 200,
glitch1TimeMax: 400,
glitch2TimeMin: 10,
glitch2TimeMax: 100,
});
});
function intro() {
if (localStorage.getItem("team_id") === null){
infoCentre.setUp();
}
}
function achievementUnlock(title, text, timer) {
infoCentre.achievementUnlock(title, text, timer);
}
function testhttp() {
requestCentre.httpRequest("get", "/hello");
}
function forgotPassword() {
infoCentre.toast("info", "Hint", "I wonder if any requests are being made when logging in? 🤔", 3000);
}
function forgotEmail() {
infoCentre.toast("info", "Hint", "I wonder if there is any email validation in the code.. 🤔", 3000)
}
function loggedIn() {
if (localStorage.getItem("loggedIn") !== "true") {
window.location.replace("index.html")
}
}
function q1check() {
if (localStorage.getItem("q1") !== "complete") {
window.location.replace("q1.html")
}
}
function q2check() {
if (localStorage.getItem("q2") !== "complete") {
window.location.replace("q2.html")
}
}
function q3check() {
if (localStorage.getItem("q3") !== "complete") {
window.location.replace("q3.html")
}
}
function checkQ1Answer(answer) {
//TODO UPDATE server call
if (requestCentre.httpRequest("Put", "http://51.143.154.149:8080/code-group/" + localStorage.getItem("team_id") + "/answers/" + answer.capitalize()) === 200) {
infoCentre.achievementUnlock("Achievement Unlocked", "That was an ugly baby!", 3000);
localStorage.setItem("q1", "complete");
window.location.replace("q2.html");
} else {
infoCentre.toast("error", "Error", "That's not the image", 3000);
}
}
function checkQ2Answer(answer) {
//TODO UPDATE SERVER CALL
if (requestCentre.httpRequest("Put", "http://51.143.154.149:8080/code-group/" + localStorage.getItem("team_id") + "/answers/" + answer) === 200) {
infoCentre.achievementUnlock("Achievement Unlocked", "Well that ain't big!", 3000);
localStorage.setItem("q2", "complete");
localStorage.setItem("pageStyle", "normal");
window.location.replace("q3.html");
} else {
infoCentre.toast("error", "Error", "That's not the correct size", 3000);
}
}
function checkQ3Answer(answer) {
//TODO UPDATE SERVER CALL
if (requestCentre.httpRequest("Put", "http://51.143.154.149:8080/code-group/" + localStorage.getItem("team_id") + "/answers/" + answer.capitalize()) === 200) {
infoCentre.achievementUnlock("Achievement Unlocked", "Almost...", 3000);
localStorage.setItem("q3", "complete");
window.location.replace("complete.html");
} else {
infoCentre.toast("error", "Error", "That's not correct", 3000);
}
}