Properly escape html in error or warning.

This commit is contained in:
Dieter De Paepe 2016-11-29 10:55:57 +01:00
parent aa23ef52eb
commit 5f4bd66d36
2 changed files with 5 additions and 5 deletions

View File

@ -14,8 +14,8 @@
<textarea class="area" id="ta_turtle"></textarea>
<input type="button" id="btn_validate" value="Validate!"/>
</form>
<p id="errors"></p>
<p id="warnings"></p>
<ul id="errors"></ul>
<ul id="warnings"></ul>
<p id="results"></p>
<script src="js/app.js"></script>
</body>

View File

@ -5,15 +5,15 @@ $("#btn_validate").click( function () {
validate($("#ta_turtle").val(), function (feedback) {
$.each(feedback.warnings, function (index, warning) {
$("#warnings").append('<p id="warning' + index + '">' + warning + '<br/>');
$("#warnings").append($('<li id="warning' + index + '">').text(warning));
});
$.each(feedback.errors, function (index, error) {
$("#errors").append('<p id="error' + index + '">' + error + '<br/>');
$("#errors").append($('<li id="error' + index + '">').text(error));
});
if (feedback.errors.length === 0 && feedback.warnings.length === 0) {
$("#results").append("Congrats! We've validated your output and it contains 0 errors or warnings.");
$("#results").append("Congrats! Your syntax is correct.");
}
});
});