Boas-vindas ao Power Pixel

Junte-se a comunidade! Crie o seu próprio conteúdo, e faça amizades.EntrarCriar uma conta

Código de Reputação

4 participantes

Júnior Duarte Júnior Duarte  • Sex 5 Dez 2014 - 21:17

Código de Reputação Empty Código de Reputação Sex 5 Dez 2014 - 21:17

Minha questão:
Olá galera, mais uma vez preciso do conhecimento dos senhores, hehehe.

Atualmente uso esse code no Fórum para a reputação.

Código:
$(document).ready(function() {
    //Reputação
    $(".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).attr('style','background-color: rgb(141, 177, 62);background-image: url(http://i38.servimg.com/u/f38/17/31/71/58/highli10.png);border-top-left-radius: 3px;border-top-right-radius: 3px;border-bottom-right-radius: 3px;border-bottom-left-radius: 3px;color: rgb(255, 255, 255);font-weight: bold;display: block;margin: 0 auto;margin-bottom: 3px;padding: 3px 7px;max-width: 125px;text-align: center;text-shadow: rgba(0, 0, 0, 0.298039) 0px -1px 0px;background-position: 0px 1px;background-repeat: repeat no-repeat;');
    $(this).append('<span class="title" style="font-weight:normal"></span>');
    if(rep == 0) {
            $(this).find('.title').text('Neutro');
            $(this).find('.title').addClass('rep-red');
            $(this).attr('style','background-color: rgb(16, 16, 16)!important;background-image: url(http://i38.servimg.com/u/f38/17/31/71/58/highli10.png);border-top-left-radius: 3px;border-top-right-radius: 3px;border-bottom-right-radius: 3px;border-bottom-left-radius: 3px;color: rgb(255, 255, 255);font-weight: bold;display: block;margin: 0 auto;margin-bottom: 3px;padding: 3px 7px;max-width: 125px;text-align: center;text-shadow: rgba(0,0,0,0.3) 0px -1px 0px;background-position: 0px 1px;background-repeat: repeat no-repeat;');
    }
    if(rep >= 1 && rep < 20) {
            $(this).find('.title').text('Um dia Eu Chego lá');
            $(this).addClass('rep-red');
    }
    if(rep >= 20 && rep < 49) {
            $(this).find('.title').text('Minha Reputação está Boa');
            $(this).addClass('rep-yellow');
    }
    if(rep >=50) {
            $(this).find('.title').text('Excelente');
    }
    });
    });

Funciona perfeitamente, só que queria algumas alterações no CODE, no Fórum usamos a reputação negativa para identificar possíveis membros que só querem sugar, flooders etc. Alguém poderia alterar o código adicionando a reputação negativa? Quando o membro estiver com a reputação negativa aquele quadrado ficar vermelho, podem só começar eu especifico o valor e a mensagem da reputação, tentei mas não deu certo. Até fica -1 e a mensagem mas o quadrado não muda de cor.


Endereço do meu fórum:
[Tens de ter uma conta e sessão iniciada para poderes visualizar este link]

Versão:
PunBB

HeroWaar HeroWaar  • Sex 5 Dez 2014 - 22:38

Código de Reputação Empty Re: Código de Reputação Sex 5 Dez 2014 - 22:38

Olá,

O proprio codigo ja tem uma parte para a cor vermelha, localiza
Código:
    if(rep >= 1 && rep < 20) {
            $(this).find('.title').text('Um dia Eu Chego lá');
            $(this).addClass('rep-red');
    }

Portanto para alterar para negativo baste alterar para o seguinte:
Código:
    if(rep < 0) {
            $(this).find('.title').text('REP negativa');
            $(this).addClass('rep-red');
    }

HeroWaar,

Júnior Duarte Júnior Duarte  • Ter 9 Dez 2014 - 20:02

Código de Reputação Empty Re: Código de Reputação Ter 9 Dez 2014 - 20:02

Reputação da mensagem: 100% (1 votos)
Olá amigo, perdi o CSS desse código, acaso poderia informar o mesmo? Achei aqui na BS mas já fucei todos os tópicos mas ainda não encontrei

Júnior Duarte Júnior Duarte  • Qui 11 Dez 2014 - 20:48

Código de Reputação Empty Re: Código de Reputação Qui 11 Dez 2014 - 20:48

Reputação da mensagem: 100% (1 votos)
boas galera, achei o css, porém o code que o amigo moderador não é funcional. O reputação negativa não fica com o quadrado vermelho. Alguém pode ajudar? Como faço para que depois do 0 a reputação fique com a cor vermelha e com o informação escrita "Reputação Negativa"?

HeroWaar HeroWaar  • Qui 11 Dez 2014 - 22:34

Código de Reputação Empty Re: Código de Reputação Qui 11 Dez 2014 - 22:34

Olá, este é com o CSS

Veja se resulta
Código:

if(rep < 0) {
        $(this).find('.title').text('REP negativa');
        $(this).css({
            'background': '#f2dede',
            'color': '#a94442'
        });
}

HW,

Júnior Duarte Júnior Duarte  • Sex 12 Dez 2014 - 10:20

Código de Reputação Empty Re: Código de Reputação Sex 12 Dez 2014 - 10:20

Não resulta amigo segue o print.

[Tens de ter uma conta e sessão iniciada para poderes visualizar esta imagem]

Perceba que o código entende que é essa parte dele a ser usada:

Código:
if(rep >= 1 && rep < 15) {
            $(this).find('.title').text('Minha Reputação está Boa');
            $(this).addClass('rep-yellow');
    }


E não esse como deveria:

Código:
 if(rep < 0) {
        $(this).find('.title').text('REP negativa');
        $(this).addClass('rep-red');
    }

Júnior Duarte Júnior Duarte  • Seg 15 Dez 2014 - 12:39

Código de Reputação Empty Re: Código de Reputação Seg 15 Dez 2014 - 12:39

HeroWaar escreveu:Olá, este é com o CSS

Veja se resulta
Código:

if(rep < 0) {
        $(this).find('.title').text('REP negativa');
        $(this).css({
            'background': '#f2dede',
            'color': '#a94442'
        });
}
HW,

E ai amigão, algum solução?

Daemon Daemon  • Sex 19 Dez 2014 - 15:22

Código de Reputação Empty Re: Código de Reputação Sex 19 Dez 2014 - 15:22

Leia o tutorial e modifique o código: [Tens de ter uma conta e sessão iniciada para poderes visualizar este link]


Até mais!

Júnior Duarte Júnior Duarte  • Sex 19 Dez 2014 - 16:59

Código de Reputação Empty Re: Código de Reputação Sex 19 Dez 2014 - 16:59

Então Daemon, eu ja li esse tutorial e já modifiquei o código, veja acima que não fica da forma que deveria. O Código que contem as reputações negativas não fica como atribuído, veja um exemplo.

Um membro com + 8 Rep, tem o quadrante verde e a frase "Sou um Bom membro"
Um membro que tem - 8 Rep, deveria ter o quadrante vermelho e a frase "Sou um péssimo membro", no entanto fica do mesmo modo do que tem a reputação positiva, entende?

[S]herlock H. [S]herlock H.  • Sáb 20 Dez 2014 - 12:15

Código de Reputação Empty Re: Código de Reputação Sáb 20 Dez 2014 - 12:15

Reputação da mensagem: 100% (1 votos)
Amigo, que tal separar primeiro o css do js?
Vamos lá, utilize este abaixo:
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) {
            $('.title', this).text('Neutro');
            $(this).addClass('zero');
    }
    else if(rep >= 1 && rep < 5) {
            $('.title', this).text('Iniciante');
    }
    else if(rep >= 5 && rep < 10) {
            $('.title', this).text('Membro ativo');
    }
    else if(rep >= 10) {
            $('.title', this).text('Excelente');
    }
    });
    });
Edite ao seu gosto, e me mande editado!

Júnior Duarte Júnior Duarte  • Seg 22 Dez 2014 - 14:56

Código de Reputação Empty Re: Código de Reputação Seg 22 Dez 2014 - 14:56

Olá amigo, segue editado.

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) {
        $('.title', this).text('Neutro');
        $(this).addClass('zero');
}
else if(rep >= -1 && rep < -5) {
        $('.title', this).text('Estou indo para o mau caminho');
}
else if(rep >= -5 && rep < -10) {
        $('.title', this).text('Sou um péssimo Membro');
}
else if(rep >= -10 && rep < -15) {
        $('.title', this).text('Daqui há pouco vou ser Banido');
}
else if(rep >= 1 && rep < 20) {
        $('.title', this).text('Iniciante');
}
else if(rep >= 20 && rep < 50) {
        $('.title', this).text('Sou um bom Membro');
}
else if(rep >= 50 && rep < 90) {
        $('.title', this).text('Já sou um astro no IEx');
}
else if(rep >= 90 && rep < 150) {
        $('.title', this).text('Sou um Lenda');
}
else if(rep >= 150) {
        $('.title', this).text('IEx Foda');
}
});
});

Agradeço a ajuda.

Daemon Daemon  • Seg 22 Dez 2014 - 15:40

Código de Reputação Empty Re: Código de Reputação Seg 22 Dez 2014 - 15:40

