summaryrefslogtreecommitdiff
path: root/school/node_modules/pronote-api/src/data
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
committerMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
commit3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch)
tree75be5fba4368472fb11c8015aee026b2b9a71888 /school/node_modules/pronote-api/src/data
parent8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff)
downloadpluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'school/node_modules/pronote-api/src/data')
-rw-r--r--school/node_modules/pronote-api/src/data/dates.js82
-rw-r--r--school/node_modules/pronote-api/src/data/files.js14
-rw-r--r--school/node_modules/pronote-api/src/data/html.js16
-rw-r--r--school/node_modules/pronote-api/src/data/id.js33
-rw-r--r--school/node_modules/pronote-api/src/data/objects.js44
-rw-r--r--school/node_modules/pronote-api/src/data/periods.js24
-rw-r--r--school/node_modules/pronote-api/src/data/types.js87
7 files changed, 0 insertions, 300 deletions
diff --git a/school/node_modules/pronote-api/src/data/dates.js b/school/node_modules/pronote-api/src/data/dates.js
deleted file mode 100644
index 52377ba..0000000
--- a/school/node_modules/pronote-api/src/data/dates.js
+++ /dev/null
@@ -1,82 +0,0 @@
-function toPronoteWeek(session, date)
-{
- const firstWeek = toUTCWeek(session.params.firstDay);
- const week = toUTCWeek(date);
-
- if (week >= firstWeek) {
- return week - firstWeek + 1;
- }
-
- return 52 - (firstWeek - week) + 1; // Trust me this works
-}
-
-function toUTCWeek(date)
-{
- const firstDay = new Date((new Date()).getFullYear(), 0, 1);
- return Math.ceil((((date - firstDay) / 86400000) + firstDay.getDay() + 1) / 7);
-}
-
-function toPronoteDay(session, date)
-{
- return Math.ceil((date - session.params.firstDay) / 86400000);
-}
-
-function fromPronoteDay(session, day)
-{
- const date = new Date(session.params.firstDay.getTime());
- date.setDate(date.getDate() + day - 1);
-
- return date;
-}
-
-function toPronoteDate(date)
-{
- return `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()} ` +
- `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
-}
-
-function fromPronoteHours(hours)
-{
- return ~~hours[0] + ~~hours.substring(2) / 60;
-}
-
-function parseDate(string)
-{
- const date = new Date();
- const split = string.split(' ');
-
- const day = split[0].split('/');
-
- date.setFullYear(~~day[2], (~~day[1]) - 1, ~~day[0]);
- date.setMilliseconds(0);
-
- if (split.length > 1)
- {
- const time = split[1].split(':');
-
- date.setHours(~~time[0]);
- date.setMinutes(~~time[1]);
- date.setSeconds(~~time[2]);
- }
- else
- {
- date.setHours(0);
- date.setMinutes(0);
- date.setSeconds(0);
- }
-
- return date;
-}
-
-module.exports = {
- toPronoteWeek,
- toUTCWeek,
-
- toPronoteDay,
- fromPronoteDay,
-
- toPronoteDate,
- parseDate,
-
- fromPronoteHours
-};
diff --git a/school/node_modules/pronote-api/src/data/files.js b/school/node_modules/pronote-api/src/data/files.js
deleted file mode 100644
index aea0e8e..0000000
--- a/school/node_modules/pronote-api/src/data/files.js
+++ /dev/null
@@ -1,14 +0,0 @@
-const { toPronote } = require('./objects');
-const { cipher } = require('../cipher');
-
-const EXTERNAL_FILES_FOLDER = 'FichiersExternes/';
-
-function getFileURL(session, { id, name, type })
-{
- const fileID = cipher(session, JSON.stringify(toPronote({ id, type })));
- const fileName = encodeURIComponent(encodeURIComponent(name)); // *Clown emoji*
-
- return session.server + EXTERNAL_FILES_FOLDER + fileID + '/' + fileName + '?Session=' + session.id;
-}
-
-module.exports = { getFileURL };
diff --git a/school/node_modules/pronote-api/src/data/html.js b/school/node_modules/pronote-api/src/data/html.js
deleted file mode 100644
index 33a4f0d..0000000
--- a/school/node_modules/pronote-api/src/data/html.js
+++ /dev/null
@@ -1,16 +0,0 @@
-const { stripHtml } = require('string-strip-html');
-
-function fromHTML(text)
-{
- if (!text) {
- if (text === undefined) {
- return null;
- }
-
- return text;
- }
-
- return stripHtml(text).result;
-}
-
-module.exports = fromHTML;
diff --git a/school/node_modules/pronote-api/src/data/id.js b/school/node_modules/pronote-api/src/data/id.js
deleted file mode 100644
index 2c3c2d3..0000000
--- a/school/node_modules/pronote-api/src/data/id.js
+++ /dev/null
@@ -1,33 +0,0 @@
-const { h64 } = require('xxhashjs');
-
-function withId(obj, fields, extraData)
-{
- const result = {};
- for (const field of fields) {
- result[field] = obj[field];
- }
-
- if (extraData) {
- result.__extraData = extraData;
- }
-
- return {
- id: h64(JSON.stringify(result), 0).toString(16),
- ...obj
- };
-}
-
-function checkDuplicates(objs)
-{
- for (const obj of objs) {
- const duplicates = objs.filter(o => o.id === obj.id);
-
- if (duplicates.length > 1) {
- duplicates.forEach((d, i) => d.id = d.id.substring(0, d.id.length - 1) + i);
- }
- }
-
- return objs;
-}
-
-module.exports = { withId, checkDuplicates };
diff --git a/school/node_modules/pronote-api/src/data/objects.js b/school/node_modules/pronote-api/src/data/objects.js
deleted file mode 100644
index 5cc985e..0000000
--- a/school/node_modules/pronote-api/src/data/objects.js
+++ /dev/null
@@ -1,44 +0,0 @@
-function fromPronote({ N, L, G, ...obj } = {}, fn = null, gName = 'type') {
- const result = {};
-
- if (typeof fn === 'string') {
- gName = fn;
- fn = null;
- }
-
- if (N) {
- result.id = N;
- }
- if (L) {
- result.name = L;
- }
- if (G !== undefined && gName) {
- result[gName] = G;
- }
-
- return {
- ...result,
- ...(fn ? fn(G && gName ? obj : { G, ...obj }) : {})
- };
-}
-
-function toPronote({ id, name, type } = {}) {
- const result = {};
-
- if (id) {
- result.N = id;
- }
- if (name) {
- result.L = name;
- }
- if (type) {
- result.G = type;
- }
-
- return result;
-}
-
-module.exports = {
- fromPronote,
- toPronote
-};
diff --git a/school/node_modules/pronote-api/src/data/periods.js b/school/node_modules/pronote-api/src/data/periods.js
deleted file mode 100644
index a13039d..0000000
--- a/school/node_modules/pronote-api/src/data/periods.js
+++ /dev/null
@@ -1,24 +0,0 @@
-function getPeriodBy(session, period, type = null)
-{
- const Type = ['trimester', 'semester', 'year'];
- const periods = session.params.periods;
- if (!type || Type.indexOf(type) === -1) {
- type = 'trimester'
- }
- if (!period) {
- const now = Date.now();
- return periods.find(p => now >= p.from && now <= p.to && p.kind === type) || periods[5];
- } else if (typeof period === 'string') {
- for (const p of periods) {
- if (p.name === period) {
- return p;
- }
- }
- }
-
- return period;
-}
-
-module.exports = {
- getPeriodBy
-};
diff --git a/school/node_modules/pronote-api/src/data/types.js b/school/node_modules/pronote-api/src/data/types.js
deleted file mode 100644
index a77e35f..0000000
--- a/school/node_modules/pronote-api/src/data/types.js
+++ /dev/null
@@ -1,87 +0,0 @@
-const { fromPronote } = require('./objects');
-
-function parseDate(str)
-{
- const date = new Date();
- const split = str.split(' ');
-
- const day = split[0].split('/');
-
- date.setFullYear(~~day[2], (~~day[1]) - 1, ~~day[0]);
- date.setMilliseconds(0);
-
- if (split.length > 1) {
- const time = split[1].split(':');
-
- date.setHours(~~time[0]);
- date.setMinutes(~~time[1]);
- date.setSeconds(~~time[2]);
- } else {
- date.setHours(0);
- date.setMinutes(0);
- date.setSeconds(0);
- }
-
- return date;
-}
-
-function parseRange(str)
-{
- const content = str.substring(1, str.length - 1).split(',');
- const result = [];
-
- for (const val of content) {
- if (val.includes('..')) {
- const index = val.indexOf('..');
- for (let i = ~~val.substring(0, index); i <= ~~val.substring(index + 2); i++) {
- result.push(i);
- }
- } else {
- result.push(~~val);
- }
- }
-
- return result;
-}
-
-function parse({ _T: type, V: value } = {}, f = null, g = 'type')
-{
- if (!value) {
- if (value === undefined) {
- return null;
- }
-
- return value;
- }
-
- switch (type) {
- case 7: // Date
- return parseDate(value);
- case 8: // ? (Range)
- case 11: // ? (Range)
- case 26: // ? (Range)
- return parseRange(value);
- case 10: // Mark / Number
- value = value.replace('|', '-');
-
- if (value.indexOf(',') !== -1) {
- return parseFloat(value.replace(',', '.'));
- }
-
- return ~~value;
- case 21: // HTML content
- case 23: // URL
- case 24: // Object (includes Array)
- case 25: // Resource
- default:
- if (f !== false && value.map) {
- return value.map(o => fromPronote(o, f, g));
- } else if (f !== false && (value.N || value.L)) {
- return fromPronote(value, f, g);
- }
-
- return value;
- }
-}
-
-module.exports = parse;