/*
A Mootools anti-spam email revealer
Licenses:
(c) Creative Commons
http://creativecommons.org/licenses/by-sa/3.0/us/
Author: Kevin Hoang Le | http://kevin-le.appspot.com
Date: 2008-11-01
Version: 0.1 : Initial
*/
var AntiSpamEmailRevealer = new Class({
Extends: Slider,
initialize: function(options) {
this.background = $(options.background);
this.backgroundColor = options.backgroundColor;
this.knob = $(options.knob);
this.knobColor = options.knobColor;
this.masked = options.masked;
this.reveal = $(options.reveal);
this.email = options.hidden;
this.emailLength = this.email.length;
var s = '';
for (var i = 0; i < this.email.length; i++) {
s += this.masked;
}
this.reveal.innerHTML = s;
this.parent(this.background, this.knob, {
steps: this.emailLength,
onChange: function(step){
var s = '';
for (var i = 0; i < step; i++) {
s += this.email[i];
}
for (var i = step; i < this.emailLength; i++) {
s += this.masked;
}
this.reveal.innerHTML = "" + s + "";
}
});
this.background.setStyle('background', this.backgroundColor)
this.knob.setStyle('background', this.knobColor);
this.knob.setStyle('cursor', 'pointer');
this.set(0);
}
});
var RevealEmail = function() {
return {
run : function(options) {
if (options.hidden != null) {
new AntiSpamEmailRevealer(options);
}
else {
var ajaxReq = new Request({
url: options.ajaxUrl,
method: "POST",
onComplete: function(jsonObj) {
var response = JSON.decode(jsonObj);
options.hidden = response.xyz;
new AntiSpamEmailRevealer(options);
}
});
ajaxReq.send();
}
}
}
}();