mirror of
https://github.com/neocities/neocities.git
synced 2025-07-22 02:26:07 +02:00
better homework checking for tutorial up to page 6
This commit is contained in:
parent
322a87b1d0
commit
8c5b9a803d
5 changed files with 67 additions and 31 deletions
|
@ -27,14 +27,25 @@
|
|||
var html = editor.getValue()
|
||||
|
||||
/* TODO: Make .+ ignore any spaces or newlines or whatever. </a> lol </p> is fine too. */
|
||||
var match = '<html.+>.+<body>.+<img.+src="/cat.png">.+</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/7')
|
||||
var img = preview().find('img')
|
||||
|
||||
if(img.length == 0) {
|
||||
notok("I couldn't find the <img src=\"/cat.png\"> tag, try again!")
|
||||
return
|
||||
}
|
||||
|
||||
if(img.attr('src') === undefined) {
|
||||
notok("There's no src=\"/cat.png\" in the <img> tag, try adding that.")
|
||||
return
|
||||
}
|
||||
|
||||
if(img.attr('src') == '' || img.attr('src').match(/\s+/)) {
|
||||
notok("The src attribute in the <img> tag can't be empty, try it like this: src=\"/cat.png\"")
|
||||
return
|
||||
}
|
||||
|
||||
sessionStorage.setItem('tutorialHtml', html)
|
||||
ok('Great, you did it!', '/tutorial/html/7')
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue