T O P I C R E V I E W |
Etymon |
Posted - 20 May 2006 : 18:34:04 Does anyone have a way that I can set an option in the user's profile that when they log in that the text on the site is converted to ALL CAPS?
I have a member whose eyesight is very poor. I can covert the messages she types and the messages that she reads which were type be others by using lcase and ucase, but for everything besides the messages (like the navigation tree, etc.), I want to find an easier way than putting "if" "then" and "end if" statements everywhere.
Thank you,
Etymon < |
15 L A T E S T R E P L I E S (Newest First) |
Etymon |
Posted - 22 May 2006 : 17:30:46 That's ok, dayve.
Thank you for all of your hard work anyway!
The CaseIt function is still something that I can use, and I'm sure she'll feel better if she knows that her posts look like she's not shouting at everyone.
Thank you for sharing your code!
Sincerely,
Etymon < |
dayve |
Posted - 22 May 2006 : 16:59:12 Well, there are just so many conditions to code for, but I did find something I thought was cute. It capitalizes as you type. While it is not perfect, it does give me some ideas.
http://www.hafresno.org/test/autocap.html< |
Etymon |
Posted - 22 May 2006 : 04:18:46 Oh, dayve!
Don't wipe yourself out on this, ok?!
Thank you for the code though. It looks complicated ... no doubt!
Cheers,
Etymon< |
dayve |
Posted - 21 May 2006 : 19:43:41 quote: Originally posted by Etymon
Thank you dayve,
I figured if there was a way that you might know it better than I.
Etymon
I am not completely happy with this but wanted to get something to you before I call it the evening. I will play around with it a bit more tomorrow ... that is unless someone else can tweak it better.
Function CaseIt(fText)
Dim fTextArray, firstCharacter, lengthSentence, capitalizedSentence, sentenceStart, fBreakArray, fBreaks
fText = lcase(fText)
fText = replace(fText, "<br />", " <br /> ")
fTextArray = split(fText, ". ")
For i = lbound(fTextArray) to ubound(fTextArray)
if InStr(fTextArray(i), "<br />") = 0 then
firstCharacter = ucase(left(fTextArray(i),1))
sentenceStart = 2
else
fBreakArray = ubound(split(fText, "<br />"))
fTextArray(i) = Replace(fTextArray(i), "<br />", "")
for j = 1 to fBreakArray
fBreaks = fBreaks + "<br />"
next
firstCharacter = ucase(left(ltrim(fTextArray(i)), 1))
firstCharacter = fBreaks & firstCharacter
sentenceStart = 3 + ((j-2)*2)
end if
lengthSentence = len(fTextArray(i))
capitalizedSentence = firstCharacter & mid(fTextArray(i), sentenceStart, lengthSentence)
CaseIt = CaseIt & capitalizedSentence
if i < ubound(fTextArray) then CaseIt = CaseIt & ". "
Next
End Function
Example: http://www.burningsoulsforum.com/caseit.asp
PS. Whatever you do, just don't share the code with http://www.thedailywtf.com
BAH!!! I must be tired. I didn't account for question marks and exclamation points. I've also made way too many assumptions on what characters precede a sentence. I didn't account for things like italicize, bolding, etc. More edits < |
Etymon |
Posted - 21 May 2006 : 19:09:48 Thank you dayve,
I figured if there was a way that you might know it better than I.
Etymon < |
dayve |
Posted - 21 May 2006 : 18:24:30 DOH! ... I know why it is doing it and there is not an easy fix. However, I have some ideas and one of those includes a RegEx technique found here:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21780040.html
UPDATE: The RegEx example in the link above fails the same way. The problem being is that a carriage return is an HTML break <br /> so the script things the first character after the last sentence is a <. There will be additional conditional checks needed for this function to work. Should be able to do it but just looking for the cleanest way. < |
Etymon |
Posted - 21 May 2006 : 17:32:28 Hi dayve,
I ran into a snag.
The CaseIt works really nice on the first paragraph, but not on the others that follow it. Those paragraphs are all converted to lowercase completely.
What do I need to do to make the function recognize line breaks?
Thanks again,
Etymon < |
Etymon |
Posted - 21 May 2006 : 15:24:04 The CaseIt function seems to be what I am after.
Reference: This is the conversation I had with her this week: http://www.cricketscreations.com/forum/topic.asp?TOPIC_ID=153
Posting Messages: I need the CaseIt function for her messages that she types that are going from her posts into the database, so that she can still type in ALL CAPS, but the input going into the database will be filtered by the CaseIt function. It will look closer to a normal post than it would if it were all caps.
Reading Messages: The UCase() I need for messages that she reads that have been posted by everyone else that are coming out of the database and are being filtered by the UCase() to make the case larger for only her. This way she will be able to read the messages on the board without getting worn out.
I know it's hard to read in all caps, but this is the only option this lady has. This is just a MOD for one lady who can't read that well. She's a friend from another forum we administered and we got complaints from some members that she was shouting. So, instead of changing from all caps, she tries to dim the brightness of her text as to not offend. I just want her to glide through the posts like everyone else does.
I'm going to put it into profile page as an option for "sight-impaired" members to use.
I'd like to wrap it up as a MOD and put your name in with the credits Dayve, if that is ok with you. Actually, since it will have a dbs_ file, I'll include Huwr into it as well since that was his code originally, I think.
Cheers,
Etymon < |
dayve |
Posted - 21 May 2006 : 14:10:11 quote: Originally posted by AnonJr
heck of a lot better than the function I wrote.. granted it covered quite a few other cases, but it just wasn't practical. Just so you know, I was using it to strip away the caps lock that the nurses seem to so love.
I may post it just for reference, but it'll have to wait until I get to work tomorrow.
I work with 2 applications that are DOS and UNIX based and for some reason all the text in these applications are in all CAPS. I too have the same problem with users just being accustomed to using all CAPS and it just drives me absolutely insane. I've developed web applications that provide listings for the public and I can't tell you how many times they have updated their request to have me display the information in all CAPS. I ALWAYS refuse and tell them how ridiculous it would be to do that.< |
AnonJr |
Posted - 21 May 2006 : 14:03:18 heck of a lot better than the function I wrote.. granted it covered quite a few other cases, but it just wasn't practical. Just so you know, I was using it to strip away the caps lock that the nurses seem to so love.
I may post it just for reference, but it'll have to wait until I get to work tomorrow.< |
dayve |
Posted - 21 May 2006 : 13:20:45 quote: Originally posted by AnonJr
I'd forgotten about that particular bit of CSS...
The other reason I like using the CSS technique over the PCase function is for things like this where special characters encapsulate words that should be capitalized:
nine inch nails - sin (dub)
PCase Result:
Nine Inch Nails - Sin (dub)
CSS Result:
Nine Inch Nails - Sin (Dub)< |
AnonJr |
Posted - 21 May 2006 : 13:10:42 I'd forgotten about that particular bit of CSS...< |
dayve |
Posted - 21 May 2006 : 12:36:53 If you know for a fact that this person is really good using periods, then you could use a function similar to this:
Function CaseIt(fText)
Dim fTextArray, firstCharacter, lengthSentence, capitalizedSentence
fText = lcase(fText)
fTextArray = split(fText, ". ")
For i = lbound(fTextArray) to ubound(fTextArray)
firstCharacter = ucase(left(fTextArray(i),1))
lengthSentence = len(fTextArray(i))
capitalizedSentence = firstCharacter & mid(fTextArray(i), 2, lengthSentence)
CaseIt = CaseIt & capitalizedSentence
if i < ubound(fTextArray) then CaseIt = CaseIt & ". "
Next
End Function
Mind you that I used long variable names so you can see what is going on. Personally I don't like the way this is handled, but it does work. Here is a demo:
http://www.burningsoulsforum.com/caseit.asp
I also got to thinking that we have a resident RegEx guru around here, -gary, that may be able to throw something together.
Since I mentioned this function earlier, I figured I would share it as well. It is the Proper Case function I use for when I really need every word in a sentence capitalized.
Function PCase(string)
Dim Tmp, Word, Tmp1, Tmp2, firstCt, a, sentence, c, i
If IsNull(string) Then
PCase = Null
Exit Function
Else
string = CStr( string )
End If
a = Split( string, vbCrLf )
c = UBound(a)
i = 0
For each sentence in a
Tmp = Trim( sentence )
Tmp = split( sentence, " " )
For Each Word In Tmp
Word = Trim( Word )
Tmp1 = UCase( Left( Word, 1 ) )
Tmp2 = LCase( Mid( Word, 2 ) )
PCase = PCase & Tmp1 & tmp2 & " "
Next
PCase = Left( PCase, Len(PCase) - 1 )
If i = c then
Else
PCase = PCase & vbCrLf
End If
i = i + 1
Next
End Function
However, since using the method noted earlier combining the LCase() and CSS, I rarely use this function anymore.
< |
dayve |
Posted - 21 May 2006 : 11:39:39 quote: Originally posted by Etymon
Ok, I found something that interests me for the upper/lower case delimna. The first post is a function, but the second is in a language that is not familiar to me. The second appears from reading the author's reply to be more along my needs.
1) Thread: Change Case to Title Case?
http://dbforums.com/showpost.php?s=894db062aca65befb1edb2234c0331b5&p=1362916&postcount=2
2) Thread: Converting to Upper Case
http://forums.databasejournal.com/archive/index.php/t-14300.html
Does anyone have any idea how to convert the second one over to work with an Access database?
Thank you,
Etymon
I'm still not quite sure why you would want to do that, but using Proper Case or Title Case is as simple as doing something like this:
<span style="text-transform: capitalize;"><%= LCase(strField) %></span>
I have a PCase function that I have used in ASP but found the above a lot slimmer in coding. It can easily be applied to your forum code as well with some conditional logic if you wanted it to be a feature that can be turned on and off but I still feel compelled to tell you that it is not a good idea. If you need the size of the text changed on the fly for visitors, check out the link to the script I posted earlier in this thread.
UPDATE: The one I posted earlier is not free, but this one is:
http://dhtmlnirvana.com/content/fontsize/fontsize1.html
Demo:
http://dhtmlnirvana.com/content/dhtml/fontsize/fontsizer.html#< |
AnonJr |
Posted - 21 May 2006 : 01:22:30 Nope. But I'd strongly suggest helping her with a screen-magnifier (there's one built into Windows, not good but its there), or educating on how to use the browser's "text-size" functions, or working with dayve's solution. All three won't cost you a bit server-side in terms of performance or potential for error.
Besides, as documented in several areas, all-caps is harder to read. By making everything all-caps you may be making it more visible but not more readable.
If anything, I would put in a function to convert all posts to sentence-case just to stop the people who are really yelling. < |
|
|