@@ -21,8 +21,7 @@ const nodata = {
21
21
de : 'Höt gits nüd.'
22
22
}
23
23
24
- const alternatives = [
25
- {
24
+ const alternatives = [ {
26
25
fr : 'Allez au Küban. 🥙' ,
27
26
de : 'Gang halt zum Küban. 🌯'
28
27
} ,
@@ -36,8 +35,7 @@ const alternatives = [
36
35
}
37
36
]
38
37
39
- const error =
40
- {
38
+ const error = {
41
39
fr : 'Oups. Quelque chose a mal tourné. ☠️' ,
42
40
de : 'Ups, da esch öppis schief glaufe. ☠️'
43
41
}
@@ -48,10 +46,10 @@ const cheerio = require('cheerio');
48
46
const today = new Date ( ) ;
49
47
50
48
// setting for mardi francophone (can be overwritten)
51
- let lang = today . getDay ( ) == 2 ? 'fr' : 'de' ;
49
+ let lang = today . getDay ( ) === 2 ? 'fr' : 'de' ;
52
50
53
51
// 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 ) {
55
53
today . setDate ( today . getDate ( ) + 1 ) ;
56
54
}
57
55
@@ -71,14 +69,14 @@ console.clear();
71
69
walk ( 1 ) ;
72
70
73
71
/*
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
+ */
77
75
request ( uri , ( error , response , html ) => {
78
76
// empty data array for results
79
77
var data = [ ] ;
80
78
81
- if ( response && response . statusCode == 200 ) {
79
+ if ( response && response . statusCode === 200 ) {
82
80
// define the loaded DOM as $ for jQuery syntax
83
81
var $ = cheerio . load ( html ) ;
84
82
@@ -129,79 +127,78 @@ function getMultilingualURI(args) {
129
127
var uri = uriDE ;
130
128
131
129
// 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
+ } ) ) {
135
133
lang = 'fr' ;
136
134
}
137
135
138
136
// 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
+ } ) ) {
142
140
lang = 'de' ;
143
141
}
144
142
145
143
// set URI to correct language
146
- lang == 'fr' ? uri = uriFR : uri = uriDE ;
144
+ lang === 'fr' ? uri = uriFR : uri = uriDE ;
147
145
148
146
return uri ;
149
147
}
150
148
151
149
/*
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
+ */
157
155
function checkTodayDate ( check ) {
158
156
var dd = String ( today . getDate ( ) ) . padStart ( 2 , '0' ) ;
159
157
var mm = String ( today . getMonth ( ) + 1 ) . padStart ( 2 , '0' ) ;
160
158
var yyyy = today . getFullYear ( )
161
159
var yy = yyyy % 100 ;
162
- return ( check == dd + '.' + mm + '.' + yy ) || ( check == dd + '.' + mm + '.' + yyyy ) ;
160
+ return ( check === dd + '.' + mm + '.' + yy ) || ( check = == dd + '.' + mm + '.' + yyyy ) ;
163
161
}
164
162
165
163
/*
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
+ */
170
168
function formatColumnString ( input ) {
171
169
return input . replace ( / ( [ \r \t \n ] ) + / g, '' )
172
170
}
173
171
174
172
/*
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
+ */
178
176
function printMenu ( data ) {
179
177
dinnerReady = true ;
180
178
const food = [ '🍳' , '🍝' , '🥗' , '🥘' , '🌭' , '🍔' , '🍟' , '🥙' , '🍛' ] ;
181
179
182
180
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 ] ) ;
185
183
console . log ( data [ 2 ] . replace ( / ( [ a - z ] | [ à - ú ] ) ( [ A - Z ] | [ À - Ú ] ) / g, '$1, $2' ) + '\n' ) ;
186
- }
187
- else {
184
+ } else {
188
185
console . log ( '\n' + nodata [ lang ] ) ;
189
186
console . log ( alternatives [ Math . floor ( Math . random ( ) * alternatives . length ) ] [ lang ] + '\n' ) ;
190
187
}
191
188
192
189
}
193
190
194
191
/*
195
- * Loading animation, custom made for slow BFH network ;)
196
- */
192
+ * Loading animation, custom made for slow BFH network ;)
193
+ */
197
194
function walk ( i ) {
198
195
if ( ! dinnerReady ) {
199
196
const walker = [ '🚶🏼' , '🏃' ] ;
200
197
const text = waiting [ lang ] ;
201
198
process . stdout . write ( ' ' + walker [ i ] + text ) ;
202
199
process . stdout . write ( "\r" ) ;
203
200
setTimeout ( ( ) => {
204
- walk ( i == 1 ? 0 : 1 ) ;
201
+ walk ( i === 1 ? 0 : 1 ) ;
205
202
} , 200 ) ;
206
203
}
207
204
}
0 commit comments