Author |
Topic |
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 14 November 2004 : 01:47:52
|
Description This mod will allow users to put HTML tables in posts, it also checks to make sure the tables are written using correct syntax, and that all closing tags are present. The code also allows for attributes of align=center, align=left, align=right, valign=top, valign=bottom, border attributes in the [td] and [table] tag; border, cellspacing, cellpadding in [table] tag
I got the idea while sifting through stuff I missed while I was gone... came across This post
Updated 12/07/04 - Fixed line breaks within <table> tags issue, and now multiple tables within a single post works (before it didnt)
Demo 1 - Demo 2 (Test account: test/test)
Syntax:
[table table] = <table> [table align=center valign=top table] = <table align="center" valign="top"> [table border=1 cellspacing=1 table] = <table border=1 cellspacing=1>
Get the idea? you have to add table] to the end of every tag, except the closing tags
so [table align=center table][tr table][td table]Cell 1[/td][/tr][/table] is correct syntax.
You do NOT want to use linebreaks while making a table, unless you are within table cells. Some reason it wont filter out the breaks like I'd planned....
CODE Instructions: Put the following code in your inc_func_common.asp file right after you find "function extratags(fString)"
dim tblCode, ftrLoc, ftdLoc, ftrClo, ftdClo, ftblEn, JoinBack
dim ftblBr, clearBreaksS1, clearBreaksS2
tblCode = Split(fString, "[table")
For i=0 to Ubound(tblCode)
ftblBr = InStr(tblCode(i), " table]")
ftrLoc = InStr(tblCode(i), "[tr")
ftdLoc = InStr(tblCode(i), "[td")
ftrClo = InStr(tblCode(i), "[/tr]")
ftdClo = InStr(tblCode(i), "[/td]")
ftblEn = InStr(tblCode(i), "[/table]")
ClearBreaksS1 = Left(tblCode(i), ftblEn)
ClearBreaksS2 = Replace(ClearBreaksS1, "<br>", " ")
ClearBreaksS2 = Replace(ClearBreaksS2, "<br />", " ")
ClearBreaksS2 = Replace(ClearBreaksS2, Chr(10), " ")
tblCode(i) = replace(tblCode(i), ClearBreaks1, ClearBreaks2)
if ftdLoc > ftrLoc and _
(ftdClo > ftdLoc and ftdClo < ftrClo) and _
(ftrClo < ftblEn and ftrClo > ftdClo) and _
ftblEn > ftrClo and _
CountSubs(tblCode(i), "[tr")=CountSubs(tblCode(i), "[/tr]") and _
CountSubs(tblCode(i), "[td")=CountSubs(tblCode(i), "[/td]") and _
CountSubs(fString, "[/table]")=Ubound(tblCode) then
tblCode(i) = replace(tblCode(i), " align=center", " align=""center""")
tblCode(i) = replace(tblCode(i), " align=left", " align=""left""")
tblCode(i) = replace(tblCode(i), " align=right", " align=""right""")
tblCode(i) = replace(tblCode(i), " valign=top", " valign=""top""")
tblCode(i) = replace(tblCode(i), " valign=bottom", " valign=""bottom""")
tblCode(i) = replace(tblCode(i), "[tr", "<tr")
tblCode(i) = replace(tblCode(i), "[td", "<td")
tblCode(i) = replace(tblCode(i), "[/td]", "</td>")
tblCode(i) = replace(tblCode(i), "[/tr]", "</tr>")
tblCode(i) = replace(tblCode(i), "[/table]", "</table>")
tblCode(i) = replace(tblCode(i), " table]", ">")
JoinBack = "<table"
else
JoinBack = "[table"
end if
Next
fString = Join(tblCode, JoinBack)
also... You must add the following function to inc_func_common.asp
function CountSubs(fString, fSubString)
CountSubs = UBound(split(fString, fSubString))
end function
|
-Stim |
Edited by - Da_Stimulator on 07 December 2004 09:18:01 |
|
OneWayMule
Dev. Team Member & Support Moderator
Austria
4969 Posts |
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 14 November 2004 : 01:54:46
|
ugh.... old habits die hard |
-Stim |
|
|
homeacademy
Junior Member
USA
163 Posts |
Posted - 14 November 2004 : 08:15:26
|
Thanks for doing this, stimmy. I went to http://stimmy.a1.no-ip.org/topic.asp?TOPIC_ID=20, logged in and tried to test. I did something along the lines of
[table align=center table][tr table][td align=center table]Testing...[/td][td align=right table]Still testin'[/td][/tr][/table]
I may have typed something wrong when I posted, I'm really not sure, but now it gives a VBScript error when it tries to display my reply. See http://stimmy.a1.no-ip.org/topic.asp?TOPIC_ID=20. I can't click edit to get back to what I actually typed. I could look up my reply ID in the source and enter the edit URL manually, but I'm too lazy... Do you know what is causing the problem? |
|
|
PeeWee.Inc
Senior Member
United Kingdom
1893 Posts |
Posted - 14 November 2004 : 09:13:57
|
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'cLng'
/inc_func_common.asp, line 695
You get that on a replie after useing this mod, or so it seems on your site Stimmy
Keep up the good work and i hope it gets sorted |
De Priofundus Calmo Ad Te Damine |
|
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 14 November 2004 : 11:54:44
|
has nothing to do with this.... wtf thats the chkTime function |
-Stim |
|
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 14 November 2004 : 12:03:11
|
Fixed.... was something with the PM mod |
-Stim |
|
|
serritzlev
Junior Member
Denmark
291 Posts |
Posted - 14 November 2004 : 12:39:48
|
Now is back to do a tool bare there do the insert table align < else >, i dont think many can codes the html whay write this here [table align=center table][tr table][td align=center table]if that can ben done in a toolbar or again after the text (Testing...)[/td][td align=right table]Still testin'[/td][/tr][/table].
That is therfore many want the htmlarea mybi combine this white the insert code or a must is born.
BUT KIB THE GOOD WORKS ALIVE: the ide is greath.
|
|
Edited by - serritzlev on 14 November 2004 12:40:45 |
|
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 14 November 2004 : 12:40:12
|
I did this a long time ago and ended up with disastrous results because members would forget a tag or misuse it and it destroys the entire structure of the forum at times. I would be very careful allowing members to use this. poorly constructed tables can wreak havoc.
Update: Just tried it on your forum and I see if the table sequence is not correct, it will not try to build the table so you shouldn't end up with the problems I had mentioned. |
|
Edited by - dayve on 14 November 2004 12:45:46 |
|
|
PeeWee.Inc
Senior Member
United Kingdom
1893 Posts |
Posted - 14 November 2004 : 12:47:01
|
whats the line on 695?
[edit] Never mind then |
De Priofundus Calmo Ad Te Damine |
Edited by - PeeWee.Inc on 14 November 2004 12:53:50 |
|
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 14 November 2004 : 13:20:34
|
quote: Originally posted by dayve
I did this a long time ago and ended up with disastrous results because members would forget a tag or misuse it and it destroys the entire structure of the forum at times. I would be very careful allowing members to use this. poorly constructed tables can wreak havoc.
Update: Just tried it on your forum and I see if the table sequence is not correct, it will not try to build the table so you shouldn't end up with the problems I had mentioned.
Yeah I made it check for correct syntax that was my main concern when writing this |
-Stim |
|
|
homeacademy
Junior Member
USA
163 Posts |
Posted - 18 November 2004 : 08:21:12
|
Nice mod, works well... However, why do we have to use [table table] for the insertation instead of just [table]. For people (like me) who are used to HTML coding, having to put 'table' twice is annoying and against what I'm used to. Why'd you do it that way? |
|
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 18 November 2004 : 12:59:04
|
I tried it just like HTML, but when replacing the ] it messed up any other forum code.... so it was either a choice of [table] without being able to set attributes (boring table), or add something to identify the closing tag.... |
-Stim |
|
|
homeacademy
Junior Member
USA
163 Posts |
Posted - 18 November 2004 : 16:41:51
|
Okay, I see. Definatly choose attributes over the ommision of a closing tag. BUT, tho I haven't looked at the code, why does it mess up other forum code? For example, if I want to change font, I do [font face=whatever] not [font face=whatever font]. What's different about your situation? I'll look at the code later and see if it is obvious to me, but just curious... |
|
|
Da_Stimulator
DEV Team Forum Moderator
USA
3373 Posts |
Posted - 18 November 2004 : 16:44:36
|
because the code function specifically looks for each individual font in that situation. In the table tags situation, if I were to do that, I'd have to specify every possible attribute, or make some unavailable. I suppose I could do that, but I like it being flexible. |
-Stim |
|
|
homeacademy
Junior Member
USA
163 Posts |
Posted - 18 November 2004 : 22:16:50
|
Okay, got it - thanks. |
|
|
Topic |
|