diff --git a/views/tutorial/html/7.erb b/views/tutorial/html/7.erb index 03cc42be..bead414f 100644 --- a/views/tutorial/html/7.erb +++ b/views/tutorial/html/7.erb @@ -33,15 +33,28 @@ function checkHomework() { var html = editor.getValue() - /* TODO: Make .+ ignore any spaces or newlines or whatever. lol

is fine too. */ - var match = '.+.+.+.+' - 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/8') + if(!html.match(new XRegExp('', 'gis'))) { + notok("I don't see the <ul> and </ul> tag!") + return } + + var ul = preview().find('ul') + + if(ul.find('li').length == 0) { + notok("Okay, I see the ul, but no li. Try adding a list item to it: <li>Yarn</li>") + return + } + + var liText = ul.find('li').first().text() + + if(liText == '' || liText.match(/\s+/)) { + notok("I don't see any text in the li. Try using it like this: <li>Yarn</li>") + return + } + + if(ul.find('li')) + + sessionStorage.setItem('tutorialHtml', html) + ok('Awesome list!', '/tutorial/html/8') } diff --git a/views/tutorial/html/8.erb b/views/tutorial/html/8.erb index 79f2fbbb..dff1adf5 100644 --- a/views/tutorial/html/8.erb +++ b/views/tutorial/html/8.erb @@ -1,7 +1,10 @@
- Now add a link to one of your list items. If nested properly, it should look something like this: -
<li><a href="http://yarn.com">Yarn</a></li> + Now add a link to one of your list items. If nested properly, it should look similar to this: +
+
+ <li>
  <a href="http://yarn.com">Yarn</a>
</li>
+
@@ -23,15 +26,23 @@ function checkHomework() { var html = editor.getValue() - /* TODO: Make .+ ignore any spaces or newlines or whatever. lol

is fine too. */ - var match = '.+.+.+.+' - 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/9') + var a = preview().find('li a') + if(a.length == 0) { + notok("I don't see a link in your <li></li>, try adding one.") + return } + + if(a.attr('href') === undefined || a.attr('href') == '') { + notok('You need to add an href to your a tag, like: 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, you did it!', '/tutorial/html/9') }