The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Need help with Replies Count Javascript

View previous topic View next topic Go down

Solved Need help with Replies Count Javascript

Post by Van-Helsing on 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
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

What is your forum link ?

SSYT
Forumember

Male Posts : 39
Reputation : 2
Language : RO-10, EN-3, FR-1
Location : Romania

http://help.forumgratuit.ro/forum

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Hello my forum link is:

Spoiler:

Code:
http://linux-team.forumgreek.com/

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by SSYT on 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);
        });
    }
});

SSYT
Forumember

Male Posts : 39
Reputation : 2
Language : RO-10, EN-3, FR-1
Location : Romania

http://help.forumgratuit.ro/forum

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing on 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:
Code:

$(function(){
var p = $('.main-head p.h2')[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;
$(p).replaceWith('<span class="countpost">'+nl+'</span>');
$('.countpost', p).html(nl);
});
}
});

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

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by SSYT on 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

SSYT
Forumember

Male Posts : 39
Reputation : 2
Language : RO-10, EN-3, FR-1
Location : Romania

http://help.forumgratuit.ro/forum

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing on 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
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Bump

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Ange Tuteur on 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>');
        });
        }
        });

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Hello AngeVery 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

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Ange Tuteur on 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.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Thank you very much. Its solved.

Van-Helsing
Hyperactive

Male Posts : 2198
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

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

Topic Solved & Archived


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


SLGray
Administrator
Administrator

Male Posts : 35670
Reputation : 2375
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


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