Skip to content

Commit

Permalink
Added lower case methods, not removing the upper case methods quite y…
Browse files Browse the repository at this point in the history
…et since they

are definitely being used. Updated documentation to use the lower case
methods.
  • Loading branch information
Rob McVey committed Apr 22, 2015
1 parent e45c19e commit dfb4183
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ It's really easy to use. Just include the egg.js file on the page...
<script type="text/javascript" src="/path/to/egg.js"></script>
```

...then use the `AddCode()` function to add in your easter eggs. You need to pass it the character sequence to trigger the easter egg callback (which can either be in plain English or Javascript key codes), a function to trigger when it happens, and an optional set of metadata. Metadata can be anything from a string to an object.
...then use the `addCode()` function to add in your easter eggs. You need to pass it the character sequence to trigger the easter egg callback (which can either be in plain English or Javascript key codes), a function to trigger when it happens, and an optional set of metadata. Metadata can be anything from a string to an object.

```js
var egg = new Egg();
egg
.AddCode("up,up,down,down,left,right,left,right,b,a", function() {
.addCode("up,up,down,down,left,right,left,right,b,a", function() {
jQuery('#egggif').fadeIn(500, function() {
window.setTimeout(function() { jQuery('#egggif').hide(); }, 5000);
}, "konami-code");
})
.AddHook(function(){
.addHook(function(){
console.log("Hook called for: " + this.activeEgg.keys);
console.log(this.activeEgg.metadata);
})
.Listen();
.listen();
```

You can also define the easter egg using the constructor:
Expand All @@ -34,10 +34,10 @@ var egg = new Egg("up,up,down,down,left,right,left,right,b,a", function() {
jQuery('#egggif').fadeIn(500, function() {
window.setTimeout(function() { jQuery('#egggif').hide(); }, 5000);
}, "konami-code");
}).Listen();
}).listen();
```

You can also add a hook, as shown above using `AddHook()`, that will run after any egg code is triggered. You could use it to fire a Google Analytics event or send out a tweet that someone finally found your easter egg. Hooks get access to the whole Egg.js object so you can pull information about the easter egg that fired via `this.activeEgg`
You can also add a hook, as shown above using `addHook()`, that will run after any egg code is triggered. You could use it to fire a Google Analytics event or send out a tweet that someone finally found your easter egg. Hooks get access to the whole Egg.js object so you can pull information about the easter egg that fired via `this.activeEgg`


### Why?
Expand Down
4 changes: 4 additions & 0 deletions egg.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ Egg.prototype.Listen = function() {
return this;
};

Egg.prototype.listen = Egg.prototype.Listen;
Egg.prototype.addCode = Egg.prototype.AddCode;
Egg.prototype.addHook = Egg.prototype.AddHook;

// EGGSAMPLE
// var egg = new Egg();
// egg
Expand Down

0 comments on commit dfb4183

Please sign in to comment.