");
+
+ var listaCuvinte = localStorage.getItem("listaCuvinte");
+ if (listaCuvinte != null) {
+ $("select[name=lista_cuvinte]").val(listaCuvinte);
+ newGame(eval(listaCuvinte));
+ } else {
+ newGame(animale_eu);
+ }
+
+ $("select[name=lista_cuvinte]").on("change", function() {
+ localStorage.setItem("listaCuvinte", $(this).val());
+ }).next().click(function() {
+ // eval for transforming string into object ref!!!
+ newGame(eval($(this).prev().val())); // POSSIBLE EXPLOIT!!
+ // prev for mobile <3
+ });
+
+ $('#game').fadeIn("slow");
+
+});
+
+$(document).on("keypress", function(e) {
+ var key = e.keyCode || e.which;
+ var key2 = String.fromCharCode(key).toLowerCase();
+
+ ion.sound.play("button_tiny");
+
+ $('.litera_msg').fadeIn('slow');
+ $('.litera').html(key2);
+
+ //already guessed, check,
+ if (check(key2)) {
+ $('.litera_msg2').html("aceasta litera se afla in cuvant.");
+ updateArray(key2);
+ $('.word').html(charArray1);
+ } else {
+ $('.litera_msg2').html("aceasta litera nu se afla in cuvant.");
+
+ incercari--;
+
+ if (incercari > -1) {
+ $("#human").attr('src', "./img/" + incercari + ".png");
+ $('#incercari').html(incercari);
+ updateLetters(key2);
+ if (incercari == 0)
+ gameOver();
+ }
+ }
+
+ // check if arrays are equal
+ if (arraysEqual(charArray1, charArray2)) {
+ gameWon();
+ }
+})
+
+function gameWon() {
+ if (WINDOW_W <= MOBILE_WIDH) {
+ ion.sound.play("ta_da");
+ alert("Felicita e tenersi per mano")
+ window.location.reload(); // mobile
+ return;
+ }
+ //alert("You're winner!");
+
+ if (WINDOW_W > MOBILE_WIDH)
+ $('#gamewon').fadeIn('slow');
+ $(document).off(); // Detach keypress handler
+ ion.sound.play("ta_da"); // Play victory sound
+
+ $('#gamewon img').click(function() {
+ window.location.reload();
+ });
+
+ $(document).on("keypress", function(e) {
+ var key = e.keyCode || e.which;
+ if (key == 13)
+ window.location.reload(); // Da reset la handlere :-)
+ });
+}
+
+function gameOver() {
+ if (WINDOW_W <= MOBILE_WIDH) {
+ ion.sound.play("sad_trombone");
+ alert("Ai pierdut! CUVANT: " + word);
+ window.location.reload(); // for mobile phones
+ return; // for slower mobile phones
+ }
+
+ $('#incercari_msg').html("Game Over!");
+ $('#lose_word').html(word);
+
+ if (WINDOW_W > MOBILE_WIDH)
+ $('#gameover').fadeIn('slow');
+ $(document).off(); // Detach keypress handler
+ ion.sound.play("sad_trombone");
+
+ $('#gameover img').click(function() {
+ window.location.reload();
+ });
+ $(document).on("keypress", function(e) {
+ var key = e.keyCode || e.which;
+ if (key == 13)
+ window.location.reload();
+ });
+}
+
+function check(guess) {
+ return word.indexOf(guess) > -1;
+}
+
+function updateLetters(guess) {
+
+ var len = missArray.length;
+ if (!($.inArray(guess, missArray) > -1)) {
+ missArray[len] = guess;
+ }
+ $('.litere').html(missArray + " ");
+
+}
+
+function updateArray(guess) {
+ guess = guess.toLowerCase();
+
+ for (i = 0; i < charArray1.length; i++) {
+ if (charArray2[i] == guess) {
+ charArray1[i] = guess;
+ }
+ }
+}
+
+function arraysEqual(a, b) {
+ if (a === b) return true;
+ if (a == null || b == null) return false;
+ if (a.length != b.length) return false;
+
+ for (var i = 0; i < a.length; ++i) {
+ if (a[i] !== b[i]) return false;
+ }
+ return true;
+}
diff --git a/src/game.min.js b/src/game.min.js
new file mode 100644
index 0000000..658b57f
--- /dev/null
+++ b/src/game.min.js
@@ -0,0 +1 @@
+function newGame(a){for(word=a[Math.floor(Math.random()*a.length)],incercari=6,charArray1=[],charArray2=[],missArray=[],i=0;i=WINDOW_W?(ion.sound.play("ta_da"),alert("Felicita e tenersi per mano"),void window.location.reload()):(WINDOW_W>MOBILE_WIDH&&$("#gamewon").fadeIn("slow"),$(document).off(),ion.sound.play("ta_da"),$("#gamewon img").click(function(){window.location.reload()}),void $(document).on("keypress",function(a){var r=a.keyCode||a.which;13==r&&window.location.reload()}))}function gameOver(){return MOBILE_WIDH>=WINDOW_W?(ion.sound.play("sad_trombone"),alert("Ai pierdut! CUVANT: "+word),void window.location.reload()):($("#incercari_msg").html("Game Over!"),$("#lose_word").html(word),WINDOW_W>MOBILE_WIDH&&$("#gameover").fadeIn("slow"),$(document).off(),ion.sound.play("sad_trombone"),$("#gameover img").click(function(){window.location.reload()}),void $(document).on("keypress",function(a){var r=a.keyCode||a.which;13==r&&window.location.reload()}))}function check(a){return word.indexOf(a)>-1}function updateLetters(a){var r=missArray.length;$.inArray(a,missArray)>-1||(missArray[r]=a),$(".litere").html(missArray+" ")}function updateArray(a){for(a=a.toLowerCase(),i=0;iSpanzuratoareacreated by@Niutenisu
');var listaCuvinte=localStorage.getItem("listaCuvinte");null!=listaCuvinte?($("select[name=lista_cuvinte]").val(listaCuvinte),newGame(eval(listaCuvinte))):newGame(animale_eu),$("select[name=lista_cuvinte]").on("change",function(){localStorage.setItem("listaCuvinte",$(this).val())}).next().click(function(){newGame(eval($(this).prev().val()))}),$("#game").fadeIn("slow")}),$(document).on("keypress",function(a){var r=a.keyCode||a.which,e=String.fromCharCode(r).toLowerCase();ion.sound.play("button_tiny"),$(".litera_msg").fadeIn("slow"),$(".litera").html(e),check(e)?($(".litera_msg2").html("aceasta litera se afla in cuvant."),updateArray(e),$(".word").html(charArray1)):($(".litera_msg2").html("aceasta litera nu se afla in cuvant."),incercari--,incercari>-1&&($("#human").attr("src","./img/"+incercari+".png"),$("#incercari").html(incercari),updateLetters(e),0==incercari&&gameOver())),arraysEqual(charArray1,charArray2)&&gameWon()});
diff --git a/src/hangman2.html b/src/hangman2.html
new file mode 100644
index 0000000..0f937c2
--- /dev/null
+++ b/src/hangman2.html
@@ -0,0 +1,122 @@
+
+
+
+
+ Spanzuratoarea
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Spanzuratoarea!
+
+
+
Incearca sa ghicesti cuvantul:
+
+
Introdu aici litera:
+
+
+
+
Ai apasat pe "
+
+
+
+ "
+
+
+
+
+
+
+
+
+
+
+
+
Incearca sa ghicesti cuvantul:
+
+
Apasa pe o litera de pe tastatura!
+
+
Ai apasat pe "
+
+
+
+ ""
+
+
+
+
Instructiuni:
+
Incearca sa ghicesti cuvantul! Ai 6 incercari pana cand vei fi spanzurat