forked from fabrixxm/restaurant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
levels.js
378 lines (365 loc) · 16.5 KB
/
levels.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
// Hash the array and compare the arrays!
// Key
// a = small apple .small
// A = apple
// o = small orange, .small
// O = orange
// p = small pickle, .small
// P = pickle
// () = plate open / close
// {} = fancy plate open / close
// [] = bento open close tags
strings['en'] = {
'table' : 'table',
'apple' : 'apple',
'orange' : 'orange',
'pickle' : 'pickle',
'plate' : 'plate',
'bento' : 'bento',
'fancy' : 'fancy',
'small' : 'small',
/* ui */
"Level {0} of {1}" : 'Level {0} of {1}',
'str1' : "No worries, you've got this!",
'str2' : "You're about to learn CSS Selectors!\nSelectors are how you pick which element to apply styles to.",
'str3' : "AlExhibit 1 - A CSS Rule",
'str4' : 'Here, the "p" is the selector (selects all <p> elements) and applies the margin-bottom style.',
'str5' : "To play, type in a CSS selector in the editor below to select the correct items on the table. If you get it right, you'll advance to the next level.",
'str6': "Hover over the items on the table to see their HTML markup.",
'str7': "Get help with selectors on the right! →",
'str8': "Ok, got it!",
'str9': "Help, I'm stuck!",
'str10': "<div class='file-name'>style.css</div> CSS Editor",
'str11': "Type in a CSS selector",
'str12': "enter",
'str13': "{<br/>/* Styles would go here. */<br/>}",
'str14': '<br/>/* <br/>Type a number to skip to a level.<br/>Ex → "5" for level 5 <br/>*/',
'str15': "<div class='file-name'>table.html</div> HTML Viewer",
'str16': "What is this?",
'str17': "It's a little game to help you learn CSS selectors. Type in the correct selector to complete each level. Get help on the right."
}
levels['en'] = [
{
helpTitle : "Select elements by their type",
selectorName : "Type Selector",
doThis : "Select the plates",
selector : "plate",
syntax : "A",
help : "Selects all elements of type <strong>A</strong>. Type refers to the type of tag, so <tag>div</tag>, <tag>p</tag> and <tag>ul</tag> are all different element types.",
examples : [
'<strong>div</strong> selects all <tag>div</tag> elements.',
'<strong>p</strong> selects all <tag>p</tag> elements.',
],
board: "()()"
},
{
doThis : "Select the bento boxes",
selector : "bento",
syntax : "A",
helpTitle : "Select elements by their type",
selectorName : "Type Selector",
help : "Selects all elements of type <strong>A</strong>. Type refers to the type of tag, so <tag>div</tag>, <tag>p</tag> and <tag>ul</tag> are all different element types.",
examples : [
'<strong>div</strong> will select all <tag>div</tag> elements.',
'<strong>p</strong> will select all <tag>p</tag> elements.',
],
board: "[]()[]"
},
{
doThis : "Select the fancy plate",
selector : "#fancy",
selectorName: "ID Selector",
helpTitle: "Select elements with an ID",
syntax: "#id",
help : 'Selects the element with the <strong>id</strong> attribute. You can also combine the ID selector with the type selector.',
examples : [
'<strong>#cool</strong> will select any element with <strong>id="cool"</strong>',
'<strong>ul#long</strong> will select <strong><ul id="long"></strong>'
],
board: "{}()[]"
},
{
helpTitle: "Select an element inside another element",
selectorName : "Descendant Selector",
doThis : "Select the apple on the plate",
selector : "plate apple",
syntax: "A B",
help : "Selects all <strong>B</strong> inside of <strong>A</strong>. Here <strong>B</strong> is the descendant element, meaning an element that is inside of another element.",
examples : [
'<strong>p strong</strong> will select all <strong><strong></strong> that are descendants of any <strong><p></strong>',
'<strong>#fancy span</strong> will select any <strong><span></strong> that is a descendant of any element with <strong>id="fancy"</strong>',
],
board: "[](A)A"
},
{
doThis : "Select the pickle on the fancy plate",
selector : "#fancy pickle",
helpTitle: "Combine the Descendant & ID Selectors",
syntax: "#id A",
help : 'You can combine any selector with the descendent selector.',
examples : [
'<strong>#cool span</strong> will select all <strong><span></strong> elements that are inside of elements with <strong>id="cool"</strong>'
],
board: "[O]{P}(P)"
},
{
doThis : "Select the small apples",
selector : ".small",
selectorName: "Class Selector",
helpTitle: "Select elements by their class",
syntax: ".classname",
help : 'The class selector selects all elements with that class attribute. Elements can only have one ID, but many classes.',
examples : [
'<strong>.neato</strong> selects all elements with <strong>class="neato"</strong>'
],
board: "Aa(a)()"
},
{
doThis : "Select the small oranges",
selector : "orange.small",
helpTitle: "Combine the Class Selector",
syntax: "A.className",
help : 'You can combine the class selector with other selectors, like the type selector.',
examples : [
'<strong>ul.important</strong> will select all <strong><ul></strong> elements that have <strong>class="important"</strong>',
'<strong>#big.wide</strong> will select all elements with <strong>id="big"</strong> that also have <strong>class="wide"</strong>'
],
board: "Aa[o](O)(o)"
},
{
doThis : "Select the small oranges in the bentos",
selector : "bento orange.small",
syntax: "Put your back into it!",
helpTitle: "You can do it...",
help : 'Combine what you learned in the last few levels to solve this one!',
board: "A(o)[o][a][o]"
},
{
doThis : "Select all the plates and bentos",
selector : "plate,bento",
selectorName : "Comma Combinator",
helpTitle: "Combine, selectors, with... commas!",
syntax : "A, B",
help : 'Thanks to Shatner technology, this will select all <strong>A</strong> and <strong>B</strong> elements. You can combine any selectors this way, and you can specify more than two.',
examples: [
'<strong>p, .fun</strong> will select all <tag>p</tag> elements as well as all elements with <strong>class="fun"</strong>',
'<strong>a, p, div</strong> will select all <tag>a</tag>, <tag>p</tag> and <tag>div</tag> elements'
],
board: "pP(P)[P](P)Pp"
},
{
doThis : "Select all the things!",
selector : "*",
selectorName: "The Universal Selector",
helpTitle: "You can select everything!",
syntax : "*",
help : 'You can select all elements with the universal selector! ',
examples : [
'<strong>p *</strong> will select every element inside all <strong><p></strong> elements.'
],
board: "A(o)[][O]{)"
},
{
doThis : "Select everything on a plate",
selector : "plate *",
syntax : "A *",
helpTitle: "Combine the Universal Selector",
help : 'This will select all elements inside of <strong>A</strong>.',
examples : [
'<strong>p *</strong> will select every element inside all <strong><p></strong> elements.',
'<strong>ul.fancy *</strong> will select every element inside all <strong><ul class="fancy"></strong> elements.'
],
board: "{o}(P)a(A)"
},
{
doThis : "Select every apple that's next to a plate",
selector : "plate + apple",
helpTitle: "Select an element that directly follows another element",
selectorName: "Adjacent Sibling Selector",
syntax : "A + B",
help : "This selects all <strong>B</strong> elements that directly follow <strong>A</strong>. Elements that follow one another are called siblings. They're on the same level, or depth. <br/><br/>In the HTML markup for this level, elements that have the same indentation are siblings.",
examples : [
'<strong>p + .intro</strong> will select every element with <strong>class="intro"</strong> that directly follows a <tag>p</tag>',
'<strong>div + a</strong> will select every <tag>a</tag> element that directly follows a <tag>div</tag>'
],
board: "[a]()a()Aaa"
},
{
selectorName: "General Sibling Selector",
helpTitle: "Select elements that follows another element",
syntax: "A ~ B",
doThis : "Select every pickle to the right of the bento",
selector : "bento ~ pickle",
help : "You can select all siblings of an element that follow it. This is like the Adjacent Selector (A + B) except it gets all of the following elements instead of one.",
examples : [
'<strong>A ~ B</strong> will select all <strong>B</strong> that follow a <strong>A</strong>'
],
board: "P[o]pP(P)(p)"
},
{
selectorName: "Child Selector",
syntax: "A > B ",
doThis : "Select the apple directly on a plate",
selector : "plate > apple",
helpTitle: "Select direct children of an element",
help : "You can select elements that are direct children of other elements. A child element is any element that is nested direclty in another element. <br><br>Elements that are nested deeper than that are called descendant elements.",
examples : [
'<strong>A > B</strong> will select all <strong>B</strong> that are a direct children <strong>A</strong>'
],
board: "([A])(A)()Aa"
},
{
selectorName: "First Child Pseudo-selector",
helpTitle: "Select a first child element inside of another element",
doThis : "Select the top orange",
selector : "plate :first-child",
syntax: ":first-child",
help : "You can select the first child element. A child element is any element that is directly nested in another element. You can combine this pseudo-selector with other selectors.",
examples : [
'<strong>:first-child</strong> selects all first child elements.',
'<strong>p:first-child</strong> selects all first child <strong><p></strong> elements.',
'<strong>div p:first-child</strong> selects all first child <strong><p></strong> elements that are in a <strong><div></strong>.'
],
board: "[]()(OOO)p"
},
{
selectorName: "Only Child Pseudo-selector",
helpTitle: "Select an element that are the only element inside of another one.",
doThis : "Select apple and the pickle on the plates",
selector : "plate :only-child",
syntax: ":only-child",
help : "You can select any element that is the only element inside of another one.",
examples : [
'<strong>span:only-child</strong> selects the <strong><span></strong> elements that are the only child of some other element.',
'<strong>ul li:only-child</strong> selects the only <strong><li></strong> element that are in a <strong><ul></strong>.'
],
board: "(A)(p)[]P(oO)p"
},
{
selectorName: "Last Child Pseudo-selector",
helpTitle: "Select the last element inside of another element",
doThis : "Select the small apple and the pickle",
selector : ".small:last-child",
syntax: ":last-child",
help : "You can use this selector to select an element that is the last child element inside of another element. <br><br>Pro Tip → In cases where there is only one element, that element counts as the first-child, only-child and last-child!",
examples : [
'<strong>:last-child</strong> selects all last-child elements.',
'<strong>span:last-child</strong> selects all last-child <strong><span></strong> elements.',
'<strong>ul li:last-child</strong> selects the last <strong><li></strong> elements inside of any <strong><ul></strong>.'
],
board: "{a)()(oO)p"
},
{
selectorName: "Nth Child Pseudo-selector",
helpTitle: "Select an element by its order in another element",
doThis : "Select the 3rd plate",
selector : ":nth-child(3)",
syntax: ":nth-child(A)",
help : "Selects the <strong>nth</strong> (Ex: 1st, 3rd, 12th etc.) child element in another element.",
examples : [
'<strong>:nth-child(8)</strong> selects every element that is the 8th child of another element.',
'<strong>div p:nth-child(2)</strong> selects the second <strong>p</strong> in every <strong>div</strong>',
],
board: "()()(){}"
},
{
selectorName: "Nth Last Child Selector",
helpTitle: "Select an element by its order in another element, counting from the back",
doThis : "Select the 1st bento",
selector : "bento:nth-last-child(4)",
syntax: ":nth-last-child(A)",
help : "Selects the children from the bottom of the parent. This is like nth-child, but counting from the back!",
examples : [
'<strong>:nth-last-child(2)</strong> selects all second-to-last child elements.'
],
board: "()[]a(OOO)[]"
},
{
selectorName: "First of Type Selector",
helpTitle: "Select the first element of a specific type",
doThis : "Select first apple",
selector : "apple:first-of-type",
syntax: ":first-of-type",
help : "Selects the first element of that type within another element.",
examples : [
'<strong>span:first-of-type</strong> selects the first <strong><span></strong> in any element.'
],
board: "Aaaa(oO)"
},
{
selectorName: "Nth of Type Selector",
// helpTitle: "Nth of Type Selector",
doThis: "Select all even plates",
selector: "plate:nth-of-type(even)",
syntax: ":nth-of-type(A)",
help: "Selects a specific element based on its type and order in another element - or even or odd instances of that element.",
examples: [
'<strong>div:nth-of-type(2)</strong> selects the second instance of a div.',
'<strong>.example:nth-of-type(odd)</strong> selects all odd instances of a the example class.'
],
board: "()()()(){}()"
},
{
selectorName: "Nth-of-type Selector with Formula",
// helpTitle: "Nth-of-type Selector with formula",
doThis: "Select every 2nd plate, starting from the 3rd",
selector: "plate:nth-of-type(2n+3)",
syntax: ":nth-of-type(An+B)",
help: "The nth-of-type formula selects every nth element, starting the count at a specific instance of that element.",
examples: [
'<strong>span:nth-of-type(6n+2)</strong> selects every 6th instance of a <tag>span</tag>, starting from (and including) the second instance.'
],
board: "()(p)(a)()(A)()"
},
{
selectorName: "Only of Type Selector",
helpTitle: "Select elements that are the only ones of their type",
selector : "apple:only-of-type",
syntax: ":only-of-type",
doThis : "Select the apple on the middle plate.",
help : "Selects the only element of its type within another element.",
examples : [
'<strong>p span:only-of-type</strong> selects a <tag>span</tag> within any <tag>p</tag> if it is the only <tag>span</tag> in there.'
],
board: "(aA)(a)(p)"
},
{
selectorName: "Last of Type Selector",
helpTitle: "Select the last element of a specific type",
doThis : "Select the second apple and orange",
selector : ".small:last-of-type",
syntax: ":last-of-type",
help : "Selects each last element of that type within another element. Remember type refers the kind of tag, so <tag>p</tag> and <tag>span</tag> are different types. <br><br> I wonder if this is how the last dinosaur was selected before it went extinct.",
examples : [
'<strong>div:last-of-type</strong> selects the last <strong><div></strong> in every element.',
'<strong>p span:last-of-type</strong> selects the last <strong><span></strong> in every <strong><p></strong>.'
],
board: "ooPPaa"
},
{
selectorName: "Empty Selector",
helpTitle: "Select elements that don't have children",
doThis : "Select the empty bentos",
selector : "bento:empty",
syntax: ":empty",
help : "Selects elements that don't have any other elements inside of them.",
examples : [
'<strong>div:empty</strong> selects all empty <strong><div></strong> elements.'
],
board: "[][p][][]"
},
{
selectorName: "Negation Pseudo-class",
helpTitle: "Select all elements that don't match the negation selector",
doThis : "Select the big apples",
selector : "apple:not(.small)",
syntax: ":not(X)",
help : 'You can use this to select all elements that do not match selector <strong>"X"</strong>.',
examples : [
'<strong>:not(#fancy)</strong> selects all elements that do not have <strong>id="fancy"</strong>.',
'<strong>div:not(:first-child)</strong> selects every <tag>div</tag> that is not a first child.',
'<strong>:not(.big, .medium)</strong> selects all elements that do not have <strong>class="big"</strong> or <strong>class="medium"</strong>.'
],
board: "{a}(A)A(o)p"
}
];