Skip to content

Instantly share code, notes, and snippets.

@felquis
Created September 8, 2012 18:13
Show Gist options
  • Save felquis/3678211 to your computer and use it in GitHub Desktop.
Save felquis/3678211 to your computer and use it in GitHub Desktop.
Um teste qualquer..
;(function () {
var Plusplus = function (init) {
// Verifica se foi usado new
if ( !(this instanceof Plusplus) ) {
return new Plusplus(init);
}
// Minha variável de ouro
var number = init || 0;
// Return var number
this._getNumber_ = function () {
return number;
}
// Incrementa var number;
this._plusplus_ = function () {
number++;
}
// end Plusplus
}
// Return number
Plusplus.prototype.getNumber = function() {
return this._getNumber_();
};
// Incrementa mais 1 e retorna o number
Plusplus.prototype.setNumber = function() {
this._plusplus_();
return this._getNumber_();
};
if (!window.Plusplus) {
window.Plusplus = Plusplus;
}
})();
;(function () {
var game = Plusplus(10),
$a = document.querySelectorAll('#clickme')[0];
$a.addEventListener('click', function (e) {
e.preventDefault();
this.innerHTML = 'Click me! '+ game.setNumber();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment