Home Community Mys-Script Creative Off-Topic |
|
|
Thread Tools | Display Modes |
#11
|
||||
|
||||
Konami Code Install
1 - You need a link to jQuery. My Bootstrap theme comes with it. If you don't have it, hop into **root**/templates/**your theme**/template.tpl and before </body>, add this: HTML Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> HTML Code:
;(function( $, window, document, undefined){ var keys = [] $.fn.konami_code = function( options ) { var settings = $.extend(true, {}, $.fn.konami_code.defaults, options ) var executionCount = 0 $(this).keydown(function(e) { if(settings.maximum > executionCount){ keys.push( e.keyCode ) } // console.log(keys.toString()) if ( keys.toString().indexOf( settings[settings.activeCode] ) >= 0 ){ // execute the specified callback function when the activeCode is detected // if I ever use event triggers I'll need to append the event argument object to the end of settings.arguments settings.callback.apply( settings.scope, settings.arguments ) executionCount++; // empty the array containing the key sequence entered by the user keys = [] } else if (keys.length >1000) { keys = [] //a crude way to keep the array from getting too big for no reason--a better check would be to clear after a long delay between keypresses (400-800ms) } }) console.log('konami_code: power on') return this } //end $.fn.konami_code() defaultCallback = function(){ console.log("power up") alert("power up") } $.fn.konami_code.defaults = { konami: '38,38,40,40,37,39,37,39,66,65', SFII: '40,82,38,76,89,66,88,65', callback: defaultCallback, activeCode: 'konami', maximum: 1000000000000000, scope: window } })( jQuery , window, document) HTML Code:
<script src="{$home}js/jQuery_konami_code.js"></script> HTML Code:
<script type="text/javascript"> myCallback = function(){ alert('yay!') } $(document).konami_code({ callback: myCallback }) </script> This code is now operational on every page in your site. As a reminder, the Konami Code is up, up, down, down, left, right, left, right, b, a. For some further reading on how this code can be modified, check out the github repository for it.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A small question regarding adoption limits and promo codes..c: | Pear | Feedback and Suggestions | 2 | 06-25-2014 10:06 PM |
Hiding the adoption ID? | Aasixx | Questions and Supports | 8 | 11-01-2012 10:26 AM |
Promo Codes | SilverDragonTears | Questions and Supports | 2 | 06-30-2012 01:22 PM |
promo codes | maximillion | Questions and Supports | 5 | 07-05-2011 06:28 PM |
Admins Can View All Active Promo Codes | HIddenPanda | Mys v1.1.x Mods | 0 | 07-15-2010 06:55 PM |
What's New? |
What's Hot? |
What's Popular? |