Aqui está:
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) {
        $('.title', this).text('Sou um péssimo membro');
        $(this).css({
            'background': '#f2dede',
            'color': '#a94442'
        });
}
else if(rep == 0) {
        $('.title', this).text('Neutro');
        $(this).addClass('zero');
}
else if(rep >= 1 && rep < 20) {
        $('.title', this).text('Iniciante');
}
else if(rep >= 20 && rep < 50) {
        $('.title', this).text('Sou um bom Membro');
}
else if(rep >= 50 && rep < 90) {
        $('.title', this).text('Já sou um astro no IEx');
}
else if(rep >= 90 && rep < 150) {
        $('.title', this).text('Sou um Lenda');
}
else if(rep >= 150) {
        $('.title', this).text('IEx Foda');
}
});
});
Até!

Júnior Duarte Júnior Duarte  • Seg 22 Dez 2014 - 16:11

Júnior Duarte Júnior Duarte  • Seg 29 Dez 2014 - 15:08

Código de Reputação Empty Re: Código de Reputação Seg 29 Dez 2014 - 15:08

Ai galera, ainda preciso de ajuda aqui.

HeroWaar HeroWaar  • Ter 6 Jan 2015 - 8:53

Código de Reputação Empty Re: Código de Reputação Ter 6 Jan 2015 - 8:53

Olá,

Tente 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() {
        rep = $(this).html().split('<br>')[0].split('</span>')[2].toString();
        $(this).addClass('reputation');
        $(this).append('<span class="title" style="font-weight:normal"></span>');
        if (rep.indexOf('-') > -1) {
            rep = $(this).text().match(/\d+/g);
            if (rep >= 1 && rep < 5) {
                $('.title', this).text('Estou indo para o mau caminho');
            } else if (rep >= 5 && rep < 10) {
                $('.title', this).text('Sou um péssimo Membro');
            } else if (rep >= 10 && rep < 15) {
                $('.title', this).text('Daqui há pouco vou ser Banido');
            }
        } else {
            if (rep == 0) {
                $('.title', this).text('Neutro');
                $(this).addClass('zero');
            } else if (rep >= 1 && rep < 20) {
                $('.title', this).text('Iniciante');
            } else if (rep >= 20 && rep < 50) {
                $('.title', this).text('Sou um bom Membro');
            } else if (rep >= 50 && rep < 90) {
                $('.title', this).text('Já sou um astro no IEx');
            } else if (rep >= 90 && rep < 150) {
                $('.title', this).text('Sou um Lenda');
            } else if (rep >= 150) {
                $('.title', this).text('IEx Foda');
            } 
        }
    });
});

HW,

Júnior Duarte Júnior Duarte  • Qui 8 Jan 2015 - 11:42

Código de Reputação Empty Re: Código de Reputação Qui 8 Jan 2015 - 11:42

Opa amigo, agora funcionou, só apenas gostaria que o Quadrante ficasse Vermelho das Negativas, tem como?

Daemon Daemon  • Qui 8 Jan 2015 - 11:54

Código de Reputação Empty Re: Código de Reputação Qui 8 Jan 2015 - 11:54

Reputação da mensagem: 100% (1 votos)
Visto que você teve exito com o último código passado pelo [Tens de ter uma conta e sessão iniciada para poderes visualizar este link], irei apenas modificá-lo para que apareça o quadro vermelho.
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() {
        rep = $(this).html().split('<br>')[0].split('</span>')[2].toString();
        $(this).addClass('reputation');
        $(this).append('<span class="title" style="font-weight:normal"></span>');
        if (rep.indexOf('-') > -1) {
            rep = $(this).text().match(/\d+/g);
            $(this).addClass('negative');
            if (rep >= 1 && rep < 5) {
                $('.title', this).text('Estou indo para o mau caminho');
            } else if (rep >= 5 && rep < 10) {
                $('.title', this).text('Sou um péssimo Membro');
            } else if (rep >= 10 && rep < 15) {
                $('.title', this).text('Daqui há pouco vou ser Banido');
            }
        } else {
            if (rep == 0) {
                $('.title', this).text('Neutro');
                $(this).addClass('zero');
            } else if (rep >= 1 && rep < 20) {
                $('.title', this).text('Iniciante');
            } else if (rep >= 20 && rep < 50) {
                $('.title', this).text('Sou um bom Membro');
            } else if (rep >= 50 && rep < 90) {
                $('.title', this).text('Já sou um astro no IEx');
            } else if (rep >= 90 && rep < 150) {
                $('.title', this).text('Sou um Lenda');
            } else if (rep >= 150) {
                $('.title', this).text('IEx Foda');
            } 
        }
    });
});

Desta forma, será adicionado a classe "negative" aos que tiverem reputação negativa.
Utilize desta forma no css:
Código:
.negative {
atributo css aqui...
}


Até mais!

HeroWaar HeroWaar  • Qui 8 Jan 2015 - 11:54

Código de Reputação Empty Re: Código de Reputação Qui 8 Jan 2015 - 11:54

Reputação da mensagem: 100% (1 votos)
Olá,

Faça um teste
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() {
        rep = $(this).html().split('<br>')[0].split('</span>')[2].toString();
        $(this).addClass('reputation');
        $(this).append('<span class="title" style="font-weight:normal"></span>');
        if (rep.indexOf('-') > -1) {
            rep = $(this).text().match(/\d+/g);
            $(this).css({
                'background': 'rgb(242, 222, 222)',
                'color': 'rgb(169, 68, 66)',
            });
            if (rep >= 1 && rep < 5) {
                $('.title', this).text('Estou indo para o mau caminho');
            } else if (rep >= 5 && rep < 10) {
                $('.title', this).text('Sou um péssimo Membro');
            } else if (rep >= 10 && rep < 15) {
                $('.title', this).text('Daqui há pouco vou ser Banido');
            }
        } else {
            if (rep == 0) {
                $('.title', this).text('Neutro');
                $(this).addClass('zero');
            } else if (rep >= 1 && rep < 20) {
                $('.title', this).text('Iniciante');
            } else if (rep >= 20 && rep < 50) {
                $('.title', this).text('Sou um bom Membro');
            } else if (rep >= 50 && rep < 90) {
                $('.title', this).text('Já sou um astro no IEx');
            } else if (rep >= 90 && rep < 150) {
                $('.title', this).text('Sou um Lenda');
            } else if (rep >= 150) {
                $('.title', this).text('IEx Foda');
            } 
        }
    });
});

HW,

Júnior Duarte Júnior Duarte  • Qui 8 Jan 2015 - 12:13

Código de Reputação Empty Re: Código de Reputação Qui 8 Jan 2015 - 12:13

Daemon não entendi, quais seriam os atributos?

[list=linenums]
[*].negative {

[*]atributo css aqui...

[*]}

[/list]


Hero olha como ficou, a letra ficou vermelha, preciso que o quadrado verde fique vermelho das reputações negativas. Entende?

[Tens de ter uma conta e sessão iniciada para poderes visualizar esta imagem]

HeroWaar HeroWaar  • Qui 8 Jan 2015 - 12:32

Código de Reputação Empty Re: Código de Reputação Qui 8 Jan 2015 - 12:32

Reputação da mensagem: 100% (1 votos)
Olá, vamos seguir o código do Daemon,

JS:
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() {
            rep = $(this).html().split('<br>')[0].split('</span>')[2].toString();
            $(this).addClass('reputation');
            $(this).append('<span class="title" style="font-weight:normal"></span>');
            if (rep.indexOf('-') > -1) {
                rep = $(this).text().match(/\d+/g);
                $(this).addClass('negative');
                if (rep >= 1 && rep < 5) {
                    $('.title', this).text('Estou indo para o mau caminho');
                } else if (rep >= 5 && rep < 10) {
                    $('.title', this).text('Sou um péssimo Membro');
                } else if (rep >= 10 && rep < 15) {
                    $('.title', this).text('Daqui há pouco vou ser Banido');
                }
            } else {
                if (rep == 0) {
                    $('.title', this).text('Neutro');
                    $(this).addClass('zero');
                } else if (rep >= 1 && rep < 20) {
                    $('.title', this).text('Iniciante');
                } else if (rep >= 20 && rep < 50) {
                    $('.title', this).text('Sou um bom Membro');
                } else if (rep >= 50 && rep < 90) {
                    $('.title', this).text('Já sou um astro no IEx');
                } else if (rep >= 90 && rep < 150) {
                    $('.title', this).text('Sou um Lenda');
                } else if (rep >= 150) {
                    $('.title', this).text('IEx Foda');
                } 
            }
        });
    });

CSS:
Código:
.negative, .negative .label span {
background': rgb(242, 222, 222) !important;
color': rgb(169, 68, 66) !important;
}

Júnior Duarte Júnior Duarte  • Qui 8 Jan 2015 - 12:46

Código de Reputação Empty Re: Código de Reputação Qui 8 Jan 2015 - 12:46

Agora sim amigo, ficou ótimo, obrigado pela ajuda. Pode fechar o tópico.

HeroWaar HeroWaar  • Qui 8 Jan 2015 - 12:50

Código de Reputação Empty Re: Código de Reputação Qui 8 Jan 2015 - 12:50

[sucesso=Tópico Resolvido; e Bloqueado][/sucesso]

Conteúdo patrocinado  • 

Código de Reputação Empty Re: Código de Reputação

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