mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
cleaner tutorial match code, improved page 2 logic
This commit is contained in:
parent
4f0eb2b82b
commit
10789f46f4
2 changed files with 25 additions and 31 deletions
|
@ -35,46 +35,28 @@
|
||||||
|
|
||||||
function checkHomework() {
|
function checkHomework() {
|
||||||
var html = editor.getValue()
|
var html = editor.getValue()
|
||||||
var match = '<html>.+</html>'
|
|
||||||
|
|
||||||
var re = new XRegExp(match, 'gis')
|
if(!html.tutorialMatches('<html>.+</html>')) {
|
||||||
|
notok("You're missing the HTML element tag! Your web site must begin with <html> and end with </html>.")
|
||||||
if(html.match(re) === null) {
|
|
||||||
notok("You're missing the HTML element tag! Your web site must begin with <html> and end with </html>.")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
var match = '<html.+>.+<body></body>.+</html>'
|
|
||||||
|
|
||||||
var re = new XRegExp(match, 'gis')
|
if(html.tutorialMatches('Hello World!')) {
|
||||||
|
|
||||||
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) {
|
|
||||||
notok("Hint: Try changing \"Hello World\" to something else.")
|
notok("Hint: Try changing \"Hello World\" to something else.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!html.tutorialMatches('<html>.+<body>.+</body>.+</html>')) {
|
||||||
|
notok('Missing the <body> and/or the </body> tag.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(html.match(/<body>[\s\n]+<\/body>/) !== null) {
|
||||||
|
notok('Need to add text between the <body> and the </body> tags.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
sessionStorage.setItem('tutorialHtml', html)
|
sessionStorage.setItem('tutorialHtml', html)
|
||||||
ok('Great, you did it!', '/tutorial/html/3')
|
ok('Great, you did it!', '/tutorial/html/3')
|
||||||
/*
|
|
||||||
var match = '<html.+>.+<body>.+</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/3')
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -80,6 +80,18 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var infoObj = $('.error')
|
var infoObj = $('.error')
|
||||||
|
|
||||||
|
String.prototype.tutorialMatches = function(regex, opts) {
|
||||||
|
if(!opts)
|
||||||
|
var opts = 'gis'
|
||||||
|
|
||||||
|
var result = this.match(new XRegExp(regex, opts))
|
||||||
|
|
||||||
|
if(result == null)
|
||||||
|
return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
function notok(msg) {
|
function notok(msg) {
|
||||||
displayInfo('<i class="fa fa-exclamation-triangle"></i> ' + msg, {
|
displayInfo('<i class="fa fa-exclamation-triangle"></i> ' + msg, {
|
||||||
background: '#93771B'
|
background: '#93771B'
|
||||||
|
|
Loading…
Add table
Reference in a new issue