Recent Topics

[2.x] Konami Code using jQuery

Started by on Jun 04, 2009 – Contents updated: Jun 04, 2009

Jun 04, 2009 07:26    

My b2evolution Version: 2.x

I got some code to insert Konami code using jQuery but I ca't seem to get it to work.

Code

/**
* Cheat Code: a jQuery Plugin
* @author: Trevor Morris (trovster)
* @url: http://www.trovster.com/lab/code/plugins/jquery.cheat-code.js
* @documentation: http://www.trovster.com/lab/plugins/cheat-code/
* @published: 10/05/2009
* @updated: 10/05/2009
*/
if(typeof jQuery != 'undefined') {
  jQuery(function($) {
    $.fn.extend({
      cheatCode: function(options) {
        var $$  = $(this),
          s  = $.extend({}, $.fn.cheatCode.defaults, options),
          o   = $.metadata ? $.extend({}, s, $$.metadata()) : s,
          k  = [];
        
        return this.each(
          function() {
            $$.bind('keydown.cheatCode' + o.code.toString(), function(e){
              k.push(e.keyCode);
              if(k.toString().indexOf(o.code) >= 0){
                k = [];
                o.activated.call(this, o);
                unbind.call(this, o);
              }
            });
          }
        );
      }
    });
    
    complete = function(o){
      var $overlay = $('<div class="overlay"></div>')
        $message = $('<div class="modal"></div>');
      
      $message.text(o.message).appendTo('body');
      $overlay.appendTo('body');
      setTimeout(function(){
        $message.fadeOut(500, function(){
          $(this).remove();
          $overlay.fadeOut(500, function(){
            $(this).remove();
          });
        });
      }, 1000);
    };
    
    unbind = function(o){
      if(o.unbind===true) {
        $(this).unbind('keydown.cheatCode' + o.code.toString());
      }
    };
    
    $.fn.cheatCode.defaults = {
      'code'     : '38,38,40,40,37,39,37,39,66,65',
      'unbind'  : true,
      'activated'  : complete,
      'message'  : 'Cheat Code Activated'
    };
  });
}
and also the jQuery plugin.

Code

/**
* Skeleton: a jQuery Plugin
* @author: Trevor Morris (trovster)
* @url: http://www.trovster.com/lab/code/plugins/jquery.skeleton.js
* @documentation: http://www.trovster.com/lab/plugins/skeleton/
* @published: 11/09/2008
* @updated: 29/09/2008
*
* @notes:
* Convention *I* use:
*  - $var is a jQuery object
*  - Quote key/value pairs
*  - Use o['key'] syntax when reading key/value
*/
if(typeof jQuery != 'undefined') {
  jQuery(function($) {
    $.fn.extend({
      skeleton: function(options) {
        var settings = $.extend({}, $.fn.skeleton.defaults, options);
      
        return this.each(
          function() {
            if($.fn.jquery < '1.2.6') {return;}
            var $t = $(this);
            var o = $.metadata ? $.extend({}, settings, $t.metadata()) : settings;
            
            /**
            * Start your Plugin Here…
            */
          }
        );
      }
    });
    
    /**
    * Set your Plugin Defaults Here…
    */
    $.fn.skeleton.defaults = {};
  });
}

Do I insert this code into one of the PHP files or what? Sorry, I'm a novice.

Jun 09, 2009 16:03

I will ask for the author include some clear license, so I will make a konami plugin for b2evolution

Jun 15, 2009 16:16

Now it has a license ;) Will tryto make it this week.


Form is loading...

CMS + user community – This forum is powered by b2evolution CMS, a complete engine for your website.