//
// *** Smiley Script V 3.0 ***
// Original author: EasterEgg (http://www.xanga.com/easteregg)
//
// You can use this code freely, as long as the entire script remains
// intact, including the copyright notice.
//
// Many thanks to Alice Woodrome (http://www.xanga.com/Alice), who handpicked
// the emoticons that are currently present in this version of the script.
//
// VERSION HISTORY
//
// 1.0 (February 11, 2003)
// - initial release
//
// 2.0 (May 12, 2003)
// - cross browser: it runs in IE, Netscape, Mozilla and Opera
// - ready for the upcoming (beta tested) changes at Xanga
// - clickable smileys, even for non-IE users, displayed in buttons
// - customizable number of smileys displayed in one row
// - customizable smiley button size
// - easily adjustable: only two arrays to maintain
//
// 2.1 (May 12, 2003)
// - preloading images for faster performance
// - XP Bugfix
//
// 2.2 (May 17, 2003)
// - necessary adjustments made because of recent changes at Xanga
// - made suitable for Mac users!
// - runs only at the comment page for increased performance
//
// 3.0 (Nov 5, 2005)
// - script was broken, due to changes at Xanga. Fixed.
// - script overall revised, some obsolete code removed.
//
// HOW TO USE:
// For use at Xanga only. Copy this entire code (including the script tags)
// and paste in the Website Stats box at your Look and Feel page. Make sure
// the previous version of this script (if any) is completely removed first.
//
// The script contains two arrays: "textSmileys" and "realSmileys". The items
// present in the array "textSmileys" will be automatically replaced with the
// corresponding images in the array "realSmileys". You can modify the arrays
// as you see fit, as long as both arrays keep the exact same number of items.
//
// For example, suppose you want to add some smiley to the script... that would mean
// in "textSmileys" you would add a shorthand like ":some_smiley:" or {somesmiley},
// and in "realSmileys" you would add it's url: "http://www.dude.com/some_smiley.gif".
//
// SETTINGS:
// - "maxNumberOfSmileysPerRow": number of smileys that will be displayed in one row.
// Smileys above that number will automatically be added to a new line. 10 by default.
// - "buttonSize": size of the smiley buttons in pixels. 30 px by default.
//
// AVAILABILITY:
// The script has been tested in the latest versions of IE, Netscape,
// Mozilla and Opera (Windows 98).
//
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(
"\./",
"-0-",
"=]",
"@@",
"SLEEP",
":halo:",
":lovly:",
":hi:",
":elephant:",
":rain:",
":sun:",
":cloudy:",
":tense:",
":smoke:",
":::",
":pig:",
":*:",
":car:",
"",
":umbrella:",
":chrismas:",
":`:",
":duck:");
// *** add the url's from the corresponding images below
var realSmileys = new Array(
"http://i55.photobucket.com/albums/g145/LWYAN924/aicon358.gif",
"http://i55.photobucket.com/albums/g145/LWYAN924/aicon364.gif",
"http://i55.photobucket.com/albums/g145/LWYAN924/kaeru0-02.gif",
"http://i55.photobucket.com/albums/g145/LWYAN924/kaeru01.gif",
"http://i55.photobucket.com/albums/g145/LWYAN924/b-oyasumi.gif",
"http://i55.photobucket.com/albums/g145/LWYAN924/iii-34.gif",
"http://i55.photobucket.com/albums/g145/LWYAN924/aicon356.gif",
"http://i55.photobucket.com/albums/g145/LWYAN924/123.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/kao13.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/kao14.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/kao15.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/kao16.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/05hand03.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/05hand04.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/doraemon_13.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/370.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/b-ame.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/b-hare.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/b-kaminari.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/b-orooro.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/tabako.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/ring_b03.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/buta.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/01_05.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/bus_b03.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/03hart01.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/01ame.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/ame02_02.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/02_a10.gif",
"http://i72.photobucket.com/albums/i183/puiyixf/DUCK.gif");
// *** number of smileys that will be displayed per row
var maxNumberOfSmileysPerRow = 10;
// *** 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 = ''
replacement = allTableData[i].innerHTML.replace(textSmileys[n],smiley);
allTableData[i].innerHTML = replacement;
}
}
}
}
}
if (document.getElementById('idSmileyBar'))
{
var smileyCollection = new Array(realSmileys.length);
var smileyBar = '';
if (document.getElementById('htmleditor'))
{
for (i = 0; i < smileyCollection.length; ++i)
{
smileyCollection[i] = '' +
'';
}
}
else
{
for (i = 0; i < smileyCollection.length; ++i)
{
smileyCollection[i] = '' +
'';
}
}
for (i = 0; i < smileyCollection.length; ++i)
{
if (i != 0)
if ( (i/maxNumberOfSmileysPerRow).toString().indexOf('.') == -1)
smileyBar = smileyBar + '
';
smileyBar = smileyBar + smileyCollection[i];
}
// add SmileyBar
infoLink = ' 'Smiley Script
';
smileyBarHtml = '
Add Emoticons
' +
'Simply add emoticons to your comments by clicking them! ' +
infoLink + smileyBar + '
';
obj2 = document.getElementById('idSmileyBar');
obj2.innerHTML = smileyBarHtml;
}
}
if (document.getElementById('idSmileyBar'))
replaceTextSmileys();
|