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.
The forum of the forums
4 posters

    How to prevent the request limit in this javascript via the localstorage?

    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 2nd 2014, 2:22 pm

    Hi all,
    I have a javascript in my overall_header to display the avatar in the navigation bar

    Code:

                          <li><div id="avatar"><script>
                    jQuery(document).ready(function(){
                      jQuery.get('/profile?mode=editprofile&page_profil=avatars', function(data) {
                          link = jQuery('.frm dl dd img', data).attr('src');
                          if(link){
                                                jQuery('#avatar').html('<center><img src="'+link+'" width="25px" height="25px" /></center>');
                          }else{
                            jQuery('#avatar').html('');
                          }
                      });
                    });
          </script></div></li>      

    How can I adapt it to prevent the Request Limit Exceeded?

    Best Regards,
    Dark-Avenger


    Last edited by Dark-Avenger on June 9th 2014, 2:56 pm; edited 2 times in total
    Paulostge
    Paulostge
    Forumember


    Male Posts : 129
    Reputation : 17
    Language : Greek
    Location : Greece

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Paulostge June 3rd 2014, 10:29 am

    yes this can be done
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 3rd 2014, 10:35 am

    Hi Paulos,
    Do you know how can I fix it?
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 5th 2014, 9:32 am

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 6th 2014, 2:34 pm

    Bump
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 6th 2014, 6:08 pm

    Hello,

    In this case, you don't need to use Ajax, Forumotion has a var to do this for you!!

    Your code can be resumed on this
    Code:
    <li>
        <div id="avatar"></div>
    </li>
    <script>
        jQuery(function(){
            var avatar = _userdata["avatar"];
            jQuery('#avatar').append(avatar);
        });
    </script>


    Best regards, Wagner
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 6th 2014, 10:01 pm

    How can I change avatar's size with this script?
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 6th 2014, 11:06 pm

    You just need to put a CSS rule.. Something like this
    Code:
    #avatar img{width:WIDTHVALUE;height:HEIGHTVALUE}

    Just put the rules you want...
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 7th 2014, 12:12 am

    It still reaches the requests limit. I dont know but I have removed the javascript from template and request limit hits on each move which I can make in my ACP and I have removed 2-3 javascripts to make my forum more light.
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 7th 2014, 1:05 am

    Can you send your forum link? I will check if i know what is doing this...
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 7th 2014, 1:08 am

    Wagner' wrote:Can you send your forum link? I will check if i know what is doing this...
    Yes sure here it is:
    Spoiler:
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 7th 2014, 1:20 am

    Hmm, I'm brazilian, Greek it's too hard to me xD
    But, i don't see any script who is doing this.. And few minutes navigating in your forum i dont have reached any RL... Dont you think its your internet?
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 7th 2014, 1:24 am

    Do you know if these codes for IPB Profile makes to many requests to server?

    Profile JS:
    Code:

    if(/\/?u(\d+)wall$/.test(location.pathname)) {
                jQuery(document).ready(function(){if(jQuery('#profile-advanced-layout #tabs li a').length){
                var nevoskin=jQuery('#profile-advanced-layout #tabs li:eq(1) a').attr('href');
                window.location.href=nevoskin;
                }})};
                if(/\/?u(\d+)stats$/.test(location.pathname)) {
                jQuery(document).ready(function(){if(jQuery('#profile-advanced-layout #tabs li a').length){
                var nevoskin=jQuery('#profile-advanced-layout #tabs li:eq(1) a').attr('href');
                window.location.href=nevoskin;
                }})};
                if(/\/?u(\d+)friends$/.test(location.pathname)) {
                jQuery(document).ready(function(){if(jQuery('#profile-advanced-layout #tabs li a').length){
                var nevoskin=jQuery('#profile-advanced-layout #tabs li:eq(1) a').attr('href');
                window.location.href=nevoskin;
                }})};
                if(/\/?u(\d+)contact$/.test(location.pathname)) {
                jQuery(document).ready(function(){if(jQuery('#profile-advanced-layout #tabs li a').length){
                var nevoskin=jQuery('#profile-advanced-layout #tabs li:eq(1) a').attr('href');
                window.location.href=nevoskin;
                }})};
                $("meta[http-equiv='refresh'][content]:first").each(function(){window.location.href=$(this).attr("content").replace(/^.*;url=/,"")});

    IPB JS:

    Code:

    if(/\/?u(\d+)$/.test(location.pathname)) {
                jQuery(document).ready(function(){if(jQuery('#profile-advanced-right').length){
                var avataripb=jQuery('#profile-advanced-right .main-content.clearfix.center img:first-child').attr('src');
                var tabsipb=jQuery('#profile-advanced-layout #profile-advanced-left #tabs').html();var infoipbge=jQuery('#profile-advanced-left #profile-advanced-details .middleline').html();
                var listfriends=jQuery('.main-content.clearfix[style^="padding:0.3em;text-align:center;"]').html();
                var prfiletoadd=jQuery('#profile-advanced-right #profile-advanced-add').html();
                var usernameipb=jQuery('#profile-advanced-right .module.main:eq(0) .main-head .h3').text().split(' (conectado)').join('');var miregistro=jQuery('.middleline #field_id-4 dd div:eq(0)').html();
                var monedas=jQuery('.middleline #field_id-13 dd div:eq(0)').html();
                var reputipb=jQuery('.middleline #field_id-14 dd div:eq(0)').html();
                var mid=jQuery('#profile-advanced-layout #tabs li:eq(3) a').attr('href').match(/[0-9]+/);
                var onlineipb=jQuery('#profile-advanced-right .main-head:eq(0) .h3 em').text().replace(/[(]/gi,' ').replace(/[)]/gi,' ');
                jQuery('#profile-advanced-right').after('<div class="ipb-profile">
                <div class="nav-ipb-top"><span>Επισκόπηση Προφίλ Μέλους:  <span id="useridhahs"> '+usernameipb+'</span></span></div>
                <div class="mod-left">
                <div class="profile-ava"><img id="ipd-avatar" src="'+avataripb +'" /> </div>
                <div class="ipb-tab-us">'+tabsipb+'</div></div>
                <div class="mod-center">
                <div class="sub-panel-top"><div class="usernam-ipb">'+usernameipb+'</div>
                <div class="register-date">Εγγράφηκε στις:    '+miregistro+'</div>
            <div class="ofline-ipb">Copyright©& nbsp; PunBB.biz & nbsp;& & nbsp; 15-Tronos</div>
                <div class="lass-activiti"></div>
                <div class="rating-profile">
                <img src="http://i.imgur.com/jFLWgyz.png"/>
                <img src="http://i.imgur.com/jFLWgyz.png"/>
                <img src="http://i.imgur.com/jFLWgyz.png"/>
                <img src="http://i.imgur.com/jFLWgyz.png"/>
                <img src="http://i.imgur.com/jFLWgyz.png"/>
                </div><div class="profi-add-ipb">'+prfiletoadd+'
                <a id="men"href="/privmsg?mode=post&u='+mid+'">Αποστολή Προσωπικού Μηνύματος</a>
                <a id="search-i"href="/spa/'+usernameipb+'">Βρείτε το περιεχόμενο μου</a>
                </div>
                </div>
                <div class="main-info-ipb">
                <div class="co-ipb" id="profile">
                <div class="ipb-m-title">
                <h2 id="wallcomment">Σχόλια Προφίλ</h2>
                <h2 id="estadis">Λεπτομέρειες Προφίλ</h2>
                <h2 id="estadisgene"><span>Στατιστικά</span></h2>
                <h2 id="friends">Φίλοι</h2>
                <h2 id="contacto">Επικοινωνία</h2></div>
                <div class="mensajeprofile"></div>
                <div class="m-info-ipb"><div class="in-ipb">'+infoipbge+'
                <div class="contac-me-ipb"></div>
                </div>
                <div class="band-right">
                <div class="repu-ipb"><span id="cs">'+monedas+'</span><div id="sub">Βαθμοί</div></div>
                <div class="coin-ipb"><span>'+reputipb+'</span><div iid="re-p"> Φήμη</div></div>
                <div class="module-ipb-right">
                <h2>Φίλοι</h2>
                <div class="main-ipb-f">'+listfriends+'</div>
                </div>
                </div>
                </div>
                <div class="estadis-ipb"></div>
                <div class="friends-ips"></div>
                <div class="contact-ips"></div></div>
                </div></div>
                </div>');
                }});
                $(document).ready(function(){if(jQuery('#profile-advanced-right').length){
                $('.estoyenline-i:contains("conectado") .ofline-ipb').attr('style','display:none;');
                $('.estoyenline-i:contains("conectado")').attr('style','padding:0px 5px;');
                var linkwall=jQuery('#tabs ul li a:eq(0)').attr('href');
                jQuery(".mensajeprofile").load(linkwall+' #profile-advanced-details .main-content');
                var linkestaipb=jQuery('#tabs ul li a:eq(2)').attr('href');
                jQuery(".estadis-ipb").load(linkestaipb+' #profile-advanced-details .main-content');
                jQuery(".lass-activiti").load(linkestaipb+' #profile-advanced-details .main-content.clearfix .stats-field.genmed ul li:contains("Última visita :")');
                var linkfriendipb=jQuery('#tabs ul li a:eq(3)').attr('href');
                jQuery(".friends-ips").load(linkfriendipb+' #profile-advanced-details .main-content');
                var linkcontaipb=jQuery('#tabs ul li a:eq(4)').attr('href');
                jQuery(".contact-ips").load(linkcontaipb+' #profile-advanced-details .main-content');
                }});
                $(document).ready(function(){if(jQuery('#profile-advanced-right').length){ // Script del Slider
                    $(".mensajeprofile, .estadis-ipb, .friends-ips, .contact-ips") . hide();
                    $('.m-info-ipb').addClass('activetab');
                 $(".ipb-tab-us ul li:eq(0)").click(function(e){
                        $('.ipb-tab-us li ,.co-ipb div').removeClass('activetab');
                        $(this).addClass('activetab');
                        $('.mensajeprofile').addClass('activetab').fadeToggle();
                        $('.estadis-ipb, .m-info-ipb, .friends-ips, .contact-ips') . hide('');
                        return false;
                        e.preventDefault();
                    });
                 $(".ipb-tab-us ul li:eq(1)").click(function(e){
                        $('.ipb-tab-us li ,.co-ipb div').removeClass('activetab');
                        $(this).addClass('activetab');
                        $('.m-info-ipb').addClass('activetab').fadeToggle();
                        $('.mensajeprofile, .estadis-ipb, .friends-ips, .contact-ips') . hide('');
                        return false;
                        e.preventDefault();
                    });
                $(".ipb-tab-us ul li:eq(2)").click(function(e){
                        $('.ipb-tab-us li ,.co-ipb div').removeClass('activetab');
                        $(this).addClass('activetab');
                        $('.estadis-ipb').addClass('activetab').fadeToggle();
                        $('.mensajeprofile, .m-info-ipb, .friends-ips, .contact-ips') . hide('');
                        return false;
                        e.preventDefault();
                    });
                $(".ipb-tab-us ul li:eq(3)").click(function(e){
                        $('.ipb-tab-us li ,.co-ipb div').removeClass('activetab');
                        $(this).addClass('activetab');
                        $('.friends-ips').addClass('activetab').fadeToggle();
                        $('.mensajeprofile, .m-info-ipb, .estadis-ipb, .contact-ips') . hide('');
                        return false;
                        e.preventDefault();
                    });
                $(".ipb-tab-us ul li:eq(4)").click(function(e){
                        $('.ipb-tab-us li ,.co-ipb div').removeClass('activetab');
                        $(this).addClass('activetab');
                        $('.contact-ips').addClass('activetab').fadeToggle();
                        $('.mensajeprofile, .m-info-ipb, .estadis-ipb, .friends-ips') . hide('');
                        return false;
                        e.preventDefault();
                    });
                }});
                $(document).ready(function(){if(jQuery('#profile-advanced-right').length){
                $(".ipb-tab-us ul li:first-child > a").click(function(e){$('.co-ipb').attr('id', 'profilewall');});
                $(".ipb-tab-us ul li:first-child + li > a").click(function(e){$('.co-ipb').attr('id', 'profile');});
                $(".ipb-tab-us ul li:first-child + li +li > a").click(function(e){$('.co-ipb').attr('id', 'estadisticas');});
                $(".ipb-tab-us ul li:first-child + li +li +li > a").click(function(e){$('.co-ipb').attr('id', 'friends');});
                $(".ipb-tab-us ul li:first-child + li +li + li +li > a").click(function(e){$('.co-ipb').attr('id', 'contacto');
                });
                }});
                $(document).ready(function(){if(jQuery('#profile-advanced-right').length){jQuery('#profile-advanced-right').remove()};});
                $(document).ready(function(){if(jQuery('#profile-advanced-layout').length){jQuery('#profile-advanced-layout').remove()};});
                }
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 7th 2014, 1:29 am

    Hmm, the second script (IPB JS) make too much requests..

    See:

    1.
    Code:
    jQuery(".contact-ips").load(linkcontaipb + ' #profile-advanced-details .main-content');

    2.
    Code:
    jQuery(".friends-ips").load(linkfriendipb + ' #profile-advanced-details .main-content');

    3.
    Code:
    jQuery(".lass-activiti").load(linkestaipb + ' #profile-advanced-details .main-content.clearfix .stats-field.genmed ul li:contains("Última visita :")');

    4.
    Code:
    jQuery(".estadis-ipb").load(linkestaipb + ' #profile-advanced-details .main-content');

    5.
    Code:
    jQuery(".mensajeprofile").load(linkwall + ' #profile-advanced-details .main-content');


    Just 4, or 5 I don't remember now, it's sufficient to make a RL...
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 7th 2014, 1:31 am

    Is it better to remove them? Because the tutorial says to check In all the pages.
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 7th 2014, 1:33 am

    Hmm, where did you get that? There are some words in portuguese, so did you get in a portuguese forum, right?

    Can you send the link to the tutorial? So i can check if is there any better way to do this...
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 7th 2014, 1:40 am

    I found them in punbb.biz before two-three months. I think this is an updated link http://www.punbb.biz/t316-javascript-ipb-profile-v220022014-jq191  I just found my reply to get the codes.
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 7th 2014, 1:48 am

    Hmm, so.. I think they have stolen this tutorial from some brazilian forum or something like that, i dont know... But, i think is this script is doing that to your forum... Its better to remove it.. (I think x.x)

    @Edit: Reading the tutorial... Wait a sec..
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 7th 2014, 1:54 am

    Ok I am waiting if there is a solution or if not to delete them.
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 7th 2014, 2:08 am

    I think is better to do a another code, by yourself..

    About your question of storage, its simple:

    Setting items
    Code:
    localStorage.setItem('key','value');

    Getting items
    Code:
    localStorage.getItem('key');

    Example
    Run in your console
    Code:
    var name = prompt('What\'s your name?');
        localStorage.setItem('name',name);

    To get you name
    Code:
    alert( localStorage.getItem('name') );

    You can close the browser, but when you comes back the name is in there (:

    Best regards, Wagner
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 9th 2014, 2:07 pm

    Ok I have removed some javascripts and now the problem with Requests Limits have been solved.

    One more question: Do you know how many load functions must I have in my javascripts to skip the requests limits and how can I know how may .load functions firing the port?

    With Best Regards,
    Dark-Avenger
    Wagner'
    Wagner'
    Forumember


    Male Posts : 48
    Reputation : 6
    Language : Portuguese
    Location : Brazil

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Wagner' June 9th 2014, 2:54 pm

    What is your browser?

    In Google Chrome you can check the requests at Network tab in Developer Tools..

    I think 5 requests in 10 seconds can make a request limit.. Just need to check if this is right..
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Van-Helsing June 9th 2014, 2:55 pm

    Ok thanks Wagner.

    Best Regards,
    Dark-Avenger
    Derri
    Derri
    Helper
    Helper


    Male Posts : 8711
    Reputation : 638
    Language : English & Basic French
    Location : Scotland, United Kingdom

    Solved Re: How to prevent the request limit in this javascript via the localstorage?

    Post by Derri June 11th 2014, 1:18 am

    Since this topic is marked solved I'll move it to the archive.

      Current date/time is September 22nd 2024, 7:40 pm