Posted By

sondosia on 12/30/06


Tagged

design xanga blogs blogging webdesign smileys


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

shachi
vali29
korzhik


Smiley Script


 / Published in: JavaScript
 

URL: http://www.xanga.com/easteregg

Adds custom smileys to xanga

  1. <script type="text/javascript">
  2. //
  3. // *** Smiley Script V 3.0 ***
  4. // Original author: EasterEgg (http://www.xanga.com/easteregg)
  5. //
  6. // You can use this code freely, as long as the entire script remains
  7. // intact, including the copyright notice.
  8. //
  9. // Many thanks to Alice Woodrome (http://www.xanga.com/Alice), who handpicked
  10. // the emoticons that are currently present in this version of the script.
  11. //
  12. // VERSION HISTORY
  13. //
  14. // 1.0 (February 11, 2003)
  15. // - initial release
  16. //
  17. // 2.0 (May 12, 2003)
  18. // - cross browser: it runs in IE, Netscape, Mozilla and Opera
  19. // - ready for the upcoming (beta tested) changes at Xanga
  20. // - clickable smileys, even for non-IE users, displayed in buttons
  21. // - customizable number of smileys displayed in one row
  22. // - customizable smiley button size
  23. // - easily adjustable: only two arrays to maintain
  24. //
  25. // 2.1 (May 12, 2003)
  26. // - preloading images for faster performance
  27. // - XP Bugfix
  28. //
  29. // 2.2 (May 17, 2003)
  30. // - necessary adjustments made because of recent changes at Xanga
  31. // - made suitable for Mac users!
  32. // - runs only at the comment page for increased performance
  33. //
  34. // 3.0 (Nov 5, 2005)
  35. // - script was broken, due to changes at Xanga. Fixed.
  36. // - script overall revised, some obsolete code removed.
  37. //
  38. // HOW TO USE:
  39. // For use at Xanga only. Copy this entire code (including the script tags)
  40. // and paste in the Website Stats box at your Look and Feel page. Make sure
  41. // the previous version of this script (if any) is completely removed first.
  42. //
  43. // The script contains two arrays: "textSmileys" and "realSmileys". The items
  44. // present in the array "textSmileys" will be automatically replaced with the
  45. // corresponding images in the array "realSmileys". You can modify the arrays
  46. // as you see fit, as long as both arrays keep the exact same number of items.
  47. //
  48. // For example, suppose you want to add some smiley to the script... that would mean
  49. // in "textSmileys" you would add a shorthand like ":some_smiley:" or {somesmiley},
  50. // and in "realSmileys" you would add it's url: "http://www.dude.com/some_smiley.gif".
  51. //
  52. // SETTINGS:
  53. // - "maxNumberOfSmileysPerRow": number of smileys that will be displayed in one row.
  54. // Smileys above that number will automatically be added to a new line. 10 by default.
  55. // - "buttonSize": size of the smiley buttons in pixels. 30 px by default.
  56. //
  57. // AVAILABILITY:
  58. // The script has been tested in the latest versions of IE, Netscape,
  59. // Mozilla and Opera (Windows 98).
  60. //
  61. function typeSmiley(sSmiley)
  62. {
  63. if (document.getElementsByTagName('textarea')[0].getAttribute('name') == 'bdescr')
  64. var editor = document.getElementsByTagName('textarea')[0];
  65. else
  66. {
  67. var allTextAreas = document.getElementsByTagName('textarea');
  68. for (i = 0; i < allTextAreas.length; ++i)
  69. {
  70. if (allTextAreas[i].getAttribute('name') == 'bdescr')
  71. {
  72. var editor = allTextAreas[i];
  73. break;
  74. }
  75. }
  76. }
  77. editor.value = editor.value + sSmiley;
  78. }
  79. function replaceTextSmileys()
  80. {
  81. // ***add textual emoticons to the array below
  82. var textSmileys = new Array(
  83. ":)",
  84. ":(",
  85. ":wink:",
  86. ":p",
  87. ":lol:",
  88. ":mad:",
  89. ":heartbeat:",
  90. ":love:",
  91. ":eprop:",
  92. ":wave:",
  93. ":sunny:",
  94. ":wha:",
  95. ":yes:",
  96. ":sleepy:",
  97. ":rolleyes:",
  98. ":lookaround:",
  99. ":eek:",
  100. ":confused_2:",
  101. ":nono:",
  102. ":fun:",
  103. ":goodjob:",
  104. ":giggle:",
  105. ":cry:",
  106. ":shysmile:",
  107. ":jealous:",
  108. ":whocares:",
  109. ":spinning:",
  110. ":coolman:",
  111. ":littlekiss:",
  112. ":laugh:");
  113. // *** add the url's from the corresponding images below
  114. var realSmileys = new Array(
  115. "http://www.xanga.com/Images/smiley1.gif",
  116. "http://www.xanga.com/Images/smiley2.gif",
  117. "http://i.xanga.com/Alice/AliceSmileyAnimatedWink.gif",
  118. "http://www.xanga.com/Images/smiley4.gif",
  119. "http://i.xanga.com/Alice/Smileylol.gif",
  120. "http://i.xanga.com/Alice/7_mad.gif",
  121. "http://i.xanga.com/Alice/heartbeating.gif",
  122. "http://i.xanga.com/Alice/SmileLove.gif",
  123. "http://i.xanga.com/Alice/eProp.gif",
  124. "http://i.xanga.com/Alice/SmileyWave.gif",
  125. "http://i.xanga.com/Alice/sunnySmiley.gif",
  126. "http://i.xanga.com/Alice/wha.gif",
  127. "http://i.xanga.com/Alice/yes.gif",
  128. "http://i.xanga.com/Alice/Smileysleep.gif",
  129. "http://i.xanga.com/Alice/Smileyrolleyes.gif",
  130. "http://i.xanga.com/Alice/SmileyLookaround.gif",
  131. "http://i.xanga.com/Alice/Smileyeek.gif",
  132. "http://i.xanga.com/Alice/Smileyconfused.gif",
  133. "http://i.xanga.com/Alice/SmileyAnimatedNoNo.gif",
  134. "http://i.xanga.com/Alice/propeller.gif",
  135. "http://i.xanga.com/Alice/goodjob.gif",
  136. "http://i.xanga.com/Alice/emot-giggle.gif",
  137. "http://i.xanga.com/Alice/blueAnimatedCry.gif",
  138. "http://i.xanga.com/Alice/Animatedshysmile.gif",
  139. "http://i.xanga.com/Alice/AliceJealous.gif",
  140. "http://i.xanga.com/Alice/19_indifferent.gif",
  141. "http://i.xanga.com/Alice/Smileyspinning.gif",
  142. "http://i.xanga.com/Alice/25_coolguy.gif",
  143. "http://i.xanga.com/Alice/AliceSmileyAnimatedBlinkKiss.gif",
  144. "http://i.xanga.com/Alice/LaughingAgua.gif");
  145. // *** number of smileys that will be displayed per row
  146. var maxNumberOfSmileysPerRow = 10;
  147. // *** button size in pixels
  148. var buttonSize = 30;
  149. // preloading images
  150. var preloadedImages = new Array(realSmileys.length);
  151. for (i = 0; i < preloadedImages.length; ++i)
  152. {
  153. preloadedImages[i] = new Image();
  154. preloadedImages[i].src = realSmileys[i];
  155. }
  156.  
  157. var allTableData = document.getElementsByTagName('td');
  158. var indx;
  159. var smiley;
  160. var replacement;
  161.  
  162. for (var i = 0 ; i < allTableData.length ; ++i )
  163. {
  164. for ( var n = 0 ; n < textSmileys.length; ++n )
  165. {
  166. if ((allTableData[i].innerHTML.toUpperCase().indexOf('TABLE') == -1) &&
  167. (allTableData[i].innerHTML.indexOf('previewHTML()') == -1))
  168. {
  169. indx = allTableData[i].innerHTML.indexOf(textSmileys[n]);
  170. if (indx != -1)
  171. {
  172. while (indx != -1)
  173. {
  174. replacement = '';
  175. indx = allTableData[i].innerHTML.indexOf(textSmileys[n]);
  176. smiley = '<img src=\"' + realSmileys[n] + '">'
  177. replacement = allTableData[i].innerHTML.replace(textSmileys[n],smiley);
  178. allTableData[i].innerHTML = replacement;
  179. }
  180. }
  181. }
  182.  
  183. }
  184. }
  185.  
  186. if (document.getElementById('idSmileyBar'))
  187. {
  188. var smileyCollection = new Array(realSmileys.length);
  189. var smileyBar = '';
  190.  
  191. if (document.getElementById('htmleditor'))
  192. {
  193. for (i = 0; i < smileyCollection.length; ++i)
  194. {
  195. smileyCollection[i] = '<button type="button" value="" ' +
  196. 'style="width:' + buttonSize + 'px; height:' +
  197. buttonSize + 'px;" onclick="javascript:insertHTML(\' ' +
  198. textSmileys[i] + '\'); return false;">' +
  199. '<img src=\"' + realSmileys[i] + '" alt="' + textSmileys[i] +
  200. '"></button>';
  201. }
  202. }
  203. else
  204. {
  205. for (i = 0; i < smileyCollection.length; ++i)
  206. {
  207. smileyCollection[i] = '<button type="button" value="" ' +
  208. 'style="width:' + buttonSize + 'px; height:' +
  209. buttonSize + 'px;" onclick="javascript:typeSmiley(\' ' +
  210. textSmileys[i] + '\'); return false;">' +
  211. '<img src=\"' + realSmileys[i] + '" alt="' + textSmileys[i] +
  212. '"></button>';
  213. }
  214. }
  215.  
  216. for (i = 0; i < smileyCollection.length; ++i)
  217. {
  218. if (i != 0)
  219. if ( (i/maxNumberOfSmileysPerRow).toString().indexOf('.') == -1)
  220. smileyBar = smileyBar + '<BR>';
  221. smileyBar = smileyBar + smileyCollection[i];
  222. }
  223. // add SmileyBar
  224. infoLink = '<a href="http://www.alicewoodrome.com/smileyscript.html"' +
  225. 'target=blank><font style="font-size: xx-small; font-weight: normal;">' +
  226. 'Smiley Script</font><a/><br><br>';
  227. smileyBarHtml = '<br><b>Add Emoticons</b><br><font style="font-size: xx-small">' +
  228. 'Simply add emoticons to your comments by clicking them!</font> ' +
  229. infoLink + smileyBar + '<br><br>';
  230. obj2 = document.getElementById('idSmileyBar');
  231. obj2.innerHTML = smileyBarHtml;
  232. }
  233. }
  234. if (document.getElementById('idSmileyBar'))
  235. replaceTextSmileys();
  236. </script>

Report this snippet  

You need to login to post a comment.