diff --git a/views/tutorial/html/2.erb b/views/tutorial/html/2.erb index d716b422..769fdb02 100644 --- a/views/tutorial/html/2.erb +++ b/views/tutorial/html/2.erb @@ -35,46 +35,28 @@ function checkHomework() { var html = editor.getValue() - var match = '.+' - var re = new XRegExp(match, 'gis') - - if(html.match(re) === null) { - notok("You're missing the HTML element tag! Your web site must begin with and end with .") + if(!html.tutorialMatches('.+')) { + notok("You're missing the HTML element tag! Your web site must begin with <html> and end with </html>.") return } -/* - var match = '.+.+' - var re = new XRegExp(match, 'gis') - - if(html.match(re) === null) { - notok("You need to add some text inside the <body></body>.") - return - } -*/ - var match = 'Hello World' - - var re = new XRegExp(match, 'gis') - - if(html.match(re) !== null) { + if(html.tutorialMatches('Hello World!')) { notok("Hint: Try changing \"Hello World\" to something else.") return } + if(!html.tutorialMatches('.+.+.+')) { + notok('Missing the <body> and/or the </body> tag.') + return + } + + if(html.match(/[\s\n]+<\/body>/) !== null) { + notok('Need to add text between the <body> and the </body> tags.') + return + } + sessionStorage.setItem('tutorialHtml', html) ok('Great, you did it!', '/tutorial/html/3') -/* - 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/3') - } -*/ } diff --git a/views/tutorial/layout.erb b/views/tutorial/layout.erb index e7b36b5a..487e6de2 100644 --- a/views/tutorial/layout.erb +++ b/views/tutorial/layout.erb @@ -80,6 +80,18 @@