Skip to content

Commit

Permalink
Ugly web interface added
Browse files Browse the repository at this point in the history
But it works!!!1
  • Loading branch information
nieske authored and nieske committed Oct 20, 2013
1 parent ca282ba commit 65236d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
20 changes: 18 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,26 @@

<h1>Welcome to Untangle!</h1>

<div id="puzzle"></div>



<input id="answer" type="text" placeholder="Your answer here">
<button id="button">Check!</button>
<div id="outcome"></div>

<script src="untangle.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(document).ready(function() {
puzzle.forEach(function(word) {
$('#puzzle').append('<div>' + word + '</div>');
});

$('#button').click(function() {
var userAnswer = $('#answer').val();
var correct = checkAnswer(userAnswer);
$('#outcome').text(correct ? 'hoera' : 'jammer');
});
});
</script>
</body>
</html>
7 changes: 5 additions & 2 deletions untangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ var puzzles = [
];


var text = puzzles[Math.floor(puzzles.length * Math.random())];
var text = getRandomElement(puzzles);
var rightAnswer = text.toLowerCase();
var puzzle = text.toLowerCase().split(' ').sort();

function getRandomElement(list) {
return list[Math.floor(list.length * Math.random())];
}

function checkAnswer(userAnswer) {
return userAnswer.toLowerCase() === rightAnswer;
}
}

0 comments on commit 65236d8

Please sign in to comment.