diff --git a/game/static/game/js/level_editor.js b/game/static/game/js/level_editor.js index 5e12059b4..498117060 100644 --- a/game/static/game/js/level_editor.js +++ b/game/static/game/js/level_editor.js @@ -643,7 +643,7 @@ ocargo.LevelEditor = function(levelId) { return; } - const regex = /^(\w?[ ]?)*$/; + const regex = /^[\w ]*$/; const validString = regex.exec(nameInput.val()); if (!validString) { ocargo.Drawing.startPopup( @@ -1685,7 +1685,7 @@ ocargo.LevelEditor = function(levelId) { var bBox = image.getBBox(); imageWidth = bBox.width; imageHeight = bBox.height; - + var paperPosition = paper.position(); originX = x - paperPosition.left + paper.scrollLeft() - imageWidth/2; originY = y - paperPosition.top + paper.scrollTop() - imageHeight/2; @@ -1697,7 +1697,7 @@ ocargo.LevelEditor = function(levelId) { } function onDragEnd() { - + if (trashcanOpen) { cow.destroy(); unmarkOldCowSquare(controlledCoord, cow); @@ -1714,15 +1714,15 @@ ocargo.LevelEditor = function(levelId) { else { var cowX = paperX; var cowY = paperY; - + if (paperWidth < paperX + imageWidth) { cowX = paperWidth - imageWidth } - + if (paperHeight < paperY + imageHeight) { cowY = paperHeight - imageHeight } - + image.transform('t' + cowX + ',' + cowY); } } @@ -1875,12 +1875,12 @@ ocargo.LevelEditor = function(levelId) { internalCow.destroy(); } } - + if (!trashcanOpen) { setCowMarkingsOnMouseUp(controlledCoord, internalCow); adjustCowGroupMinMaxFields(internalCow); } - + $(document) .off('mousemove', handleDraggableCowDragging) .off('mouseup mouseleave', handleDraggableCowMouseUp); @@ -2416,7 +2416,7 @@ ocargo.LevelEditor = function(levelId) { ">pigeons`; - + const cowHTML = ` 0) { - state.lesson = $('#description').val(); + if (descriptionValue.length > 0) { + if (regex.exec(descriptionValue)) { + state.lesson = descriptionValue; + } + else { + ocargo.Drawing.startPopup( + "Oh no!", + "You used some invalid characters for your level description.", + "Try saving your level again using only" + + " letters and numbers and standard punctuation." + ); + return + } } - if ($('#hint').val().length > 0) { - state.hint = $('#hint').val(); + if (hintValue.length > 0) { + if (regex.exec(hintValue)) { + state.hint = hintValue; + } + else { + ocargo.Drawing.startPopup( + "Oh no!", + "You used some invalid characters for your level hint.", + "Try saving your level again using only" + + " letters and numbers and standard punctuation." + ); + return + } } // Other data