Skip to content

Commit

Permalink
Add Konami Code to Paint
Browse files Browse the repository at this point in the history
  • Loading branch information
1j01 committed Apr 8, 2018
1 parent cd639ee commit aac59ee
Show file tree
Hide file tree
Showing 6 changed files with 557 additions and 1 deletion.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
326 changes: 326 additions & 0 deletions images/windows-98-logo-vector-by-pkmnct-plus-js-logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions programs/jspaint/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@
<script src="src/menus.js"></script>
<script src="src/canvas-change.js"></script>
<script src="src/sessions.js"></script>
<script src="lib/konami.js"></script>
<script src="src/vaporwave-fun.js"></script>
</body>
</html>
55 changes: 55 additions & 0 deletions programs/jspaint/lib/konami.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @license konami-js v1.0.1
* http://mck.me/mit-license
*/
var Konami = {};

(function(Konami, window) {
'use strict';

/**
* Creates an event handler responding to the specified sequence.
* @param {...number|function()} arguments
* @return {function(Event)}
*/
var sequence = Konami.sequence = function() {
var sequence = Array.prototype.slice.call(arguments),
state = 0;

/**
* Event handler
* @param {Event|number} e
*/
return function(e) {
// patch legacy IE
e = (e || window.event);
e = (e.keyCode || e.which || e);

if (e === sequence[state] || e === sequence[(state = 0)]) {
// move next and peek
var action = sequence[++state];

// sequence complete when a function is reached
if (typeof action !== 'function') {
return;
}

// fire action
action();

// reset when sequence completed
state = 0;
}
};
};

/**
* Creates an event handler responding to the Konami Code.
* @param {function()} action completed sequence callback
* @return {function(Event)}
*/
Konami.code = function(action) {
return sequence(38, 38, 40, 40, 37, 39, 37, 39, 66, 65, action);
};

})(Konami, window);

0 comments on commit aac59ee

Please sign in to comment.