added js files header + added minified version

This commit is contained in:
2015-09-02 22:30:36 +02:00
parent 48f9a5ca16
commit b596edf4d7
4 changed files with 39 additions and 26 deletions
+1
View File
@@ -16,3 +16,4 @@ It's super simple:
```
Tested to work in Chrome and Firefox.
+3 -1
View File
@@ -3,7 +3,7 @@
<head>
<title>Konami code example</title>
<script src="konami.js"></script>
<script src="konami.min.js"></script>
<script>
konami(function () {
@@ -18,6 +18,8 @@
<p>You did not know that, did you? Well now you do. Also, ostrich is a fish.</p>
<p>Hint: the code is <code>↑↑↓↓←→←→BA</code></p>
</body>
</html>
+29 -25
View File
@@ -1,33 +1,37 @@
// https://github.com/MightyPork/konami.js | MIT License
/*! konami.js
https://github.com/MightyPork/konami.js
(c) MightyPork 2015, MIT License
Usage: konami(callback);
*/
(function (window) {
"use strict";
"use strict";
var d = window.document;
var keys = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
var progress = 0;
var d = window.document;
var keys = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
var progress = 0;
window.konami = function (h) {
var listener = function (e) {
if (e.keyCode == keys[progress]) {
if (++progress == keys.length) {
console.log('コナミ');
window.konami = function (h) {
var listener = function (e) {
if (e.keyCode == keys[progress]) {
if (++progress == keys.length) {
console.log('コナミ');
if (typeof h == 'function') {
h();
}
if (typeof h == 'function') {
h();
}
progress = 0;
}
} else {
progress = 0;
}
};
progress = 0;
}
} else {
progress = 0;
}
};
if (d.addEventListener) {
d.addEventListener('keyup', listener);
} else {
d.onkeyup = listener;
}
};
if (d.addEventListener) {
d.addEventListener('keyup', listener);
} else {
d.onkeyup = listener;
}
};
})(window);
+6
View File
@@ -0,0 +1,6 @@
/*! konami.js
https://github.com/MightyPork/konami.js
(c) MightyPork 2015, MIT License
Usage: konami(callback);
*/
!function(n){"use strict";var e=n.document,o=[38,38,40,40,37,39,37,39,66,65],t=0;n.konami=function(n){var i=function(e){e.keyCode==o[t]?++t==o.length&&(console.log("コナミ"),"function"==typeof n&&n(),t=0):t=0};e.addEventListener?e.addEventListener("keyup",i):e.onkeyup=i}}(window);