improved flow for 7 and 8

This commit is contained in:
Kyle Drake 2016-04-17 17:23:31 -07:00
parent 8c5b9a803d
commit 1f6ef958dc
2 changed files with 44 additions and 20 deletions

View file

@ -33,15 +33,28 @@
function checkHomework() {
var html = editor.getValue()
/* TODO: Make .+ ignore any spaces or newlines or whatever. </a> lol </p> is fine too. */
var match = '<html.+>.+<body>.+<ul>.+<li>.+</li>.+</ul>.+</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/8')
if(!html.match(new XRegExp('<ul>.+</ul>', 'gis'))) {
notok("I don't see the &lt;ul&gt; and &lt;/ul&gt; tag!")
return
}
var ul = preview().find('ul')
if(ul.find('li').length == 0) {
notok("Okay, I see the <strong>ul</strong>, but no <strong>li</strong>. Try adding a list item to it: &lt;li&gt;Yarn&lt;/li&gt;")
return
}
var liText = ul.find('li').first().text()
if(liText == '' || liText.match(/\s+/)) {
notok("I don't see any text in the <strong>li</strong>. Try using it like this: <strong>&lt;li&gt;Yarn&lt;/li&gt;</strong>")
return
}
if(ul.find('li'))
sessionStorage.setItem('tutorialHtml', html)
ok('Awesome list!', '/tutorial/html/8')
}
</script>