-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncs.js
38 lines (37 loc) · 1.41 KB
/
funcs.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
module.exports = {
checkLog: function (req, loc){
if(req.session.loggedIn) return loc;
else return 'pages/login';
},
returnSets: function (req){
if(req.session.loggedIn) return JSON.parse(req.session.sets);
else return '';
},
getSelectedSet: function (req){
if(req.params.setName && req.session.loggedIn){
var sets = JSON.parse(req.session.sets);
var index = sets.findIndex(x => x.name === req.params.setName);
if(index !== -1){
return sets[index];
}else{
return "404";
}
}else{
return "404";
}
},
getFooterText: function(){
var possibilities = ["Stevie was here:" + "<!-- >++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<+" + "+.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>-" + "]<+. -->"];
return possibilities[Math.floor(Math.random()*possibilities.length)];
},
generateTextId: function(length){
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() *
charactersLength));
}
return result;
}
}