Script has a glitch

Go down

Solved Script has a glitch

Post by O'Malley Cat on July 17th 2018, 4:54 am

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 July 18th 2018, 11:45 am; edited 1 time in total
avatar
O'Malley Cat
New Member

Posts : 24
Reputation : 1
Language : Spanish, English

Back to top Go down

Solved Re: Script has a glitch

Post by SSYT on July 17th 2018, 3:13 pm

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();
});
avatar
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 on July 18th 2018, 10:40 pm

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



avatar
APE
Administrator
Administrator

Male Posts : 13383
Reputation : 1420
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