The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Script has a glitch

3 posters

Go down

Solved Script has a glitch

Post by O'Malley Cat Mon 16 Jul - 23:54

I had a script written for me a while ago, and I decided to use it in a community that has a lot of groups. The script is supposed to change the color of background of the poster, according to the user's group. It works flawlessly, but I noticed it doesn't work on multiple pages. Just the first page. When you select a different page after the first page, you'll see the default background image. Here's a link to my website that you'll see the issue. Working Fine Example Glitch Example

Here's the code
Code:
window.bkg={};
bkg.copyright="Code by Wolfuryo. Use at your own risk. You can modify it, but this notice must remain here. Use my code without this notice and you'll be destroyed :D";
bkg.opacity="0.9";
bkg.init=function(){
if(!/t\d+\-/.test(location.pathname)) return;
bkg.len=$(".postprofile>dl>dt>strong>a>span[style]").length;
bkg.db();
};
bkg.db=function(){
var i=0;
for(i;i<bkg.len;i++){  $(".postprofile>dl>dt>strong>a>span[style]").eq(i).parent().parent().parent().parent().parent().parent().css({
"background":$(".postprofile>dl>dt>strong>a>span[style]").eq(i).css("color"),
"opacity":bkg.opacity
});
};
};
$(function(){
bkg.init();
})


Last edited by O'Malley Cat on Wed 18 Jul - 6:45; edited 1 time in total
O'Malley Cat
O'Malley Cat
Forumember

Posts : 25
Reputation : 1
Language : Spanish, English

Back to top Go down

Solved Re: Script has a glitch

Post by SSYT Tue 17 Jul - 10:13

Hy, try this code, i tested on your forum and is fine to work.
Code:
var bkg = window.bkg || {};
bkg.copyright = "Code by Wolfuryo. Use at your own risk. You can modify it, but this notice must remain here. Use my code without this notice and you'll be destroyed :D";
bkg.opacity = "0.9";
bkg.init = function() {
    if(/\/t(\d+)-(.*?)|\/t(\d+)p(\d*)-(.*?)/.exec(location.href)) {
        if(_userdata.session_logged_in == 1) {
            bkg.len = $(".postprofile > dl > dt > strong > a > span[style]").length;
        } else {
            bkg.len = $(".postprofile > dl > dt > strong > span[style] > strong").length;
        }
       
        bkg.db(bkg.len);
        console.log(bkg.len);
    }
};


bkg.db = function(bkgLen) {
    for(let i = 0; i < bkgLen; i++) {

        if(_userdata.session_logged_in == 1) {
            $(".postprofile > dl > dt > strong > a > span[style]").eq(i).parent().parent().parent().parent().parent().parent().css({
                "background":$(".postprofile>dl>dt>strong>a>span[style]").eq(i).css("color"),
                "opacity" : bkg.opacity
            });
            console.log('Len: ' + i);
            console.log('Post: ' + $(".postprofile > dl > dt > strong > a > span[style]").eq(i).parent().parent().parent().parent().parent().parent().attr('id'));
        } else {
            $(".postprofile > dl > dt > strong > span[style]").eq(i).parent().parent().parent().parent().parent().parent().css({
                "background":$(".postprofile>dl>dt>strong>span[style]").eq(i).css("color"),
                "opacity" : bkg.opacity
            });
            console.log('Len: ' + i);
            console.log('Post: ' + $(".postprofile > dl > dt > strong > span[style]").eq(i).parent().parent().parent().parent().parent().parent().attr('id'));
        }

    };
};

$(function(){
    bkg.init();
});
SSYT
SSYT
Forumember

Male Posts : 77
Reputation : 15
Language : RO-10, EN-3, FR-1
Location : Romania

http://help.forumgratuit.ro/forum

Back to top Go down

Solved Re: Script has a glitch

Post by Ape Wed 18 Jul - 17:40

Problem solved & topic archived.
Please read our forum rules: ESF General Rules


Script has a glitch Left1212Script has a glitch Center11Script has a glitch Right112
Script has a glitch Ape_b110
Script has a glitch Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19454
Reputation : 2012
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum