Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP auto emoticons/smileys 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have seen chats and other pages, that makes the smileys you type, into pictures. Does anyone no where to find that script ????
 
Basically you have a selection of graphics on your website that correspond to emoticons. If your chat etc is html based you just do this:

post = replace(post,&quot;:)&quot;,&quot;<IMG SRC=&quot;&quot;emoticons/smile.gif&quot;&quot;>&quot;)

This will replace a smiley with a HTML image tag in someone's post assuming that is the correct path to your smiley graphic, and your chat or post processes html.

Hope that helps. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
note that the smiley face above is actually me typing a : - ) without the spaces Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
it really doesn't help. What i thought about was, when i type : - ), asp automaticly changes in to a emoticon. Just like this forum. :)
 
duckfighter, you were provided a perfect solution. what is it that you don't understand?

Code:
strOutput = replace(strOriginal,&quot;:-)&quot;,&quot;<IMG SRC=smile.gif>&quot;)
Response.Write(strOutput)

what more do you want?

---
---
 
Sorry, but i don't know how to use the code (i just began programming asp). Should i just put the script on a page ??
 

Duck, I have been programming ASP for only 3 months now from knowing nothing at all. Do a search on a search engine for ASP help or ASP Tutorials, you will find what you are looking for to get you started.
The advise you have been given here, is what you are looking for man.


P.S. Just thought on putting my two cents in. QUOTE OF THE DAY
Don't waste time telling people what you are doing or what you are going to do. Results have a way of informing the world.

<%
Jr Clown :eek:)
%>
 
Ok, i'll do that. ANyway. Thank for taking the time answering me. I'll save the code, and use it when i understand how to :)
 
Duck,
I think you were trying to get a solution that works in any chat room. The rooms that do that have special scripts that convert your smiley to an image link, and then displays the image. It has to be specially coded into each chat room, bulliten board, etc for it to work. There is no universial smiley to image code.

Hope that clears some things up. When you made this post to an ASP help area, you got an ASP code help response because that is what we all thought you wanted. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
I found out how it worked. I made it a bit bigger :)


<% input= database(&quot;files&quot;) %>
<% a = replace(input,&quot;:)&quot;,&quot;<IMG SRC=happy.gif>&quot;) %>
<% b = replace(a,&quot;:-|&quot;,&quot;<IMG SRC=neutral.gif>&quot;) %>
<% c = replace(b,&quot;:-(&quot;,&quot;<IMG SRC=mad.gif>&quot;) %>
<% Response.Write(c) %>

Sorry it took so long.
 
I want to get back to the page Emoticons (Smileys) and process them or whatever. How do I do that? I want to put them in my e-mail messages. thanks
 
Little time delay in this post [smile]

specific issue i have is using the replace function is getting it to respond properly with case insensitivity, i've attempted to do :

response.write Replace(sourcestr,&quot;:p&quot;,&quot;<img src=&quot;&quot;/images/smileys/9.gif&quot;&quot;>&quot;,vbTextCompare)

but it's case insenstive, even with the vbTextCompare
so :p and :p one would yeild a smiley, the other would remain text, i'd hate to make a huge string manipulation block of all case sensitivity combos.

any suggestions?


 
I've used this code in loads of the web aps I've written - web based HTML Editor (for my blogs), message boards, tag boards etc - and it always uses the function listed below:
Code:
    function smileyz(sSmiley)
        '-- declare vars
        dim sCreator, sName
        
        '-- query db
        oRs.Open &quot;select * from smileyz where status=1 order by len(smileyText) desc&quot;,con,3,3
        while not oRs.EOF
            sCreator    = replace(oRs(&quot;Creator&quot;),&quot;&quot;&quot;&quot;,&quot;&quot;&quot;)
            sName        = replace(oRs(&quot;smileyName&quot;),&quot;&quot;&quot;&quot;,&quot;&quot;&quot;)
            sSmiley        = replace(sSmiley,oRs(&quot;smileyText&quot;),&quot;<img src=&quot;&quot;images/&quot; & oRs(&quot;smileyImg&quot;) & &quot;&quot;&quot; title=&quot;&quot;&quot; & sName & &quot; - &quot; & sCreator & &quot;&quot;&quot; />&quot;)
        oRs.MoveNext
        wend
        oRs.Close
        
        '-- output
        smileyz    = sSmiley
    end function

where all the smileys are in a table called
Code:
smileyz
which has the structure:
Code:
Creator - (the smiley's artist - just for the alt text)
SmileyName - (uh.. the name of the image - Happy, Sad, whatever)
SmileyText - (the text to check for)
SmileyImg - (the image to replace that text with)

That way I can add extra smileys by adding the image name (SmileyImg) and the character code (SmileyText) to the database.

It's ordered by descending SmileyText length, so that you don't replace the first two characters of
Code:
:))
(grin) to make :)
Code:
)
.
If that makes sense.

Have a look over on - the &quot;Greetz&quot; section on the top right. Please don't kill it too badly... it's only a wee site...!!

Hit the &quot;smileyz&quot; link to see a list of existing smileys - clicking on one will put the character code in your message, or you can just type the character code yourself. It gets converted to the image tag when you hit &quot;add&quot;..

I thought it was nice. :) Suggestions/comments appreciated?

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
I forgot to say - I have to have a seperate entry for
Code:
:P
and
Code:
:p
. I didn't want to use
Code:
lcase / ucase
as it'd change the entire message string.

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
As far as i knw Replace is case Sensitive, and it uses vbTextCompare as it's default comparison method.
As for an workaround to find what you need you could use something like this
Code:
msg=&quot;This would be a text :p :P :d :D&quot;
set r=new RegExp
r.IgnoreCase=true
r.Global=true

r.Pattern=&quot;([:][p])&quot;
set find=r.Execute(msg)
RetStr=&quot;&quot;
For Each Match in find   ' Iterate Matches collection.
	msg=Replace(msg,Match.Value,&quot;xyz&quot;)
Next
Response.Write msg

This can be easily extrapolated to more paterns to find


________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top