View Full Version : Smilies insert position tweak
If you're using IE4+, you can now insert smilies at the cursor position. Previously, smilies (:))will only be added at the end of your text. If you're using Netscape, sorry.
Let me know if there's any problems with it.
ps. Try not to use too many smilies in one post. I think we're all able to communicate without using cartoon faces.
Punkbrad
Wed 3/5/03, 9:54PM
i :) think :( it :o works ;) paul, :D
And by the way - dont think that you can just come up in here and tell us how many smileys to use - new guy - we have our way with folks like that around here --- wait -- whats that?
OHHHH this IS HIS website--
nevermind.
Pb :p
Ah...that's perfect! =D> Now can you do the same for URLs, images, etc? :D
Originally posted by MrPython
Now can you do the same for URLs, images, etc? :D
Nah, I don't like to play with javascripts. You wanna do it? :D
Reddog99
Thu 3/6/03, 12:23AM
OK, this is another test.
Pat:eek:
EDIT: guess it dosen't work for Safari.
doub1etap
Thu 3/6/03, 12:24AM
You already did the hard part, Paul. Say you take the code written for the smilie function and make a new more generic function, like this:
function insertToTxt(txtAreaRef,strToAdd) {
if (txtAreaRef.createTextRange() && txtAreaRef.caretPos) {
var caretPos = txtAreaRef.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? strToAdd + ' ' : strToAdd + " ";
}
else {
txtAreaRef.value += strToAdd + " ";
}
txtAreaRef.focus();
}
Then anywhere the code was previously doing string concatenation (ie. +=) it could be replaced with the function call for insertToTxt.
The new smilie function would look something like this:
function smilie(thesmilie) {
insertToTxt(document.vbform.message,thesmilie);
}
and the new VBcode function:
function vbcode(theform,vbcode,prompttext) {
// insert yyy style markup
if ((normalmode(theform)) || (vbcode=="IMG")) {
inserttext = prompt(tag_prompt+"\n["+vbcode+"]xxx[/"+vbcode+"]",prompttext);
if ((inserttext != null) && (inserttext != ""))
insertToTxt(theform.message,"["+vbcode+"]"+inserttext+"[/"+vbcode+"] ");
}
else {
donotinsert = false;
for (i = 0; i < tags.length; i++) {
if (tags[i] == vbcode)
donotinsert = true;
}
if (donotinsert)
stat("already_open");
else {
insertToTxt(theform.message,"["+vbcode+"]");
arraypush(tags,vbcode);
}
}
theform.message.focus();
}
Anyways, its late.. I'm sure I missed something in there. PM me if you want me to scratch out a new version of vbcode.js
Dan
Punkbrad
Thu 3/6/03, 7:08AM
you guys are computer nerds....
If I was that smart, I'd be all...
RunCode {InsertHotChik } =
function vbcode
(bigboobs,prettyface,nicebod ) {
// insert yyy style markup
if ((reallyhorny (theform)) || (vbcode=="IMG")) {
inserttext = prompt(hasownmoney _prompt+"\n["+vbcode+"]xxx[/"+vbcode+"]",prompttext);
if ((likestocook != null) && (inserttext != ""))
insertToTxt(loves.motorcycles ,"["+fatguys +"]"+inserttext+"[/"+vbcode+"] ");
r
Kurt'sSV
Thu 3/6/03, 8:37AM
I'll wager all you guys took your mom to your senior prom too.:p
Golden_Eternity
Thu 3/6/03, 9:37AM
Nah, real geeks don't use vbcode.
doub1etap
Thu 3/6/03, 9:38AM
I couldn't go to prom, I would have missed the Star Trek marathon.
Dan :geek:
______________________________
"Are you stealing that desk?"
"I'm exercising my stock options."
Punkbrad
Thu 3/6/03, 9:39AM
Originally posted by doub1etap
I couldn't go to prom, I would have missed the Star Trek marathon.
Dan :geek:
______________________________
"Are you stealing that desk?"
"I'm exercising my stock options."
LOL - good one man... hehehe
Sentinel
Thu 3/6/03, 9:58AM
Originally posted by Kurt'sSV
I'll wager all you guys took your mom to your senior prom too.:p
No way man, she was my cousin! :p
Originally posted by doub1etap
Say you take the code written for the smilie function and make a new more generic function, like this:
function insertToTxt(txtAreaRef,strToAdd) {
(snip)
Dan
Wow... that's great. It looks perfect to me. Now why didn't I think of that... Thanks!
Now users of IE4+ can insert URL, IMG, FONT, SIZE, etc at the position of the cursor.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.