forked from flukeout/css-diner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevels.js
329 lines (323 loc) · 14.1 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
// 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
var levels = [
{
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 <strong><div></strong> elements.',
'<strong>p</strong> will select all <strong><p></strong> elements.',
],
board: "[]()[]"
},
{
doThis : "Select the fancy plate",
selector : "#fancy",
selectorName: "ID Selector",
helpTitle: "Select elements with an ID",
syntax: "#id",
help : 'Selects all elemoents element with that <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: "A #id",
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 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 an <tag>p</tag>',
'<strong>div + a</strong> will select every <tag>a</tag> element that directly follows an <tag>div</tag>'
],
board: "[a]()a()Aaa"
},
{
doThis : "Select every pickle to the right of the bento",
selector : "bento ~ pickle",
syntax: "A ~ B",
helpTitle: "General Sibling Selector",
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 an <strong>A</strong>'
],
board: "P[o]pP(P)(p)"
},
{
doThis : "Select the apple directly on a plate",
selector : "plate > apple",
helpTitle: "Child Selector",
syntax: "A > B",
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"
},
{
doThis : "Select the top orange",
selector : "plate :first-child",
syntax: ":first-child",
helpTitle: "First Child Pseudo-selector",
help : "You can select the first child element in any other element. You can combine this pseudo-selector with other selectors. A child element is any element that is directly nested in another element.",
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"
},
{
doThis : "Select apple and the pickle on the plates",
selector : "plate :only-child",
syntax: ":only-child",
helpTitle: "Only Child Pseudo-selector",
help : "You can selects any element that is the only element inside of another one.",
examples : [
'<strong>:last-child</strong> selects all last-child elements.',
'<strong>span:first-child</strong> selects all first-child <strong><span></strong> elements.',
'<strong>ul li:first-child</strong> selects all first-child <strong><li></strong> elements that are in a <strong><ul></strong>.'
],
board: "(A)(p)[]P(oO)p"
},
{
doThis : "Select the small apple and the pickle",
selector : ".small:last-child",
syntax: ":last-child",
helpTitle: "Last Child Pseudo-selector",
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"
},
{
doThis : "Select the 3rd plate",
selector : ":nth-child(3)",
syntax: ":nth-child(A)",
helpTitle: "Nth Child Selector",
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: "()()(){}"
},
{
helpTitle: "Nth-Last Child Selector",
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)[]"
},
{
helpTitle: "First of Type Selector",
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)"
},
{
helpTitle: "Nth-of-type Selector",
doThis: "Select all even plates",
selector: "plate:nth-of-type(even)",
syntax: ":nth-of-type(A)",
help: "Selects a specified number, or even/odd instances",
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: "()(){}()(){}"
},
{
helpTitle: "Only of Type Selector",
selector : "apple:only-of-type",
syntax: ":only-of-type",
doThis : "Select the apple on the middle plate.",
help : "Selects the only element of its kind within another element.",
examples : [
'<strong>p span:only-of-type</strong> selects a <strong><span></strong> within a <strong><p></strong> if it is the only <span> in there.'
],
board: "(aA)(a)(p)"
},
{
helpTitle: "Last of Type Selector",
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 <p> and <span> 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"
},
{
helpTitle: "Nth-of-type Selector with formula",
doThis: "Select every plate from the 5th",
selector: "plate:nth-of-type(1n+5)",
syntax: ":nth-of-type(An+B)",
help: "The nth-of-type formula indicates a cycle size and offset from which to start counting.",
examples: [
'<strong>span:nth-of-type(6n+2)</strong> selects every 6th instance of a span, starting from the second instance.'
],
board: "()(){}()(){}(){}()"
},
{
helpTitle: "Empty Selector",
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][][]"
},
{
doThis : "Select the big apples",
selector : "apple:not(.small)",
syntax: ":not(X)",
helpTitle: "Negation Pseudo-class",
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 <strong><div></strong> 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"
}
];