Skip to content

Instantly share code, notes, and snippets.

@ratelChief
Created April 26, 2018 09:33
Show Gist options
  • Save ratelChief/96d14bbda707e15ea1ba254313fcc990 to your computer and use it in GitHub Desktop.
Save ratelChief/96d14bbda707e15ea1ba254313fcc990 to your computer and use it in GitHub Desktop.
window.util = (function () {
var ESC_KEYCODE = 27;
var ENTER_KEYCODE = 13;
return {
isEscEvent: function (evt, action) {
if (evt.keyCode === ESC_KEYCODE) {
action();
}
},
isEnterEvent: function (evt, action) {
if (evt.keyCode === ENTER_KEYCODE) {
action();
}
},
getRandomValue: function (arr) {
var result = arr[Math.floor(Math.random() * (arr.length))];
return result;
},
getWizardName: function (wizardNames, wizardLastnames) {
var name = getRandomValue(wizardNames) + ' ' + getRandomValue(wizardLastnames);
return name;
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment