diff --git a/app/tutorial.rb b/app/tutorial.rb index 4453594d..cdba092f 100644 --- a/app/tutorial.rb +++ b/app/tutorial.rb @@ -1,3 +1,22 @@ +def default_tutorial_html + <<-EOT.strip + + + + + + My web site + + + + + Hello World! + + + +EOT +end + get '/tutorials' do erb :'tutorials' end diff --git a/public/cat.png b/public/cat.png index d4be8f21..7d8eeadb 100644 Binary files a/public/cat.png and b/public/cat.png differ diff --git a/views/tutorial/html/2.erb b/views/tutorial/html/2.erb index c54131c6..6f615be2 100644 --- a/views/tutorial/html/2.erb +++ b/views/tutorial/html/2.erb @@ -32,10 +32,9 @@ var answer = storedName+ "'s Website" $('#studentName').text(storedName) - function checkHomework(editor) { - var html = editor.val() - - var match = '.+.+'+answer+'.+.+' + function checkHomework() { + var html = editor.getValue() + var match = '.+.+'+answer+'.+.+' var re = new XRegExp(match, 'gis') if(html.match(re) === null) { diff --git a/views/tutorial/html/3.erb b/views/tutorial/html/3.erb index 8eb581d8..d447683a 100644 --- a/views/tutorial/html/3.erb +++ b/views/tutorial/html/3.erb @@ -32,10 +32,9 @@ $('#answer').text(answer) - function checkHomework(editor) { - var html = editor.val() - - var match = '.+.+'+answer+'.+.+' + function checkHomework() { + var html = editor.getValue() + var match = '.+.+'+answer+'.+.+' var re = new XRegExp(match, 'gis') if(html.match(re) === null) { diff --git a/views/tutorial/html/4.erb b/views/tutorial/html/4.erb index 95c1e2bf..78723156 100644 --- a/views/tutorial/html/4.erb +++ b/views/tutorial/html/4.erb @@ -9,10 +9,9 @@ + + - - - @@ -71,8 +99,7 @@ } $('.tutorial #submit').on('click', function() { - var editor = $('#editor') - var result = checkHomework(editor) + var result = checkHomework() if(result == true) { window.location.href = '/tutorial/<%= @section %>/<%= @page.to_i+1 %>' } @@ -83,18 +110,12 @@ editor.val(editor.text()) }) - $('.tutorial textarea').on('keypress keyup', function() { - $('.error').css('display', 'none') - refreshIframe() - }) - var tutorialHtml = sessionStorage.getItem('tutorialHtml') if(tutorialHtml) $('#editor').text(tutorialHtml) function refreshIframe() { - var editor = $('#editor') - $('.tutorial iframe').contents().find('html').html(editor.val()) + $('.tutorial iframe').contents().find('html').html(editor.getValue()) } $(function() {