View Full Version : smiley script not working....


XoJennaXo
02-10-2005, 09:55 PM
Whats wrong with this?.....

<script type="text/javascript">

function typeSmiley(sSmiley)
{
if (document.getElementsByTa gName('textarea')[0].getAttribute('name') == 'bdescr')
var editor = document.getElementsByTag Name('textarea')[0];
else
{
var allTextAreas = document.getElementsByTag Name('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(

"+angel+";
"+hearts+";
"+wink+";
"+grin+";
"+mad+";
"+mad+";
"+lol+";
"+lol+";
"+happyblink+";
"+madblink+";
"+yes+";
"+^^^^+";
"+^^^^+";
"+no+";
"+pant+";
"+sad+";
"+sleep+";
"+sleep+";
"+dead+";


// *** add the url's from the corresponding images below
var realSmileys = new Array(
"http://www.astroalley.com/emoticons/captWeaver.gif";
"http://www.astroalley.com/emoticons/pirateWub.gif";
"http://www.astroalley.com/emoticons/pirateWink.gif";
"http://www.astroalley.com/emoticons/pirateGrin.gif";
"http://www.astroalley.com/emoticons/pirateAngryBlinkAnim1.gif";
"http://www.astroalley.com/emoticons/pirateAngryBlinkAnim2.gif";
"http://www.astroalley.com/emoticons/pirateAnimeLol1.gif";
"http://www.astroalley.com/emoticons/pirateAnimeLol2.gif";
"http://www.astroalley.com/emoticons/pirateBlink1.gif";
"http://www.astroalley.com/emoticons/pirateBlink2.gif";
"http://www.astroalley.com/emoticons/pirateYes.gif";
"http://www.astroalley.com/emoticons/pirateLol1.gif";
"http://www.astroalley.com/emoticons/pirateLol2.gif";
"http://www.astroalley.com/emoticons/pirateNo.gif";
"http://www.astroalley.com/emoticons/piratePant1.gif";
"http://www.astroalley.com/emoticons/pirateSadBlink1.gif";
"http://www.astroalley.com/emoticons/pirateSleep1.gif";
"http://www.astroalley.com/emoticons/pirateSleep2.gif";
"http://www.astroalley.com/emoticons/pirateXxP.gif";


// *** number of smileys that will be displayed per row
var maxNumberOfSmileysPerRow = 4;
// *** 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.getElementsByTag Name('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('previ ewHTML()') == -1))
{
indx = allTableData[i].innerHTML.indexOf(textSm ileys[n]);
if (indx != -1)
{
while (indx != -1)
{
replacement = '';
indx = allTableData[i].innerHTML.indexOf(textSm ileys[n]);
smiley = '<img src=\"' + realSmileys[n] + '">'
replacement = allTableData[i].innerHTML.replace(textSm ileys[n],smiley);
allTableData[i].innerHTML = replacement;
}
}
}

}
}

if (document.URL.indexOf('we blogs') != -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="javascript: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="javascript: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="http://www.xanga.com/item.aspx?user=drmstwizar d&tab=weblogs&uid=100884918"' +
'target=blank><font style="font-size: xx-small; font-weight: normal;">' +
'HERE</font><a/><br><br>';
smileyBarHtml = '<br><b>Smileys modified by drmstwizard</b><br><font style="font-size: xx-small">' +
'If you want to get these smileys too, click -----></font> ' +
infoLink + smileyBar + '<br><br>';
if (navigator.userAgent.inde xOf('Mac') == -1)
{
if (document.getElementById( 'htmleditor'))
var obj1 = document.getElementById(' htmleditor').parentNode;
else
{
if (document.getElementsByTa gName('textarea')[0].getAttribute('name') == 'bdescr')
var obj1 = document.getElementsByTag Name('textarea')[0].parentNode;
else
{
var allTextAreas = document.getElementsByTag Name('textarea');
for (i = 0; i < allTextAreas.length; ++i)
{
if (allTextAreas[i].getAttribute('name') == 'bdescr')
{
var obj1 = allTextAreas[i].parentNode;
break;
}
}
}
}
var obj2 = document.createElement('s pan');
obj2.setAttribute('ID','i dSmileyBar');
obj2.innerHTML = smileyBarHtml;
obj1.insertBefore(obj2,ob j1.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('previ ewHTML()') == -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('we blogs') != -1)
replaceTextSmileys();
</script>


thanks... :)

tokyo bleu
02-11-2005, 01:32 AM
Where did you get the script from? If you got it from another forum, it'd be appreciated if you linked to the specific topic.