Compare commits

...

146 commits

Author SHA1 Message Date
05750ec31a bla 2023-01-17 13:16:58 +01:00
a7431e4250 bla 2023-01-17 13:15:33 +01:00
ef180b615c bla 2023-01-17 13:14:26 +01:00
997d906331 bla 2023-01-17 13:14:03 +01:00
2a2a6be194 bla 2023-01-17 13:13:00 +01:00
971b390758 bla 2023-01-17 13:05:55 +01:00
b9cff4e461 bla 2023-01-10 20:38:02 +01:00
6aeca3fc26 bla 2023-01-10 13:37:49 +01:00
johan
a79a8d77ba dsd 2023-01-10 11:51:10 +01:00
johan
5f95e0a4cd ee 2023-01-10 10:10:02 +01:00
johan
a39fbeb826 Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-10 10:00:35 +01:00
johan
b03f1642f0 tra 2023-01-10 10:00:25 +01:00
b850592ede Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-10 09:57:56 +01:00
d8745e4e07 bla 2023-01-10 09:57:48 +01:00
johan
add3ac8ebd Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-10 09:55:10 +01:00
johan
09cf8410f0 q 2023-01-10 09:54:46 +01:00
932d035cd8 bla 2023-01-10 09:53:21 +01:00
johan
fc86c8092d sdf 2023-01-10 09:51:53 +01:00
johan
c6ca4bf4c6 qsdqsd 2023-01-10 09:51:15 +01:00
johan
26c0a7b372 ds 2023-01-10 09:40:40 +01:00
johan
a9161ddea9 dqsd 2023-01-10 09:38:41 +01:00
johan
543e5345e1 qsdf 2023-01-10 09:37:14 +01:00
johan
2aa03b8582 Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-10 09:34:12 +01:00
johan
38d3519a86 sfds 2023-01-10 09:34:07 +01:00
3c902a9516 bla 2023-01-10 09:32:13 +01:00
2c98addf50 bla 2023-01-10 09:31:00 +01:00
2620256da9 bla 2023-01-10 09:30:30 +01:00
b5bf2a347b bla 2023-01-10 09:25:06 +01:00
f933456c22 bla 2023-01-10 09:19:29 +01:00
307a16d25d Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-10 09:18:00 +01:00
3b596472de bla 2023-01-10 09:17:52 +01:00
johan
e8ecae93fb fsd 2023-01-10 09:02:51 +01:00
johan
f2c2bbaae9 ca 2023-01-10 08:58:05 +01:00
2d15d097bd bla 2023-01-09 16:17:01 +01:00
3274a65eb9 bla 2023-01-09 16:13:33 +01:00
9027022d4d Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-09 16:12:46 +01:00
71c245774d bla 2023-01-09 16:12:34 +01:00
johan
67cd8f7fe1 Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-09 11:16:30 +01:00
johan
aac90540f5 padding 2023-01-09 11:16:03 +01:00
6c7d0801c2 bla 2023-01-09 11:05:28 +01:00
e64ba35d3a Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-09 10:39:01 +01:00
956b570f67 bla 2023-01-09 10:38:50 +01:00
johan
00b419ef8f Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-09 09:49:31 +01:00
johan
2cc2c3abb0 added refused 2023-01-09 09:49:19 +01:00
1777e5abdc bla 2023-01-09 09:39:25 +01:00
johan
aafe149fe3 TAILLE DE MA BITE 2023-01-09 09:38:03 +01:00
cdb63e5508 bla 2023-01-09 09:26:19 +01:00
johan
0d76017e47 dfsdf 2023-01-09 09:02:50 +01:00
johan
fdba8ab26f IMPORTANT 2023-01-08 20:58:23 +01:00
johan
609f0ec9d0 fin 2023-01-08 20:44:25 +01:00
johan
625c4a8bb3 treasure ok 2023-01-08 20:07:10 +01:00
johan
6e384b472b Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-08 19:14:36 +01:00
d017e30cc5 bla 2023-01-09 00:15:57 +01:00
71228d0fcf bla 2023-01-09 00:10:18 +01:00
bcbe73bac2 bla 2023-01-09 00:04:25 +01:00
johan
4cae1a7325 POOUPUPPPPPPPPPPPPP 2023-01-08 19:14:17 +01:00
johan
b18d476c8c Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-08 18:06:06 +01:00
a6b6fdcd50 bla 2023-01-08 23:44:49 +01:00
1b4692e701 bla 2023-01-08 23:43:02 +01:00
f3b715da48 bla 2023-01-08 23:24:53 +01:00
df92dd65ba bla 2023-01-08 23:22:50 +01:00
72a9b4f533 bla 2023-01-08 23:19:51 +01:00
0743d9de40 bla 2023-01-08 23:18:31 +01:00
f87b5076d0 bla 2023-01-08 23:14:04 +01:00
e3f4b5e9cf bla 2023-01-08 23:08:41 +01:00
4dd1827ee7 bla 2023-01-08 23:06:34 +01:00
622b5624d0 bla 2023-01-08 22:59:32 +01:00
9dc2c1a7ed bla 2023-01-08 22:53:50 +01:00
bcd5da4adb bla 2023-01-08 22:36:56 +01:00
2ac563f77a bla 2023-01-08 22:29:11 +01:00
757b3a4c22 bla 2023-01-08 22:27:11 +01:00
2f08f5b323 blaa 2023-01-08 22:25:38 +01:00
baf4e39b6a bla 2023-01-08 22:24:12 +01:00
68ffd6188e bla 2023-01-08 22:24:03 +01:00
40fd5b1e60 raaah same 2023-01-08 22:22:13 +01:00
edfb7e80bf bla 2023-01-08 22:21:47 +01:00
3c6e2e3780 bruuhuhuh 2023-01-08 22:18:37 +01:00
69e7960233 Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-08 20:21:01 +01:00
b05d6dc3c0 bla 2023-01-08 20:20:59 +01:00
johan
a19233a610 blab 2023-01-08 18:05:48 +01:00
johan
40adbe15fd ca marche 2023-01-08 17:47:33 +01:00
johan
68b2fb3464 On peut manger des crêpes, à table ! 2023-01-08 16:34:56 +01:00
johan
7e97165435 Un jour je serais le meilleur dresseur 2023-01-08 12:41:10 +01:00
johan
fd1fb9736a Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2023-01-07 17:47:04 +01:00
johan
350bec7cfe Comment est votre blanquette ? 2023-01-07 17:46:33 +01:00
62e031e63a bla 2023-01-07 15:11:25 +01:00
7bd3aa4bb0 bla 2023-01-07 14:53:47 +01:00
johan
3d7dde29dc Merge branch 'ohnoyoutriggeredmytrapcard' 2023-01-05 22:23:25 +01:00
c960f961ce LAST COMMIT AS FAR AS I'M CONCERNED 2023-01-04 00:43:59 +01:00
3d12c9e573 tmp 2023-01-04 00:38:12 +01:00
9b12b070ef bla 2023-01-04 00:36:48 +01:00
de6a12a912 END for me boi 2023-01-04 00:30:39 +01:00
62acb5cdc7 bla 2023-01-04 00:25:40 +01:00
69945cdb14 bla 2023-01-04 00:22:40 +01:00
d38ce339b5 bla 2023-01-04 00:16:49 +01:00
c9f4d0f605 bla 2023-01-04 00:13:37 +01:00
b5244c8fa6 bla 2023-01-04 00:11:19 +01:00
655d44e918 bla 2023-01-04 00:08:05 +01:00
311c25f2c9 bla 2023-01-04 00:04:27 +01:00
cf68b137da gitignore update 2023-01-04 00:03:23 +01:00
eec9d39a4a bla 2023-01-03 23:48:11 +01:00
944efbd6fc bla 2023-01-03 23:47:12 +01:00
a098c71b7b bla 2023-01-03 23:44:30 +01:00
3d06efd8e3 bla 2023-01-03 23:40:55 +01:00
3dd6a09845 bla 2023-01-03 23:38:44 +01:00
44ddf8e7cf bla 2023-01-03 23:35:10 +01:00
fcd2eb8eae bla 2023-01-03 23:32:56 +01:00
0143bb0050 tmp 2023-01-03 23:29:22 +01:00
542d88437d logical error 2023-01-03 23:25:48 +01:00
12a549f7f2 bla 2023-01-03 23:11:42 +01:00
5cacbb003f tmp 2023-01-03 23:06:06 +01:00
3fbff1b78e bla 2023-01-03 22:50:45 +01:00
2e0487f67e bla 2023-01-03 22:39:11 +01:00
6447a35715 bla 2023-01-03 22:25:10 +01:00
f389f14bf8 bla 2023-01-03 22:23:47 +01:00
4598a026ee bla 2023-01-03 22:07:05 +01:00
899a03c76b bla 2023-01-03 22:00:10 +01:00
3951f5875a bla 2023-01-03 21:56:03 +01:00
b78c63f630 bla 2023-01-03 21:53:43 +01:00
1cf6eefbc1 bla 2023-01-03 21:52:14 +01:00
2dfc547957 bla 2023-01-03 21:32:08 +01:00
08da575cd3 bla 2023-01-03 21:07:45 +01:00
b5d63c7adc bla 2023-01-03 21:04:09 +01:00
c82a00e35b bla 2023-01-03 20:58:46 +01:00
702e4156e5 bla 2023-01-03 20:48:52 +01:00
ae6bbb07f3 jquery stuff not handling vanilla... 2023-01-03 20:35:48 +01:00
46d2ad6dc5 ...
...
2023-01-03 20:32:14 +01:00
875a43e677 ... 2023-01-03 20:31:29 +01:00
5a46e2576d weird 2023-01-03 20:26:50 +01:00
5ddb074394 same 2023-01-03 20:24:31 +01:00
ff636bc355 same 2023-01-03 20:20:27 +01:00
ae1f8029d8 minor fixes 2023-01-03 20:15:40 +01:00
1e6c1adc38 fixe johan's mistakes... 2023-01-03 20:13:45 +01:00
2636d30743 add some listeners 2023-01-02 23:45:00 +01:00
c58cf255d3 same 2023-01-02 23:36:25 +01:00
b58b20d9be some fixes 2023-01-02 23:35:30 +01:00
54c58ab6ea Admin page html + js finished 2023-01-02 23:33:43 +01:00
e8cca14021 admin prank management html and js done 2023-01-02 21:38:58 +01:00
9bd674db95 same 2023-01-01 21:45:41 +01:00
bd852937a6 admin page.... 2023-01-01 21:40:58 +01:00
6e53a1e40a this is not rust.... 2023-01-01 19:27:49 +01:00
d416e62d65 bla 2022-12-21 23:42:53 +01:00
1829515873 bla 2022-12-21 23:37:53 +01:00
fb9b4757e1 fixed history system 2022-12-21 23:25:34 +01:00
12e1af1339 Merge branch 'master' of git.rezo-rm.fr:BDEMetz/bde-liste 2022-12-21 23:24:30 +01:00
4d28d4fec1 Edit history 2022-12-21 23:22:56 +01:00
9 changed files with 1463 additions and 115 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
# Directories and files
node_modules/
static/images/
package-lock.json
prankdata.txt
activitydata.txt

