Adicionar ranks com javascript

2 participantes

Ver o tópico anterior Ver o tópico seguinte Ir para baixo

Tópico resolvido Adicionar ranks com javascript

Mensagem por Tyui22222 25.10.14 19:04

Queria Que Acrescentacem os seguintes ranks

Neutro = 0
Iniciante = 2
Nub = 5
Bom = 35
Razoavel = 50
Excelente = 100
Membro++ = 150
Boss = 200
Guru = 300

JS

$(document).ready(function() {
$(".pun .post .user").each(function(){
$(this).html($(this).html().replace(/<span class="label/g,'<dd><div class="post_field"><span class="label'));
});
$('.user-info .post_field:contains("Reputação")').each(function() {
var rep = $(this).text().match(/\d+/g);
$(this).addClass('reputation');
$(this).append('<span class="title" style="font-weight:normal"></span>');
if(rep == 0) {
        $(this).find('.title').text('Neutro');
        $(this).addClass('zero');
}
else if(rep >= 10 && rep < 55) {
        $(this).find('.title').text('Iniciante');
}
else if(rep >= 55 && rep < 100) {
        $(this).find('.title').text('Membro ativo');
}
else if(rep >= 100) {
        $(this).find('.title').text('Excelente');
}
});
});
Tyui22222

Tyui22222
***

Membro desde : 09/10/2014
Mensagens : 189
Pontos : 269

http://darkcraftforum24hrs.forumeiros.com

Ir para o topo Ir para baixo

Tópico resolvido Re: Adicionar ranks com javascript

Mensagem por Shaman 25.10.14 21:39

Código:
$(document).ready(function() {
$(".pun .post .user").each(function(){
$(this).html($(this).html().replace(/<span class="label/g,'<dd><div class="post_field"><span class="label'));
});
$('.user-info .post_field:contains("Reputação")').each(function() {
var rep = $(this).text().match(/\d+/g);
$(this).addClass('reputation');
$(this).append('<span class="title" style="font-weight:normal"></span>');
if(rep == 0) {
        $(this).find('.title').text('Neutro');
        $(this).addClass('zero');
}
else if(rep >= 1 && rep < 2) {
        $(this).find('.title').text('Iniciante');
}
else if(rep >= 2 && rep < 5) {
        $(this).find('.title').text('Nub');
}

else if(rep >= 5 && rep < 35) {
        $(this).find('.title').text('Bom');
}

else if(rep >= 35 && rep < 50) {
        $(this).find('.title').text('Razoavel');
}

else if(rep >= 50 && rep < 100) {
        $(this).find('.title').text('Excelente');
}

else if(rep >= 100 && rep < 200) {
        $(this).find('.title').text('Boss');
}

else if(rep >= 200 && rep < 300) {
        $(this).find('.title').text('Guru');
}

});
});

Tente este.


Ou se preferir pode tentar este:

Código:
$(document).ready(function() {
$(".pun .post .user").each(function(){
$(this).html($(this).html().replace(/<span class="label/g,'<dd><div class="post_field"><span class="label'));
});
$('.user-info .post_field:contains("Reputação")').each(function() {
var rep = $(this).text().match(/\d+/g);
$(this).addClass('reputation');
$(this).append('<span class="title" style="font-weight:normal"></span>');
if(rep == 0) {
        $(this).find('.title').text('Neutro');
        $(this).addClass('zero');
}
else if(rep >= 2) {
        $(this).find('.title').text('Iniciante');
}

else if(rep >= 5) {
        $(this).find('.title').text('Nub');
}

else if(rep >= 35) {
        $(this).find('.title').text('Bom');
}

else if(rep >= 50) {
        $(this).find('.title').text('Razoavel');
}

else if(rep >= 100) {
        $(this).find('.title').text('Excelente');
}

else if(rep >= 150) {
        $(this).find('.title').text('Membro++');
}

else if(rep >= 200) {
        $(this).find('.title').text('Boss');
}

else if(rep >= 300) {
        $(this).find('.title').text('Guru');
}
});
});


PS: Não sei mexer muito com JavaScript mas esse tava fácil, acho que o 1º código é funcional ja o 2º não testei.
LucaS.
Shaman

Shaman
Super Membro

Membro desde : 30/01/2014
Mensagens : 1787
Pontos : 2448

http://brasilplayvicio.com.br

Ir para o topo Ir para baixo

Tópico resolvido Re: Adicionar ranks com javascript

Mensagem por Tyui22222 25.10.14 23:16

resolvido.
Tyui22222

Tyui22222
***

Membro desde : 09/10/2014
Mensagens : 189
Pontos : 269

http://darkcraftforum24hrs.forumeiros.com

Ir para o topo Ir para baixo

Ver o tópico anterior Ver o tópico seguinte Ir para o topo

- Tópicos semelhantes

Permissões neste sub-fórum
Não podes responder a tópicos