some Examples:
//instantiate with autostart set to true (+ a Starcraft Code):
mooCheatDemo = new MooCheatCode({
autostart : true,
codes:{
'starcraft' : 'f, o, o, d, f, o, r, t, h, o, u, g, h, t',
'doom' : 'i, d, d, q, d'
}
});
//add Cheat Code:
mooCheatDemo.addCode('testcode2', 'y, x');
//Event for any cheatcode:
mooCheatDemo.addEvent('match': function(ev){
alert('Name:'+ev.name+', Code:'+ev.value);
});
//Event for individual code:
mooCheatDemo.addEvent('match_starcraft': function(ev){
alert('this is from starcraft...');
});
//not really a feature - list of codes:
var codeHTML = 'available codes:<br /><ul>';
for(var code in mooCheatDemo.options.codes) {
codeHTML += '<li>'+mooCheatDemo.options.codes[code]+'</li>';
}
codeHTML += '</ul>';
options:
var myCheats = new MooCheatCode({
autostart: false, //start automatically
maxCache: 20, //max size of cached keypresses
tickIntervalLength: 1000, //interval to match cache with codes
stopPropagation: true, //cancels Firefox' findasyoutype feature...
codes: {} //something like {
// 'code1': 'q, w, e, r, t, up, down',
// 'code2': 'a, s, d, f, g'
//}
});
'useful' methods (they all return the MooCheatCode instance):
myCheats
.addCode(name, code) // Adds Single Code
.addCodes({'name1': code1, 'name2': code2}) // Adds Codes
.start(option) // Starts.
.stop(option); // Stops.
events:
myCheats.addEvents({
'match': function(ev){ //fired if any code is matched
//ev.name, ev.code
},
'match'+name: function(ev){ //fired if string 'name' is a match
//ev.name, ev.code
},
'addcode': function(ev){ //fired after addCode();
//ev.name, ev.code
},
'addcodes': function(ev){ //fired after addCode();
//ev is like {'name1': code1, 'name2': code2}
},
'start': function(ev){ //fired after start();
//ev = options for start()
},
'stop': function(ev){ //fired after stop();
//ev = options for stop();
}
});
look at the page source for more weird examples and lame 'hidden' secred codes...