Skip to content

Commit fb73c68

Browse files
committed
Merge branch 'developer'
2 parents c1d20a8 + b493dd5 commit fb73c68

File tree

1 file changed

+34
-37
lines changed

1 file changed

+34
-37
lines changed

mensa.js

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ const nodata = {
2121
de: 'Höt gits nüd.'
2222
}
2323

24-
const alternatives = [
25-
{
24+
const alternatives = [{
2625
fr: 'Allez au Küban. 🥙',
2726
de: 'Gang halt zum Küban. 🌯'
2827
},
@@ -36,8 +35,7 @@ const alternatives = [
3635
}
3736
]
3837

39-
const error =
40-
{
38+
const error = {
4139
fr: 'Oups. Quelque chose a mal tourné. ☠️',
4240
de: 'Ups, da esch öppis schief glaufe. ☠️'
4341
}
@@ -48,10 +46,10 @@ const cheerio = require('cheerio');
4846
const today = new Date();
4947

5048
// setting for mardi francophone (can be overwritten)
51-
let lang = today.getDay() == 2 ? 'fr' : 'de';
49+
let lang = today.getDay() === 2 ? 'fr' : 'de';
5250

5351
// in the afternoon, we want to get tomorrows menu
54-
if(today.getHours() > 13 && today.getDay() != 5){
52+
if (today.getHours() > 13 && today.getDay() != 5) {
5553
today.setDate(today.getDate() + 1);
5654
}
5755

@@ -71,14 +69,14 @@ console.clear();
7169
walk(1);
7270

7371
/*
74-
* Connects to the specified URI and reads today's cantina menu in Biel.
75-
* The validation process only checks against today's day to only display relevant menu entries.
76-
*/
72+
* Connects to the specified URI and reads today's cantina menu in Biel.
73+
* The validation process only checks against today's day to only display relevant menu entries.
74+
*/
7775
request(uri, (error, response, html) => {
7876
// empty data array for results
7977
var data = [];
8078

81-
if (response && response.statusCode == 200) {
79+
if (response && response.statusCode === 200) {
8280
// define the loaded DOM as $ for jQuery syntax
8381
var $ = cheerio.load(html);
8482

@@ -129,79 +127,78 @@ function getMultilingualURI(args) {
129127
var uri = uriDE;
130128

131129
// check if the argument for FR has been specified (optional)
132-
if(args.some((val) => {
133-
return val === '--fr';
134-
})){
130+
if (args.some((val) => {
131+
return val === '--fr';
132+
})) {
135133
lang = 'fr';
136134
}
137135

138136
// make it possible to override mardi francophone
139-
if(args.some((val) => {
140-
return val === '--de';
141-
})){
137+
if (args.some((val) => {
138+
return val === '--de';
139+
})) {
142140
lang = 'de';
143141
}
144142

145143
// set URI to correct language
146-
lang == 'fr' ? uri = uriFR : uri = uriDE;
144+
lang === 'fr' ? uri = uriFR : uri = uriDE;
147145

148146
return uri;
149147
}
150148

151149
/*
152-
* Returns the current date as dd.mm.yyyy
153-
* Formatted explicitly to match the content on site
154-
*
155-
* @return: today's date in the validating format
156-
*/
150+
* Returns the current date as dd.mm.yyyy
151+
* Formatted explicitly to match the content on site
152+
*
153+
* @return: today's date in the validating format
154+
*/
157155
function checkTodayDate(check) {
158156
var dd = String(today.getDate()).padStart(2, '0');
159157
var mm = String(today.getMonth() + 1).padStart(2, '0');
160158
var yyyy = today.getFullYear()
161159
var yy = yyyy % 100;
162-
return (check == dd + '.' + mm + '.' + yy) || (check == dd + '.' + mm + '.' + yyyy);
160+
return (check === dd + '.' + mm + '.' + yy) || (check === dd + '.' + mm + '.' + yyyy);
163161
}
164162

165163
/*
166-
* Returns the string of a column without spacing-characters
167-
*
168-
* @return: Formatted string without spacing
169-
*/
164+
* Returns the string of a column without spacing-characters
165+
*
166+
* @return: Formatted string without spacing
167+
*/
170168
function formatColumnString(input) {
171169
return input.replace(/([\r\t\n])+/g, '')
172170
}
173171

174172
/*
175-
* Print the menu inside the console.
176-
* See README.md to learn how you can bind this output to a terminal command!
177-
*/
173+
* Print the menu inside the console.
174+
* See README.md to learn how you can bind this output to a terminal command!
175+
*/
178176
function printMenu(data) {
179177
dinnerReady = true;
180178
const food = ['🍳', '🍝', '🥗', '🥘', '🌭', '🍔', '🍟', '🥙', '🍛'];
181179

182180
console.clear();
183-
if(data[0]){
184-
console.log('\n' + food[Math.floor(Math.random() * food.length)] + ' ' + data[0] + ' ' + data[1]);
181+
if (data[0]) {
182+
console.log(food[Math.floor(Math.random() * food.length)], data[0], data[1]);
185183
console.log(data[2].replace(/([a-z]|[à-ú])([A-Z]|[À-Ú])/g, '$1, $2') + '\n');
186-
}
187-
else {
184+
} else {
188185
console.log('\n' + nodata[lang]);
189186
console.log(alternatives[Math.floor(Math.random() * alternatives.length)][lang] + '\n');
190187
}
191188

192189
}
193190

194191
/*
195-
* Loading animation, custom made for slow BFH network ;)
196-
*/
192+
* Loading animation, custom made for slow BFH network ;)
193+
*/
197194
function walk(i) {
198195
if (!dinnerReady) {
199196
const walker = ['🚶🏼', '🏃'];
200197
const text = waiting[lang];
201198
process.stdout.write(' ' + walker[i] + text);
202199
process.stdout.write("\r");
203200
setTimeout(() => {
204-
walk(i == 1 ? 0 : 1);
201+
walk(i === 1 ? 0 : 1);
205202
}, 200);
206203
}
207204
}

0 commit comments

Comments
 (0)