Log In · Register

 
Emoticon script
tmacli
post Jul 11 2005, 02:20 PM
Post #1


Newbie
*

Group: Member
Posts: 1
Joined: Oct 2004
Member No: 54,456



I have made an emoticon script for smileys but when I placed it in the website stats section and click submit, the smileys do not show up. I would appreciate it if someone is able to help me and thank you for your time.

[CODEBOX]<script type="text/javascript">

function typeSmiley(sSmiley)
{
if (document.getElementsByTagName('textarea')[0].getAttribute('name') == 'bdescr')
var editor = document.getElementsByTagName('textarea')[0];
else
{
var allTextAreas = document.getElementsByTagName('textarea');
for (i = 0; i < allTextAreas.length; ++i)
{
if (allTextAreas[i].getAttribute('name') == 'bdescr')
{
var editor = allTextAreas[i];
break;
}
}
}
editor.value = editor.value + sSmiley;
}

function replaceTextSmileys()
{
// ***add textual emoticons to the array below
var textSmileys = new Array(
"catface",
"That's a no-no.",
"sad",
":blink:",
"Shut yo mouth!",
":tired:",
":happy:",
":bam bam: :pow pow:",
":sob sob:",
":infuriated:",
":Hahaha:",
"I LOVE it!",
":clap clap:",
"Umm... hehe",
"Waaa???!!",
"-_-;;",
":drools:",
"YAY!!!",
"LMAO",
"AHHH!!!",
"Hehehe... *blushes*",
"ZZZZZ...",
"Say what??!!",
"Sucka yo blood",
":touches fingers:",
"NO WAY!",
":wink:",
":flattered:",
":teehee:,
":cuckoo crazy:",
":throws up:",
":Booyaa!",
"Ooohhh, really??!!",
"Huh???",
":fainted:");


// *** add the url's from the corresponding images below
var realSmileys = new Array(
"http://img246.imageshack.us/img246/2848/13hl.gif",
"http://img246.imageshack.us/img246/7079/24jf.gif",
"http://img246.imageshack.us/img246/1425/35nn.gif",
"http://img246.imageshack.us/img246/6208/40jy.gif",
"http://img246.imageshack.us/img246/6973/58ya.gif",
"http://img246.imageshack.us/img246/617/62ea.gif",
"http://img246.imageshack.us/img246/5466/78tu.gif",
"http://img246.imageshack.us/img246/2650/89hs.gif",
"http://img246.imageshack.us/img246/8489/98vw.gif",
"http://img246.imageshack.us/img246/265/102ii.gif",
"http://img246.imageshack.us/img246/1827/113ye.gif",
"http://img246.imageshack.us/img246/4249/125zz.gif",
"http://img246.imageshack.us/img246/6734/139gm.gif",
"http://img246.imageshack.us/img246/6225/147mo.gif",
"http://img246.imageshack.us/img246/8193/154cl.gif",
"http://img246.imageshack.us/img246/1754/166tr.gif",
"http://img246.imageshack.us/img246/7304/173ur.gif",
"http://img246.imageshack.us/img246/6554/185dx.gif",
"http://img246.imageshack.us/img246/3224/194sy.gif",
"http://img246.imageshack.us/img246/6053/201na.gif",
"http://img246.imageshack.us/img246/7078/213we.gif",
"http://img246.imageshack.us/img246/2666/229wv.gif",
"http://img246.imageshack.us/img246/6951/230dm.gif",
"http://img246.imageshack.us/img246/173/249dc.gif",
"http://img246.imageshack.us/img246/4963/257lx.gif",
"http://img246.imageshack.us/img246/4905/260ae.gif",
"http://img246.imageshack.us/img246/9036/272th.gif",
"http://img246.imageshack.us/img246/9748/287ut.gif",
"http://img246.imageshack.us/img246/6574/298po.gif",
"http://img246.imageshack.us/img246/6189/309fr.gif",
"http://img246.imageshack.us/img246/6681/310mr.gif",
"http://img246.imageshack.us/img246/2919/328fe.gif",
"http://img246.imageshack.us/img246/6544/331ef.gif",
"http://img246.imageshack.us/img246/6153/341wv.gif",
"http://img246.imageshack.us/img246/5442/356nk.gif");

// *** number of smileys that will be displayed per row
var maxNumberOfSmileysPerRow = 7;
// *** button size in pixels
var buttonSize = 30;
// preloading images
var preloadedImages = new Array(realSmileys.length);
for (i = 0; i < preloadedImages.length; ++i)
{
preloadedImages[i] = new Image();
preloadedImages[i].src = realSmileys[i];
}

var allTableData = document.getElementsByTagName('td');
var indx;
var smiley;
var replacement;

for (var i = 0; i < allTableData.length; ++i )
{
for ( var n = 0; n < textSmileys.length; ++n )
{
if ((allTableData[i].innerHTML.toUpperCase().indexOf('TABLE') == -1) &&
(allTableData[i].innerHTML.indexOf('previewHTML()') == -1))
{
indx = allTableData[i].innerHTML.indexOf(textSmileys[n]);
if (indx != -1)
{
while (indx != -1)
{
replacement = '';
indx = allTableData[i].innerHTML.indexOf(textSmileys[n]);
smiley = '<img src=\"' + realSmileys[n] + '">'
replacement = allTableData[i].innerHTML.replace(textSmileys[n],smiley);
allTableData[i].innerHTML = replacement;
}
}
}

}
}

if (document.URL.indexOf('weblogs') != -1)
{
var smileyCollection = new Array(realSmileys.length);
var smileyBar = '';

if (document.getElementById('htmleditor'))
{
for (i = 0; i < smileyCollection.length; ++i)
{
smileyCollection[i] = '<button type="button" value="" ' +
'style="width:' + buttonSize + 'px; height:' +
buttonSize + 'px;" onclick="java script:insertHTML(\' ' +
textSmileys[i] + '\'); return false;">' +
'<img src=\"' + realSmileys[i] + '" alt="' + textSmileys[i] +
'"></button>';
}
}
else
{
for (i = 0; i < smileyCollection.length; ++i)
{
smileyCollection[i] = '<button type="button" value="" ' +
'style="width:' + buttonSize + 'px; height:' +
buttonSize + 'px;" onclick="java script:typeSmiley(\' ' +
textSmileys[i] + '\'); return false;">' +
'<img src=\"' + realSmileys[i] + '" alt="' + textSmileys[i] +
'"></button>';
}
}


for (i = 0; i < smileyCollection.length; ++i)
{
if (i != 0)
if ( (i/maxNumberOfSmileysPerRow).toString().indexOf('.') == -1)
smileyBar = smileyBar + '<BR>';
smileyBar = smileyBar + smileyCollection[i];
}

// add SmileyBar
infoLink = '<a href="www.xanga.com/elementoffir3"' +
'target=blank><font style="font-size: xx-small; font-weight: normal;">' +
'Smiley Script</font><a/><br><br>';
smileyBarHtml = '<br><b>Add Emoticons</b><br><font style="font-size: xx-small">' +
'Simply add emoticons to your comments by clicking them!</font> ' +
infoLink + smileyBar + '<br><br>';

if (navigator.userAgent.indexOf('Mac') == -1)
{
if (document.getElementById('htmleditor'))
var obj1 = document.getElementById('htmleditor').parentNode;
else
{
if (document.getElementsByTagName('textarea')[0].getAttribute('name') == 'bdescr')
var obj1 = document.getElementsByTagName('textarea')[0].parentNode;
else
{
var allTextAreas = document.getElementsByTagName('textarea');
for (i = 0; i < allTextAreas.length; ++i)
{
if (allTextAreas[i].getAttribute('name') == 'bdescr')
{
var obj1 = allTextAreas[i].parentNode;
break;
}
}
}
}
var obj2 = document.createElement('span');
obj2.setAttribute('ID','idSmileyBar');
obj2.innerHTML = smileyBarHtml;
obj1.insertBefore(obj2,obj1.firstChild);
}
else
{
// alternative solution for the Mac
for (var i = 0; i < allTableData.length; ++i )
{
if ((allTableData[i].innerHTML.toUpperCase().indexOf('TABLE') == -1) &&
(allTableData[i].innerHTML.indexOf('previewHTML()') == -1))
{
if (allTableData[i].innerHTML.toUpperCase().indexOf('(OPTIONAL)') != -1)
{
var temp = allTableData[i].innerHTML;
allTableData[i].innerHTML = temp + '<br>' + smileyBarHtml;
break;
}
}
}
}
}

}
if (document.URL.indexOf('weblogs') != -1)
replaceTextSmileys();
</script>
 

Posts in this topic
tmacli   Emoticon script   Jul 11 2005, 02:20 PM


Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: