-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasdText.js
54 lines (53 loc) · 1.68 KB
/
asdText.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;(function($) {
$.fn.asd = function(options){
function contrario(colores){
colores.r = parseInt(255-colores.r);
colores.g = parseInt(255-colores.g);
colores.b = parseInt(255-colores.b);
return colores;
}
var r, g, b, color, bgcolor = 0;
var div = this;
var text = $(this).text();
var letters = text.split('');
for(var i = 0; i < letters.length; i++){
if(options.rcolor){
r = parseInt((Math.random()*255)+1);
g = parseInt((Math.random()*255)+1);
b = parseInt((Math.random()*255)+1);
bgcolor = "rgb("+r+", "+g+", "+b+")";
color = "black";
if(!options.fcolor){
if((r+g+b) <= 382){
color = "white";
}else{
color = "black";
}
}else{
var colores = contrario({
r: r,
g: g,
b: b
});
color = "rgb("+colores.r+", "+colores.g+", "+colores.b+")";
}
}
if(letters[i] !== ' '){
letters[i] = "<span style='text-transform:uppercase;font-size: 20px;font-weight: bold; padding: 0px 5px;display: none; background: "+bgcolor+"; color: "+color+";'>"+letters[i]+"</span>";
}else{
letters[i] = "<span style='text-transform:uppercase;font-size: 20px;font-weight: bold; padding: 5px;display: none;'>"+letters[i]+"</span>";
}
}
var all = letters.join('');
$(div).html(all);
for(i = 0; i < letters.length; i++){
setTimeout(function(){
if(options.fade){
$("span:not(:visible):first", div).fadeIn();
}else{
$("span:not(:visible):first", div).show();
}
}, (i*150));
}
};
})(jQuery);