268
index.js
View file

@ -1,41 +1,34 @@
const fastify = require('fastify')({ logger: true })
const fs = require('fs');
const path = require('path')
var LdapAuth = require('ldapauth-fork');
const CryptoJS = require("crypto-js");
// var LdapAuth = require('ldapauth-fork');
var usersBdd = "usersBdd.txt";
var prankPath = "prankdata.txt";
var activityPath = "activitydata.txt";
var treasurePath = "treasuredata.txt";
var goldenUsersPath = "goldenusers.txt";
var servicePath = "servicestate.txt";
initFs();
let UsersBDD = JSON.parse(fs.readFileSync(usersBdd));
let PrankData = JSON.parse(fs.readFileSync(prankPath));
let ActivityData = JSON.parse(fs.readFileSync(activityPath));
let TreasureData = JSON.parse(fs.readFileSync(treasurePath));
let GoldenUsers = JSON.parse(fs.readFileSync(goldenUsersPath));
let AdminUsersUid = ["asyncnomi", "johan", "enthalpine", "fas", "arina", "billy", "remi", "pierre", "matmaz", "", "", ""];
let ServiceState = JSON.parse(fs.readFileSync(servicePath));
let AdminUsersUid = ["asyncnomi", "johan", "enthalpine", "fleur", "arina", "billy", "remi", "pierre", "matmaz", "mariusdrgc", "agathe", "jsansa"];
let UsersToken = {};
let TokenDurationSecond = 3600;
let TokenDurationSecond = 360000;
let MaxAmountCrepe = 10;
let Supplements = ["nature", "sucre", "nutella", "confiture"];
var ldapConf = JSON.parse(fs.readFileSync("ldap-conf.json"));
var LDAP = new LdapAuth({
url: 'ldap://10.5.0.44',
bindDN: 'cn='+ ldapConf.bindUser +',ou=service-users,dc=ldap,dc=rezo-rm,dc=fr',
bindCredentials: ldapConf.bindPassword,
searchBase: 'dc=ldap,dc=rezo-rm,dc=fr',
searchFilter: '(uid={{username}})',
reconnect: true,
});
LDAP.on('error', function (err) {
console.error('LdapAuth: ', err);
});
ldapConf = null;
fastify.addContentTypeParser('application/json', {
parseAs: 'string'
parseAs: 'string',
bodyLimit: 10485760
}, function(req, body, done) {
try {
var json = JSON.parse(body)
@ -51,28 +44,39 @@ fastify.register(require('@fastify/static'), {
decorateReply: false
})
fastify.get('/', async (request, reply) => {
reply.redirect('/index.html')
})
fastify.post('/login', async (request, reply) => {
let content = request.body;
if (content.hasOwnProperty("user")
&& content.hasOwnProperty("password")) {
let res = await authenticate(content.user, content.password);
if (res.authState) {
let now = new Date();
UsersToken[res.authUser.uid] = {
token: makeid(64),
expire: now.setSeconds(now.getSeconds() + TokenDurationSecond)
if (UsersBDD.hasOwnProperty(content.user)) {
var hash;
try {
hash = CryptoJS.SHA512(content.password).toString();
} catch {
return {
success: false,
why: "Wrong username or password"
}
}
return {
success: true,
user: {
uid: res.authUser.uid,
givenName: res.authUser.givenName
},
token: UsersToken[res.authUser.uid].token
if (hash === UsersBDD[content.user].password) {
let now = new Date();
UsersToken[content.user] = {
token: makeid(64),
expire: now.setSeconds(now.getSeconds() + TokenDurationSecond)
}
return {
success: true,
user: {
uid: content.user,
isAdmin: AdminUsersUid.includes(content.user)
},
token: UsersToken[content.user].token
}
} else {
return {
success: false,
why: "Wrong username or password"
}
}
} else {
return {
@ -88,10 +92,88 @@ fastify.post('/login', async (request, reply) => {
}
})
fastify.post('/register', async (request, reply) => {
let content = request.body;
if (content.hasOwnProperty("user")
&& content.hasOwnProperty("password")) {
if (UsersBDD.hasOwnProperty(content.user)) {
return {
success: false,
why: "This user already exists"
}
} else {
var hash;
try {
hash = CryptoJS.SHA512(content.password).toString();
} catch {
return {
success: false,
why: "What are you doing bruh ??"
}
}
UsersBDD[content.user] = {
password: hash
}
saveData(usersBdd, UsersBDD);
let now = new Date();
UsersToken[content.user] = {
token: makeid(64),
expire: now.setSeconds(now.getSeconds() + TokenDurationSecond)
}
return {
success: true,
user: {
uid: content.user,
isAdmin: AdminUsersUid.includes(content.user)
},
token: UsersToken[content.user].token
}
}
} else {
return {
success: false,
why: "The username or password is missing"
}
}
})
fastify.post('/switchState', async (request, reply) => {
let content = request.body;
let auth = checkAuthetification(content);
if (auth.success) {
if (AdminUsersUid.includes(content.uid)) {
if (ServiceState.state == "closed") {
ServiceState.state = "open";
} else {
ServiceState.state = "closed";
}
saveData(servicePath, ServiceState);
return {
success: true,
state: ServiceState.state
}
} else {
return {
success: false,
why: "Not allowed"
}
}
} else {
return auth
}
})
fastify.post('/addPrank', async (request, reply) => {
let content = request.body;
let auth = checkAuthetification(content);
if (auth.success) {
if (ServiceState.state == "closed"
&& !AdminUsersUid.includes(content.uid)) {
return {
success: false,
why: "The service is for now, closed"
}
}
if ("type" in content) {
let prankUid = makeid(16);
if ("prankUid" in content) {
@ -117,10 +199,11 @@ fastify.post('/addPrank', async (request, reply) => {
&& "supplement" in content) {
let amount = parseInt(content.amount)
if (!isNaN(amount)) {
if (!Supplements.contains(content.supplement)) {
if (Supplements.includes(content.supplement)) {
if (amount < MaxAmountCrepe) {
let prankUid = makeid(16);
PrankData[prankUid] = {
date: new Date(),
creator: content.uid,
type: content.type,
where: content.where,
@ -132,7 +215,7 @@ fastify.post('/addPrank', async (request, reply) => {
}
saveData(prankPath, PrankData);
return {
sucess: true,
success: true,
uid: prankUid,
prank: PrankData[prankUid]
}
@ -176,7 +259,7 @@ fastify.post('/addPrank', async (request, reply) => {
}
saveData(prankPath, PrankData);
return {
sucess: true,
success: true,
uid: prankUid,
prank: PrankData[prankUid]
}
@ -291,7 +374,7 @@ fastify.post('/get', async (request, reply) => {
case "prank":
if (AdminUsersUid.includes(content.uid)) {
return {
sucess: true,
success: true,
prankData: PrankData
}
} else {
@ -309,27 +392,37 @@ fastify.post('/get', async (request, reply) => {
break;
case "activity":
return {
sucess: true,
success: true,
activityData: ActivityData
}
break;
case "treasure":
let treasureData = JSON.parse(JSON.stringify(TreasureData));
for (treasure in treasureData) {
treasureData[treasure].activity = ActivityData[treasureData[treasure].activityUid];
}
if (AdminUsersUid.includes(content.uid)) {
return {
sucess: true,
prankData: TreasureData
}
} else {
let treasureData = {};
for (treasure in TreasureData) {
if (TreasureData[treasure].creator == content.uid) {
treasureData[treasure] = TreasureData[treasure];
}
}
return {
success: true,
treasureData: treasureData
}
} else {
let treasureDataUser = {};
for (treasure in treasureData) {
if (treasureData[treasure].creator == content.uid) {
treasureDataUser[treasure] = treasureData[treasure];
}
}
return {
success: true,
treasureData: treasureDataUser
}
}
break;
case "state":
return {
success: true,
state: ServiceState.state
}
break;
default:
@ -344,6 +437,18 @@ fastify.post('/get', async (request, reply) => {
why: "Missing type"
}
}
} else if ("type" in content) {
switch (content.type) {
case "activity":
return {
success: true,
activityData: ActivityData
}
break;
default:
return auth;
break;
}
} else {
return auth
}
@ -381,7 +486,7 @@ fastify.post('/addActivity', async (request, reply) => {
}
saveData(activityPath, ActivityData);
return {
sucess: true,
success: true,
uid: activityUid,
activity: ActivityData[activityUid]
}
@ -403,7 +508,7 @@ fastify.post('/addActivity', async (request, reply) => {
}
saveData(activityPath, ActivityData);
return {
sucess: true,
success: true,
uid: activityUid,
activity: ActivityData[activityUid]
}
@ -454,16 +559,16 @@ fastify.post('/sendTreasure', async (request, reply) => {
&& "activityUid" in content) {
let treasureUid = makeid(16);
if ("treasureUid" in content) {
let treasureExists = check(content, "activityUid", ActivityData)
let treasureExists = check(content, "treasureUid", TreasureData)
if (treasureExists.success) {
if (treasureData[treasureUid].state != "Pending"
&& treasureData[treasureUid].creator == content.uid) {
if (TreasureData[content.treasureUid].state != "Pending"
|| TreasureData[content.treasureUid].creator != content.uid) {
return {
success: false,
why: "You cannot edit already accepted or refused treasure request, or request form other people"
}
} else {
treasureUid = content.prankUid;
treasureUid = content.treasureUid;
}
} else {
return treasureExists;
@ -473,15 +578,29 @@ fastify.post('/sendTreasure', async (request, reply) => {
if (activityExists.success) {
if (ActivityData[content.activityUid].type == "treasure") {
let imageUid = makeid(128);
fs.writeFileSync("static/images/"+imageUid, content.image);
let fileImage = `
<!DOCTYPE html>
<html>
<body>
<img style='object-fit: contain; width:100%; height:100%;' src='${content.image}'/>
</body>
</html>
`
fs.writeFileSync("static/images/" + imageUid + ".html", fileImage);
TreasureData[treasureUid] = {
date: new Date(),
creator: content.uid,
image: imageUid,
desc: content.desc,
activity: content.activityUid,
activityUid: content.activityUid,
state: "Pending"
}
saveData(treasurePath, TreasureData);
return {
success: true,
uid: treasureUid,
treasure: TreasureData[treasureUid]
}
} else {
return {
success: false,
@ -538,7 +657,7 @@ fastify.post('/acceptTreasure', async (request, reply) => {
if (treasureExists.success) {
TreasureData[content.treasureUid].state = "Accepted";
saveData(treasurePath, TreasureData);
ActivityData[GoldenUsers[activityUid].activityUid].treasureState = "Accepted";
ActivityData[TreasureData[content.treasureUid].activityUid].treasureState = "Accepted";
saveData(activityPath, ActivityData);
GoldenUsers[TreasureData[content.treasureUid].activityUid] = {
userUid: TreasureData[content.treasureUid].creator,
@ -581,7 +700,7 @@ fastify.post('/isGolden', async (request, reply) => {
}
}
return {
sucess: false
success: false
}
} else {
return auth
@ -592,24 +711,6 @@ function saveData(path, data) {
fs.writeFileSync(path, JSON.stringify(data));
}
function authenticate(user, pwd) {
return new Promise((resolve, reject) => {
LDAP.authenticate(user, pwd, function(err, user) {
if (user && err == null) {
resolve({
authState: true,
authUser: user
});
} else {
resolve({
authState: false,
authUser: null
});
}
});
})
}
function checkAuthetification(content) {
if (content.hasOwnProperty("uid")
&& content.hasOwnProperty("token")) {
@ -684,6 +785,9 @@ function checkManage(content, input, data) {
}
function initFs() {
if (!fs.existsSync(usersBdd)) {
fs.writeFileSync(usersBdd, "{}");
}
if (!fs.existsSync(prankPath)) {
fs.writeFileSync(prankPath, "{}");
}
@ -696,6 +800,12 @@ function initFs() {
if (!fs.existsSync(goldenUsersPath)) {
fs.writeFileSync(goldenUsersPath, "{}");
}
if (!fs.existsSync(servicePath)) {
fs.writeFileSync(servicePath, JSON.stringify({state: 'closed'}));
}
if (!fs.existsSync("static/images")){
fs.mkdirSync("static/images");
}
}
function makeid(length) {

View file

@ -10,6 +10,7 @@
"license": "ISC",
"dependencies": {
"@fastify/static": "^6.6.0",
"crypto-js": "^4.1.1",
"fastify": "^4.10.2",
"ldapauth-fork": "^5.0.5",
"password-prompt": "^1.1.2"

View file

@ -73,8 +73,8 @@ a:hover {
background: url("../img/background-letter.jpg");
background-size: cover;
background-position: right;
transition: 1.5s transform 0s ease-out;
overflow: scroll;
transition: 1s transform 0s ease-out;
}
#logo {
@ -92,7 +92,7 @@ a:hover {
text-align: center;
}
#spacer {
.spacer {
padding: 1px;
margin: 30px 0 30px 0;
background-color: #00000054;
@ -134,8 +134,6 @@ a:hover {
}
#login-form {
margin-top: 25vh;
margin-bottom: 10vh;
padding: 0px;
width: 50vw;
}
@ -149,7 +147,7 @@ a:hover {
width: 100%;
}
.login-form-control {
.form-control {
width: 100%;
border: none;
border-bottom: 1px solid #d75b00;
@ -158,7 +156,7 @@ a:hover {
padding: 5px;
}
.login-form-control:focus {
.form-control:focus {
outline: none;
border-bottom: 2px solid #923e01;
}
@ -182,6 +180,144 @@ button[type="submit"]:hover {
color: #ffffff;
}
.admin-textarea, .admin-input-date, #activityType {
background: none;
border: none;
border-bottom: 1px solid orange;
margin: 5px 0px;
font-size: 15px;
height: 27px;
margin-left: 10px;
}
.activity, .prank, .treasure {
display: flex;
flex-direction: column;
margin: 30px 0;
border-bottom: 2px solid grey;
padding-bottom: 30px;
}
.activity>*, .prank>*, .treasure>* {
display: flex;
flex-direction: row;
align-items: center;
}
.activity-btn, .prank-btn, .treasure-btn {
display: flex;
flex-direction: row;
}
.activity-btn>*, .prank-btn>*, .treasure-btn>* {
margin-left: auto;
border: 1px solid orange;
padding: 10px;
border-radius: 5px;
background: #fa45;
cursor: pointer;
}
.activity-btn>*:hover, .prank-btn>*:hover, .treasure-btn>*:hover {
background-color: #faa5;
}
#admin-header {
display: flex;
flex-direction: row;
}
.admin-menu {
display: flex;
flex: 1;
align-items: center;
justify-content: center;
border-right: 3px solid black;
height: 40px;
font-size: 30px;
cursor: pointer;
}
.admin-menu:hover {
background-color: #00000036;
}
.admin-menu:first-of-type {
border-left: 3px solid black;
}
.activity-uid, .prank-uid, .prank-date, .treasure-uid, .treasure-date, #activite-place {
color: #00000078;
margin-top: 5px;
font-size: 12px;
}
.prank-date, .treasure-date {
margin-left: 10px;
}
.treasure-image>a {
margin-left: 10px;
}
#error-message, #error-message-demande, #error-message-register {
color: red;
}
.treasure {
padding: 0 20px 20px 20px;
}
.treasure-submitted {
background-color: rgba(67, 67, 67, 0.296);
}
.treasure-accepted {
background-color: rgba(0, 255, 0, 0.46);
}
.treasure-refused {
background-color: rgba(255, 0, 0, 0.397);
}
.overlay {
z-index: 99;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
opacity: 0;
visibility: hidden;
}
#treasure-popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: calc(100% - 10vw);
position: relative;
transition: all 5s ease-in-out;
}
.close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.close:hover {
color: #d75b00;
text-decoration: none;
}
@media screen and (max-width: 800px) {
.bg-full {
display: none;
@ -189,6 +325,7 @@ button[type="submit"]:hover {
.container {
margin: 0px;
width: 100%;
height: 100%;
top: 0;
border-radius: 0px;
box-shadow: none;
@ -200,7 +337,7 @@ button[type="submit"]:hover {
#logo > img {
width: 150px;
}
#spacer {
.spacer {
display: none;
}
.row-section {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 252 KiB

View file

@ -38,16 +38,18 @@
</div>
<div class="column-section">
<h1>Prochaine activité</h1>
<span id="timer">00:00:10</span>
<p id="activite-desc">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Dicta tenetur tempora similique. A id esse expedita atque dolor eum itaque fugiat enim nisi dicta. Architecto mollitia quasi sed voluptatibus? Veniam.</p>
<span id="timer">2 jours 00:00:10</span>
<h2 id="activite-title"></h2>
<p id="activite-desc"></p>
<p id="activite-place"></p>
</div>
<hr/>
<div class="row-section">
<div class="column-section">
<h1>Planning des activité</h1>
<h1>Planning des activités</h1>
<img src="img/schedule.png" id="schedule" alt="Planning des activité" srcset="">
</div>
<div id="spacer" class="column-section"></div>
<div class="sapcer column-section"></div>
<div class="column-section">
<h1>Ordre de mission</h1>
<a id="prank-button">
@ -56,8 +58,7 @@
</a>
<p id="prank-desc">
OSS 110'Metz est une organisation remplie d'espions qualifiés pour remplir presque toutes tes demandes !
Cliquez sur le bouton ci-dessus puis suivez les instructions. Attention, un compte <a href="https://re2o.rezo-rm.fr/users/new_user" target="_blank">Rezo</a>
est nécessaire afin de garantir l'identité des demandeurs !
Cliquez sur le bouton ci-dessus puis suivez les instructions.
</p>
</div>
</div>
@ -65,7 +66,7 @@
<div class="column-section">
<h1>Chasse au trésor</h1>
<p id="chasse-desc">
Chaque jour de la semaine tes espions préférés ont préparé pour toi une <i style="font-weight: 900;">chasse au trésor</i> !
Pendante toute la semaine tes espions préférés ont préparé pour toi une <i style="font-weight: 900;">chasse au trésor</i> !
Résous les énigmes pour tenter de gagner le fameux <u>ticket d'or</u>. Il te permettra de t'abrever gratuitement pendants les évènements festifs !
</p>
</div>
@ -79,39 +80,139 @@
</footer>
</div>
<div id="admin-page" style="display: none">
<div id="admin-page" class="container" style="display: none">
<div id="admin-header">
<div id="admin-prank" class="admin-menu">Prank</div>
<div id="admin-treasure" class="admin-menu">Trésors</div>
<div id="admin-activity" class="admin-menu">Activités</div>
</div>
<div id="admin-content">
</div>
</div> <!-- end admin page -->
<div class="container" id="login-page" style="display: none;">
<p>Connection</p>
<div class="column-section">
<div id="login-form">
<div class="form-group">
<input type="text" class="login-form-control" placeholder="Nom d'espion" name="login" id="login"/>
<input type="text" class="form-control" placeholder="Nom d'espion" name="login" id="login"/>
</div>
<div class="form-group">
<input type="password" class="login-form-control" placeholder="Mot de passe secret" name="password" id="password" />
<input type="password" class="form-control" placeholder="Mot de passe secret" name="password" id="password" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" id="login-button">Se connecter</button>
</div>
<div class="form-group">
<p id="error-message"></p>
</div>
</div>
</div>
<p>Inscription</p>
<div class="column-section">
<div id="register-form">
<div class="form-group">
<input type="text" class="form-control" placeholder="Nom d'espion" name="login" id="register-user"/>
</div>
<div class="form-group">
<input type="password" class="form-control" placeholder="Mot de passe secret" name="password" id="register-password" />
</div>
<div class="form-group">
<input type="password" class="form-control" placeholder="Confirmer le mot de passe secret" name="password" id="register-password-confirm" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" id="register-button">S'inscrire</button>
</div>
<div class="form-group">
<p id="error-message-register"></p>
</div>
</div>
</div>
<hr/>
<div class="row banner">
<h2>Notice de l'espion</h2>
<h2>Notice pour l'espion</h2>
<p id="notice-espion">
Seul les espions reconnus par le Rézo pourrons se connecter pour jouer des tours à leurs camarrades.
Si tu n'es pas encore un espion reconnu, tu peux le devenir <a href="https://re2o.rezo-rm.fr/users/new_user" target="_blank">ici</a>.
Vous êtes espions et devez savoir retenir des mots de passe, car pour des raisons de sécurité celui-ci ne peut pas être changé. Alors faite attention !
</p>
</div>
</div> <!-- end login page -->
<div id="demande-page" style="display: none">
<div id="demande-page" class="container" style="display: none">
<div class="column-section">
<h1>Demandes</h1>
<p>Ici vous pouvez demandez à un espion aguerri de vous livrer des crêpes. Aussi, vous pouvez tentez de valider la chasse au trésor du jour !
Pour cela il suffit d'envoyer une photo du ticket avec l'endroit où vous l'avez trouvé.
</p>
</div>
<hr/>
<div class="row-section">
<div class="column-section" id="demande-form">
<h2>Crêpes</h2>
<div class="form-group">
<input type="text" class="form-control" placeholder="Lieu de livraison" id="demande-where">
</div>
<div class="form-group">
<input type="number" class="form-control" placeholder="Quantité" max="9" id="demande-amount">
</div>
<div class="form-group">
<select class="form-control" id="demande-supp">
<option value="nature">Nature</option>
<option value="sucre">Sucre</option>
<option value="nutella">Nutella</option>
<option value="confiture">Confiture</option>
</select>
</div>
<div class="form-group">
<textarea class="form-control" placeholder="Notes" id="demande-notes" ></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" id="demande-button">Envoyer</button>
</div>
<div class="form-group">
<p id="error-message-demande"></p>
</div>
</div>
</div>
<hr/>
<div class="column-section">
<h2>Chasse au trésor</h2>
<p>Retrouve ici toutes les énigmes. Celles en vert sont déjà resolues alors dépéchez vous de résoudre les autres !</p>
<div class="column-section" id="treasure-list">
</div>
</div>
<hr/>
<div class="column-section">
<h1>Vos demandes en cours</h1>
<div class="column-section" id="demande-list"></div>
</div>
</div> <!-- end demande page -->
</div>
<div class="overlay">
<div id="treasure-popup">
<div class="column-section">
<h2>Soumettre la résolution d'une énigme !</h2>
<a class="close" href="#">&times;</a>
<p id="treasure-popup-title"></p>
<input type="hidden" id="treasure-popup-uid">
<input type="hidden" id="treasure-popup-activity-uid">
<div class="form-group">
<input class="form-control" type="file" id="treasure-popup-image" >
</div>
<div class="form-group">
<textarea class="form-control" id="treasure-popup-desc" placeholder="Ajouter une description"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" id="treasure-popup-button">Envoyer</button>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script src="https://unpkg.com/typeit@8.7.0/dist/index.umd.js"></script>
<script src="js/main.js" defer></script>

View file

@ -1,4 +1,4 @@
var $animation_elements = $("#prank-desc, #activite-desc, #chasse-desc, #notice-espion");
var $animation_elements = $("#prank-desc, #chasse-desc, #notice-espion");
var $window = $(window)
function check_if_in_view() {
@ -18,7 +18,7 @@ function check_if_in_view() {
if(!$element.hasClass('animated')) {
$element.addClass('animated');
var a = new TypeIt('#' + $element.attr('id'), {
speed: 30,
speed: 50,
lifeLike: true,
})
.go();

File diff suppressed because it is too large Load diff

29
stats.js Normal file
View file

@ -0,0 +1,29 @@
const fs = require('fs');
let PrankData = JSON.parse(fs.readFileSync("prankdata.txt"));
let nbPrank = 0;
let nbCrepe = 0;
let meanCrepe = 0;
let userPrank = {};
for (var uid in PrankData) {
if (PrankData[uid].type == "crêpe") {
if (PrankData[uid].state == "Done") {
nbPrank ++;
nbCrepe += parseInt(PrankData[uid].amount)
if (!userPrank[PrankData[uid].creator]) {
userPrank[PrankData[uid].creator] = 0;
}
userPrank[PrankData[uid].creator] += parseInt(PrankData[uid].amount);
}
}
}
meanCrepe = nbCrepe / nbPrank;
console.log("Nombre de mission mission achevé: " + nbPrank)
console.log("Nombre de crêpe servis: " + nbCrepe)
console.log("Nombre moyen de crêpe par demande: " + meanCrepe + "\n")
for (var user in userPrank) {
console.log(user + " a commandé " + userPrank[user] + " crêpe")
}