mirror of
https://github.com/neocities/neocities.git
synced 2025-07-20 17:46:05 +02:00
better homework checking for tutorial up to page 6
This commit is contained in:
parent
322a87b1d0
commit
8c5b9a803d
5 changed files with 67 additions and 31 deletions
|
@ -3,9 +3,9 @@
|
|||
You're writing HTML! You're doing it! Everything you need to know is just another tag!
|
||||
</div>
|
||||
<div class="dialogue" style="top: -20px; width: 320px">
|
||||
<p>For example, links look like this:</p>
|
||||
<p>For example, a link to another site looks like this:</p>
|
||||
|
||||
<p><strong><a href="http://neocities.org">Check out Neocities!</a></strong></p>
|
||||
<p><strong><a href="//neocities.org">Check out Neocities!</a></strong></p>
|
||||
|
||||
<p>Add a link to your favorite site to<br> the end of the paragraph, right<br> before the </p> closing tag!</p>
|
||||
</div>
|
||||
|
@ -15,11 +15,13 @@
|
|||
<h4>Nesting</h4>
|
||||
<p>Tags always need to be nested properly, like Russian dolls. So this is okay:
|
||||
<pre>
|
||||
<p>Welcome! <a>Link!</a></p>
|
||||
<p>Welcome! <a href="//neocities.org">Link!</a></p>
|
||||
</pre>
|
||||
|
||||
But this isn't!
|
||||
But this is not correct:
|
||||
|
||||
<p>Welcome! <a>Link!</p></a>
|
||||
<pre>
|
||||
<p>Welcome! <a href="//neocities.org">Link!</p></a>
|
||||
</pre>
|
||||
</p>
|
||||
</div>
|
||||
|
@ -31,11 +33,36 @@ But this isn't!
|
|||
var match = '<html.+>.+<body>.+<h1>.+</h1>.+<p>.+<a.+href=".+">.+</a>[^.+]?</p>.+</body>.+</html>'
|
||||
var re = new XRegExp(match, 'gis')
|
||||
|
||||
if(html.match(re) === null) {
|
||||
notok("That's not right! Try again.")
|
||||
} else {
|
||||
sessionStorage.setItem('tutorialHtml', html)
|
||||
ok('Great, you did it!', '/tutorial/html/6')
|
||||
var p = preview().find('p')
|
||||
|
||||
if(p.length == 0) {
|
||||
notok("Couldn't find a paragraph! Did you accidentally delete it? Add it back or click the reset button to start over.")
|
||||
return
|
||||
}
|
||||
|
||||
var a = p.find('a')
|
||||
|
||||
if(a.length == 0) {
|
||||
notok("Couldn't find an <a> link in your paragraph, try to add it inside the paragraph.")
|
||||
return
|
||||
}
|
||||
|
||||
if(a.attr('href') === undefined) {
|
||||
notok("Your a tag is missing an href attribute. Try writing it like this: <a href=\"//neocities.org\"> and don't forget the closing <a> tag!")
|
||||
return
|
||||
}
|
||||
|
||||
if(a.attr('href') == '' || a.attr('href').match(/\s+/)) {
|
||||
notok('You need to add a url to the <strong>href</strong>, like this: href="//neocities.org"')
|
||||
return
|
||||
}
|
||||
|
||||
if(a.text() == '' || a.text().match(/\s+/)) {
|
||||
notok('You need to add a name for your link, which is the text between the <a> tag, and the closing tag </a>')
|
||||
return
|
||||
}
|
||||
|
||||
sessionStorage.setItem('tutorialHtml', html)
|
||||
ok('Great, nice link!', '/tutorial/html/6')
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue