Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Zetaboards Modifications
  • [SC] Bold Topics With Less Than X Replies
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
[SC] Bold Topics With Less Than X Replies
Tweet Topic Started: May 3 2009, 03:23 PM (895 Views)
Vitality May 3 2009, 03:23 PM Post #1
Member Avatar
Tabula Rasa

Posts:
784
Group:
Former Staff
Member
#320
Joined:
Jul 26, 2008
What does it do: It will bold the topic title of the topics that have less than a specified number of replies. It's a feature to promote new topics.
Preview: None at the moment.
Where does it go: Below the Board

There are two versions of this code. If you'ree anti-jQuery, you can go ahead an use the one I have made in classic JS (I did this to get back in the swing of classic). Or, if you're concerned about space, you can go ahead an use the other version Reid had so kindly coded up.

The classic JS version
Code: HTML
 
<script type="text/javascript">
/*Vitality - ZBCode*/
if(location.href.indexOf("forum/")!=-1){
var xReply=10;
var theTd=document.getElementsByTagName("td");
var eRepl=theTd.length;
while(eRepl--){
if(theTd[eRepl].className=="c_cat-replies"&&theTd[eRepl].innerHTML.indexOf("stats/list/?tid=")!=-1){
var eRnum=theTd[eRepl].innerHTML.split(
"\">")[1].split("</a>")[0];
if(eRnum<xReply){
var newFind=theTd[eRepl].parentNode.childNodes;
var newL=newFind.length;
while(newL--){
if(newFind[newL].className=="c_cat-title"){
newFind[newL].getElementsByTagName("a")[0].style.fontWeight='bold';
}}}}}}
</script>


Reid's version
Code: HTML
 
<script type="text/javascript">
/*Reid - ZBCode*/
if (location.href.indexOf("/forum/")!=-1) {
var xReply=10;
$("td.c_cat-replies").each(function(){
if (parseInt($.trim($(this).children("a").text()))<xReply) {
$(this).parent().children("td.c_cat-title").children("a").css({'font-weight':'bold'});
}})}
</script>


Okay, so the only editing you can do is deciding on what amount of replies you want before the topic title turns regular again. Right now it is set to have all topics with less than 10 replies to turn bold, but if you want more or less, all you have to do is edit this line (it's the same for both versions):
Code:
 
var xReply=10;
That is right near the top of the code and can be changed to whatever number you like.

Thank you Reid for the help!
Offline Profile Goto Top
 
DaMeiN May 3 2009, 04:49 PM Post #2
Member Avatar
Oo.SpawN.oO

Posts:
204
Group:
Member
Member
#2,589
Joined:
Mar 16, 2009
Coding language
HTML/CSS
So where does this go?

I've tried it in all the sections I believe with no affects :(

Thanks.
Posted Image

† You fall to your knees, you beg you plead. Can I be someone else, for all the times I hate myself.. †
† You refuse to bend, so I keep bending until I break... †
Offline Profile Goto Top
 
Vitality May 3 2009, 04:52 PM Post #3
Member Avatar
Tabula Rasa

Posts:
784
Group:
Former Staff
Member
#320
Joined:
Jul 26, 2008
It goes Below the Board and it will effect the topics that have less replies than the number you've set in the forum view.
Offline Profile Goto Top
 
Pilla May 4 2009, 05:53 PM Post #4
Member Avatar


Posts:
205
Group:
Dedicated
Member
#2,450
Joined:
Feb 26, 2009
nice code!
Offline Profile Goto Top
 
daveclarkedaveclarke Jun 5 2009, 05:23 AM Post #5
Member Avatar
Adrenaline Site Owner

Posts:
117
Group:
Dedicated
Member
#3,047
Joined:
May 23, 2009
Coding language
None
nice code! it works fine for me can this be edited so tht instead of it being bold it could be a different font colour?
Posted ImagePosted Image
Offline Profile Goto Top
 
Dorith Jun 8 2009, 01:52 AM Post #6
Member Avatar
Has just entered the Matrix

Posts:
2,069
Group:
Former Staff
Member
#1,854
Joined:
Dec 23, 2008
Sorry if I'm not allowed to modify another person's code, but I'm just answering the question for the person above. If I'm now allowed to do this, then just trash this post.

@daveclarkedaveclarke
Where it says:
Code:
 
$(this).parent().children("td.c_cat-title").children("a").css({'font-weight':'bold'});

Change it to:
Code:
 
$(this).parent().children("td.c_cat-title").children("a").css({'color':'red'});

And where it says 'red', change that to whichever color you'd like it to be.

Hope that helps :D
Posted Image
Posted Image
(Made emoticon using Codes Rock's Smiley Generator)
Offline Profile Goto Top
 
Reid Jun 8 2009, 11:44 AM Post #7
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Feel free to edit my version, but I can't give permission for Vitality. :P
The Resource Board
Offline Profile Goto Top
 
speeddemon32q Jul 18 2010, 03:55 PM Post #8


Posts:
2
Group:
Member
Member
#2,170
Joined:
Jan 30, 2009
This is a great code. Thanks so much. Just wondering, if I wanted to bold and change color, how would I put them both in there?
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Zetaboards Modifications · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 7:39 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy