MINI-MOD: Using every HEX color in Forum Code - Posted (907 Views)
Average Member
SiSL
Posts: 671
671
This mini-mod actually helps you use any HEX color on your forum code.
Example: [color="#FF00FF"]Text here[/color="#FF00FF"]
Add this function somewhere in your inc_func_common.asp

Code:
Function doColorCode(fstring)
set re = new RegExp
re.pattern = "\[color=("")(\#)([a-f0-9]{6})+("")\]"
re.ignorecase = true
re.global = true
set matches = re.execute(fstring) ' find matches
if matches.count <> 0 then
for each match in matches
changetext = Replace(Replace(match.value,"[color=" &chr(34),"<span style=""color: "),chr(34) & "]",chr(34) & ">")
fstring = Replace(fstring, match.value, changetext)
next
end if
re.pattern = "\[\/color=("")(\#)([a-f0-9]{6})+("")\]"
re.ignorecase = true
re.global = true
set matches = re.execute(fstring) ' find matches
if matches.count <> 0 then
for each match in matches
changetext = Replace(Replace(match.value,"[/color=" & chr(34) ,"</span style=""color: "),chr(34) & "]",chr(34) & ">")
fstring = Replace(fstring, match.value, changetext)
next
end if
doColorCode = fstring
set re = nothing
set matches = nothing
end function

Find following line in inc_func_common.asp

Code:
		fString = extratags(fString)

Add following right above it:

Code:
		fString = doColorCode(fstring)


And that's it :)

I would love someone can actually write a "Prompt" mode addition to it, but I guess best way is to make an iframe visible on an icon and let users pick colors :)

You can see a working demo at with using [renk="#FF0000"]test[/renk] (because renk = color in my language :P)

http://www.amedia.org/forum/
User: demo Password: test

EDIT: Updated Font Tags with SPAN<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
Nifty mod you've got there SiSL!!!!! Impressive! Quick question though about using the font tag ; I've been told by many people already that the <font> tag is 'deprecated'. In other words ; we shoulnd't use it anymore... So, you might want to use <SPAN style="text-color: #EAEAAE">
With that in mind you could also whipp up a nice 'magic marker' mod from this mod. For instance : ]blabla[/marker;"> which then is transformed into something like this: <SPAN style="background-color: #123456">blabla</span>.
(I see you know how to create a regular expression, so I alsmost do not dare to ask, but do you think you could remodel this mod to a regular expression ánd so that it uses the [tip=""][/tip] instead of [tip=**][/tip] syntax ? It would be very much appreciated if you could have a look at that mod, to see if it's possible! However, it's not easy to define a recurring pattern between the ""'s, as it's free format text....of any length...)<
Posted
Average Member
SiSL
Posts: 671
671
I will take a look quickly :)

PS: Same can be applied to [quote="nick"]message[/quote] I guess too :) Hmm I may go further with [quote nick="post" time="this" replyid="this"] stuff :P (btw I added stuff for people picking colors on my website)

But point there in your mod, there is no limiter like (6) characters top will be only A-F and 0-9 characters, there for need a task still removing unwanted stuff such as < > however, I guess it may work out well :)
<
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
ooooooh....this opens up so many hot possibilities!!!! <
Posted
Average Member
SiSL
Posts: 671
671
Posted
Forum Admin
HuwR
Posts: 20611
20611
I'm not sure I agree with the [quote = "nick"] approach as people could abuse it and start wrongly attributing comments to other users<
Posted
Average Member
SiSL
Posts: 671
671
Originally posted by HuwR
This can be already abused

Like that :) So I dont think it is much of thing that is "actually" would be believed by users without seeing original reply that is quoted.<
Posted
Average Member
SiSL
Posts: 671
671
Originally posted by MarcelG
(I see you know how to create a regular expression, so I alsmost do not dare to ask, but do you think you could remodel this mod to a regular expression ánd so that it uses the [tip=""][/tip] instead of [tip=**][/tip] syntax ? It would be very much appreciated if you could have a look at that mod, to see if it's possible! However, it's not easy to define a recurring pattern between the ""'s, as it's free format text....of any length...)

Here you go (with that, you cannot use " (quote) in tips tho..
EDIT: code makes it problem, here is link
I guess one of downsides of this, cursor don't really follow [tip][/tip] line. it changes front [tip] to yours and final tip to </span>

and oops, sorry, fixed the link<
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
Originally posted by SiSL Here you go (with that, you cannot use " (quote) in tips tho.. EDIT: code makes it problem, here is link
Thanks, but that link isn't working (it points to forum.snitz.com)<
Posted
Average Member
SiSL
Posts: 671
671
Changed link and you know you have to add
Code:
fString = doTips(fstring)

EDIT: I changed your function again Marcel (updated txt in link) now you can also use " (quote) too..
Such as:

[tip="This is "the mighty" MarcelG"]Tip here[/tip]<
Posted
Retired Support Moderator
MarcelG
Posts: 2625
2625
Great!!! Thanks! Now just finding a way to replace all instances of tip=** by tip="" bigsmile
By the way, looking at the function, I see that it makes no difference for images being used inbetween the tip-tag. Do you reckon you could update the function to leave out the span style in case the text between the tip-tags is an image (e.g. starts with [img] or [bimg=left] or [img=left] or [img=right] or [bimg=right], and ends with [/img], or [/img=left] or [/bimg=left] or [/bimg=right] or [/img=right] (upper/lowercase) ?)

Sorry to take this topic completely offtrack by the way....smile<
You Must enter a message