From 10789f46f416cd5de1cac37b8a7c6b598b75f817 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Fri, 15 Apr 2016 15:35:01 -0700 Subject: [PATCH] cleaner tutorial match code, improved page 2 logic --- views/tutorial/html/2.erb | 44 ++++++++++++--------------------------- views/tutorial/layout.erb | 12 +++++++++++ 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/views/tutorial/html/2.erb b/views/tutorial/html/2.erb index faf7837a..30bd4cd9 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 e34cfc01..a6c93c85 100644 --- a/views/tutorial/layout.erb +++ b/views/tutorial/layout.erb @@ -80,6 +80,18 @@