Need help with Replies Count Javascript Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

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.
4 posters

    Need help with Replies Count Javascript

    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Need help with Replies Count Javascript

    Post by Van-Helsing June 13th 2014, 10:58 am

    Hi all,
    I am facing a problem with a javascript which it counts the number of replies in a post:

    Code:

    $(function(){
             var p = $('.main-head p.h2')[0];
             var paging = $('p.paging');
             var nf = $('.posthead').last().find('h2 strong').text().match(/\d+/g)-1;
             var link =  $('p.paging').not('img').find('a:last').attr('href');
            if(!paging) {
                $(p).replaceWith('<span class="countpost">'+nf+'</span>');
            }else if(paging) {
             $.get(link, function(data) {
                var nl = $('.posthead:last', data).find('h2 strong').text().match(/\d+/g)-1;
                $(p).replaceWith('<span class="countpost">'+nl+'</span>');
             });
            }
            });

    This script it doesn't return the number of replies it returns the false value - 1 http://prntscr.com/3sce8m , furthermore I am facing and another problem that I can move the text of this script a little right because its covering the the basic/regular view buttons http://prntscr.com/3sceix .


    Last edited by Dark-Avenger on July 7th 2014, 9:01 pm; edited 2 times in total
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 15th 2014, 1:37 am

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 16th 2014, 2:37 am

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 18th 2014, 2:06 pm

    bump
    SSYT
    SSYT
    Forumember


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

    Solved Re: Need help with Replies Count Javascript

    Post by SSYT June 19th 2014, 11:16 am

    What is your forum link ?
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 19th 2014, 2:05 pm

    Hello my forum link is:

    Spoiler:
    SSYT
    SSYT
    Forumember


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

    Solved Re: Need help with Replies Count Javascript

    Post by SSYT June 19th 2014, 4:18 pm

    Try new Smile
    Code:
    $(function(){
        var p = $('.main-head')[0];
        var paging = $('p.paging');
        var nf = $('.post_id').last().find('.post_number').text().match(/\d+/g)-1;
        var link =  $('p.paging').not('img').find('a:last').attr('href');
        if(!paging) {
            $(p).prepend('<span class="countpost">'+nf+'</span>');
        }
       else if(paging) {
            $.get(link, function(data) {
                var nl = $('.post_id').last().find('.post_number').text().match(/\d+/g)-1;
                $('.countpost', p).html(nl);
            });
        }
    });
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 19th 2014, 11:13 pm

    Hi Inferno,
    I tried your code but it didn't work and I have modify the javascript into this code

    Spoiler:

    and now its displaying the replies number with the text but the replaceWith function covers the Basic/Regular View Javascript's buttons. Is there another function instead the replaceWith to fix the problem.

    Before adding the Count Post Javascript : http://prntscr.com/3uk6yp
    After adding the Post Count Javascript   : http://prntscr.com/3uk62t

    Is there a way to fix it? Something is going wrong with this function.

    Best Regards,
    Dark-Avenger
    SSYT
    SSYT
    Forumember


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

    Solved Re: Need help with Replies Count Javascript

    Post by SSYT June 20th 2014, 8:50 am

    Try new Smile
    Code:
    $(function(){
        var p = $('.main-head')[0];
        var paging = $('p.paging');
        var nf = $('.post_id').last().find('.post_number').text().match(/\d+/g)-1;
        var link =  $('p.paging').not('img').find('a:last').attr('href');
        if(!paging) {
            $(p).prepend('<span class="countpost">'+nf+' reply this topic</span>');
        }
      else if(paging) {
            $.get(link, function(data) {
                var nl = $('.post_id').last().find('.post_number').text().match(/\d+/g)-1;
                $('.countpost', p).html(nl+' reply this topic');
            });
        }
    });

    And CSS:
    Code:
    .countpost{
    float: right;
    }
    [/code]

    Not edit the codes Smile
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 20th 2014, 9:05 am

    Hi Inferno,
    I have substitute the codes but they aren't working http://prntscr.com/3un8pv they dont display anything in the right side of the titlebar. Sad
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 21st 2014, 10:51 am

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

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

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 23rd 2014, 1:02 pm

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 24th 2014, 1:05 pm

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

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

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 26th 2014, 2:27 pm

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 27th 2014, 2:28 pm

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing June 28th 2014, 8:15 pm

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

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

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing July 2nd 2014, 12:18 am

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing July 4th 2014, 12:27 am

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing July 5th 2014, 1:47 am

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing July 6th 2014, 2:17 am

    Bump
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing July 7th 2014, 10:58 am

    Bump
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Need help with Replies Count Javascript

    Post by Ange Tuteur July 7th 2014, 12:02 pm

    Hi,

    Try this :
    Code:
    $(function(){
            var p = $('.main-head p.h2')[0];
            var paging = $('p.paging');
            var nf = $('.post_number').text().match(/\d+/g)-1;
            var link =  $('p.paging').not('img').find('a:last').attr('href');
            if(!paging) {
                $(p).after('<span class="countpost">'+nf+'</span>');
            }else if(paging) {
            $.get(link, function(data) {
                var nl = $('.post_number:last', data).text().match(/\d+/g)-1;
                $(p).after('<span class="countpost">'+nl+'</span>');
            });
            }
            });
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing July 7th 2014, 3:17 pm

    Hello Ange Very Happy ,
    Its working but I can't decrease the space between the number of posts and the text now its displaying like this http://prntscr.com/4092ap

    Best Regards,
    Dark-Avenger
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Need help with Replies Count Javascript

    Post by Ange Tuteur July 7th 2014, 5:03 pm

    In your CSS stylesheet is this Rule :
    Code:
    .countpost:after {
        content: " Απαντήσεις σε αυτό το θέμα";
        margin-left: 150px;
    }

    Decrease the value of margin-left to decrease the size of the gap.
    Van-Helsing
    Van-Helsing
    Hyperactive


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

    Solved Re: Need help with Replies Count Javascript

    Post by Van-Helsing July 7th 2014, 9:00 pm

    Thank you very much. Its solved.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51500
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Need help with Replies Count Javascript

    Post by SLGray July 7th 2014, 9:08 pm

    Topic Solved & Archived



    Need help with Replies Count Javascript Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.