Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Code Requests
  • Completed Requests
  • [Completed] [ZB] Customizable Tables
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
  • Pages:
  • 1
  • 2
[Completed] [ZB] Customizable Tables
Tweet Topic Started: Sep 22 2009, 03:39 PM (374 Views)
SkzzXx Sep 22 2009, 03:39 PM Post #1


Posts:
14
Group:
Member
Member
#3,274
Joined:
Jun 30, 2009
Since doHTML is out of the way, I'm trying to figure out a way to still get as much customization as possible over a post, such as changing the table border and background color of posted content, with an image, etc... Any RolePlayers who have used doHTML tables ought to know what I'm talking about. These are things that seemingly can't really be done without doHTML but I still want to see how much I can do without it.

Either this needs a code, or I'm just dull. :P
Offline Profile Goto Top
 
Reid Sep 22 2009, 03:58 PM Post #2
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
I'm working on this at the moment - it should be finished shortly... just finishing up testing,
The Resource Board
Offline Profile Goto Top
 
SkzzXx Sep 22 2009, 04:20 PM Post #3


Posts:
14
Group:
Member
Member
#3,274
Joined:
Jun 30, 2009
:D Thanks! I can't wait to see it. I hope I explained myself well enough, I really didn't know how to put it in words.
Offline Profile Goto Top
 
Reid Sep 22 2009, 04:23 PM Post #4
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
Okay, so. Put this in the 'below the board' section of your board template:
Code:
 
<script type='text/javascript'>
// <![CDATA[
$('td:contains([ctable)').each(function(){
this.innerHTML = this.innerHTML.replace(/\[ctable([^\]]*?)\](.*?)(?:<br(?:\s?\/)?>)?\[\/ctable\]/gi, function(m_text, first_m, second_m) {
return "<table" + first_m + ">" + second_m.replace(/(?:<br(?:\s?\/)?>)?\[(\/?)td(.*?)\]/gi, "<$1td$2>").replace(/(?:<br(?:\s?\/)?>)?\[(\/?)tr(.*?)\]/gi, "<$1tr$2>").replace(/(?:<br(?:\s?\/)?>)?\[(\/?)thead(.*?)\]/gi, "<$1thead$2>").replace(/(?:<br(?:\s?\/)?>)?\[(\/?)tbody(.*?)\]/gi, "<$1tbody$2>").replace(/(?:<br(?:\s?\/)?>)?\[(\/?)th(.*?)\]/gi, "<$1th$2>") + "</table>";
});
});
// ]]>
</script>
Then you should be able to use tables like so:
Code:
 
[ctable]
[thead]
[tr][th colspan='2']Some table[/th][/tr]
[/thead]
[tbody]
[tr][th]Stuff[/th][th]Price[/th][/tr]
[tr][td style='background:black; color:white']Potatoes[/td][td style='color:blue']$1.00[/td][/tr]
[tr][td]Fruit[/td][td]$1.01[/td][/tr]
[/tbody]
[/ctable]
You have to use [ctable] instead of [table] because there is already a [table] BBCode. As you can see, you just use the regular ol' table tags from there - albeit with brackets. You can use any HTML attribute you so wish. You don't have to have the thead and tbody and all of that nonsense, either, it's just good to create nice looking tables. So you just create a table like you would in HTML, just you use square brackets instead of angle brackets.

Tell me if you have any problems with this. There were some odd things going on when I was writing it, so I'm not sure if will work 100% in all situations. It was an interesting script to write, to say the least. :P
The Resource Board
Offline Profile Goto Top
 
Reid Sep 22 2009, 04:29 PM Post #5
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
Mmm I re-read your post a few times and I apparently misunderstood you....... or did I? Not sure. Anyways, that was a fun table code anyways. :D
The Resource Board
Offline Profile Goto Top
 
Choco Sep 22 2009, 04:38 PM Post #6
Member Avatar
¡ʎɹoʇɔɐɟ ʎʇıʌɐɹƃ ɐ uı pǝddɐɹʇ ɯ,ı 'dןǝɥ

Posts:
589
Group:
Admins
Member
#3,272
Joined:
Jun 30, 2009
Coding language
Everything
Reid
Sep 22 2009, 04:29 PM
Mmm I re-read your post a few times and I apparently misunderstood you....... or did I? Not sure. Anyways, that was a fun table code anyways. :D
Might want to filter out onevent events, or filter out JS from table attributes...otherwise people will start highjacking topics!
Posted ImageIt's a magical world, Hobbes, ol'd buddy... ...let's go exploring!
In progress: Something Special ;)
Offline Profile Goto Top
 
SkzzXx Sep 22 2009, 05:04 PM Post #7


Posts:
14
Group:
Member
Member
#3,274
Joined:
Jun 30, 2009
No, no, it's exactly what I wanted. At least I'm pretty sure it is. I just converted a doHTML piece to this, and it looked nice, so I'm guessing it works. :) I'm going to keep playing around with it to try and understand it more -- if I have any problems, I'll be sure to ask you. Thank you!

Actually, just to ask another question -- this wouldn't permit style tags too, would it? Like:

Code:
 
<style>
#footer {
color: 345987;
}
</style>


Just in tag format, like you said?
Edited by SkzzXx, Sep 22 2009, 05:07 PM.
Offline Profile Goto Top
 
Reid Sep 22 2009, 05:36 PM Post #8
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
Erm - no - I'm not sure what you're trying to accomplish though. :P

It only creates a table bbcode (more extensive one)... not any other HTML or anything. :P

What do you need CSS for? You can style your table through the 'style' attribute on the table itself.
The Resource Board
Offline Profile Goto Top
 
SkzzXx Sep 22 2009, 05:41 PM Post #9


Posts:
14
Group:
Member
Member
#3,274
Joined:
Jun 30, 2009
Reid
Sep 22 2009, 05:36 PM
What do you need CSS for? You can style your table through the 'style' attribute on the table itself.
Awright. It was curiosity. I'm not that savvy with coding yet, but I know that some people who might join my board would want to be able to have customizable tables, even if they have to rearrange the coding, and while I don't know much about coding from scratch, I'm pretty good at converting one code to another without a thorough understanding of what I'm doing. x)

So, I did figure out how to use the style attribute other than trying to use CSS.
Offline Profile Goto Top
 
Reid Sep 22 2009, 05:57 PM Post #10
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
SkzzXx
Sep 22 2009, 05:41 PM
Reid
Sep 22 2009, 05:36 PM
What do you need CSS for? You can style your table through the 'style' attribute on the table itself.
Awright. It was curiosity. I'm not that savvy with coding yet, but I know that some people who might join my board would want to be able to have customizable tables, even if they have to rearrange the coding, and while I don't know much about coding from scratch, I'm pretty good at converting one code to another without a thorough understanding of what I'm doing. x)

So, I did figure out how to use the style attribute other than trying to use CSS.
Yeah, they should be able to create any form of table they want tbh. The code is fairly flexible.
The Resource Board
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Completed Requests · Next Topic »
Locked Topic
  • Pages:
  • 1
  • 2

Track Topic · E-mail Topic Time: 2:27 PM Jul 11
Hosted for free by ZetaBoards · Privacy Policy