add logic for tutorial requirement

This commit is contained in:
Kyle Drake 2024-03-01 12:50:41 -06:00
parent 01aab733bb
commit 2ff8365651
9 changed files with 32 additions and 9 deletions

View file

@ -31,6 +31,7 @@
</div>
<script>
sessionStorage.setItem('tutorialHtml', '')
$('#checkButton').on('click', function(button) {
checkHomework($('#nameInput').val())
})

View file

@ -44,6 +44,6 @@
}
sessionStorage.setItem('tutorialHtml', html)
ok('Great, you did it!', '/tutorial/html/9')
ok('Great, you did it!', '/tutorial/html/9?csrf_token=<%= Rack::Utils.escape csrf_token %>')
}
</script>

View file

@ -20,7 +20,7 @@
$('#saveToSite').on('click', function() {
$.ajax({
url: '/site_files/save/index.html?csrf_token=<%= Rack::Utils.escape csrf_token %>',
url: '/site_files/upload?csrf_token=<%= Rack::Utils.escape csrf_token %>&filename=<%= Rack::Utils.escape 'index.html' %>&site_id=<%= current_site.id %>',
data: sessionStorage.getItem('tutorialHtml'),
processData: false,
contentType: false,
@ -29,11 +29,7 @@
alert('There has been an error saving your file, please try again. If it continues to fail, make a copy of the file locally so you don\'t lose your changes!')
},
success: function(response){
if(response == 'ok') {
window.location = '/tutorial/html/10'
} else {
alert('There has been an error saving your file, please try again. If it continues to fail, make a copy of the file locally so you don\'t lose your changes!')
}
window.location = '/tutorial/html/10'
}
})