Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
Merge branch 'gsolbeck-development' into development: GuessWhat preve…
Browse files Browse the repository at this point in the history
…nt multiword hint exploit
  • Loading branch information
mcsooks committed Aug 12, 2014
2 parents 6794c8a + 51bada9 commit b026146
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions www/js/mg.game.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ MG_GAME_API = function ($) {
}
},

preventEvents : function (element, events) {
for (var i = 0; i < events.length; i++) {
element.bind(events[i], function (e) { e.preventDefault(); });
}
},

/*
* Standardized interface to call the GameAPI action. Allowing games to
* implement additional API call back functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ MG_GAME_GUESSWHAT = function ($) {

MG_GAME_GUESSWHAT.wordField = $("#tag");

//From ZenTag (mg.game.zentag.js:23)
// TODO: Refactor this part
// allowed keys, in game
$("#tag").bind("keydown", function(event) {
if (event.shiftKey) { // When pressing shift, only allow these
return (
(event.which >= 97 && event.which <= 122) || // a-z
(event.which >= 65 && event.which <= 90) // A-Z
);
}
else {
return (
(event.which >= 97 && event.which <= 122) ||// a-z
(event.which >= 65 && event.which <= 90) || // A-Z
event.which === 8 || event.which == 13
);
}
});

//Prevent paste/cut/copy
MG_GAME_API.preventEvents(MG_GAME_GUESSWHAT.wordField, ["paste", "cut", "copy"]);

// submit on enter
MG_GAME_GUESSWHAT.wordField.focus().keydown(function (event) {
if (event.keyCode == 13) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ MG_GAME_NEXTAG = function ($) {
}
});

//Prevent paste/cut/copy
MG_GAME_API.preventEvents(MG_GAME_NEXTAG.wordField, ["paste", "cut", "copy"]);

MG_GAME_NEXTAG.submitButton = $("#button-play").click(MG_GAME_NEXTAG.onsubmit);
// TRY to get pass button to submit correct value.
MG_GAME_NEXTAG.passButton = $("#button-pass").click(MG_GAME_NEXTAG.onpass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ MG_GAME_ONEUP = function ($) {

MG_GAME_ONEUP.wordField = $("#word");

//Prevent paste/cut/copy
MG_GAME_API.preventEvents(MG_GAME_ONEUP.wordField, ["paste", "cut", "copy"]);

$('nav#menu-left').mmenu();
$('nav#menu-right').mmenu({
position:'right',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ MG_GAME_PYRAMID = function ($) {
}
});

//Prevent paste/cut/copy
MG_GAME_API.preventEvents(MG_GAME_PYRAMID.wordField, ["paste", "cut", "copy"]);

MG_GAME_PYRAMID.submitButton = $("#button-play").click(MG_GAME_PYRAMID.onsubmit);
// Delete the default footer content.
$("#footer").html("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ MG_GAME_STUPIDROBOT = function ($) {
return event.which != 32;
});

//Prevent paste/cut/copy
MG_GAME_API.preventEvents(MG_GAME_STUPIDROBOT.wordField, ["paste", "cut", "copy"]);

// set original level
if (typeof(noTicker) == 'undefined')
MG_GAME_STUPIDROBOT.timerTick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ MG_GAME_ZENPOND = function ($) {
}
});

//Prevent paste/cut/copy
MG_GAME_API.preventEvents(MG_GAME_ZENPOND.wordField, ["paste", "cut", "copy"]);

MG_GAME_ZENPOND.submitButton = $("#button-play").click(MG_GAME_ZENPOND.onsubmit);

// call the game API's init settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ MG_GAME_ZENTAG = function ($) {
}
});

//Prevent paste/cut/copy
MG_GAME_API.preventEvents(MG_GAME_ZENTAG.wordField, ["paste", "cut", "copy"]);

MG_GAME_ZENTAG.submitButton = $("#button-play").click(MG_GAME_ZENTAG.onsubmit);
// TRY to get pass button to submit correct value.
MG_GAME_ZENTAG.passButton = $("#button-pass").click(MG_GAME_ZENTAG.onpass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ MG_GAME_ZENTAG_PLAYONCE = function ($) {
return false;
}
});

//Prevent paste/cut/copy
MG_GAME_API.preventEvents(MG_GAME_ZENTAG_PLAYONCE.wordField, ["paste", "cut", "copy"]);

MG_GAME_ZENTAG_PLAYONCE.submitButton = $("#button-play").click(MG_GAME_ZENTAG_PLAYONCE.onsubmit);
// TRY to get pass button to submit correct value.
Expand Down

0 comments on commit b026146

Please sign in to comment.