Need help with Replies Count Javascript
4 posters
Page 1 of 1
Need help with Replies Count Javascript
Hi all,
I am facing a problem with a javascript which it counts the number of replies in a post:
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 .
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
Re: Need help with Replies Count Javascript
Hello my forum link is:
- Spoiler:
- Code:
http://linux-team.forumgreek.com/
Re: Need help with Replies Count Javascript
Try new
- 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);
});
}
});
Re: Need help with Replies Count Javascript
Hi Inferno,
I tried your code but it didn't work and I have modify the javascript into this code
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
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
Re: Need help with Replies Count Javascript
Try new
And CSS:
Not edit the codes
- 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;
}
Not edit the codes
Re: Need help with Replies Count Javascript
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.
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.
Re: Need help with Replies Count Javascript
Hi,
Try this :
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>');
});
}
});
Re: Need help with Replies Count Javascript
Hello Ange ,
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
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
Re: Need help with Replies Count Javascript
In your CSS stylesheet is this Rule :
Decrease the value of margin-left to decrease the size of the gap.
- Code:
.countpost:after {
content: " Απαντήσεις σε αυτό το θέμα";
margin-left: 150px;
}
Decrease the value of margin-left to decrease the size of the gap.
Re: Need help with Replies Count Javascript
Topic Solved & Archived
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Making Javascript word count box have a different text input colour
» How do I make a forum area not count towards post count..?
» new replies
» Link to Replies
» Delete replies??
» How do I make a forum area not count towards post count..?
» new replies
» Link to Replies
» Delete replies??
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum