//
// *** Smiley Script ***
//
// (c)2003 by EasterEgg, http://www.xanga.com/easteregg// Motley Emoticon Revision by Tenacity, http://www.xanga.com/tenacity
//
// WHAT'S NEW?
//
// 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
//
// 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(
":smile:",
":biggrin:",
":laugh:",
":bugeyes:",
":cool:",
":eyeroll:",
":worried:",
":frown:",
":f_you:",
":snicker:",
":wink:",
":heart:",
":wave:",
":grrr:",
":clap:",
":nanana:",
":loony:",
":smoke:",
":huh?:",
":scuse_me?:",
":peace:",
":frustrated:",
":moon:",
":bighug:",
":bigbounce:",
":clown:",
":zzzzz:",
":coffee:",
":spam:",
":evilgrin:",
":dork:",
":hammer:",
":wtf?:",
":tsktsk:",
":puke:",
":idunno:",
":rofl:",
":stickdance:",
":devilgrin:",
":bow:",
":innocent:",
":smooch:",
":waaahh:",
":amen:",
":weirdo:",
":stupid:",
":2beers:",
":smack!:",
":eyes_wink:",
":lip_kiss:",
":blush:",
":eek:",
":grouphug:",
":femmeblk:",
":femmeblnd:");
// *** add the url's from the corresponding images below
var realSmileys = new Array(
"http://i.xanga.com/tenacity/smiley1.gif",
"http://i.xanga.com/tenacity/smiley5.gif",
"http://i.xanga.com/tenacity/laughsmiley.gif",
"http://i.xanga.com/tenacity/smily369.gif",
"http://i.xanga.com/tenacity/cool2.gif",
"http://i.xanga.com/tenacity/rolleyes.gif",
"http://i.xanga.com/tenacity/worried.gif",
"http://i.xanga.com/tenacity/smily251.gif",
"http://i.xanga.com/tenacity/smily591.gif",
"http://i.xanga.com/tenacity/13.gif",
"http://i.xanga.com/tenacity/yelloweyebrow.gif",
"http://i.xanga.com/tenacity/heart.gif",
"http://i.xanga.com/tenacity/smily171.gif",
"http://i.xanga.com/tenacity/signgrr.gif",
"http://i.xanga.com/tenacity/appl.gif",
"http://i.xanga.com/tenacity/nanana.gif",
"http://i.xanga.com/tenacity/nutty.gif",
"http://i.xanga.com/tenacity/smoke.gif",
"http://i.xanga.com/tenacity/gif66.gif",
"http://i.xanga.com/tenacity/20.gif",
"http://i.xanga.com/tenacity/57.gif",
"http://i.xanga.com/tenacity/banghead.gif",
"http://i.xanga.com/tenacity/moon.gif",
"http://i.xanga.com/tenacity/bighug.gif",
"http://i.xanga.com/tenacity/biggrinbounce.gif",
"http://i.xanga.com/tenacity/clown.gif",
"http://i.xanga.com/tenacity/snooze.gif",
"http://i.xanga.com/tenacity/morning.gif",
"http://i.xanga.com/tenacity/spam.gif",
"http://i.xanga.com/tenacity/evilgrin.gif",
"http://i.xanga.com/tenacity/dorky05.gif",
"http://i.xanga.com/tenacity/knockknock.gif",
"http://i.xanga.com/tenacity/WTF2.gif",
"http://i.xanga.com/tenacity/tut.gif",
"http://i.xanga.com/tenacity/pike1.gif",
"http://i.xanga.com/tenacity/idunno.gif",
"http://i.xanga.com/tenacity/rofl.gif",
"http://i.xanga.com/tenacity/smiley_387.gif",
"http://i.xanga.com/tenacity/devil-smiley-041.gif",
"http://i.xanga.com/tenacity/bow.gif",
"http://i.xanga.com/tenacity/smiley_281.gif",
"http://i.xanga.com/tenacity/smiley_596.gif",
"http://i.xanga.com/tenacity/smiley_810.gif",
"http://i.xanga.com/tenacity/amen.gif",
"http://i.xanga.com/tenacity/sign_wierdo.gif",
"http://i.xanga.com/tenacity/stupid.gif",
"http://i.xanga.com/tenacity/2beers.gif",
"http://i.xanga.com/tenacity/smack.gif",
"http://i.xanga.com/tenacity/realwink2.gif",
"http://i.xanga.com/tenacity/insolite_108.gif",
"http://i.xanga.com/tenacity/blush.gif",
"http://i.xanga.com/tenacity/eek.gif",
"http://i.xanga.com/tenacity/grouphug.gif",
"http://i.xanga.com/tenacity/femmeblack.gif",
"http://i.xanga.com/tenacity/blndwhip.gif");
// *** number of smileys that will be displayed per row
var maxNumberOfSmileysPerRow = 11;
// *** button size in pixels
var buttonSize = 45;
// 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.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] = '';
}
}
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 - Motley Emoticon Version
';
smileyBarHtml = ' Add Emoticons ' +
'Simply add emoticons to your comments by clicking them! ' +
infoLink + smileyBar + '
';
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 + ' ' + smileyBarHtml;
break;
}
}
}
}
}
}
if (document.URL.indexOf('weblogs') != -1)
replaceTextSmileys();
var no = 15; // snow number
var speed = 9; // smaller number moves the snow faster
var snowflake = "http://www2.uic.edu/~dblanc2/snow.gif";
var ns4up = (document.layers) ? 1 : 0; // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0; i < no; ++ i) {
dx[i] = 0; // set coordinate variables
xp[i] = Math.random()*(doc_width-50); // set position variables
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20; // set amplitude variables
stx[i] = 0.02 + Math.random()/10; // set step variables
sty[i] = 0.7 + Math.random(); // set step variables
if (ns4up) { // set layers
if (i == 0) {
document.write("");
} else {
document.write("");
}
} else if (ie4up) {
if (i == 0) {
document.write("
");
} else {
document.write("
");
}
}
}
function snowNS() { // Netscape main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
("snowNS()", speed);
}
function snowIE() { // IE main animation function
for (i = 0; i < no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
("snowIE()", speed);
}
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}
// End -->