Author |
Topic |
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 07 January 2004 : 03:38:28
|
I've got a rather simple problem, but I am afraid that there is no solution. However, as there are many guru's around here, I want to raise the following question here. At my forum there are some clanmembers who use a default username, which is build as this : -dP.<username> So, for instance we've got a -dP.Josdaboss, and a -dP.NoVa. Now, the following happens (see this example), when -dp.Josdaboss posts something, his username is 'broken' right after the '-'character. I've set the column width to 90, but if the username is too large it will stretch automatically, and that's no problem, but when there is a '-'character it will break... Is there any way that I could prevent this from happening ? I have no problem with the username breaking at a space (for instance 'John Doe' or whatever as a username), but I do not want it to break at the - sign. Thanks in advance! |
portfolio - linkshrinker - oxle - twitter |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 07 January 2004 : 05:24:04
|
add the nowrap property to the table cell displaying them |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 07 January 2004 : 06:52:15
|
That's done, but it still wraps
<td bgcolor="F0F8FF" valign="top" width="90" nowrap>
<p><font face="Tahoma" size="2"><b><span class="spnMessageText"><a
href="pop_profile.asp?mode=display&id=89" title="View -dP.josdaboss's Profile"
onMouseOver="(window.status='View -dP.josdaboss\'s Profile');
return true" onMouseOut="(window.status=''); return true">-dP.josdaboss</a></span></b></font><br />
<font color="000033" face="Tahoma" size="1"><small>sherrif</small></font><br />
<img src="images/icon_star_gold.gif" width="10"
height="9" border="0" alt="" title="" />
<img src="images/icon_star_gold.gif" width="10" height="9"
border="0" alt="" title="" /><br..... |
portfolio - linkshrinker - oxle - twitter |
Edited by - MarcelG on 07 January 2004 06:53:25 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 07 January 2004 : 07:13:57
|
the only thing you can do is try using something other than -, it is a hyphen and that is probably why it splits it, try using a : or something instead |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 07 January 2004 : 07:57:33
|
Ha! I have found something!! If you were to place it between the <nobr> </nobr> tags, it won't break! I'd have to make a check, to see if there is a '-' in the username, and if so, place these tags around it. Mmmh...gonna start fiddling around. It would have to be put around the words, not including the spaces. (at a space it may brake!) In normal language it would be : If there are one or more '-' in the profileLink(ChkString(Reply_MemberName,"display"), then there should be <nobr> </nobr> around each 'word' in profileLink(ChkString(Reply_MemberName,"display").
So, for instance the username 'Johnny -dp.Joe' would be '<nobr>Johnny</nobr> <nobr>-dp.Joe</nobr>, and '-dp.Josdaboss' would be '<nobr>-dp.Josdaboss</nobr>'.
I think I should change the profileLink function for that...and that would be in ... inc_func_common.asp :
function profileLink(fName, fID)
if instr(fName,"img src=") > 0 then
strExtraStuff = ""
else
strExtraStuff = " title=""View " & fName & "'s Profile""" & dWStatus("View " & fName & "'s Profile")
end if
if strUseExtendedProfile then
strReturn = "<a href=""pop_profile.asp?mode=display&id=" & fID & """" & strExtraStuff & ">"
else
strReturn = "<a href=""JavaScript:openWindow3('pop_profile.asp?mode=display&id=" & fID & "')""" & strExtraStuff & ">"
end if
profileLink = strReturn & fName & "</a>"
end function
HuwR, are you willing to lend a hand in doing this trick ? |
portfolio - linkshrinker - oxle - twitter |
Edited by - MarcelG on 07 January 2004 07:59:17 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 07 January 2004 : 08:07:13
|
why don't you just wrap the whole username in a single set of <nobr> tags, then you wan't need to fiddle arround checking for - |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 07 January 2004 : 08:08:28
|
You'd only need to use <nobr> on those words that actually contain a -, i.e. 'Johnny -dp.Joe' would become 'Johnny <nobr>-dp.Joe</nobr>'. What you'd have to do in the function above is split fname into an array at the space(s) then, for each entry in the Array, check if there's a - in it (is there a VBScript equivalent to indexOf() in javascript?), if so modify the array entry to include <nobr> and then reassemble fname. All that could be done before the line that reads "profileLink = strReturn & fName & "</a>"". I would have provided you with code, but I'm unsure as to how to check for the presence of a chracter in a string, bar looping through the chracters in the string and comparing them to the chracter you're looking for.
<edit> ... Or you could just do what Huw suggested, hell of a lot easier that way! </edit>
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
Edited by - Shaggy on 07 January 2004 08:09:54 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 07 January 2004 : 08:15:04
|
quote:
but I'm unsure as to how to check for the presence of a chracter in a string
Instr(sourceText, findText) |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 07 January 2004 : 08:18:52
|
quote: Originally posted by HuwR
why don't you just wrap the whole username in a single set of <nobr> tags, then you wan't need to fiddle arround checking for -
But then there would be no break for a space, would there ? And that's not wat I want, especially with people using long usernames with spaces in it such as 'Your Very Best Friend'...but then again, I could also limit the length of the username, ánd use the <nobr></nobr> tag...
Guys, thanks for thinking with me here! BTW ; I found an interesting article on this 'problem' : http://www.cs.tut.fi/~jkorpela/html/nobr.html#breaks |
portfolio - linkshrinker - oxle - twitter |
Edited by - MarcelG on 07 January 2004 08:20:39 |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
Posted - 07 January 2004 : 08:30:13
|
I've done it using HuwR's method now, simply put <nobr> before the <a href tags and end the </a> with </nobr> in the Profilelink function. I am still thinking about the spaces issue (with this solution spaces are also not 'broken'), but that's an issue for later. |
portfolio - linkshrinker - oxle - twitter |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 07 January 2004 : 08:37:48
|
quote: Originally posted by marcelgoertz I am still thinking about the spaces issue (with this solution spaces are also not 'broken'), but that's an issue for later.
you could simply do an
if Instr(Membername,"-") then
wrap in <nobr>
else
don't wrap in <nobr>
end if
|
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 07 January 2004 : 09:24:14
|
If names contained a space and a hyphen and you wanted to allow a break at the space (as in your example, 'Johnny -dp.Joe'), you would need to do something along the lines of what I posted. Now that I know how to check for a character in a string (Thanks Huw ), here's the code change I was suggesting (new code in red):function profileLink(fName, fID)
if instr(fName,"img src=") > 0 then
strExtraStuff = ""
else
strExtraStuff = " title=""View " & fName & "'s Profile""" & dWStatus("View " & fName & "'s Profile")
end if
if strUseExtendedProfile then
strReturn = "<a href=""pop_profile.asp?mode=display&id=" & fID & """" & strExtraStuff & ">"
else
strReturn = "<a href=""JavaScript:openWindow3('pop_profile.asp?mode=display&id=" & fID & "')""" & strExtraStuff & ">"
end if
if instr(fName," ") then
arrfName = split(fName," ")
fName = ""
for x = 0 to ubound(arrfName)
if instr(arrfName(x),"-") then arrfName(x) = "<nobr>" & arrfName(x) & "</nobr>"
fName = fName & " " & arrfName(x)
next
elseif instr(fName,"-") then
fName = "<nobr>" & fName & "</nobr>"
end if
profileLink = strReturn & trim(fName) & "</a>"
end function It's a bit of a kludge and I haven't tested it but it should point you in the right direction.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
MarcelG
Retired Support Moderator
Netherlands
2625 Posts |
|
|
Topic |
|